errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}
}// end while
return false;
}// end function getSocket(...)
// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)
// answer OK?
function getOK($socket) {
$result = fread($socket, 2);
fgets($socket, 128);
return($result == "OK");
}// end function getOK(...)
// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)
function getInfo() {
// ---=== main program ===---
// establish connection to teamspeak server
$this->socket = $this->getSocket($this->serverAddress, $this->serverQueryPort, $errno, $errstr, 0.3);
if($this->socket == false) {
if($this->TS_debug_modus == 1) {
echo "Es wird kein Server gefunden.
Scriptabbruch: Der folgende Query Port ist falsch oder gesperrt: ".$this->serverQueryPort.""; // No Server
DIE;
} else {
return;
}
} else {
$this->serverStatus = "online";
// select the one and only running server on port 8767
$this->sendQuery($this->socket, "sel ".$this->serverUDPPort);
// retrieve answer "OK"
if(!$this->getOK($this->socket)) {
if($this->TS_debug_modus == 1) {
echo "Der Server antwortete nach der letzten Anfrage nicht mit OK.
Scriptabbruch: Der folgende UPD Port ist falsch oder gesperrt: ".$this->serverUDPPort.""; // Server didn't answer \"OK\" after last command. Aborting.
DIE;
} else {
return;
}
}// end if
$this->sendQuery($this->socket,"gi");
$this->serverinfo = array();
list($total_server_uptime, $total_server_version, $total_server_platform, $total_servers, $total_users_online, $total_users_maximal, $total_channels, $total_bytesreceived, $total_bytessend, $total_packetssend, $total_packetsreceived, $total_bwoutlastmin, $total_bwoutlastsec, $total_bwinlastmin, $total_bwinlastsec, $isp_ispname, $isp_linkurl, $isp_adminemail, $isp_countrynumber, $querstatus) = $serverinfovar;
$serverinfo = array(
"total_server_uptime" => $total_server_uptime,
"total_server_version" => $total_server_version,
"total_server_platform" => $total_server_platform,
"total_servers" => $total_servers,
"total_users_online" => $total_users_online,
"total_users_maximal" => $total_users_maximal,
"total_channels" => $total_channels,
"total_bytesreceived" => $total_bytesreceived,
"total_bytessend" => $total_bytessend,
"total_packetssend" => $total_packetssend,
"total_packetsreceived" => $total_packetsreceived,
"total_bwoutlastmin" => $total_bwoutlastmin,
"total_bwoutlastsec" => $total_bwoutlastsec,
"total_bwinlastmin" => $total_bwinlastmin,
"total_bwinlastsec" => $total_bwinlastsec,
"isp_ispname" => $isp_ispname,
"isp_linkurl" => $isp_linkurl,
"isp_adminemail" => $isp_adminemail,
"isp_countrynumber" => $isp_countrynumber,
"querstatus" => $querstatus);
// close connection to teamspeak server
$this->closeSocket($this->socket);
}// end getInfo()
}// class tss2info
}
$tss2info_ = new tss2info_;
?>