php: Server Stats

Forum for anything hard- or software related.

Moderator: Moderators

Post Reply
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

php: Server Stats

Post 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);

}

?>
Last edited by Den on Thu May 05, 2005 4:04 pm, edited 3 times in total.
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
Clown
unpossible??!?!!
Posts: 1750
Joined: Sun Jul 27, 2003 7:38 am
Location: en

Post by Clown »

Looks familiar
I don't give a shit.
tuv
is connecting
Posts: 19
Joined: Wed Aug 27, 2003 1:49 pm
Location: nl

Post by tuv »

Hah that will go on our webby. :)
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

Post ur links here :D wanna see what u made of it
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
Clown
unpossible??!?!!
Posts: 1750
Joined: Sun Jul 27, 2003 7:38 am
Location: en

Post by Clown »

You already know what I made of it :D
I don't give a shit.
kaaos
blew itself up
Posts: 361
Joined: Sat Aug 09, 2003 11:32 am
Location: fi

Post 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.
THEIR WHITE FLAGS ARE NO MATCH FOR OUR MACHINEGUNS
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

So true, but after some1 'stole' the code without asking, i kinda changed my mind
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
Deimos

Post by Deimos »

Who stole it? ;)
WOlz
is connecting
Posts: 17
Joined: Mon Jul 28, 2003 10:56 pm
Location: fi
Contact:

Post by WOlz »

so the phpBB sucks....



here is the code:





http://mureakuha.com/koodikirjasto/PHP/930/
Last edited by WOlz on Thu Oct 16, 2003 3:23 pm, edited 1 time in total.
I do not know with what weapons World War 3 will be fought, but World War 4 will be fought with sticks and stones.
WOlz
is connecting
Posts: 17
Joined: Mon Jul 28, 2003 10:56 pm
Location: fi
Contact:

Post by WOlz »

the line:

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



should be:

$this->fp = fsockopen("udp://".$address, $port, &$errno, &$errstr, 3);
I do not know with what weapons World War 3 will be fought, but World War 4 will be fought with sticks and stones.
Clown
unpossible??!?!!
Posts: 1750
Joined: Sun Jul 27, 2003 7:38 am
Location: en

Post 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?
Last edited by Clown on Thu Oct 16, 2003 3:07 pm, edited 3 times in total.
I don't give a shit.
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

Oh, sorry :) the php code i added for bbcode isnt 100% :D changes special-characters too.
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
Post Reply