Stinger
05-03-2010, 03:22 AM
Hey everyone,
I have a website that I'm putting together for an online gaming community, and I need to create or modify some kind of php code or script to basically ping the server and display an image being online if ping is successful, or offline if not.
I have a simple script here that might work (haven't been able to test it yet); will sometime as simple as that work? or is there anything else you can suggest I try.
<?PHP
$ip = "192.168.1.1";
$port = "27015";
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) {
print '<img src=img/button_serverstatus_offline.jpg>';
}
else {
print '<img src=img/button_serverstatus_online.jpg>';
fclose($sock);
}
?>
Thanks
Ryan
I have a website that I'm putting together for an online gaming community, and I need to create or modify some kind of php code or script to basically ping the server and display an image being online if ping is successful, or offline if not.
I have a simple script here that might work (haven't been able to test it yet); will sometime as simple as that work? or is there anything else you can suggest I try.
<?PHP
$ip = "192.168.1.1";
$port = "27015";
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) {
print '<img src=img/button_serverstatus_offline.jpg>';
}
else {
print '<img src=img/button_serverstatus_online.jpg>';
fclose($sock);
}
?>
Thanks
Ryan