banimod / etpro / ettv forums Forum Index banimod / etpro / ettv forums
Bani's Discussion Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP server stats

 
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> Offtopic
View previous topic :: View next topic  
Author Message
Xeon_vl



Joined: 10 Feb 2006
Posts: 33

PostPosted: Fri Mar 24, 2006 10:39 am    Post subject: PHP server stats Reply with quote

i went programming a bit, and i coded the following:
Code:

<?php
if (!$server) {
$server_ip = "66.199.231.34";
$server_port = "27960";
} else {
$server = explode(":", $server);
$server_ip = $server[0];
$server_port = $server[1];
}

$server_ip = "udp://" . $server_ip;
$connect = fsockopen($server_ip, $server_port, $errno, $errstr, 30);
if(!$connect){
echo "ERROR".$errno.$errstr;
}
socket_set_timeout ($connect, 1, 000000);
$send = "ÿÿÿÿ" . chr (0x02) . "getstatus".chr (0x00);
$lol = fputs($connect, $send);
if(!$lol){
echo "ERROR";
}
fwrite ($connect, $send);
$output = fread ($connect, 1);
echo $output;
if (! empty ($output)) {
do {
$status_pre = socket_get_status ($connect);
$output = $output . fread ($connect, 1);
$status_post = socket_get_status ($connect);
} while ($status_pre[unread_bytes] != $status_post[unread_bytes]);
} else {
echo "ERROR";
};
fclose($connect);
echo $output;
$output = explode ("\\", $output);

$max_index = array_search ("sv_maxclients", $output);
$max_clients = $output[$max_index+1];

$max_index = array_search ("mapname", $output);
$mapname = $output[$max_index+1];

$max_index = array_search ("sv_hostname", $output);
$hostname = $output[$max_index+1];

$max_index = array_search ("g_gametypestring", $output);
$gametype = $output[$max_index+1];

$last_value = count($output) - 1;
$players_string = $output[$last_value];
$players_string = explode("\"", $players_string);

$get_first_ping = explode("\n", $players_string[0]);
$players_string[0] = $get_first_ping[1];

$i = 1;
$players = 0;
while (count($players_string) != $i) {
$i++;
$i++;
$players++;
}
if (substr($mapname, 0, 3) == "dm/") {
$picture_src = str_replace("dm/", "", $mapname);
} else {
$picture_src = str_replace("obj/", "", $mapname);
}
$picture_src = "images/" . $picture_src . ".jpg";
?>
<--!HTML OUTPUT NOT POSTED TO AVOID UBERPOST -->

when i run this script i get tripple error echo. All variables stay empty. The mistake must be somewhere in the first lines...... someone knows whats wrong?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> Offtopic All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group