MW3 & Query Protocol

ADW {KAN

Junior Member
Joined
Aug 11, 2010
Likes
0
#23
How to check this?

Create a file called phpinfo.PHP paste this into it, upload to your webserver (remembering to make the file executable, then accsess with your web browser.
<?

echo phpinfo();

?>

BTW I have found a few script errors


Try this.

<?php
//************************************************************************************************************************************************
//************************************************************************************************************************************************
//************************************************************************************************************************************************
// A2S class - Copyright (c) 2005-2008 David Busby, Saiweb.co.uk
// Modification for MW3 by CyboPat (www.cybopat.net)




class A2S
{
var $srv;
var $port;

function A2S()
{
define("A2S_SERVERQUERY_GETCHALLENGE_PLAYER", "\xFF\xFF\xFF\xFF\x55\xFF\xFF\xFF\xFF");
define("A2S_INFO", "\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00");
define("A2S_PLAYER", "\xFF\xFF\xFF\xFF\x55"); // requires Challenge suffix to work
define("A2S_RULES", "\xFF\xFF\xFF\xFF\x56"); // requires Challenge suffix to work


}
function _getchallenge($t)
{
$data = $this->A2S_query(A2S_SERVERQUERY_GETCHALLENGE_PLAYER);
return substr($data,5);
}
function readString($string, &$i) {
$begin = $i;
$strlen = strlen($string);
for ($i; ($i < $strlen) && ($string{$i} != chr(0)); $i++);
$result = substr($string, $begin, $i-$begin);
$i++;
return $result;
}

function A2S_connect()
{
$this->connection = fsockopen("udp://".$this->srv, $this->port, $errorno, $errorstr, 1);
if(!$this->connection){ die("ERROR: $errorno $errorstr"); }

}
function A2S_query($query)
{
fwrite($this->connection, $query, strlen($query));
return fread($this->connection, 4096);
}
function A2S_players()
{
$data = array();
$challenge = $this->_getchallenge(null);
$buffer = $this->A2S_query(A2S_PLAYER.$challenge);
$i = 5;
$num_players = ord($buffer{$i++});

if($num_players > 0) {
for($p = 0; $p < $num_players; $p++) {
if(!empty($buffer{$i+1})) {
$data[$p]['index'] = ord($buffer{$i++});
$data[$p]['name'] = $this->readString($buffer, $i);

$frags = unpack("L", substr($buffer, $i, $i+4)); $i+=4;
$data[$p]['frags'] = $frags[1];

$time = unpack("f", substr($buffer, $i, $i+4)); $i+=4;
$time = mktime(0, 0, $time[1]);
$time = date("H:i:s", $time);
$data[$p]['time'] = $time;
}
}
}
return $data;
}

function A2S_info()
{
$buffer = $this->A2S_query(A2S_INFO);
return $buffer;
}

function A2S_close()
{
fclose($this->connection);
}

} // end class
//************************************************************************************************************************************************
//************************************************************************************************************************************************
//************************************************************************************************************************************************
function RemoveTags($retez) {
return preg_replace('~(\^[0-9])~', '', $retez);
}

$objClass = new A2S();

//SETUP IP address and PORT
// PORT = net_masterServerPort, not a game port
$objClass->srv = "66.55.131.32";
$objClass->port = 1002 ;

$objClass->A2S_connect();
$info = $objClass->A2S_info();
$player_array = $objClass->A2S_players();
$objClass->A2S_close();

$pole=explode("\\",$info);
//echo "<PRE>";print_r($pole);echo "</PRE>"; //debug
//echo "<PRE>";print_r($player_array);echo "</PRE>"; //debug


$i = 6;
$pomstr = substr($pole[0], $i);
//echo "<PRE>";print_r($pomstr);echo "</PRE>"; //debug
$pompole=explode("\x00",$pomstr);
$hostname = RemoveTags($pompole[0]);

$i = $i + strlen($pompole[0]) + 1;
$pomstr = substr($pole[0], $i);
//echo "<PRE>";print_r($pomstr);echo "</PRE>"; //debug
$pompole=explode("\x00",$pomstr);
$mapnamelong = $pompole[0];

$mapnameshort = $pole[9];

$gametype = $pole[3];

$i = $i + strlen($pompole[0]) + 1;
$pomstr = substr($pole[0], $i);
//echo "<PRE>";print_r($pomstr);echo "</PRE>"; //debug
$pompole=explode("\x00",$pomstr);
$gamedir = $pompole[0];

$i = $i + strlen($pompole[0]) + 1;
$pomstr = substr($pole[0], $i);
//echo "<PRE>";print_r($pomstr);echo "</PRE>"; //debug
$pompole=explode("\x00",$pomstr);
$gamedesc = $pompole[0];

$i = $i + strlen($pompole[0]) + 1;
$appid = substr($pole[0], $i,2);

$i = $i + 2;
$playersnum = ord(substr($pole[0], $i,1));

$i = $i + 1;
$playersmax = ord(substr($pole[0], $i,1));

$i = $i + 1;
$botsnum = ord(substr($pole[0], $i,1));

$i = $i + 1;
$dedicated = substr($pole[0], $i,1);

$i = $i + 1;
$os = substr($pole[0], $i,1);

$i = $i + 1;
$password = ord(substr($pole[0], $i,1));

$i = $i + 1;
$secure = ord(substr($pole[0], $i,1));

$hardcore = $pole[5];

$friendlyfire = $pole[19];

// OUTPUT
echo "hostname = ".$hostname."<BR>";
echo "mapnamelong = ".$mapnamelong."<BR>";
echo "mapnameshort = ".$mapnameshort."<BR>";
echo "gametype = ".$gametype."<BR>";
echo "playersnum = ".$playersnum."<BR>";
echo "playersmax = ".$playersmax."<BR>";
echo "password = ".$password."<BR>";
echo "secure = ".$secure."<BR>";
echo "hardcore = ".$hardcore."<BR>";
echo "friendlyfire = ".$friendlyfire."<BR>";
//echo "gamedir = ".$gamedir."<BR>";
//echo "gamedesc = ".$gamedesc."<BR>";
//echo "appid = ".$appid."<BR>";
//echo "botsnum = ".$botsnum."<BR>";
//echo "dedicated = ".$dedicated."<BR>";
//echo "os = ".$os."<BR>";
echo "<TABLE border='0' cellspacing='1' cellpadding='5' bgcolor='#DDDDDD'>";
echo "<TR bgcolor='#FFFFFF'><TD align='center' colspan='99'>PLAYERS</TD></TR>";
echo "<TR bgcolor='#FFFFFF'><TD>ID</TD><TD>Nick</TD><TD>Score</TD><TD>Time</TD></TR>";
for ($i = 0; $i <= $playersnum-1; $i++) {
echo "<TR bgcolor='#FFFFFF'><TD>".$player_array[$i]['index']."</TD><TD>".$player_array[$i]['name']."</TD><TD align='right'>".$player_array[$i]['frags']."</TD><TD>".$player_array[$i]['time']."</TD></TR>";
}
echo "</TABLE>";

?>
 
Joined
Jan 29, 2005
Likes
0
#27
I found something strange...

In ADW {KAN's post check line 19:
Code:
define("A2S_INFO", "\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\ x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x0 0");
There is two SPACEs in string:
Code:
.. x20\ x45 ...
and at end
Code:
... x79\x0 0");
In firt post I put this source as plain text. When you put text as plain text, this forum put SPACES in long row, check line 2,3,4. I check original source and I have no SPACES between **** **** ****
I try code with spaces in variable A2S_INFO and it doesnt work, without SPACES its ok.
check again line 19:
Code:
define("A2S_INFO", "\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00");
 
Top Bottom