1 | <?php
|
---|
2 | // Teamspeak Display Preview Release 3
|
---|
3 | // Copyright (C) 2005 Guido van Biemen (aka MrGuide@NL)
|
---|
4 | //
|
---|
5 | // This program is free software; you can redistribute it and/or modify
|
---|
6 | // it under the terms of the GNU General Public License as published by
|
---|
7 | // the Free Software Foundation; either version 2 of the License, or
|
---|
8 | // (at your option) any later version.
|
---|
9 | //
|
---|
10 | // This program is distributed in the hope that it will be useful,
|
---|
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | // GNU General Public License for more details.
|
---|
14 | //
|
---|
15 | // You should have received a copy of the GNU General Public License
|
---|
16 | // along with this program; if not, write to the Free Software
|
---|
17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 |
|
---|
19 | class teamspeakDisplayClass {
|
---|
20 |
|
---|
21 | // Removes subsequent end of line charachter from the right part of a string
|
---|
22 | function _stripEOL($evalString) {
|
---|
23 | $newLen = strlen($evalString);
|
---|
24 | while (((substr($evalString, $newLen - 1, 1) == "\r")) || ((substr($evalString, $newLen - 1, 1) == "\n"))) {
|
---|
25 | $newLen--;
|
---|
26 | }
|
---|
27 | return substr($evalString, 0, $newLen);
|
---|
28 | }
|
---|
29 |
|
---|
30 | // Opens a connection to the teamspeak server
|
---|
31 | function _openConnection(&$socket, $host, $port, $timeout) {
|
---|
32 | @$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
|
---|
33 | if ($socket and ($this->_stripEOL(fgets($socket, 4096)) == "[TS]")) {
|
---|
34 | return true;
|
---|
35 | } else {
|
---|
36 | return false;
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | // Closes the connection to the Teamspeak server
|
---|
41 | function _closeConnection($socket) {
|
---|
42 | fputs($socket, "quit\n");
|
---|
43 | fclose($socket);
|
---|
44 | }
|
---|
45 | // odstrannie diakritiky
|
---|
46 | function Kodovani ($string)
|
---|
47 | {
|
---|
48 | $st_new = ToUTF8($string);
|
---|
49 | // $st_new = strtr($string, "\xe1\xe4\xe8\xef\xe9\xec\xed\xbe\xe5\xf2\xf3\xf6\xf5\xf4\xf8\xe0\x9a\x9d\xfa\xf9\xfc\xfb\xfd\x9e\xc1\xc4\xc8\xcf\xc9\xcc\xcd\xbc\xc5\xd2\xd3\xd6\xd5\xd4\xd8\xc0\x8a\x8d\xda\xd9\xdc\xdb\xdd\x8e","aacdeeillnoooorrstuuuuyzAACDEEILLNOOOORRSTUUUUYZ" );
|
---|
50 | $st_new = htmlspecialchars($st_new);
|
---|
51 | return $st_new;
|
---|
52 | }
|
---|
53 |
|
---|
54 | // Returns the part of evalString until a tab (or the end of a string) and deletes the
|
---|
55 | // returned part from evalString (including the possible tab that follows)
|
---|
56 | function _stripPartFromString(&$evalString) {
|
---|
57 | $pos = strpos($evalString, "\t");
|
---|
58 | if(is_integer($pos)) {
|
---|
59 | $result = substr($evalString, 0, $pos);
|
---|
60 | $evalString = substr($evalString, $pos + 1);
|
---|
61 | } else {
|
---|
62 | $result = $evalString;
|
---|
63 | $evalString = "";
|
---|
64 | }
|
---|
65 | return $result;
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Removes the surrounding quotes from evalString and returns the result
|
---|
69 | function _stripQuotes($evalString) {
|
---|
70 | if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
|
---|
71 | if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);
|
---|
72 | return $evalString;
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Request, read and parse the server info:
|
---|
76 | function _getServerInfo($socket) {
|
---|
77 | fputs($socket, "si\n");
|
---|
78 | $result = array();
|
---|
79 | do {
|
---|
80 | $buffer = $this->_stripEOL(fgets($socket, 4096));
|
---|
81 | if (($buffer != "OK") && (strtoupper(substr($buffer, 0, 5)) != "ERROR")) {
|
---|
82 | $pos = strpos($buffer, '=');
|
---|
83 | if ($pos !== False) {
|
---|
84 | $result[substr($buffer, 0, $pos)] = substr($buffer, $pos + 1);
|
---|
85 | }
|
---|
86 | }
|
---|
87 | } while (($buffer != "OK") && (strtoupper(substr($buffer, 0, 5)) != "ERROR") && (!feof($socket)));
|
---|
88 | return $result;
|
---|
89 | }
|
---|
90 |
|
---|
91 | function _setPlayerDisplayImage(&$playerInfo) {
|
---|
92 | // Determine the right userpicture:
|
---|
93 | if (($playerInfo["attribute"] & 8) == 8) { $playerImage = "away"; }
|
---|
94 | else if (($playerInfo["attribute"] & 32) == 32) { $playerImage = "mutespeakers"; }
|
---|
95 | else if (($playerInfo["attribute"] & 16) == 16) { $playerImage = "mutemicrophone"; }
|
---|
96 | else if (($playerInfo["attribute"] & 1) == 1) { $playerImage = "channelcommander"; }
|
---|
97 | else { $playerImage = "normal"; }
|
---|
98 | $playerInfo["displayimage"] = $playerImage;
|
---|
99 | }
|
---|
100 |
|
---|
101 | function _setPlayerDisplayName(&$playerInfo) {
|
---|
102 | // Determine the player status (U = Unregistered, R = Registered, SA = Server Admin,
|
---|
103 | // CA = Channel Admin, AO = Auto-Operator, AV = Auto-Voice, O = Operator, V = Voice)
|
---|
104 | if (($playerInfo["userstatus"] & 4) == 4) { $playerstatus = "R"; } else { $playerstatus = 'U'; }
|
---|
105 | if (($playerInfo["userstatus"] & 1) == 1) { $playerstatus .= " SA"; }
|
---|
106 | if (($playerInfo["privileg"] & 1) == 1) { $playerstatus .= " CA"; }
|
---|
107 | if (($playerInfo["privileg"] & 8) == 8) { $playerstatus .= " AO"; }
|
---|
108 | if (($playerInfo["privileg"] & 16) == 16) { $playerstatus .= " AV"; }
|
---|
109 | if (($playerInfo["privileg"] & 2) == 2) { $playerstatus .= " O"; }
|
---|
110 | if (($playerInfo["privileg"] & 4) == 4) { $playerstatus .= " V"; }
|
---|
111 | if (($playerInfo["attribute"] & 64) == 64) { $playerstatus .= " Rec"; }
|
---|
112 |
|
---|
113 | // Determine the player attributes to be listed behind the player status (WV = Want Voice)
|
---|
114 | if (($playerInfo["attribute"] & 2) == 2) { $playerattributes = ' WV'; } else { $playerattributes = ''; }
|
---|
115 |
|
---|
116 | $playerInfo["displayname"] = $playerInfo["playername"] . " (" . $playerstatus . ")" . $playerattributes;
|
---|
117 | }
|
---|
118 |
|
---|
119 | function _getPlayerList($socket) {
|
---|
120 | // Request, read and parse the player list
|
---|
121 | fputs($socket, "pl\n");
|
---|
122 | $buffer = $this->_stripEOL(fgets($socket, 4096));
|
---|
123 | $result = array();
|
---|
124 | if (strtoupper(substr($buffer, 0, 5)) == "ERROR") { return $result; }
|
---|
125 | do {
|
---|
126 | $buffer = $this->_stripEOL(fgets($socket, 4096));
|
---|
127 | if (($buffer != "OK") && (strtoupper(substr($buffer, 0, 5)) != "ERROR")) {
|
---|
128 | $playerid = $this->_stripPartFromString($buffer);
|
---|
129 | $result[$playerid] = array(
|
---|
130 | "playerid" => $playerid,
|
---|
131 | "channelid" => $this->_stripPartFromString($buffer),
|
---|
132 | "receivedpackets" => $this->_stripPartFromString($buffer),
|
---|
133 | "receivedbytes" => $this->_stripPartFromString($buffer),
|
---|
134 | "sentpackets" => $this->_stripPartFromString($buffer),
|
---|
135 | "sentbytes" => $this->_stripPartFromString($buffer),
|
---|
136 | "paketlost" => $this->_stripPartFromString($buffer) / 100,
|
---|
137 | "pingtime" => $this->_stripPartFromString($buffer),
|
---|
138 | "totaltime" => $this->_stripPartFromString($buffer),
|
---|
139 | "idletime" => $this->_stripPartFromString($buffer),
|
---|
140 | "privileg" => $this->_stripPartFromString($buffer),
|
---|
141 | "userstatus" => $this->_stripPartFromString($buffer),
|
---|
142 | "attribute" => $this->_stripPartFromString($buffer),
|
---|
143 | "ip" => $this->_stripPartFromString($buffer),
|
---|
144 | "playername" => $this->_stripQuotes($this->_stripPartFromString($buffer)),
|
---|
145 | "loginname" => $this->_stripQuotes($this->_stripPartFromString($buffer))
|
---|
146 | );
|
---|
147 | $this->_setPlayerDisplayImage($result[$playerid]);
|
---|
148 | $this->_setPlayerDisplayName($result[$playerid]);
|
---|
149 | }
|
---|
150 | } while (($buffer != "OK") && (strtoupper(substr($buffer, 0, 5)) != "ERROR") && (!feof($socket)));
|
---|
151 | return $result;
|
---|
152 | }
|
---|
153 |
|
---|
154 | function _getLimitedPlayerList($socket, $channelList) {
|
---|
155 | $playerList = $this->_getPlayerList($socket);
|
---|
156 | $result = array();
|
---|
157 | foreach($playerList as $playerInfo) {
|
---|
158 | foreach($channelList as $channelInfo) {
|
---|
159 | if ($playerInfo["channelid"] == $channelInfo["channelid"]) {
|
---|
160 | $result[$playerInfo["playerid"]] = $playerInfo;
|
---|
161 | }
|
---|
162 | }
|
---|
163 | }
|
---|
164 | return $result;
|
---|
165 | }
|
---|
166 |
|
---|
167 | function _setChannelDisplayName(&$channelInfo) {
|
---|
168 | if ($channelInfo["parent"] != -1) {
|
---|
169 | $channelInfo["displayname"] = $channelInfo["channelname"];
|
---|
170 | } else {
|
---|
171 | // Determine the channel status (U = Unregisterd, R = Registered, M = Moderated,
|
---|
172 | // P = Passworded, S = Sub-channels, D = Default).
|
---|
173 | if (($channelInfo["flags"] & 1) == 1) { $channelstatus = 'U'; } else { $channelstatus = 'R'; }
|
---|
174 | if (($channelInfo["flags"] & 2) == 2) { $channelstatus .= 'M'; }
|
---|
175 | if (($channelInfo["flags"] & 4) == 4) { $channelstatus .= 'P'; }
|
---|
176 | if (($channelInfo["flags"] & 8) == 8) { $channelstatus .= 'S'; }
|
---|
177 | if (($channelInfo["flags"] & 16) == 16) { $channelstatus .= 'D'; }
|
---|
178 | $channelInfo["displayname"] = $channelInfo["channelname"] . " (" . $channelstatus . ")";
|
---|
179 | }
|
---|
180 | }
|
---|
181 |
|
---|
182 | function _getChannelList($socket) {
|
---|
183 | // Request, read and parse the channel list
|
---|
184 | fputs($socket, "cl\n");
|
---|
185 | $buffer = $this->_stripEOL(fgets($socket, 4096));
|
---|
186 | $result = array();
|
---|
187 | if (strtoupper(substr($buffer, 0, 5)) == "ERROR") { return $result; }
|
---|
188 | do {
|
---|
189 | $buffer = $this->_stripEOL(fgets($socket, 4096));
|
---|
190 | if (($buffer != "OK") && (strtoupper(substr($buffer, 0, 5)) != "ERROR")) {
|
---|
191 | $channelid = $this->_stripPartFromString($buffer);
|
---|
192 | $result[$channelid] = array(
|
---|
193 | "channelid" => $channelid,
|
---|
194 | "codec" => $this->_stripPartFromString($buffer),
|
---|
195 | "parent" => $this->_stripPartFromString($buffer),
|
---|
196 | "order" => $this->_stripPartFromString($buffer),
|
---|
197 | "maxplayers" => $this->_stripPartFromString($buffer),
|
---|
198 | "channelname" => $this->_stripQuotes($this->_stripPartFromString($buffer)),
|
---|
199 | "flags" => $this->_stripPartFromString($buffer),
|
---|
200 | "password" => $this->_stripPartFromString($buffer),
|
---|
201 | "topic" => $this->_stripQuotes($this->_stripPartFromString($buffer))
|
---|
202 | );
|
---|
203 | $this->_setChannelDisplayName($result[$channelid]);
|
---|
204 | }
|
---|
205 | } while (($buffer != "OK") && (strtoupper(substr($buffer, 0, 5)) != "ERROR") && (!feof($socket)));
|
---|
206 | return $result;
|
---|
207 | }
|
---|
208 |
|
---|
209 | function _getLimitedChannelList($socket, $limitChannel) {
|
---|
210 | $channelList = $this->_getChannelList($socket);
|
---|
211 | $result = array();
|
---|
212 | foreach($channelList as $channelInfo) {
|
---|
213 | if ($channelInfo["parent"] == -1) {
|
---|
214 | if ($channelInfo["channelname"] == $limitChannel) {
|
---|
215 | $result[$channelInfo["channelid"]] = $channelInfo;
|
---|
216 | foreach($channelList as $subChannelInfo) {
|
---|
217 | if ($subChannelInfo["parent"] == $channelInfo["channelid"]) {
|
---|
218 | $result[$subChannelInfo["channelid"]] = $subChannelInfo;
|
---|
219 | }
|
---|
220 | }
|
---|
221 | }
|
---|
222 | }
|
---|
223 | }
|
---|
224 | return $result;
|
---|
225 | }
|
---|
226 |
|
---|
227 | function _selectServer($socket, $port) {
|
---|
228 | // Request the server to select the server which is hosted on the port set in serverUDPPort
|
---|
229 | fputs($socket, "sel ".$port . "\n");
|
---|
230 |
|
---|
231 | // Read server response on request to select a server
|
---|
232 | return ($this->_stripEOL(fgets($socket, 4096)) == "OK");
|
---|
233 | }
|
---|
234 |
|
---|
235 | // Queries the Teamspeak server
|
---|
236 | function queryTeamspeakServerEx($settings) {
|
---|
237 | $result = array();
|
---|
238 |
|
---|
239 | // Try to establish a connection to the teamspeak server
|
---|
240 | if (! $this->_openConnection($socket, $settings["serveraddress"], $settings["serverqueryport"], 0.3)) {
|
---|
241 | $result["queryerror"] = 1;
|
---|
242 | } else if (! $this->_selectServer($socket, $settings["serverudpport"])) {
|
---|
243 | $result["queryerror"] = 2;
|
---|
244 | $this->_closeConnection($socket);
|
---|
245 | } else {
|
---|
246 | $result["queryerror"] = 0;
|
---|
247 | $result["serverinfo"] = $this->_getServerInfo($socket);
|
---|
248 | $result["channellist"] = ($settings["limitchannel"] == "") ? $this->_getChannelList($socket) : $this->_getLimitedChannelList($socket, $settings["limitchannel"]);
|
---|
249 | $result["playerlist"] = ($settings["limitchannel"] == "") ? $this->_getPlayerList($socket) : $this->_getLimitedPlayerList($socket, $result["channellist"]);
|
---|
250 | $this->_closeConnection($socket);
|
---|
251 | }
|
---|
252 | return $result;
|
---|
253 | }
|
---|
254 |
|
---|
255 | function queryTeamspeakServer($serverAddress, $serverUDPPort, $serverQueryPort) {
|
---|
256 | $settings = $this->getDefaultSettings();
|
---|
257 | $settings["serveraddress"] = $serverAddress;
|
---|
258 | $settings["serverudpport"] = $serverUDPPort;
|
---|
259 | $settings["serverqueryport"] = $serverQueryPort;
|
---|
260 | return $this->queryTeamspeakServerEx($settings);
|
---|
261 | }
|
---|
262 |
|
---|
263 | function _orderAlphaGetString($string) {
|
---|
264 | $lowerstring = strtolower($string);
|
---|
265 | $result = "";
|
---|
266 | for ($i = 0; $i < strlen($lowerstring); $i++) {
|
---|
267 | if (strpos("0123456789abcdefghijklmnopqrstuvwxyz", substr($lowerstring, $i, 1)) !== false) {
|
---|
268 | $result .= substr($lowerstring, $i, 1);
|
---|
269 | }
|
---|
270 | }
|
---|
271 | return $result;
|
---|
272 | }
|
---|
273 |
|
---|
274 | function _orderAlpha($str1, $str2) {
|
---|
275 | return strcmp($this->_orderAlphaGetString($str1), $this->_orderAlphaGetString($str2));
|
---|
276 | }
|
---|
277 |
|
---|
278 | function _compareChannel($a, $b) {
|
---|
279 | if ($a["order"] != $b["order"]) { return ($a["order"] < $b["order"]) ? -1 : 1; }
|
---|
280 | else { return $this->_orderAlpha($a["displayname"], $b["displayname"]); }
|
---|
281 | }
|
---|
282 |
|
---|
283 | function _comparePlayer($a, $b) {
|
---|
284 | // Determine userlevel (0 = Not server admin, 1 = Server admin)
|
---|
285 | $userlevela = $a["userstatus"] & 1;
|
---|
286 | $userlevelb = $b["userstatus"] & 1;
|
---|
287 | if ($userlevela != $userlevelb) { return ($userlevela < $userlevelb) ? 1 : -1; }
|
---|
288 | else { return $this->_orderAlpha($a["displayname"], $b["displayname"]); }
|
---|
289 | }
|
---|
290 |
|
---|
291 | function sortServerInfo(&$serverInfo) {
|
---|
292 | usort($serverInfo["channellist"], array($this, "_compareChannel"));
|
---|
293 | usort($serverInfo["playerlist"], array($this, "_comparePlayer"));
|
---|
294 | }
|
---|
295 |
|
---|
296 | function _formatTime($totaltime) {
|
---|
297 | $hours = floor($totaltime / 3600);
|
---|
298 | $minutes = floor(($totaltime % 3600) / 60);
|
---|
299 | return (($hours < 10) ? "0" : "") . $hours . ":" . (($minutes < 10) ? "0" : "") . $minutes;
|
---|
300 | }
|
---|
301 |
|
---|
302 | // Returns the codec name
|
---|
303 | function _getCodecName($codec) {
|
---|
304 | if ($codec == 0) { return "CELP 5.1 Kbit"; }
|
---|
305 | else if ($codec == 1) { return "CELP 6.3 Kbit"; }
|
---|
306 | else if ($codec == 2) { return "GSM 14.8 Kbit"; }
|
---|
307 | else if ($codec == 3) { return "GSM 16.4 Kbit"; }
|
---|
308 | else if ($codec == 4) { return "CELP Windows 5.2 Kbit"; }
|
---|
309 | else if ($codec == 5) { return "Speex 3.4 Kbit"; }
|
---|
310 | else if ($codec == 6) { return "Speex 5.2 Kbit"; }
|
---|
311 | else if ($codec == 7) { return "Speex 7.2 Kbit"; }
|
---|
312 | else if ($codec == 8) { return "Speex 9.3 Kbit"; }
|
---|
313 | else if ($codec == 9) { return "Speex 12.3 Kbit"; }
|
---|
314 | else if ($codec == 10) { return "Speex 16.3 Kbit"; }
|
---|
315 | else if ($codec == 11) { return "Speex 19.5 Kbit"; }
|
---|
316 | else if ($codec == 12) { return "Speex 25.9 Kbit"; }
|
---|
317 | else { return "Unknown (" . $codec . ")"; }
|
---|
318 | }
|
---|
319 |
|
---|
320 | function getDefaultSettings() {
|
---|
321 | $result = array();
|
---|
322 | $result["serveraddress"] = "";
|
---|
323 | $result["serverudpport"] = 8767;
|
---|
324 | $result["serverqueryport"] = 51234;
|
---|
325 | $result["limitchannel"] = "";
|
---|
326 | $result["forbiddennicknamechars"] = "()[]{}";
|
---|
327 | return $result;
|
---|
328 | }
|
---|
329 |
|
---|
330 | // Main function (queries, sorts and displays the teamspeak serverinfo). Its code is not
|
---|
331 | // very readable... well what shall I say about it... it was hard to write so it should
|
---|
332 | // be hard to read >:)
|
---|
333 | function displayTeamspeakEx($settings) {
|
---|
334 | global $html;
|
---|
335 |
|
---|
336 | $serverInfo = $this->queryTeamspeakServerEx($settings);
|
---|
337 |
|
---|
338 | echo("<div id=\"teamspeakdisplay\">\n");
|
---|
339 | if ($serverInfo["queryerror"] != 0) {
|
---|
340 | $popupInfo = "Server address: " . $settings["serveraddress"] . (($settings["serverudpport"] != 8767) ? (":" . $settings["serverudpport"]): "");
|
---|
341 | if ($serverInfo["queryerror"] == 1) {
|
---|
342 | $popupInfo .= ", Error: could not connect to query port";
|
---|
343 | } else {
|
---|
344 | $popupInfo .= ", Error: no server running on port " . $settings["serverudpport"];
|
---|
345 | }
|
---|
346 | echo("<table><tr><td>");
|
---|
347 | echo("<img src=\"".$html->Link('/inc/teamspeakdisplay/teamspeak_offline.png')."\" alt=\"\" title=\"" . $popupInfo . "\">");
|
---|
348 | echo("</td><td class=\"teamspeakserver\" title=\"" . $popupInfo . "\">");
|
---|
349 | echo("Server offline");
|
---|
350 | echo("</td></tr></table>\n");
|
---|
351 | } else {
|
---|
352 | $this->sortServerInfo($serverInfo);
|
---|
353 |
|
---|
354 | // Generate javascript for teamspeak hyperlinks
|
---|
355 | $jsTeamspeakId = md5($settings["serveraddress"] . ":" . $settings["serverudpport"]);
|
---|
356 | echo("<script type=\"text/javascript\"><!--\n");
|
---|
357 | echo("function stringOk_" . $jsTeamspeakId . "(string, forbiddenChars) {\n");
|
---|
358 | echo(" for(var i = 0; i < string.length; i++) {\n");
|
---|
359 | echo(" if (forbiddenChars.indexOf(string.charAt(i)) > -1) {\n");
|
---|
360 | echo(" return false;\n");
|
---|
361 | echo(" }\n");
|
---|
362 | echo(" }\n");
|
---|
363 | echo(" return true;\n");
|
---|
364 | echo("}\n");
|
---|
365 | echo("function enterServer_" . $jsTeamspeakId . "() {\n");
|
---|
366 | echo(" enterSubChannel_" . $jsTeamspeakId . "(null, false, null);\n");
|
---|
367 | echo("}\n");
|
---|
368 | echo("function enterChannel_" . $jsTeamspeakId . "(channelName, channelPassworded) {\n");
|
---|
369 | echo(" enterSubChannel_" . $jsTeamspeakId . "(channelName, channelPassworded, null);\n");
|
---|
370 | echo("}\n");
|
---|
371 | echo("function enterSubChannel_" . $jsTeamspeakId . "(channelName, channelPassworded, subChannelName) {\n");
|
---|
372 | echo(" var serveraddress = 'teamspeak://" . $settings["serveraddress"] . ":" . $settings["serverudpport"] . "';\n");
|
---|
373 | echo(" var nickname=window.prompt('Enter your nickname', '');\n");
|
---|
374 | echo(" if (nickname == null) {\n");
|
---|
375 | echo(" return;\n");
|
---|
376 | echo(" } else if (! stringOk_" . $jsTeamspeakId . "(nickname, '" . str_replace("'", "\\'", $settings["forbiddennicknamechars"]) . "')) {\n");
|
---|
377 | echo(" window.alert('Could not enter the teamspeak server because the nickname you entered contains one or more of these forbidden characters: " . str_replace("'", "\\'", $settings["forbiddennicknamechars"]) . "');\n");
|
---|
378 | echo(" return;\n");
|
---|
379 | echo(" } else if (nickname == \"\") {\n");
|
---|
380 | echo(" window.alert('Could not enter the teamspeak server because you did not enter your nickname');\n");
|
---|
381 | echo(" return;\n");
|
---|
382 | echo(" }\n");
|
---|
383 | echo(" serveraddress = serveraddress + \"/nickname=\" + escape(nickname);\n");
|
---|
384 | if ($serverInfo["serverinfo"]["server_password"] == "1") {
|
---|
385 | echo(" var password=window.prompt('Enter the teamspeak server password for " . $serverInfo["serverinfo"]["server_name"] . "', '');\n");
|
---|
386 | echo(" if (password == null) {\n");
|
---|
387 | echo(" return;\n");
|
---|
388 | echo(" } else if (password == \"\") {\n");
|
---|
389 | echo(" window.alert('Could not enter the teamspeak server because you did not enter a server password');\n");
|
---|
390 | echo(" return;\n");
|
---|
391 | echo(" }\n");
|
---|
392 | echo(" serveraddress = serveraddress + \"?password=\" + escape(password);\n");
|
---|
393 | }
|
---|
394 | echo(" if (channelName != null) { serveraddress = serveraddress + \"?channel=\" + escape(channelName); }\n");
|
---|
395 | echo(" if (channelPassworded) {\n");
|
---|
396 | echo(" var channelpassword=window.prompt('Enter the channel password for channel ' + channelName, '');\n");
|
---|
397 | echo(" if (channelpassword == null) {\n");
|
---|
398 | echo(" return;\n");
|
---|
399 | echo(" } else if (channelpassword == \"\") {\n");
|
---|
400 | echo(" window.alert('Could not enter the teamspeak server because you did not enter a channel password');\n");
|
---|
401 | echo(" return;\n");
|
---|
402 | echo(" }\n");
|
---|
403 | echo(" serveraddress = serveraddress + \"?channelpassword=\" + escape(channelpassword);\n");
|
---|
404 | echo(" }\n");
|
---|
405 | echo(" if (subChannelName != null) { serveraddress = serveraddress + \"?subchannel=\" + escape(subChannelName); }\n");
|
---|
406 | echo(" window.location=serveraddress;\n");
|
---|
407 | echo("}\n");
|
---|
408 | echo("//--></script>\n");
|
---|
409 |
|
---|
410 | $popupInfo = "Server address: " . $settings["serveraddress"] . (($settings["serverudpport"] != 8767) ? (":" . $settings["serverudpport"]): "") . ", Max players: " . $serverInfo["serverinfo"]["server_maxusers"] . ", Uptime: " . $this->_formatTime($serverInfo["serverinfo"]["server_uptime"]);
|
---|
411 |
|
---|
412 | // Print the topmost element of the teamspeak tree
|
---|
413 | echo("<table><tr><td>");
|
---|
414 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/teamspeak_online.png")."\" alt=\"\" title=\"" . $popupInfo . "\">");
|
---|
415 | echo("</td><td class=\"teamspeakserver\" title=\"" . $popupInfo . "\">");
|
---|
416 | echo("<a class=\"teamspeakserver\" href=\"javascript:enterServer_" . $jsTeamspeakId . "();\">");
|
---|
417 | echo(str_replace(" ", " ", $this -> Kodovani($serverInfo["serverinfo"]["server_name"])));
|
---|
418 | echo("</a>");
|
---|
419 | echo("</td></tr></table>\n");
|
---|
420 |
|
---|
421 | // Count the number of channels to be listed:
|
---|
422 | $currentchannels = 0;
|
---|
423 | foreach($serverInfo["channellist"] as $channelInfo) {
|
---|
424 | if ($channelInfo["parent"] == -1) {
|
---|
425 | $currentchannels++;
|
---|
426 | }
|
---|
427 | }
|
---|
428 |
|
---|
429 | // Initialize the channelcounter to zero
|
---|
430 | $counter = 0;
|
---|
431 |
|
---|
432 | // Loop through all channels:
|
---|
433 | foreach($serverInfo["channellist"] as $channelInfo) { if ($channelInfo["parent"] == -1) {
|
---|
434 |
|
---|
435 | // determine number of players in channel
|
---|
436 | $currentplayers = 0;
|
---|
437 | foreach($serverInfo["playerlist"] as $playerInfo) {
|
---|
438 | if($playerInfo["channelid"] == $channelInfo["channelid"]) $currentplayers++;
|
---|
439 | }
|
---|
440 |
|
---|
441 | // Count the number of channels to be listed:
|
---|
442 | $currentplayersandsubchannels = $currentplayers;
|
---|
443 | foreach($serverInfo["channellist"] as $subchannelInfo) {
|
---|
444 | if ($subchannelInfo["parent"] == $channelInfo["channelid"]) {
|
---|
445 | $currentplayersandsubchannels++;
|
---|
446 | }
|
---|
447 | }
|
---|
448 |
|
---|
449 | $popupInfo = "Max players: " . $channelInfo["maxplayers"] . ", Codec: " . $this->_getCodecName($channelInfo["codec"]);
|
---|
450 | if ($channelInfo["topic"] != "") { $popupInfo = $popupInfo . ", Topic: " . $channelInfo["topic"]; }
|
---|
451 |
|
---|
452 | // Display channel:
|
---|
453 | echo("<table><tr><td>");
|
---|
454 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter + 1) == $currentchannels) ? "3" : "2") . ".png")."\" alt=\"\">");
|
---|
455 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/channel.png")."\" alt=\"\" title=\"" . $popupInfo . "\">");
|
---|
456 | echo("</td><td class=\"teamspeakchannel\" title=\"" . $popupInfo . "\">");
|
---|
457 | echo("<a class=\"teamspeakchannel\" href=\"javascript:enterChannel_" . $jsTeamspeakId . "('" . str_replace("'", "\'", $channelInfo["channelname"]) . "', " . (($channelInfo["password"]) == "1" ? "true" : "false") . ");\">");
|
---|
458 | echo(str_replace(" ", " ", $this -> Kodovani($channelInfo["displayname"])));
|
---|
459 | echo("</a>");
|
---|
460 | echo("</td></tr></table>\n");
|
---|
461 |
|
---|
462 | // Initialize the playercounter for this channel to zero
|
---|
463 | $counter_playerandsubchannels = 0;
|
---|
464 |
|
---|
465 | // Loop through all players in the current channel:
|
---|
466 | foreach($serverInfo["playerlist"] as $playerInfo) {
|
---|
467 |
|
---|
468 | // Is the current player in the current channel?
|
---|
469 | if ($playerInfo["channelid"] == $channelInfo["channelid"]) {
|
---|
470 |
|
---|
471 | $popupInfo = "Time online: " . $this->_formatTime($playerInfo["totaltime"]) . ", Time idle: " . $this->_formatTime($playerInfo["idletime"]) . ", Ping: " . $playerInfo["pingtime"] . "ms";
|
---|
472 |
|
---|
473 | // Display player:
|
---|
474 | echo("<table><tr><td>");
|
---|
475 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter + 1) == $currentchannels) ? "4" : "1") . ".png")."\" alt=\"\">");
|
---|
476 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter_playerandsubchannels + 1) == $currentplayersandsubchannels) ? "3" : "2") . ".png")."\" alt=\"\">");
|
---|
477 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/player_" . $playerInfo["displayimage"] . ".png")."\" alt=\"" . $playerInfo["displayimage"] . "\" title=\"" . $popupInfo . "\">");
|
---|
478 | echo("</td><td class=\"teamspeakplayer\" title=\"" . $popupInfo . "\">");
|
---|
479 | echo(str_replace(" ", " ", $this -> Kodovani($playerInfo["displayname"])));
|
---|
480 | echo("</td></tr></table>\n");
|
---|
481 |
|
---|
482 | // Increase the player counter:
|
---|
483 | $counter_playerandsubchannels++;
|
---|
484 | }
|
---|
485 | }
|
---|
486 |
|
---|
487 | // Loop through all channels:
|
---|
488 | foreach($serverInfo["channellist"] as $subchannelInfo) { if ($subchannelInfo["parent"] == $channelInfo["channelid"]) {
|
---|
489 | // determine number of players in channel
|
---|
490 | $currentplayers = 0;
|
---|
491 | foreach($serverInfo["playerlist"] as $playerInfo) {
|
---|
492 | if($playerInfo["channelid"] == $subchannelInfo["channelid"]) $currentplayers++;
|
---|
493 | }
|
---|
494 |
|
---|
495 | $popupInfo = "Max players: " . $subchannelInfo["maxplayers"] . ", Codec: " . $this->_getCodecName($subchannelInfo["codec"]);
|
---|
496 | if ($subchannelInfo["topic"] != "") { $popupInfo = $popupInfo . ", Topic: " . $subchannelInfo["topic"]; }
|
---|
497 |
|
---|
498 | // Display channel:
|
---|
499 | echo("<table><tr><td>");
|
---|
500 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter + 1) == $currentchannels) ? "4" : "1") . ".png")."\" alt=\"\">");
|
---|
501 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter_playerandsubchannels + 1) == $currentplayersandsubchannels) ? "3" : "2") . ".png")."\" alt=\"\">");
|
---|
502 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/channel.png")."\" alt=\"\" title=\"" . $popupInfo . "\">");
|
---|
503 | echo("</td><td class=\"teamspeaksubchannel\" title=\"" . $popupInfo . "\">");
|
---|
504 | echo("<a class=\"teamspeaksubchannel\" href=\"javascript:enterSubChannel_" . $jsTeamspeakId . "('" . str_replace("'", "\'", $channelInfo["channelname"]) . "', " . (($channelInfo["password"]) == "1" ? "true" : "false") . ", '" . str_replace("'", "\'", $subchannelInfo["channelname"]) . "');\">");
|
---|
505 | echo(str_replace(" ", " ", $this -> Kodovani($subchannelInfo["displayname"])));
|
---|
506 | echo("</a>");
|
---|
507 | echo("</td></tr></table>\n");
|
---|
508 |
|
---|
509 | // Initialize the playercounter for this channel to zero
|
---|
510 | $counter_player = 0;
|
---|
511 |
|
---|
512 | // Loop through all players in the current channel:
|
---|
513 | foreach($serverInfo["playerlist"] as $playerInfo) {
|
---|
514 |
|
---|
515 | // Is the current player in the current channel?
|
---|
516 | if ($playerInfo["channelid"] == $subchannelInfo["channelid"]) {
|
---|
517 |
|
---|
518 | $popupInfo = "Time online: " . $this->_formatTime($playerInfo["totaltime"]) . ", Time idle: " . $this->_formatTime($playerInfo["idletime"]) . ", Ping: " . $playerInfo["pingtime"] . "ms";
|
---|
519 |
|
---|
520 | // Display player:
|
---|
521 | echo("<table><tr><td>");
|
---|
522 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter + 1) == $currentchannels) ? "4" : "1") . ".png")."\" alt=\"\">");
|
---|
523 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter_playerandsubchannels + 1) == $currentplayersandsubchannels) ? "4" : "1") . ".png")."\" alt=\"\">");
|
---|
524 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/treeimage" . ((($counter_player + 1) == $currentplayers) ? "3" : "2") . ".png")."\" alt=\"\">");
|
---|
525 | echo("<img src=\"".$html->Link("/inc/teamspeakdisplay/player_" . $playerInfo["displayimage"] . ".png")."\" alt=\"" . $playerInfo["displayimage"] . "\" title=\"" . $popupInfo . "\">");
|
---|
526 | echo("</td><td class=\"teamspeakplayer\" title=\"" . $popupInfo . "\">");
|
---|
527 | echo(str_replace(" ", " ", $this -> Kodovani($playerInfo["displayname"])));
|
---|
528 | echo("</td></tr></table>\n");
|
---|
529 |
|
---|
530 | // Increase the player counter:
|
---|
531 | $counter_player++;
|
---|
532 | }
|
---|
533 | }
|
---|
534 |
|
---|
535 | // Increase the channelcounter
|
---|
536 | $counter_playerandsubchannels++;
|
---|
537 | } }
|
---|
538 |
|
---|
539 | // Increase the channelcounter
|
---|
540 | $counter++;
|
---|
541 | } }
|
---|
542 | }
|
---|
543 | echo("</div>\n");
|
---|
544 | }
|
---|
545 |
|
---|
546 | function displayTeamspeak($serverAddress, $serverUDPPort=8767, $serverQueryPort=51234) {
|
---|
547 | $settings = $this->getDefaultSettings();
|
---|
548 | $settings["serveraddress"] = $serverAddress;
|
---|
549 | $settings["serverudpport"] = $serverUDPPort;
|
---|
550 | $settings["serverqueryport"] = $serverQueryPort;
|
---|
551 | $this->displayTeamspeakEx($settings);
|
---|
552 | }
|
---|
553 |
|
---|
554 | }
|
---|
555 |
|
---|
556 | // Create an instance of the Teamspeak Display Class
|
---|
557 | $teamspeakDisplay = new teamspeakDisplayClass;
|
---|
558 |
|
---|
559 | ?>
|
---|