You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 339 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - TeamSpeak Block [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
CaptDD
Corporal
Corporal


Joined: Jan 02, 2005
Posts: 51

Location: Manistee, MI, USA

PostPosted: Mon Feb 21, 2005 1:32 pm Reply with quoteBack to top

DeathToMe asked if anyone figured out how to post two teamspeak server blocks. I have been able to modify the code to allow a single block to show the status of two servers including individual log in's. Here is the code.
Code:
<?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-Teamspeak_dual.php                                                */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2004 by jaj (jaj@nukecops.com)          */
/* http://nukecops.com                                             */
/************************************************************************/
/* Cosmetic changes by CaptDD at webmaster@rapidfireclan.com
/* Changed to Show 2 Servers With Logins for each           */
/* http://rapidfireclan.com                                              */
/************************************************************************/



// **** settings - to be edited before first use ****

$serverAddress = "xxx.xxx.xxx.xxx";  // can be ip address or url

$serverQueryPort = 51234;  // default 51234, must be accessible and usable. check server.ini

$serverUDPPort = 8767;  // default 8767

$serverAddress1 = "xxx.xxx.xxx.xxx";  // can be ip address or url

$serverQueryPort1 = 51234;  // default 51234, must be accessible and usable. check server.ini

$serverUDPPort1 = 8768;  // 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 &quot;OK&quot; 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 .= "#1 TeamSpeak Server"; //Name Of Your  First Server
$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\"> NICKNAME--Registered Users";
$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 + '?loginname=' + testform.LOGINNAME.value + '?password=' + testform.PASSWORD.value;\"></center>";
$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>"
 ."";
// *****Server # 2******


// MAIN PROGRAM START

// establish connection to teamspeak server
$socket = getSocket($serverAddress1, $serverQueryPort1, $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 8768
sendQuery($socket, "sel ".$serverUDPPort1);

// retrieve answer "OK"
if(!getOK($socket)) {
   die("Server didn't answer &quot;OK&quot; 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 .= "#2 TeamSpeak Server";
$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=\"testform1\">";
$content .= "<input type=\"text\" name=\"NICKNAME\"> NICKNAME";
$content .= "<br>";
$content .= "<input type=\"text\" name=\"LOGINNAME\"> LOGIN NAME";
$content .= "<br>";
//$content .= "<input type=\"text\" name=\"PASSWORD\"> PASSWORD--Registered Users";
//$content .= "<br>";
$content .= "<input type=\"button\" value=\"-->Submit<--\" onClick=\"location.href='teamspeak://$serverAddress $serverUDPPortnickname=' + testform1.NICKNAME.value + '?loginname=' + testform1.LOGINNAME.value;\"></center>";//* add if using password after LOGINNAME.value before ;  *//  + '?password=' + testform1.PASSWORD.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>"
 ."";






?>


You will need to edit the top section with your server information and can also edit the server names at lines 215 and 369.

You can also view and download the block from my site http://www.rapidfireclan.com. No registration required.

_________________
Image
Find all posts by CaptDDView user's profileSend private messageVisit poster's websiteAIM AddressMSN Messenger
CaptDD
Corporal
Corporal


Joined: Jan 02, 2005
Posts: 51

Location: Manistee, MI, USA

PostPosted: Fri Feb 25, 2005 8:17 am Reply with quoteBack to top

I found an error in the code made available from JWP1987. I was having problems with his block not posting data to the database. Below are the two lines of corrected code.
Line 141
Code:
$db->sql_query("INSERT INTO ts_user (pl_id, pl_channelid, pl_pktssend, pl_bytessend, pl_pktsrecv, pl_bytesrecv, pl_pktloss, pl_ping, pl_logintime , pl_idletime, pl_channelprivileges, pl_playerprivileges, pl_playerflags, pl_ipaddress, pl_nickname, pl_loginname) VALUES ('$pl_id', '$pl_channelid', '$pl_pktssend', '$pl_bytessend', '$pl_pktsrecv', '$pl_bytesrecv', '$pl_pktloss', '$pl_ping', '$pl_logintime', '$pl_idletime', '$pl_channelprivileges', '$pl_playerprivileges', '$pl_playerflags', '$pl_ipaddress', '$pl_nickname', ' $pl_loginname')");

Line 164
Code:
$db->sql_query("INSERT INTO ts_channel (channel_id, cl_codec, cl_parent, cl_order, cl_maxuser, cl_name, cl_flags, cl_private, cl_topic) VALUES ('$channel_id', '$cl_codec', '$cl_parent', '$cl_order', '$cl_maxuser', '$cl_name', '$cl_flags', '$cl_private', '$cl_topic')");

The block still does not work correctly but is closer. It now shows the channel and user information. However it only shows the correct number of channels and users. It does not show the channel names, user names or correct permissions.
If someone else can help to get the rest of the code corrected it would be much appreciated.

_________________
Image
Find all posts by CaptDDView user's profileSend private messageVisit poster's websiteAIM AddressMSN Messenger
CaptDD
Corporal
Corporal


Joined: Jan 02, 2005
Posts: 51

Location: Manistee, MI, USA

PostPosted: Fri Feb 25, 2005 1:09 pm Reply with quoteBack to top

FINALLY,

I have JWP1987's block and module working. It is viewable on my site http://www.rapidfireclan.com. The files can be downloaded from my site at http://www.rapidfireclan.com/modules.php?name=Downloads&d_op=getit&lid=13

Enjoy

_________________
Image
Find all posts by CaptDDView user's profileSend private messageVisit poster's websiteAIM AddressMSN Messenger
Krusher
Nuke Cadet
Nuke Cadet


Joined: Mar 05, 2005
Posts: 3


PostPosted: Sat Mar 05, 2005 5:33 pm Reply with quoteBack to top

yepp


Last edited by Krusher on Sat Mar 05, 2005 6:10 pm; edited 2 times in total
Find all posts by KrusherView user's profileSend private messageVisit poster's website
Krusher
Nuke Cadet
Nuke Cadet


Joined: Mar 05, 2005
Posts: 3


PostPosted: Sat Mar 05, 2005 5:34 pm Reply with quoteBack to top

There it is - Two guarenteed working servers in one block -- Yes it is an edit - Check it out at http://www.us-tactical.com.. If anyone would like the block - e-mail me at pmore66@us-tactical.com ..
Find all posts by KrusherView user's profileSend private messageVisit poster's website
Krusher
Nuke Cadet
Nuke Cadet


Joined: Mar 05, 2005
Posts: 3


PostPosted: Sun Mar 06, 2005 11:42 am Reply with quoteBack to top

I forgot to add that by adding servers to the block, make sure the very first server is the one that goes down the least - Reason is that if the primary server goes down, the other servers on the block goes down - So far i've been sucessfull in adding 3 servers to one block.
Find all posts by KrusherView user's profileSend private messageVisit poster's website
indebt
Nuke Cadet
Nuke Cadet


Joined: May 08, 2005
Posts: 1

Location: Vassar, MI

PostPosted: Sun May 08, 2005 9:27 am Reply with quoteBack to top

CaptDD wrote:
FINALLY,

I have JWP1987's block and module working. It is viewable on my site http://www.rapidfireclan.com. The files can be downloaded from my site at http://www.rapidfireclan.com/modules.php?name=Downloads&d_op=getit&lid=13

Enjoy


The download there is not the same as what JWP1987 posted. I to am having problems with the tcpqueryport error. I do see on your website that it is working.

And in the earler post above you mention about the database queries but I dont see any difference in the ones that you posted and the ones in the original file. -edit- duh! I really should learn to read! Please ignore this.

Can you either post your code for the block you are using or post what you did to get it to work?

TIA
Find all posts by indebtView user's profileSend private messageVisit poster's website
CaptDD
Corporal
Corporal


Joined: Jan 02, 2005
Posts: 51

Location: Manistee, MI, USA

PostPosted: Mon May 09, 2005 3:52 pm Reply with quoteBack to top

The biggest issue getting the block to work beyond the tcpqueryport error is making sure you edit the code to the correct TCP Query Port for your TS Server. If you host it yourself it is listed in the server.ini file. You need to be sure the port is open in your router if you use one. If you do not host it yourself you need to check with your host as to the port they have open for TCP Queries.

Be sure that you have followed the instructions carefully, I forgot to include them with my original zip file, they are there now. To be sure that the DB scrips are working properly check the to MySql tables for data.

Hope this helps

_________________
Image
Find all posts by CaptDDView user's profileSend private messageVisit poster's websiteAIM AddressMSN Messenger
Dice101
Nuke Cadet
Nuke Cadet


Joined: Nov 13, 2005
Posts: 1


PostPosted: Mon Nov 14, 2005 11:12 am Reply with quoteBack to top

Hey guys well i seem to be having a problem. I copyed the script on Page 1 on this thread and when i go to the blocks and add it, it says this

''Fatal error: Call to undefined function: getusrinfo() in /usr/export/www/hosting/mysitename/Includes/blocks/block_teamspeak.php on line 19.'' Does anybody have a clue of what that means? Thanks.
Find all posts by Dice101View user's profileSend private message
SDA_Marksman
Nuke Cadet
Nuke Cadet


Joined: Nov 23, 2005
Posts: 5


PostPosted: Thu Nov 24, 2005 8:23 am Reply with quoteBack to top

all these TS blocks are great, however everyone has skirted around the issue of 'What if your server has a server password?'

What do we do if the server has a password please?!
Find all posts by SDA_MarksmanView user's profileSend private message
CaptDD
Corporal
Corporal


Joined: Jan 02, 2005
Posts: 51

Location: Manistee, MI, USA

PostPosted: Thu Nov 24, 2005 3:07 pm Reply with quoteBack to top

Hello,

Due to a contact made by a viewer of these posts, I have become aware that my links don't work as my previous clan folded.

Here is the link for the Teamspeak Block and Module
http://www.captdd.com/DD/Teamspeak-block-module.zip




@ SDA_Marksman - The TS block pulls the data from a query port of the TS Server. Passwords do not affect the blocks performance only players ability to log in via the block.

_________________
Image
Find all posts by CaptDDView user's profileSend private messageVisit poster's websiteAIM AddressMSN Messenger
ssace
Lieutenant
Lieutenant


Joined: Dec 29, 2005
Posts: 175


PostPosted: Sun Jan 29, 2006 12:45 pm Reply with quoteBack to top

I tried the code at the top but it only served as a login point. the block had fields to enter nickname, username & password.

I need a block or module that will allow me to show 2 TS servers in the same block with channels that can be joined by clicking on the channel. I have found a block that works well with webpost but it can only show 1 server.
Find all posts by ssaceView user's profileSend private message
-Javier-
Nuke Cadet
Nuke Cadet


Joined: Nov 17, 2004
Posts: 5


PostPosted: Wed Jul 04, 2007 7:50 pm Reply with quoteBack to top

I have this block working in my web but now the TS server has password, How can I modify this script to allow connect to a server with password?

(sorry my english, it's not my native lenguage).
Find all posts by -Javier-View user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
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



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.054 Seconds - 228 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::