0 Members and 1 Guest are viewing this topic.
<?php // Using Socketfunctions $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_clear_error($s); socket_connect($s, $host, $port+123); if(socket_last_error()) { echo 'Error'.socket_last_error().': '.socket_strerror(socket_last_error()); socket_clear_error($s); #return false; } socket_write($s,"s"); if(socket_last_error()) { echo 'Error'.socket_last_error().': '.socket_strerror(socket_last_error()); socket_clear_error($s); #return false; } $vsock = socket_read($s, 4096); // read to "virtual socket" $vpos = 0; // virtual socket "pointer" socket_close($s); $s = $vsock; vsocket_read($s,4);?>
<?//Settings.$ipaddress = '127.0.0.1';$port = '20000';//Ping your server and then retrieve infoif(fsockopen ($ipaddress, $port, $errno, $errstr, 15))print_r(ASE($ipaddress,$port));elseecho 'The requested server is offline';?>
SNIP
<?php//Original by: Christian Celler//Player Details by: ChrisBGK//Modified/Re-written by: Frenchiefunction parse_ase (&$string) { $size = intval (ord (substr ($string, 0, 1))); if ($size > 0) $value = substr ($string, 1, $size-1); else $value = NULL; $string = substr ($string, $size); return ($value);}function ASE($host, $port) {$socket = socket_create (AF_INET, SOCK_DGRAM, SOL_UDP); if (!(@socket_connect ($socket, $host, $port+123))) return('Error'); //Could not connect socket_set_option ($socket, SOL_SOCKET, SO_RCVTIMEO, array ('sec' => 0, 'usec' => 500000)); socket_send ($socket, 's', 1, 0); //Read all Data while ($data = @socket_read ($socket, 16384, PHP_BINARY_READ)) $result = $output . $data; socket_close ($socket); if (empty ($result)) return('Error'); //No output $result = substr ($result, 4); parse_ase ($result); $info['port'] = parse_ase ($result); $info['servername'] = parse_ase ($result); $info['ip'] = gethostbyname($host); $info['mode'] = parse_ase ($result); $info['map'] = parse_ase ($result); $info['version'] = parse_ase ($result); $info['passworded'] = parse_ase ($result); $info['numplayers'] = parse_ase ($result); $info['maxplayers'] = parse_ase ($result); //Loop through and retrieve Data while (ord (substr ($result, 0, 1)) > 1) $info[parse_ase($result)]= parse_ase ($result); $result =substr($result, 1); $info['players'] = Array(); if (strlen ($result) > 0) { //Check if there is still data to parse for($i=0;$i<$info['numplayers'];$i++) { $info['players'][$i] = Array(); $result =substr($result, 1); $info['players'][$i]['name'] = parse_ase($result); $info['players'][$i]['team'] = parse_ase($result); $info['players'][$i]['skin'] = parse_ase($result); $info['players'][$i]['score'] = parse_ase($result); $info['players'][$i]['ping'] = parse_ase($result); $info['players'][$i]['time'] = parse_ase($result); } } return $info;}?>
while (($size = socket_recvfrom($socket, $data, ($last = $size) + 1024, MSG_PEEK, $host, $port)) && ($last != $size)) ; // deliberately emptysocket_recvfrom($socket, $data, $size, 0, $host, $port);