1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | | PHP-Quelltext <?php
/*
* Name = TeamSpeak Viewer
* Version = 2.0
* Datum = 01.02.2006
* Datei = TSV_Config.php
* * * * * * * * * * * * * * * * * * */
class tss2info {
var $TS_Version = "2.0";
//////////////////////////////////////////////////////////
////// TeamSpeak Einstellungen ///////////////////////////
//
var $sitetitle = "[Kil@Z] Teamspeak"; // SeitenTitle und Scriptversion
var $serverAddress = "217.20.124.106"; // Hier die TeamSpeak IP Adresse eintragen !!wichtig!! (Beispiel: 217.20.124.106)
var $serverQueryPort = "51234"; // TeamSpeak QueryPort.. Schau in die server.ini von TeamSpeak (Standard 51234)
var $serverUDPPort = "8769"; // UDP Port für Teamspeak der auch hinter der IP Adresse genutzt wird (Standard 8767)
var $serverPasswort = ""; // Serverpasswort das bei Serversettings eingestellt wird (wenn kein Passwort erteilt, dann leer lassen)
// (Passwort wird meistens bei Clanservern gebraucht)
//
//
//////////////////////////////////////////////////////////
////// Erweiterte Einstellungen //////////////////////////
//
var $tabellenbreite = "140"; // Mindestbreite der Teamspeaktabelle (die einbindung mit einem IFRAME sollte 20px mehr betragen)
var $alternativer_nick = "GastNick"; // Alternativer Gastname
//
//
////// Aktivieren & Deaktivieren /////////////////////////
//
// 1 = aktiviert
// 0 = deaktiviert
//
//var $TS_subchannel_ausgabe = 0; // Sollen die Subchannels angezeigt werden? FUNKTION NOCH NICHT INTEGRIERT!!!
var $TS_channelflags_ausgabe = 0; // Sollen die Channelrechte angezeigt werden? (R,M,S,P etc.)
var $TS_userstatus_ausgabe = 1; // Soll der Status des Players angezeigt werden? (U,R,SA etc.)
var $TS_channel_anzeigen = 1; // Sollen die Channel angezeigt werden? (0 = nur Playerausgabe)
var $TS_leerchannel_anzeigen = 1; // Sollen die leeren Channel angezeigt werden?
var $TS_title_anzeigen = 1; // Soll der Title über den Channels sichtbar sein?
var $TS_overlib_mouseover = 1; // Soll der Mouseover Effekt vorhanden sein?
var $TS_refresh = 1; // Refreshen generell erlauben (inkl. Refreshlink)
var $TS_autorefresh = 1; // Autorefresh erlauben oder nicht
var $TS_autorefresh_zeit = 10; // Zeit in Sekunden angeben (Funktioniert nur, wenn autorefresh aktiviert wurde)
var $TS_blendtrans = 1; // Überblendeffekt an oder aus?
//
// Debugmodus
// (u.a. kann damit die Channelid angezeigt werden sollte sie gebraucht werden bei dem verstecken einzelner Channels)
var $TS_debug_modus = 0; // Debugmodus zur Fehlersuche an oder aus? (es werden sämtliche Variablen ausgegeben)
//
var $TS_hide_channels = array(); // Welche Channels sollen versteckt werden?
//
// Beispiel: array(CHANNELID,CHANNELID,CHANNELID,CHANNELID)
//
//
//////////////////////////////////////////////////////////
////// PHPKIT Einstellungen //////////////////////////////
//
var $phpkit_config = "../admin/config/config.php"; // Ort ab dem TeamSpeak Viewer Ordner wo die config.php des PHPKIT's liegt.
var $phpkit_gast_nick = "PHPKIT_GastNick"; // Name des Gastes der durch das PHPKIT connectet
var $include_phpkit = 0; // 1 = aktiv ; 0 = inaktiv
//
//////////////////////////////////////////////////////////
/*******************************************************/
/* Ab hier darf >>> KEIN <<< Text mehr geändert werden */
/*******************************************************/
//internal
var $socket;
// external
var $serverStatus = "offline";
var $playerList = array();
var $channelList = array();
// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 1;
while($attempts <= 1 and !$socket) {
$attempts++;
$socket = @fsockopen($host, $port, $errno, $errstr, $timeout);
$this->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(...)
// retrieves the next argument in a tabulator-separated string (PHP scanf function bug workaround)
function getNext($evalString) {
$pos = strpos($evalString, "\t");
if(is_integer($pos)) {
return substr($evalString, 0, $pos);
} else {
return $evalString;
}// end if
}// end function getNext($evalString);
// removes the first argument in a tabulator-separated string (PHP scanf function bug workaround)
function chopNext($evalString) {
$pos = strpos($evalString, "\t");
if(is_integer($pos)) {
return substr($evalString, $pos + 1);
} else {
return "";
}// end if
}// end function chopNext($evalString)
// strips the quotes around a string
function stripQuotes($evalString) {
if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);
return htmlentities($evalString);
}// end function stripQuotes($evalString)
// returns the codec name
function getVerboseCodec($codec) {
if($codec == 0) {
$codec = "CELP 5.1 Kbit";
} elseif($codec == 1) {
$codec = "CELP 6.3 Kbit";
} elseif($codec == 2) {
$codec = "GSM 14.8 Kbit";
} elseif($codec == 3) {
$codec = "GSM 16.4 Kbit";
} elseif($codec == 4) {
$codec = "CELP Windows 5.2 Kbit";
} elseif($codec == 5) {
$codec = "Speex 3.4 Kbit";
} elseif($codec == 6) {
$codec = "Speex 5.2 Kbit";
} elseif($codec == 7) {
$codec = "Speex 7.2 Kbit";
} elseif($codec == 8) {
$codec = "Speex 9.3 Kbit";
} elseif($codec == 9) {
$codec = "Speex 12.3 Kbit";
} elseif($codec == 10) {
$codec = "Speex 16.3 Kbit";
} elseif($codec == 11) {
$codec = "Speex 19.5 Kbit";
} elseif($codec == 12) {
$codec = "Speex 25.9 Kbit";
} else {
$codec = "unknown (".$codec.")";
}// end if
return $codec;
}// end function getVerboseCodec($codec);
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.<br><b>Scriptabbruch:</b> 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.<br><b>Scriptabbruch:</b> Der folgende UPD Port ist falsch oder gesperrt: ".$this->serverUDPPort.""; // Server didn't answer \"OK\" after last command. Aborting.
DIE;
} else {
return;
}
}// end if
############################################################################################
// retrieve player list
$this->sendQuery($this->socket,"pl");
// read player info
$this->playerList = array();
do {
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %[^\t]");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $paketlost, $pingtime, $totaltime, $idletime, $privileg, $userstatus, $attribute, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array(
"playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"paketlost" => $paketlost / 100,
"pingtime" => $pingtime,
"totaltime" => $totaltime,
"idletime" => $idletime,
"privileg" => $privileg,
"userstatus" => $userstatus,
"attribute" => $attribute,
"s" => $this->stripQuotes($s),
"playername" => $this->stripQuotes($playername));
}// end if
} while($playerid != "OK");
// retrieve channel list
$this->sendQuery($this->socket,"cl");
// read channel info
$this->channelList = array();
do {
$channelinfo = "";
do {
$input = fread($this->socket, 1);
if($input != "\n" && $input != "\r") $channelinfo .= $input;
} while($input != "\n");
$channelid = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelcodec = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelparent = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelorder = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelmaxplayers = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelname = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelflags = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channelpasswort = $this->getNext($channelinfo); $channelinfo = $this->chopNext($channelinfo);
$channeltopic = $this->getNext($channelinfo);
if($channelid != "OK") {
// determine number of players in channel
$playercount = 0;
foreach($this->playerList as $playerInfo) {
if($playerInfo['channelid'] == $channelid) $playercount++;
}// end foreach
$this->channelList[$channelid] = array(
"channelid" => $channelid,
"channelcodec" => $this->getVerboseCodec($channelcodec),
"channelparent" => $channelparent,
"channelorder" => $channelorder,
"channelmaxplayers" => $channelmaxplayers,
"channelname" => $this->stripQuotes($channelname),
"channelflags" => $channelflags,
"channelpasswort" => $channelpasswort,
"channeltopic" => $this->stripQuotes($channeltopic),
"channelcurrentplayers" => $playercount);
}// end if
} while($channelid != "OK");
// close connection to teamspeak server
$this->closeSocket($this->socket);
}// end getInfo()
}// class tss2info
}
$tss2info = new tss2info;
?> |