Posted on: 04/02/04 12:25am
By: kermit
Posted on: 04/02/04 12:37am
By: Blaine
Posted on: 04/02/04 12:44am
By: kermit
Posted on: 04/02/04 01:06am
By: kermit
Posted on: 04/02/04 01:53am
By: kermit
Posted on: 04/02/04 08:34am
By: Turias
Posted on: 02/11/05 10:50pm
By: Anonymous (Bob)
<?php /************************************************************************/ /* PHP-NUKE: Web Portal System */ /* =========================== */ /* */ /* Copyright (c) 2002 by Francisco Burzi (fbc@mandrakesoft.com) */ /* http://phpnuke.org */ /* */ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License. */ /************************************************************************/ /************************************************************************/ /* block-Teamspeak3.php */ /* =========================== */ /* */ /* Copyright (c) 2004 by jaj (jaj@nukecops.com) */ /* http://nukecops.com */ /************************************************************************/ /* Cosmetic changes by CaptDD at webmaster@rapidfireclan.com */ /* http://rapidfireclan.com */ /************************************************************************/ /* Additional Cosmetic changes by Aleister at admin@dcwclan.com */ /* http://www.dcwclan.com */ /************************************************************************/ // **** settings - to be edited before first use **** $serverAddress = "69.30.192.149:25"; // can be ip address or url $serverQueryPort = 14534; // default 51234, must be accessible and usable. check server.ini $serverUDPPort = 8767; // default 8767 // **** end of settings **** if (eregi("block-Teamspeak3.php", $PHP_SELF)) { Header("Location: index.php"); die(); } global $user, $cookie; getusrinfo($user); cookiedecode($user); $username = $cookie[1]; // opens a connection to the teamspeak server function getSocket($host, $port, $errno, $errstr, $timeout) { global $errno, $errstr; @$socket = fsockopen($host, $port, $errno, $errstr, $timeout); if($socket and fread($socket, 4) == "[TS]") { fgets($socket, 128); return $socket; }// end if return false; }// end function getSocket(...) // sends a query to the teamspeak server function sendQuery($socket, $query) { fputs($socket, $query."\n"); } // answer OK? function getOK($socket) { $result = fread($socket, 2); fgets($socket, 128); return($result == "OK"); } // closes the connection to the teamspeak server function closeSocket($socket) { fputs($socket, "quit"); fclose($socket); } // 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; } } // 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 ""; } } // MAIN PROGRAM START // establish connection to teamspeak server $socket = getSocket($serverAddress, $serverQueryPort, $errno, $errstr, 3); if($socket == false) { $content .= "An error connecting to the TeamSpeak server has occured!<br>\n"; $content .= "Error number: ".$errno."<br>\n"; $content .= "Error description: ".$errstr."<br>\n"; return; } // select the one and only running server on port 8767 sendQuery($socket, "sel ".$serverUDPPort); // retrieve answer "OK" if(!getOK($socket)) { die("Server didn't answer "OK" after last command. Aborting."); }// end if // retrieve player list sendQuery($socket,"pl"); // read player info $playerList = array(); //Skip the first line. It only contains header labels fgets($socket); while (true) { //Read the next line from the socket $line = fgets($socket); //Break it up on the tab delimiter $playerinfo = explode("\t", $line); //Bail out if only one element if (count($playerinfo) == 1) { //Only one element means the OK has been encountered. //The list is done. break; } //Stuff the array values into variables list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername) = $playerinfo; $playerList[$playerid] = array("playerid" => $playerid, "channelid" => $channelid, "receivedpackets" => $receivedpackets, "receivedbytes" => $receivedbytes, "sentpackets" => $sentpackets, "sentbytes" => $sentbytes, "totaltime" => $totaltime, "idletime" => $idletime, "playername" => str_replace("\"", "", $playername)); } // retrieve channel list sendQuery($socket,"cl"); // read channel info $channelList = array(); do { $channelinfo = ""; do { $input = fread($socket, 1); if($input != "\n" && $input != "\r") $channelinfo .= $input; } while($input != "\n"); $channelid = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $codec = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $parent = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $d = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $maxplayers = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $channelname = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $d = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $d = getNext($channelinfo); $channelinfo = chopNext($channelinfo); $topic = getNext($channelinfo); if($channelid != "OK") { if($isdefault == "Default") $isdefault = 1; else $isdefault = 0; // determine number of players in channel $playercount = 0; foreach($playerList as $playerInfo) { if($playerInfo[channelid] == $channelid) $playercount++; } $channelList[$channelid] = array("channelid" => $channelid, "codec" => $codec, "parent" => $parent, "maxplayers" => $maxplayers, "channelname" => $channelname, "isdefault" => $isdefault, "topic" => $topic, "currentplayers" => $playercount); } } while($channelid != "OK"); // display channel list /*$content .= "<table width=\"100%\">\n";*/ $counter = 0; foreach($channelList as $channelInfo) { // default channel? if($channelInfo[isdefault] == 1) { $channelname = $channelInfo[channelname]; } else { $channelname = $channelInfo[channelname]; } if ($channelInfo[currentplayers] > 0) { /* $content .= "<tr><td><img src=\"images/bullet_channel.gif\" border=\"0\" align=\"left\">".$channelname."</tr></td>\n";*/ $content .= "<font color=\"#FFCC00\"><strong>".$channelname."</strong></font><br>\n"; } $counter++; foreach ($playerList as $playerInfo) { if ($channelInfo[channelid] == $playerInfo[channelid]) { /* $content .= "<tr><td><img src=\"images/bullet_0.gif\" border=\"0\" align=\"left\">".$playerInfo[playername]."</tr></td>\n"; */ $temp_playername = $playerInfo[playername]; if (strlen($temp_playername) > 15) { $temp_playername = substr($temp_playername, 0, 15); $temp_playername .= "..."; } $content .= " - ".$temp_playername."<br>\n"; } } } if($counter == 0) $content .= "No channels<br>\n"; /* $content .= "</table>\n";*/ // close connection to teamspeak server closeSocket($socket); $content .= "<form name=\"testform\">"; $content .= " <input type=\"text\" name=\"NICKNAME\" size=\"12\"> Nick"; $content .= "<br>"; $content .= "<br>"; $content .= " <input type=\"text\" name=\"LOGINNAME\" size=\"12\"> Login"; $content .= "<br>"; $content .= "<br>"; $content .= " <input type=\"text\" name=\"PASSWORD\" size=\"12\"> Pass"; $content .= "<br>"; $content .= "<br>"; $content .= "<center>"; $content .= "<input type=\"button\" value=\"Submit\" onClick=\"location.href='teamspeak://$serverAddress: $serverUDPPort/nickname=' + testform.NICKNAME.value + '?loginname=' + testform.LOGINNAME.value + '?password=' + testform.PASSWORD.value;\"></center>"; $content .= "<br>"; $content .= "</form>"; $content .= "<center>"; $content .="<a href=\"http://www.goteamspeak.com\" target=\"_blank\"><img src=\"graphics/teamspeak.gif\" border=\"0\" align=absmiddle alt=\"Go to goteamspeak.com\"></a></center>" .""; ?>