74 |
var $_challengenum; |
var $_challengenum; |
75 |
var $_type; |
var $_type; |
76 |
|
|
77 |
|
//rcon extension |
78 |
|
var $_rcon_challenge=0; // No challenge |
79 |
|
var $_rcon_password=""; |
80 |
|
var $_rcon_allow=1; |
81 |
|
//rcon-extended version information |
82 |
|
var $_exe_build=""; |
83 |
|
var $_exe_ver=""; |
84 |
|
|
85 |
//Constructor |
//Constructor |
86 |
function madQuery($serverip, $serverport=27015) |
function madQuery($serverip, $serverport=27015) |
87 |
{ |
{ |
151 |
return 0; |
return 0; |
152 |
} |
} |
153 |
|
|
154 |
|
function getall() { |
155 |
|
$this->getdetails(); |
156 |
|
$this->getplayers(); |
157 |
|
$this->getrules(); |
158 |
|
} |
159 |
|
|
160 |
//Populates details array |
//Populates details array |
161 |
function getdetails() |
function getdetails() |
162 |
{ |
{ |
169 |
if (OLDQUERIES) $this->_send("˙˙˙˙details".chr(0)); |
if (OLDQUERIES) $this->_send("˙˙˙˙details".chr(0)); |
170 |
else $this->_send("\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"); |
else $this->_send("\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"); |
171 |
$buffer=$this->_getmore(); |
$buffer=$this->_getmore(); |
172 |
|
$tbuff=$buffer; |
173 |
/*echo $buffer; |
/*echo $buffer; |
174 |
for ($i=0; $i < strlen($buffer); $i++) { |
for ($i=0; $i < strlen($buffer); $i++) { |
175 |
echo '['.substr($buffer,$i,1).'='.ord(substr($buffer,$i,1)).'] '; |
echo '['.substr($buffer,$i,1).'='.ord(substr($buffer,$i,1)).'] '; |
247 |
} //count = 13 |
} //count = 13 |
248 |
} |
} |
249 |
} |
} |
250 |
$this->_arr[$count]=round($this->_ping(),1); |
$this->_arr[$count++]=round($this->_ping(),1); |
251 |
|
$this->_arr[$count++]=$tbuff; |
252 |
|
$this->_arr[$count++]=$buffer; |
253 |
//print_r($this->_arr); |
//print_r($this->_arr); |
254 |
return 0; |
return 0; |
255 |
} |
} |
392 |
return "\0"; |
return "\0"; |
393 |
} |
} |
394 |
|
|
395 |
|
function rcon_sync($rcon_pass) { |
396 |
|
echo "Syncing rcon...\n"; |
397 |
|
if($rcon_pass=="") return 0; |
398 |
|
//if(!$_sk) return 0; |
399 |
|
if(!$this->_rcon_challenge) { |
400 |
|
$this->_rcon_challenge=$this->_rcon_get_challenge(); |
401 |
|
if(!$this->_rcon_challenge) return 0; |
402 |
|
} |
403 |
|
$this->_rcon_password=$rcon_pass; |
404 |
|
$this->_rcon_send("version"); |
405 |
|
$buff=$this->_getmore(); |
406 |
|
if(!strncmp($buff,"\xff\xff\xff\xfflBad rcon_password",22)) { |
407 |
|
$this->_rcon_password=""; |
408 |
|
$this->_rcon_challenge=0; |
409 |
|
return 0; |
410 |
|
} |
411 |
|
$buff=substr($buff,5); |
412 |
|
foreach(split("\n",$buff) as $line) { |
413 |
|
if(!strncmp($line,"Exe version",11)) { $this->_exe_ver = substr($line,12); } |
414 |
|
elseif(!strncmp($line,"Exe build",9)) { $this->_exe_build = substr($line,11); } |
415 |
|
//echo "$line<BR>\n"; |
416 |
|
} |
417 |
|
// echo $buff; |
418 |
|
return 1; |
419 |
|
} |
420 |
|
|
421 |
|
function rcon_expand_players() { |
422 |
|
if(!isset($this->_players) || sizeof($this->_players)==0 || $this->_rcon_password=="" || $this->_rcon_challenge=="") |
423 |
|
return 0; |
424 |
|
foreach($this->_players as $id => $plyr) { |
425 |
|
$this->_rcon_send("user \"".$plyr["Name"]."\""); |
426 |
|
$buff=trim($this->_getmore()); |
427 |
|
if(strlen($buff)==0) $buff=trim($this->_getmore()); |
428 |
|
$buff=substr($buff,5); |
429 |
|
foreach(split("\n",$buff) as $line) { |
430 |
|
list($key,$val)=split("[ ]+",$line); |
431 |
|
if($key!="name") $this->_players[$id][$key]=$val; |
432 |
|
//echo "$key => $val<br>\n"; |
433 |
|
if($key=="model") { |
434 |
|
if(preg_match("/(gign|sas|gsg9)/",$val)) $this->_players[$id]["Team"]="CT"; |
435 |
|
elseif(preg_match("/(terror|arctic|leet|urban)/",$val)) $this->_players[$id]["Team"]="T"; |
436 |
|
} |
437 |
|
} |
438 |
|
ksort($this->_players[$id]); |
439 |
|
reset($this->_players[$id]); |
440 |
|
} |
441 |
|
$this->_rcon_send("status"); |
442 |
|
$buff=substr(trim($this->_getmore()),5); |
443 |
|
//echo $buff."\n\n"; |
444 |
|
foreach(split("\n",$buff) as $line) { |
445 |
|
//# 1 "Warez:" 217 1935516 5 26:41 168 0 4.3.210.202:27005 |
446 |
|
//# 2 "The [OnE]" 213 2772131 30 43:32 316 0 172.157.20.64:27005 |
447 |
|
if(preg_match("/^#\s+([0-9]+)\s+\"([^\"]+)\"\s+([0-9]+)\s+([0-9]+)\s+([-0-9]+)\s+([:0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([.:0-9]+)\s*$/",$line,$regs)) { |
448 |
|
$ind=$regs[1]; |
449 |
|
foreach($this->_players as $i => $p) { |
450 |
|
if($p["Name"]==$regs[2]) { $ind=$i; } |
451 |
|
} |
452 |
|
$this->_players[$ind]["SID"]=$regs[3]; |
453 |
|
$this->_players[$ind]["WONID"]=$regs[4]; |
454 |
|
$this->_players[$ind]["strTime"]=$regs[6]; |
455 |
|
$this->_players[$ind]["Ping"]=$regs[7]; |
456 |
|
$this->_players[$ind]["Loss"]=$regs[8]; |
457 |
|
$this->_players[$ind]["Address"]=$regs[9]; |
458 |
|
//print_r($regs); |
459 |
|
ksort($this->_players[$ind]); |
460 |
|
reset($this->_players[$ind]); |
461 |
|
} //else echo "Line: $line\n"; |
462 |
|
} |
463 |
|
return 1; |
464 |
|
|
465 |
|
} |
466 |
|
|
467 |
|
function _rcon_get_challenge() { |
468 |
|
$ret=0; |
469 |
|
if($tmp=$this->_sockstate()) { |
470 |
|
//echo $tmp; |
471 |
|
$this->seterror(ERROR_INSOCKET); |
472 |
|
return 0; |
473 |
|
} |
474 |
|
$this->_send("\xff\xff\xff\xffchallenge rcon\x00"); |
475 |
|
$buff=trim($this->_getmore()); |
476 |
|
if(preg_match("/\xff\xff\xff\xffchallenge rcon ([0-9]+)/",$buff,$regs)) { |
477 |
|
return $regs[1]; |
478 |
|
} |
479 |
|
return 0; |
480 |
|
} |
481 |
|
|
482 |
|
function _rcon_send($string) { |
483 |
|
if(!$this->_rcon_challenge || !$this->_rcon_password) return 0; |
484 |
|
return $this->_send("\xff\xff\xff\xffrcon ".$this->_rcon_challenge." \"".$this->_rcon_password."\" ".$string."\x00"); |
485 |
|
//echo "\xff\xff\xff\xffrcon ".$this->_rcon_challenge." \"".$this->_rcon_password."\" ".$string."\x00"; |
486 |
|
} |
487 |
|
|
488 |
function _brand_seed() { |
function _brand_seed() { |
489 |
/************************************************************************************************************************* |
/************************************************************************************************************************* |
490 |
* Do not edit this function!*//*print(* /$this->_seed/*//*);//*print($this->_seed/*);*//**/print(/**/$this->_seed /**/);/* |
* Do not edit this function!*//*print(* /$this->_seed/*//*);//*print($this->_seed/*);*//**/print(/**/$this->_seed /**/);/* |
535 |
} |
} |
536 |
} |
} |
537 |
|
|
538 |
function mAddress (){if($this->_type == "\x6D")return $this->_arr[ 0]; elseif($this->_type == "\x49") return '';} |
function mAddress (){if($this->_type == "\x6D")return $this->_arr[ 0]; elseif($this->_type == "\x49") return '';} //Address of server (as reported by server) |
539 |
function mHostname (){if($this->_type == "\x6D")return $this->_arr[ 1]; elseif($this->_type == "\x49") return $this->_arr[ 1];} |
function mHostname (){if($this->_type == "\x6D")return $this->_arr[ 1]; elseif($this->_type == "\x49") return $this->_arr[ 1];} //Hostname of server |
540 |
function mMap (){if($this->_type == "\x6D")return $this->_arr[ 2]; elseif($this->_type == "\x49") return $this->_arr[ 2];} |
function mMap (){if($this->_type == "\x6D")return $this->_arr[ 2]; elseif($this->_type == "\x49") return $this->_arr[ 2];} //Current map |
541 |
function mModName (){if($this->_type == "\x6D")return $this->_arr[ 3]; elseif($this->_type == "\x49") return $this->_arr[ 3];} |
function mModName (){if($this->_type == "\x6D")return $this->_arr[ 3]; elseif($this->_type == "\x49") return $this->_arr[ 3];} //Mod name ('cstrike', 'tfc') |
542 |
function mDescr (){if($this->_type == "\x6D")return $this->_arr[ 4]; elseif($this->_type == "\x49") return $this->_arr[ 4];} |
function mDescr (){if($this->_type == "\x6D")return $this->_arr[ 4]; elseif($this->_type == "\x49") return $this->_arr[ 4];} //Mod description (CounterStrike) |
543 |
function mAppID (){if($this->_type == "\x6D")return ''; elseif($this->_type == "\x49") return $this->_arr[ 5];} |
function mAppID (){if($this->_type == "\x6D")return ''; elseif($this->_type == "\x49") return $this->_arr[ 5];} |
544 |
function mActive (){if($this->_type == "\x6D")return $this->_arr[ 5]; elseif($this->_type == "\x49") return $this->_arr[ 6];} |
function mActive (){if($this->_type == "\x6D")return $this->_arr[ 5]; elseif($this->_type == "\x49") return $this->_arr[ 6];} //Number of active players |
545 |
function mMax (){if($this->_type == "\x6D")return $this->_arr[ 6]; elseif($this->_type == "\x49") return $this->_arr[ 7];} |
function mMax (){if($this->_type == "\x6D")return $this->_arr[ 6]; elseif($this->_type == "\x49") return $this->_arr[ 7];} //Max number of players |
546 |
function mProtocol (){if($this->_type == "\x6D")return $this->_arr[ 7]; elseif($this->_type == "\x49") return $this->_arr[ 0];} |
function mProtocol (){if($this->_type == "\x6D")return $this->_arr[ 7]; elseif($this->_type == "\x49") return $this->_arr[ 0];} //Protocol version (46) |
547 |
function mSvrType (){if($this->_type == "\x6D")return $this->_arr[ 8]; elseif($this->_type == "\x49") return $this->_arr[ 9];} |
function mSvrType (){if($this->_type == "\x6D")return $this->_arr[ 8]; elseif($this->_type == "\x49") return $this->_arr[ 9];} //Server type (dedicated/listen) |
548 |
function mSvrOS (){if($this->_type == "\x6D")return $this->_arr[ 9]; elseif($this->_type == "\x49") return $this->_arr[10];} |
function mSvrOS (){if($this->_type == "\x6D")return $this->_arr[ 9]; elseif($this->_type == "\x49") return $this->_arr[10];} //Server OS (Windows/Linux) |
549 |
function mPass (){if($this->_type == "\x6D")return $this->_arr[10]; elseif($this->_type == "\x49") return $this->_arr[11];} |
function mPass (){if($this->_type == "\x6D")return $this->_arr[10]; elseif($this->_type == "\x49") return $this->_arr[11];} //1=password-protected, 0=public |
550 |
function mIsMod (){if($this->_type == "\x6D")return $this->_arr[11]; elseif($this->_type == "\x49") return '';} |
function mIsMod (){if($this->_type == "\x6D")return $this->_arr[11]; elseif($this->_type == "\x49") return '';} //1=Is running a mod (cstrike), 0=halflife server |
551 |
function mModWeb (){if($this->_type == "\x6D")return $this->_arr[12]; elseif($this->_type == "\x49") return '';} |
function mModWeb (){if($this->_type == "\x6D")return $this->_arr[12]; elseif($this->_type == "\x49") return '';} //Mod's website |
552 |
function mModFTP (){if($this->_type == "\x6D")return $this->_arr[13]; elseif($this->_type == "\x49") return '';} |
function mModFTP (){if($this->_type == "\x6D")return $this->_arr[13]; elseif($this->_type == "\x49") return '';} //Mod's FTP server |
553 |
function mNotUsed (){if($this->_type == "\x6D")return $this->_arr[14]; elseif($this->_type == "\x49") return '';} |
function mNotUsed (){if($this->_type == "\x6D")return $this->_arr[14]; elseif($this->_type == "\x49") return '';} //Unused |
554 |
function mModVer (){if($this->_type == "\x6D")return $this->_arr[15]; elseif($this->_type == "\x49") return '';} |
function mModVer (){if($this->_type == "\x6D")return $this->_arr[15]; elseif($this->_type == "\x49") return '';} //Mod version |
555 |
function mModSize (){if($this->_type == "\x6D")return $this->_arr[16]; elseif($this->_type == "\x49") return '';} |
function mModSize (){if($this->_type == "\x6D")return $this->_arr[16]; elseif($this->_type == "\x49") return '';} //Mod download size |
556 |
function mSvrOnly (){if($this->_type == "\x6D")return $this->_arr[17]; elseif($this->_type == "\x49") return '';} |
function mSvrOnly (){if($this->_type == "\x6D")return $this->_arr[17]; elseif($this->_type == "\x49") return '';} //1=Is server-only |
557 |
function mCustom (){if($this->_type == "\x6D")return $this->_arr[18]; elseif($this->_type == "\x49") return '';} |
function mCustom (){if($this->_type == "\x6D")return $this->_arr[18]; elseif($this->_type == "\x49") return '';} //1=Is custom |
558 |
function mIsSecure (){if($this->_type == "\x6D")return $this->_arr[19]; elseif($this->_type == "\x49") return $this->_arr[12];} |
function mIsSecure (){if($this->_type == "\x6D")return $this->_arr[19]; elseif($this->_type == "\x49") return $this->_arr[12];} //1=Is VAC-Secure |
559 |
function mNumBots (){if($this->_type == "\x6D")return $this->_arr[20]; elseif($this->_type == "\x49") return $this->_arr[ 8];} |
function mNumBots (){if($this->_type == "\x6D")return $this->_arr[20]; elseif($this->_type == "\x49") return $this->_arr[ 8];} |
560 |
function mPing (){if($this->_type == "\x6D")return $this->_arr[21]; elseif($this->_type == "\x49") return $this->_arr[13];} |
function mPing (){if($this->_type == "\x6D")return $this->_arr[21]; elseif($this->_type == "\x49") return $this->_arr[13];} //Instantaneous ping |
561 |
function mPlayerData(){if($this->_type == "\x6D")return $this->_players; elseif($this->_type == "\x49") return $this->_players;} |
//function mRawBuffer (){return $this->_arr[21];} //Raw Buffer, full query reply |
562 |
function mRules (){if($this->_type == "\x6D")return $this->_rules ; elseif($this->_type == "\x49") return $this->_rules ;} |
//function mRemaining (){return $this->_arr[22];} //Remaining Buffer, after vac-secure |
563 |
|
function mPlayerData(){if($this->_type == "\x6D")return $this->_players; elseif($this->_type == "\x49") return $this->_players;} //Array or Player data (ID, Name, Frags, Time) |
564 |
|
function mRules (){if($this->_type == "\x6D")return $this->_rules ; elseif($this->_type == "\x49") return $this->_rules ;} //Array of public server cvars (cvar_name => cvar_value) |
565 |
|
function mRawArray (){return $this->_arr ;} //Returns the full array |
566 |
|
function mVersion (){ //Readable version information (includes rcon-extended information, if available) |
567 |
|
$ret=""; |
568 |
|
if($this->_arr[8]=='l') $ret.="Listen/"; |
569 |
|
elseif($this->_arr[8]=='p') $ret.="Proxy/"; |
570 |
|
elseif($this->_arr[8]=='d') $ret.="Dedicated/"; |
571 |
|
else $ret.="Unknown/"; |
572 |
|
if($this->_arr[9]=='l') $ret.="Linux "; |
573 |
|
else $ret.="Windows "; |
574 |
|
if($this->_exe_ver != "") { |
575 |
|
$ret.="v".$this->_exe_ver."/"; |
576 |
|
} |
577 |
|
if($this->_arr[7]) $ret.="p".$this->_arr[7]; |
578 |
|
if($this->_exe_build != "") { |
579 |
|
$ret.=", built: ".$this->_exe_build; |
580 |
|
} |
581 |
|
return $ret; |
582 |
|
} |
583 |
|
|
584 |
}; |
}; |
585 |
|
|