An error connecting to the TeamSpeak server has occured!
Error number:
Error description:
I have made a file called: block-TeamSpeak2.php
Added the block whit this code:
Code:
<?php
// **** settings - to be edited before first use ****
$serverAddress = "82.136.20.53"; // can be ip address or url
$serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
$serverUDPPort = 8767; // default 8767
// **** end of settings ****
if (eregi("block-Teamspeak2.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!
\n";
$content .= "Error number: ".$errno."
\n";
$content .= "Error description: ".$errstr."
\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
$counter = 0;
foreach($channelList as $channelInfo) {
// default channel?
if($channelInfo[isdefault] == 1) {
$channelname = $channelInfo[channelname];
} else {
$channelname = $channelInfo[channelname];
}
if ($channelInfo[currentplayers] > 0) {
$content .= "<img src=\"images/ts_channel.gif\" border=\"0\"> ".$channelname."
";
}
$counter++;
foreach ($playerList as $playerInfo) {
if ($channelInfo[channelid] == $playerInfo[channelid]) {
$content .= "<img src=\"images/ts_user.gif\" border=\"0\"> ".$playerInfo[playername]."
\n";
}
}
}
if($counter == 0) $content .= "No channels\n";
// close connection to teamspeak server
closeSocket($socket);
$content .= "<form name=\"testform\">";
$content .= "
";
$content .= "<input type=\"text\" name=\"NICKNAME\"> Nickname";
$content .= "
";
$content .= "<input type=\"text\" name=\"LOGINNAME\"> Login Name";
$content .= "
";
$content .= "<input type=\"text\" name=\"PASSWORD\"> Password";
$content .= "
";
$content .= "
";
$content .= "<center><input type=\"button\" value=\"Connect\" onClick=\"location.href='teamspeak://$serverAddress: $serverUDPPort/nickname=' + testform.NICKNAME.value + '?loginname=' + testform.LOGINNAME.value + '?password=' + testform.PASSWORD.value;\"></center>";
$content .= "
";
$content .= "</form>";
?>
I have edited the top
Code:
$serverAddress = "82.136.20.53"; // can be ip address or url
$serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
$serverUDPPort = 8767; // default 8767
so its suits oure connections.. still i get the error showed on start of this tread :(
Anyone??
Of someone got any other TS2 block, feel fre to post it here :D