- Readme First! - Read and follow the rules, otherwise your posts will be closed
There are currently, 55 guest(s) and 2 member(s) that are online. You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Teamspeak Block [ ]
Author
Message
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Sun Oct 03, 2004 4:59 am
Hello,
How can i put a block on my site that shows if my ts is online wich people
are on it and in wich channel or something can somebody tell me how to add it?
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Sun Oct 03, 2004 5:15 am
jaj
Corporal
Joined: Feb 25, 2004
Posts: 56
Posted:
Sun Oct 03, 2004 6:08 am
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Sun Oct 03, 2004 7:40 am
yeah exactly like that only i want it in a small block in the right side how to make it like that?
_________________[b]www.web-corner.net[/b]
jaj
Corporal
Joined: Feb 25, 2004
Posts: 56
Posted:
Sun Oct 03, 2004 4:42 pm
This is a simple Teamspeak block with a few added features....Now you may have an issue with placing the block on the right... It will work fine but if a client joins with a long name then block will be streched to fit... Other wise you will be fine...
Just copy this code and paste it into your favorite text editor and save it as block-Teamspeak.php then just activate it.... any issues let me know.....
Code:
<?php
// **** settings - to be edited before first use ****
$serverAddress = "xx.xxx.xx.xxx"; // 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-Teamspeak.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();
do {
$playerinfo = fscanf($socket, "%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $playername);
}
} while($playerid != "OK");
// 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\"></td><td colspan=\"1 \">".$channelname." </td></tr>";
}
$counter++;
foreach ($playerList as $playerInfo) {
if ($channelInfo[channelid] == $playerInfo[channelid]) {
$content .= "<tr><td></td><td colspan=0><img src=\"images/bullet_0.gif\" border=\"0\" align=left>".$playerInfo[playername]."</td></tr>\n";
}
}
}
if($counter == 0) $content .= "<tr><td colspan=\"4\" align=\"CENTER\">No channels</td></tr>\n";
$content .= "</table>\n";
// close connection to teamspeak server
closeSocket($socket);
$content .= "<form name=\"testform\">";
$content .= "<input type=\"text\" name=\"NICKNAME\" size=\"19\" > ";
$content .= "NICKNAME";
$content .= "<br>";
//$content .= "<input type=\"text\" name=\"LOGINNAME\"> LOGIN NAME--For Registered Users";
$content .= "<br>";
//$content .= "<input type=\"text\" name=\"PASSWORD\"> PASSWORD--Registered Users";
//$content .= "<br>";
$content .= "<input type=\"button\" value=\"-->Submit<--\" onClick=\"location.href='teamspeak://$serverAddress: $serverUDPPort/nickname=' + testform.NICKNAME.value \">";
$content .= "<br>";
$content .= "</form>";
$content .="<center><a href=\"http://www.goteamspeak.com\"><img src=\"https://sales.tritoncia.com/images/link_to_teamspeak.gif\" border=\"0\" alt=\"Go to Teamspeak.com\"></a></center>"
."";
?>
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Sun Oct 03, 2004 10:32 pm
im sorry i know it sounds stupid can you tell me exactly what to do cause
i need to upload then i need to activate it i dunno how
_________________[b]www.web-corner.net[/b]
jaj
Corporal
Joined: Feb 25, 2004
Posts: 56
Posted:
Mon Oct 04, 2004 3:11 am
if you can give me your Teamspeak ip and the query port that you use I will edit the code and put it in the block file for you and email it to you...
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Mon Oct 04, 2004 7:33 am
DCW_MadMax
Corporal
Joined: Mar 20, 2004
Posts: 60
Posted:
Mon Oct 04, 2004 12:17 pm
Hello.
I have been trying to add a second TS block on my site but keep comming up with errors, is it possible to add the second TS block, if so how.
Thankyou.
_________________dcwarriors.com online gaming community
jaj
Corporal
Joined: Feb 25, 2004
Posts: 56
Posted:
Mon Oct 04, 2004 1:42 pm
Raver wrote:
ok great thnx
IP: 81.205.200.79 port: 8767
server password: server
I also need the query port.... ask your TS provider what the query port # is... that is necassary in order for the block to work..
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Mon Oct 04, 2004 10:10 pm
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Mon Oct 04, 2004 10:11 pm
jaj
Corporal
Joined: Feb 25, 2004
Posts: 56
Posted:
Tue Oct 05, 2004 12:42 pm
Now you need to open that port on the server that hosts your TS...to allow the script access, to query your TS server..
Raver
Private
Joined: Oct 03, 2004
Posts: 36
Posted:
Wed Oct 06, 2004 10:56 am
jaj
Corporal
Joined: Feb 25, 2004
Posts: 56
Posted:
Wed Oct 06, 2004 12:39 pm
What operating system is the server running on?
Goto page 1 , 2 , 3 , 4 Next
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum