Forum

> > Off Topic > php server info issue
ForenübersichtOff Topic-ÜbersichtEinloggen, um zu antworten

Englisch php server info issue

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt php server info issue

Ghost-Rider
BANNED Off Offline

Zitieren
Hi.. i downloaded ketamire php server query code..
and i edited a bit.. but have some issues.
when the server is online works without any problem but when offline.. at server information show the online text and the offline text too...
so the server is offline, however the online text too shows...
how can i fixt it..
here is the code:
Spoiler >
1× editiert, zuletzt 04.07.12 12:04:14

alt Re: php server info issue

ohaz
User Off Offline

Zitieren
1
2
3
4
if ($v_temp=="") {
     ?>
    <center><font color="red"><b>OFFLINE</b></font></center>
    <?php
}
else
{
1
2
3
4
5
6
?>
    <center><img src="cs2d.png" alt="cs2d icon" height="16" width="16" /><a href="cs2d://server1-cs2dh.co.cc:36963">Join</a></center>
    <center><font color="green"><b>ONLINE</b></font></center>
    <?php
     exit;
}
try this.

alt Re: php server info issue

Ghost-Rider
BANNED Off Offline

Zitieren
i will try..
anyway one thing yet..
can i set the timeout?
because if someone browse my website
the server info too much loading....

alt Re: php server info issue

Apache uwu
User Off Offline

Zitieren
Try setting the timeout lower:

1
2
3
4
5
6
//Step 3: Prepare the functions
function server_info($ip,$port) {
     $fp = @fsockopen("udp://".$ip, $port, $errno, $errstr,3);
     fwrite($fp, chr(1).chr(0).chr(251).chr(2));
     return fread($fp,2048);
}

Notice the 3 added to fsockopen, that indicates that the server will try to connect to the given IP, and if a response is not given within 3 seconds it will assume that it is offline.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antwortenOff Topic-ÜbersichtForenübersicht