Page 1 of 1

php: Server Stats

Posted: Tue Oct 14, 2003 4:38 pm
by Den
Server Stats for Quake2, but can b easily tweaked for other games like Quake1, Quake3, HL. This Code is not for some1 who's new to coding :)


Im workin on a v3 of this code. Its using SQL and will have some 'funny' things ;) soon!


Current version: http://den.dark-millennium.de/serverstats.php

Old version:

Code: Select all

<?php

$fp = fsockopen("udp://" . $ip, $port, $errno, $errstr, 10);

if (!$fp) {

   echo "ERROR: $errno - $errstr<br>\n";

} else {

   fwrite($fp,"ÿÿÿÿstatus\x00");

   $header = fread($fp,10);

   // Read in the info from the server.

   $do = true; 

   $result = "";

   while($do) 

   { 

      $str = fread($fp,1);

      $result .= $str;

      if ( $str ==  "\n" ) $do = false;

   }

   $serverinfo = explode("\\",$result);

   echo "<br><br>";

   socket_set_blocking($fp,0);

   $do = true;

   $i = 0;

   while ($do)

   {

      $temp = fgets($fp, 100);

      if ($temp == "")

      {

         $do = false;

      }

      else

      {

          $tempplayers[$i] = $temp;

      }

      $i++;

   }

   // Display all server settings

   for ($i = 0; $i <= sizeof($serverinfo); $i++) {

      echo $serverinfo[$i] . "<br>";

   }

   // Display all players with pings and frags

   echo "frags | ping | name<br>";

   for ($i = 0; $i <= sizeof($tempplayers); $i++) {

      echo $tempplayers[$i] . "<br>";

   }

   fclose($fp);

}

?>

Posted: Tue Oct 14, 2003 5:14 pm
by Clown
Looks familiar

Posted: Tue Oct 14, 2003 5:17 pm
by tuv
Hah that will go on our webby. :)

Posted: Tue Oct 14, 2003 5:22 pm
by Den
Post ur links here :D wanna see what u made of it

Posted: Wed Oct 15, 2003 4:16 am
by Clown
You already know what I made of it :D

Posted: Wed Oct 15, 2003 7:54 am
by kaaos
nice.



I actually asked the source from you once but you didn't want to give it to me, well maybe it wasn't ready or something. it's here now and that's what counts.



cheers.

Posted: Wed Oct 15, 2003 2:50 pm
by Den
So true, but after some1 'stole' the code without asking, i kinda changed my mind

Posted: Thu Oct 16, 2003 3:31 am
by Deimos
Who stole it? ;)

Posted: Thu Oct 16, 2003 2:39 pm
by WOlz
so the phpBB sucks....



here is the code:





http://mureakuha.com/koodikirjasto/PHP/930/

Posted: Thu Oct 16, 2003 2:59 pm
by WOlz
the line:

$this->fp = fsockopen("udp://".$address, $port, &$errno, &$errstr, 3);



should be:

$this->fp = fsockopen("udp://".$address, $port, &$errno, &$errstr, 3);

Posted: Thu Oct 16, 2003 3:00 pm
by Clown
It's a shame your one doesn't really work uitto :)



edit:// I really should pay more attention :o



edit2:// It still doesn't work :D

Players 0/0 anyone?

Posted: Thu Oct 16, 2003 3:02 pm
by Den
Oh, sorry :) the php code i added for bbcode isnt 100% :D changes special-characters too.