Raggaer
Godly Member
Well since lots of people actually asked me how can this be done I decided to make a very simple function to get the basic info from a server
Keep in mind this function doesnt even check if server is offline
As you can see its very basic but should do the job
Quick example:
Keep in mind this function doesnt even check if server is offline
PHP:
Class Status
{
public $info = array();
public function LoadStatus($ip)
{
@$sock = fsockopen ($ip, '7171', $errno, $errstr, 1);
$info = chr(6).chr(0).chr(255).chr(255).'info';
fwrite($sock, $info);
$data='';
while (!feof($sock))$data .= fgets($sock, 1024);
fclose($sock);
$stats = simplexml_load_string($data);
$this->info['ip'] = $ip;
$this->info['uptime'] = $stats->serverinfo->attributes()->uptime;
$this->info['servername'] = $stats->serverinfo->attributes()->servername;
$this->info['location'] = $stats->serverinfo->attributes()->location;
$this->info['distro'] = $stats->serverinfo->attributes()->server;
$this->info['version'] = $stats->serverinfo->attributes()->version;
$this->info['client'] = $stats->serverinfo->attributes()->client;
$this->info['owner'] = $stats->owner->attributes()->name;
$this->info['email'] = $stats->owner->attributes()->email;
$this->info['players'] = $stats->players->attributes()->online;
$this->info['pmax'] = $stats->players->attributes()->max;
$this->info['ppeak'] = $stats->players->attributes()->peak;
$this->info['motd'] = $stats->motd;
$this->info['on'] = 1;
return $this->info;
}
}
As you can see its very basic but should do the job
Quick example:
PHP:
$status = new Status;
$info = $status->LoadStatus('yourserver.net');
echo 'Players online : ' . $info['players'];