rodrigor78
New Member
- Joined
- Aug 19, 2011
- Messages
- 1
- Reaction score
- 0
I need help getting my site this perfectly, plus the status appear online player, and uptime, no this is just getting offline anyone knows and can help me there's this code!
Code:
<?php
$info = chr(6).chr(0).chr(255).chr(255).'info';
$sock = @fsockopen($worldip , 7171, $errno, $errstr, 1);
if ($sock)
{
fwrite($sock, $info);
$data='';
while (!feof($sock))
$data .= fgets($sock, 1024);
fclose($sock);
// The following script shows how many players online
preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
print ' .: <font color=green>ONLINE</font> :.';
print '<br/><div style="color: #cec6a4"> .: Players: ';
print $matches[1] . '/' . $matches[2];
// The following script shows uptime
preg_match('/uptime="(\d+)"/', $data, $matches);
$h = floor($matches[1] / 3600);
$m = floor(($matches[1] - $h*3600) / 60);
// And now it prints it:
echo " :.<br/> .: Uptime: $h h $m m :.<br/><br/></div></div>";
}
else
print ' .: <font color=red>OFFLINE</font> :.<br/><br /></div>';
?>