PDA

View Full Version : Online Display Script


Bigman
06-01-2003, 19:54
Is there any way of creating a small script that works similar to ICQ, i.e when the page or script is activated it checks to see if the ts server is online if it is it displays a small online image (green light) if not then displays a red light, or something similar.



Any help appreciated.

BLIND
07-01-2003, 02:45
I'm sure this can be done with some php script, but what are you trying to use this on? a website I'm guessing? It would be fairly simple script, and I could get our scripter to write one, but right now I'm giving him the job of getting the info of who is online instead of it the server is online, or I might ask another site that I saw that on if I could borrow thiers...blah...blah...blah...

Bigman
07-01-2003, 09:49
I would like it really just for a standard php page really.

Cheers

BLIND
07-01-2003, 16:45
I'll see what we can do, but if anyone else wants to try to do this, go for it.

Brain
12-01-2003, 10:13
i have something for you. it's primitive, but works.
you might need to change some values for your own server, but it should be a good start:


:p


did you notice the biiiig fscanf call? i figured out the first number is the player id and the last string is the player name.
if you figure out the meanings of the other values i'd be happy if you would share that information.

Addict
12-01-2003, 18:03
Nice work on the script. However, it times out for me. I'll keep playing around and see what's up with it.

Brain
12-01-2003, 23:03
1.) the script uses default ports so make sure port 51234 tcp is accessible
2.) the script assumes the teamspeak server is running on the same maching as the webserver. change "localhost" to your teamspeak server's address if necessary
3.) i'm running apache 1.3.27 with php 4.3.0, tss2 and apache run on the same physical machine. the script works for me. see for yourself, i have integrated it into my clan's message board -> http://www.the-rip.de/wbboard

Addict
12-01-2003, 23:11
Yeah i got the timeout fixed.

It errors out on the first sendQuery. Almost like its not finding the right response. I'll keep digging though.

I'm running it on the same server as TS & web. I'm running Win2k Server with IIS. PHP 4.3.0.

Brain
13-01-2003, 12:17
if(getResults($socket) != "OK\n") {

i assume it is this line that causes the timeout. hmmm... windoze you say.... maybe it's another case of line break problems
try OK\r\n instead of OK\n, maybe it helps

or you can just telnet to localhost:51234 and test it yourself :)

Addict
13-01-2003, 13:23
Originally posted by Brain
if(getResults($socket) != "OK\n") {

i assume it is this line that causes the timeout. hmmm... windoze you say.... maybe it's another case of line break problems
try OK\r\n instead of OK\n, maybe it helps

or you can just telnet to localhost:51234 and test it yourself :)

No it wasn't that line timing out. It was the initial connection. Got that fixed.

I'll try the OK\r\n and see if that works. Thanks.

Addict
14-01-2003, 00:57
Got it.

For windows it does have to the \r

Thanks....

direwolf
14-01-2003, 06:10
I get this error on Linux with php 4.2.2

Internal server error! Cause unknown.



// select the one and only running server on port 8767
sendQuery($socket, "sel 8767");
if(getResults($socket) != "OK\n") {
echo("Internal server error! Cause unknown.");
exit;
}// end if



Dont know why

Addict
14-01-2003, 13:45
Originally posted by direwolf
I get this error on Linux with php 4.2.2

Dont know why
Did you try adding the \r? Immediately after the OK.
// select the one and only running server on port 8767
sendQuery($socket, "sel 8767");
if(getResults($socket) != "OK\r\n") {
echo("Internal server error! Cause unknown.");
exit;
}// end if
That's just a generic error as this script has no error handling. Also you may want to switch to PHP 4.3.0.

Brain
14-01-2003, 14:00
php before 4.3.0 needs two parameters in the fgets function. -> http://www.php.net/manual/en/function.fgets.php

i'm using php 4.3.0 on a linux webserver with linux tss2. ymmv.

Bigman
14-01-2003, 15:00
Can someone visit this page and see why im getting this error Cheers

http://bigmanrlfans.dyndns.org/listing.php

Im using IIS and PHP 4.3.0

Brain
14-01-2003, 15:09
maybe because you're using iis?

anyways, $errno and $errstr simply contain error information of fsockopen. since they are not evaluated in the script you can safely omit those parameters.

what i gave you is not a complete solution, it's just something i whipped up in 5 minutes of my free time and it was designed to serve my clan's special needs.

you are free to do whatever you want with it, except claiming it to be your own and suing me for damages.

Bigman
14-01-2003, 15:11
hehe no probs i was wondering whether it was IIS, anyways ill have a muck about.

Cheers

Addict
14-01-2003, 15:11
Originally posted by Bigman
Can someone visit this page and see why im getting this error Cheers

http://bigmanrlfans.dyndns.org/listing.php

Im using IIS and PHP 4.3.0

Be sure that you have that variable defined. $errno is in the very first function. It needs to b global. Just like the script.
function getSocket($host, $port, $errno, $errstr, $timeout) {
global $errno, $errstr;
$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
if(!$socket or fread($socket, 4) != "[TS]") {
echo("Server error: Teamspeak server not running!");
return false;
}// end if
return $socket;


Post up your entire PHP coding for that page. It will help more.

Bigman
14-01-2003, 15:15
All i have changed at the mo is the localhost to my IP bit short of time at the mo so haven;t had time to fully look at it.



<div id="teamspeak">
<?php
// 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 or fread($socket, 4) != "[TS]") {
echo("Server error: Teamspeak server not running!");
return false;
}// end if
return $socket;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// returns the result of the last query
function getResults($socket) {
return fgets($socket);
}// end function getResults(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)


// ---=== main program ===---

// establish connection to teamspeak server
$socket = getSocket("192.168.2.18", 51234, $errno, $errstr, 1);
if($socket == false) exit;

// select the one and only running server on port 8767
sendQuery($socket, "sel 8767");
if(getResults($socket) != "OK\n") {
echo("Internal server error! Cause unknown.");
exit;
}// end if

// retrieve player list
sendQuery($socket,"pl");

echo("<table><thead><th align=\"CENTER\">ID</th><th>&nbsp;</th><th align=\"CENTER\">Name</th></thead>\n");
$counter = 0;
do {
$playerinfo = fscanf ($socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s");
list($number, $d, $d, $d, $d, $d, $d, $d, $d, $d, $d, $d, $d, $s, $name) = $playerinfo;
if($number != "OK") echo("<tr><td align=\"CENTER\">$number</td><td>&nbsp;</td><td align=\"CENTER\">$name</td></tr>\n");
$counter++;
} while($number != "OK");
if($counter == 1) echo("<tr><td colspan=\"3\" align=\"CENTER\">No players on server</td></tr>\n");
echo("</table>\n");

// close connection to teamspeak server
closeSocket($socket);
?>
</div>

Addict
14-01-2003, 15:22
First....
Change
// select the one and only running server on port 8767
sendQuery($socket, "sel 8767");
if(getResults($socket) != "OK\n") {
echo("Internal server error! Cause unknown.");
exit;
}// end if

to
// select the one and only running server on port 8767
sendQuery($socket, "sel 8767");
if(getResults($socket) != "OK\r\n") {
echo("Internal server error! Cause unknown.");
exit;
}// end if


That's a known issue (thanks to my own experience);) .

Are you running the TS server & web server on the same machine? If not, is the port, 51234 open on the TS machine?

Bigman
14-01-2003, 15:26
Cheers thats sorted one bit

http://bigmanrlfans.dyndns.org/listing.php


Just something in here on the bold line. I think one of you mentioned it before.

[php]
// establish connection to teamspeak server
$socket = getSocket("192.168.2.18", 51234, $errno, $errstr, 1);
if($socket == false) exit;

[/php

Addict
14-01-2003, 15:47
Originally posted by Bigman
Cheers thats sorted one bit

http://bigmanrlfans.dyndns.org/listing.php


Just something in here on the bold line. I think one of you mentioned it before.

[php]
// establish connection to teamspeak server
$socket = getSocket("192.168.2.18", 51234, $errno, $errstr, 1);
if($socket == false) exit;

[/php

In your PHP.INI file I believe there is a register_globals section that needs to be turned on for globals to take effect in IIS. I'll look at my server here at work and see exactly what it is.

Bigman
14-01-2003, 16:06
In the PHP.ini file i commented out the following line and it works perferctly now.


error_reporting = E_ALL; display all errors, warnings and notices

cheers

Addict
14-01-2003, 16:10
Originally posted by Bigman
In the PHP.ini file i commented out the following line and it works perferctly now.


error_reporting = E_ALL; display all errors, warnings and notices

cheers

LoL. If you can't fix it, hide it. :D

Bigman
14-01-2003, 16:11
Hehe always the way for me lol

Mobious
15-01-2003, 13:23
Thanks for the script!
I have 2 questions for you..
I have tried this script on 3 different web services.. The first doesnt have Apache running.. and I got the error "Team speak Server not running" I didnt get a hit on my router so I am assuming the script didnt send any thing out.. So I tried it on a Linux server with Apache and PHP running. I got the error "Internal server error! Cause unknown" This server did send packets to my router and reached my TS2 server. I changed the OK/n to OK/r/n and still got the same thing. On the third web server which also had APache and PHP running on Linux I got "Warning: Wrong parameter count for fgets() in /var/www/html/tswebpost.php on line 21
Internal server error! Cause unknown." This server hit my router and TS2 server, here I also tried the Ok/r/n and got the same error.
My TS2 server is running on a WIN2k advanced server. My Router is a Linksys 4port dsl router. I have port 51234 open (TCP) 14534 (TCP and UPD) 9010 (UDP) 8766 (TCP and UDP) and 8767 (TCP and UDP). I have tried setting the TS2 server to the DMZ on the router with out results. I have also tried it with Zone Alarm pro on and off. I just can get it to work right.
My next question..
Is it possible to convert this to ASP?

Thanks for the help and thanks for the script..

Brain
15-01-2003, 13:29
if you use a windoze server you need to replace OK\n by OK\r\n (as addict suggested)

"Warning: Wrong parameter count for fgets() in /var/www/html/tswebpost.php on line 21" is caused by php version < 4.3.0 where fgets needs a second parameter indicating the amount of characters to read. insert 128, maybe it works.

Is it possible to convert this to ASP? - sure, go ahead. you can use my php script as basis if you like.



i'm currently conducting more research into the values returned by cl and pl.

after establishing a connection use this for some useful info:

:p


it's far from complete, current working copy can be viewed on :p

keep in mind i'm still working on the script.

seeing the interest in my online display script i'll make it more adaptable with better error handling in the future. stay tuned :)

Mobious
15-01-2003, 13:42
Thanks for the quick reply..

I did try the ok/r/n on all 3 servers. I am also using No-ip.com for a static ip service.. the server ip is vfa25radio.no-ip.com which no one has problems using to connect.. In the script I have tried that address and what ever my current ip was at the time..

I am just starting to learn ASP.. But I will try to convert it..

Addict
15-01-2003, 13:46
Originally posted by Mobious
Thanks for the script!
I have 2 questions for you..
I have tried this script on 3 different web services.. The first doesnt have Apache running.. and I got the error "Team speak Server not running" I didnt get a hit on my router so I am assuming the script didnt send any thing out.. So I tried it on a Linux server with Apache and PHP running. I got the error "Internal server error! Cause unknown" This server did send packets to my router and reached my TS2 server. I changed the OK/n to OK/r/n and still got the same thing. On the third web server which also had APache and PHP running on Linux I got "Warning: Wrong parameter count for fgets() in /var/www/html/tswebpost.php on line 21
Internal server error! Cause unknown." This server hit my router and TS2 server, here I also tried the Ok/r/n and got the same error.
My TS2 server is running on a WIN2k advanced server. My Router is a Linksys 4port dsl router. I have port 51234 open (TCP) 14534 (TCP and UPD) 9010 (UDP) 8766 (TCP and UDP) and 8767 (TCP and UDP). I have tried setting the TS2 server to the DMZ on the router with out results. I have also tried it with Zone Alarm pro on and off. I just can get it to work right.
My next question..
Is it possible to convert this to ASP?

Thanks for the help and thanks for the script..

Are you wanting to run it on IIS? That's the best choice if you have a windows machine you are going to use. What version of PHP do you have installed? Are you running TS & the web server on the same machine?

If the web server & TS reside on the same machine, there is no need to open port 51234. Port 8767 should only be open as UDP. TS does not need TCP on this port.

ASP? Sure. Its a fairly straightforward script and I'm sure you can port it. I don't know enough of ASP yet to do that (nor would I have a reason to).

I suggest you run IIS5 with PHP 4.3.0 to make this work. Are you having issues with any other PHP pages?

Mobious
15-01-2003, 15:40
I havent tried running it locally yet.. And really dont want to unless I really have to.. I havent tried anyother PHP on my local server..Because I dont have it installed.. Can I DL it from some place?

The first service that I tried has IIS5 and PHP 4.3.0 but it didnt even send a request to my router.. The error I got from that web service was that no TS server was running. Again.. I tried the OK/r/n

As far as the other 2 web services I tried, I know they are on Linux boxes but dont know what version of PHP they run.

Here is the script I tried..

<div id="teamspeak">
<?php
// 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 or fread($socket, 4) != "[TS]") {
echo("Server error: Teamspeak server not running!");
return false;
}// end if
return $socket;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// returns the result of the last query
function getResults($socket) {
return fgets($socket);
}// end function getResults(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)


// ---=== main program ===---

// establish connection to teamspeak server
$socket = getSocket("vfa25radio.no-ip.com", 51234, $errno, $errstr, 1);
if($socket == false) exit;

// select the one and only running server on port 8767
sendQuery($socket, "sel 8767");
if(getResults($socket) != "OK\r\n") {
echo("Internal server error! Cause unknown.");
exit;
}// end if

// retrieve player list
sendQuery($socket,"pl");

echo("<table><thead><th align=\"CENTER\">ID</th><th>&nbsp;</th><th align=\"CENTER\">Name</th></thead>\n");
$counter = 0;
do {
$playerinfo = fscanf ($socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s");
list($number, $d, $d, $d, $d, $d, $d, $d, $d, $d, $d, $d, $d, $s, $name) = $playerinfo;
if($number != "OK") echo("<tr><td align=\"CENTER\">$number</td><td>&nbsp;</td><td align=\"CENTER\">$name</td></tr>\n");
$counter++;
} while($number != "OK");
if($counter == 1) echo("<tr><td colspan=\"3\" align=\"CENTER\">No players on server</td></tr>\n");
echo("</table>\n");

// close connection to teamspeak server
closeSocket($socket);
?>
</div>

Where vfa25radio.no-ip.com is I also tried a literal IP (68.xxx.xxx.xxx) address and got the same results.

Ok.. one last question.. Since Im new to PHP.. I dont have a php editor.. So I used notepad.. I heard it was ok to do that.. Is that true?

Thanks again..

Brain
15-01-2003, 16:42
the newest snapshot of ts2info can be found on :p

i've adjusted some things. first, better error handling (you get to see the php error messages), second it works with php 4.2.3 as well, and third it might work with windoze servers without editing now.

mobious: can you please describe your server setup? i can help you better when i know your physical setup as well as the software.

Mobious
15-01-2003, 17:00
Sure..

TS2 server :
AMD T-Bird 1.2 ghz
1gig ram
Windows 2000 Advanced server (Hasnt been patched)
TS2 2.0.18.31

Linksys dsl router:
Open ports
51234 and the other TS2 ports needed not at home right now to check.. The server works fine..

1st Web server from webhost4life.com
http://www.webhost4life.com/hosting.asp
Go there to and look at the advanced plan.

2nd Webserver
http://www.vfa-25.com/php.php
that is the second server config.. and I just noticed it is version 4.2.2

crap.. haha Not sure what version of PHP is on webhost4life.. I sent of a request to find out..
But the query works on webhost4life it just isnt sending anything to my ts2 server..

Brain
15-01-2003, 17:03
i c... you mentioned you're not at home right now... have you tried telnetting to your ts2 server's query port from outside? does it work or do you get "connection refused"?

Mobious
15-01-2003, 17:12
I was able to connect on port 51234

Addict
15-01-2003, 17:21
My first advice is to try it locally.
www.php.net - download the PHP 4.3.0. don't use the installer. just get the zip package and read the readme file.

I can help you with the PHP install on IIS. Once you can connect locally, then we can look at other issues. Its likely that your hosts are not using PHP 4.3.0. You may want to try Brain's new version that he posted as it works on older PHP installs.

btw. Brain I see this developing into a huge script. Great work. I'll be more than happy to help you test it on Windows platforms since you seem to be a linux person.;)

Mobious
15-01-2003, 17:29
ok.. I tried the new script and here is the error I got..

An error connecting to the TeamSpeak server has occured!
Error number: 9
Error description: Bad file descriptor

Please check your server and firewall settings


I was able to telenet to port 51234 but not 8767.. should I be able to?

Addict
15-01-2003, 17:38
Originally posted by Mobious

I was able to telenet to port 51234 but not 8767.. should I be able to?
no

Mobious
15-01-2003, 17:46
I GOT IT! woohoo!

Thanks for the new script.. I put it on our squads webserver that is running linux and php4.2.2 and it works!!!

Thanks for the help guys!

Addict
15-01-2003, 18:55
Originally posted by Mobious
I GOT IT! woohoo!

Thanks for the new script.. I put it on our squads webserver that is running linux and php4.2.2 and it works!!!

Thanks for the help guys!

Glad it worked for you.

Mobious
15-01-2003, 19:37
Just a side note..
The server that it works on is a linux server.. The other server I tried it on was a Windows 2k server, it didnt work on that one.. Both servers are running PHP 4.2.2

Brain
15-01-2003, 22:18
i'm glad it works for you now mobious and thank you for your help addict.

i'm still working on the script, there's a lot of stuff i didn't figure out and without proper documentation it's a bit tedious, but manageable.

i always write the last edit date and time to the header of the script. if you want to know if there's a new version just compare the snapshot date/time with the date/time in your version.

An error connecting to the TeamSpeak server has occured!
Error number: 9
Error description: Bad file descriptor

Please check your server and firewall settings

this error message is caused by a bad $serverAddress setting imo. $serverAddress should be a computer name in your LAN (like "localhost" which is always the computer where the script is running), an ip address like "127.0.0.1", which is the same as "localhost" or an url like "www.cool-clan.com". if you give an url don't specify http:// or ftp:// or something. also sometimes you might want to omit the www and just insert the domain name, "cool-clan.com" according to the example.

Addict
16-01-2003, 01:25
Just to let you know, the new version works great. No problems so far.... :D

Bigman
19-01-2003, 23:46
How would i go about making the tables wider when i display the player list. Ive tried using width but nothing seems to happen.

http://bigmanrlfans.dyndns.org/test/test.php

Addict
19-01-2003, 23:54
Originally posted by Bigman
How would i go about making the tables wider when i display the player list. Ive tried using width but nothing seems to happen.

http://bigmanrlfans.dyndns.org/test/test.php

It looks like you're defining width by %. Try using actual pixels instead.
Instead of
<td align="left" width=40%>
Use
<td align="left" width="40">

Or whatever you want the width to be.

direwolf
20-01-2003, 08:49
No don't do that!!

% is the way to go. You just need to make sure you have your table set to 100% (if you want it to take up the whole browser) then make sure you specify % widths for <b>all<b> your table columns. Also make sure the total of all the percentages add up to 100 %

i.e.


<table width=100%>
<td width 30%>name</td>
<td width 30%>something else</td>
<td width 40%>last column</td>
</table>

Brain
20-01-2003, 09:30
as you can see in the script i don't supply any parameters to < table > in my script. just edit to change it to < table border="1" width="80%" bordercolordark="black" bordercolor="black" cellpadding="5" cellspacing="0" > or whatever you like.

note: you need to escape quotes with \" for the echo function.

Undertaker_SRS
09-02-2003, 13:18
Hi, well the script works great, after a few adjustments, we got it going perfectly, i do have one question though, we have linked this script to a image, and if anyone presses this image, the TS server will start stragiht away and log them on (as a guest), is there any way of modifying this so that the user is asked to add a nickname first ?, and them it logs on automaticly, with the given nickname ?


Thanxs

Brain
09-02-2003, 13:41
i have thought about a way to do that, but not actually tested it. as you know you can start the local teamspeak server with a special link. i'd simply use a php script that collects username, channel, whatever and produces a redirect to that special url with username and everything set.

example:

// make sure there's no output before this or you will get an error
if($user_name) {
header("Location: teamspeak://your-server:8767/?nickname=".$user_name);
} else {
// ... build html form here that asks for username and other data
}// end if


theoretically it should work, practically... don't know.

Madhouse
12-02-2003, 21:30
I did something a little differnt with this script...I took this script and modified the php version of webpost. Its not the best in the world but I did not want all the info that was included in the webpost php version but needed it a little more than what this script was.

Anyways here it is just let me know what you think....

http://modcentral.us/ts/ts.php

Bigman
13-02-2003, 19:08
Thats kinda of what i would like really madhouse. Any chance i can have the script for it. ;)

If i can can you mail me it philip.breeze@blueyonder.co.uk

Cheers

Madhouse
13-02-2003, 20:12
Just contact me later today

msn madhouse17*********
icq 92324255
aim madhouseHSA
yahoo madhouse1135

Bigman
16-02-2003, 18:59
Its ok madhouse ive written one myself now lol, only one question (open to anyone) how can i have on my page a nickname and password login bit, so when they enter their nickname and password and press login they will join my server.

Cheers

mCn
17-02-2003, 00:54
dunno but maybe this thread answers your question:
http://www.teamspeak.org/forums/showthread.php?threadid=827&highlight=command+line

Bigman
17-02-2003, 09:56
I have got it to join the server with the nickname, but when i add a server password it cant connect to the server. Here is my basic form.


<form action="teamspeak://192.168.2.2/?nickname=Nick?password=Password" method="Get" >
<input type="text" name="NickName" size="20" >
<input type="password" name="Password" >
<input type="submit" value="Logon">
</form>


Any ideas

cheers

Bigman
18-02-2003, 17:51
Also is there any way that you can display the Pings of people connected to the server.

Cheers

Brain
21-06-2003, 13:40
Update: -> :p

My query script now works with the newest RC2. Also i decided to put it into a class of its own to prevent interference with my game server query scripts.
You can see them in action on :p
Well, you can see them once the server is up again, that means probably on Monday.

Mazrick
26-06-2003, 16:19
Brain, a comment on your code.

I like a lot of what you did, I was about to do the same, but why duplicate? Here are some comments that should help to clean up your version some.

It is better to use explode on \t as in the following code. This also workes with Nick Names of more than one word.

There are also built in trim and pad functions you might want to use.

I also did some time parsing, you may know of a better way to do such parsing of a number of seconds. This is just what I came up with. Might be able to use strtotime() for some things.


$playerinfo = trim(fgets($socket));
$aPlayerinfo = explode("\t", $playerinfo);
if(count($aPlayerinfo) > 0) $number = $aPlayerinfo[0];
if(count($aPlayerinfo) > 7) $ping = $aPlayerinfo[7];
if(count($aPlayerinfo) > 8){
$logintime = $aPlayerinfo[8];
$logintime = str_pad(intval(($logintime / 60) / 60), 2, '0', STR_PAD_LEFT).
':'.str_pad((intval($logintime / 60) - intval(($logintime / 60) / 60) * 60), 2, '0', STR_PAD_LEFT).
':'.str_pad(intval(($logintime - intval($logintime / 60) * 60)), 2, '0', STR_PAD_LEFT);
}
if(count($aPlayerinfo) > 9){
$idletime = $aPlayerinfo[9];
$idletime = str_pad(intval(($idletime / 60) / 60), 2, '0', STR_PAD_LEFT).
':'.str_pad((intval($idletime / 60) - intval(($idletime / 60) / 60) * 60), 2, '0', STR_PAD_LEFT).
':'.str_pad(intval(($idletime - intval($idletime / 60) * 60)), 2, '0', STR_PAD_LEFT);
}
if(count($aPlayerinfo) > 14) $name = trim($aPlayerinfo[14], "\"");

UDG-BaZ
09-07-2003, 06:03
Using : http://christian-mueller.homeip.net/ts2/ts2info.source

Server is not located locally, using win2kserver and IIS 5.0

Not receiving any definiative errors just a blank output.

Also, When I use the PHP script IIS prompts for a password. If i replace the php with a standard html the URL can be accessed without authentication...

Routers on both ends seem to be setup properly... Any Suggestions?



Current Configuration:

<?php
class tss2info {
// ts2info.php
// (c) 2003 by Christian Müller
// non-commercial use approved, commercial users please contact me at mueller@fmi.uni-passau.de
// i give no guarantees whatsoever about the correct functioning of this script
// use at your own risk
// date: 20/06/03, 23:28

// **** settings - to be edited before first use ****
var $serverURL = "216.232.xxx.xxx"; // will be used for the connect link, don't use localhost here
var $serverAddress = "ts2.udgnet.com"; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767
// **** end of settings ****

//internal
var $socket;

// external
var $serverStatus = "offline";
var $playerList = array();
var $channelList = array();


// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 0;
while($attempts < 3 and !$socket) {
@$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
$this->errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}// end if
}// end while
return false;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// answer OK?
function getOK($socket) {
$result = fread($socket, 2);
fgets($socket, 128);
return($result == "OK");
}// end function getOK(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)

// 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;
}// end if
}// end function getNext($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 "";
}// end if
}// end function chopNext($evalString)

// strips the quotes around a string
function stripQuotes($evalString) {
if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);

return $evalString;
}// end function stripQuotes($evalString)

// returns the codec name
function getVerboseCodec($codec) {
if($codec == 0) {
$codec = "CELP 5.1 Kbit";
} elseif($codec == 1) {
$codec = "CELP 6.3 Kbit";
} elseif($codec == 2) {
$codec = "GSM 14.8 Kbit";
} elseif($codec == 3) {
$codec = "GSM 16.4 Kbit";
} elseif($codec == 4) {
$codec = "CELP Windows 5.2 Kbit";
} elseif($codec == 5) {
$codec = "Speex 3.4 Kbit";
} elseif($codec == 6) {
$codec = "Speex 5.2 Kbit";
} elseif($codec == 7) {
$codec = "Speex 7.2 Kbit";
} elseif($codec == 8) {
$codec = "Speex 9.3 Kbit";
} elseif($codec == 9) {
$codec = "Speex 12.3 Kbit";
} elseif($codec == 10) {
$codec = "Speex 16.3 Kbit";
} elseif($codec == 11) {
$codec = "Speex 19.5 Kbit";
} elseif($codec == 12) {
$codec = "Speex 25.9 Kbit";
} else {
$codec = "unknown (".$codec.")";
}// end if
return $codec;
}// end function getVerboseCodec($codec);

function getInfo() {
// ---=== main program ===---

// establish connection to teamspeak server
$this->socket = $this->getSocket($this->serverAddress, $this->serverQueryPort, $errno, $errstr, 0.3);
if($this->socket == false) {
return;
}// end if
$this->serverStatus = "online";

// select the one and only running server on port 8767
$this->sendQuery($this->socket, "sel ".$this->serverUDPPort);

// retrieve answer "OK"
if(!$this->getOK($this->socket)) {
echo "Server didn't answer &quot;OK&quot; after last command. Aborting.";
return;
}// end if

// retrieve player list
$this->sendQuery($this->socket,"pl");

// read player info
$this->playerList = array();
do {
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername));
}// end if
} while($playerid != "OK");

// retrieve channel list
$this->sendQuery($this->socket,"cl");

// read channel info
$this->channelList = array();
do {
$channelinfo = "";
do {
$input = fread($this->socket, 1);
if($input != "\n" && $input != "\r") $channelinfo .= $input;
} while($input != "\n");

$channelid = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$codec = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$parent = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$maxplayers = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$channelname = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$topic = $this->getNext($channelinfo);

if($channelid != "OK") {
if($isdefault == "Default") $isdefault = 1; else $isdefault = 0;

// determine number of players in channel
$playercount = 0;
foreach($this->playerList as $playerInfo) {
if($playerInfo[channelid] == $channelid) $playercount++;
}// end foreach

$this->channelList[$channelid] = array("channelid" => $channelid,
"codec" => $codec,
"parent" => $parent,
"maxplayers" => $maxplayers,
"channelname" => $this->stripQuotes($channelname),
"isdefault" => $isdefault,
"topic" => $this->stripQuotes($topic),
"currentplayers" => $playercount);
}// end if
} while($channelid != "OK");

// close connection to teamspeak server
$this->closeSocket($this->socket);

}// end getInfo()
}// class tss2info

$tss2info = new tss2info;
?>

Thanks In Advance,

BaZ

Brain
09-07-2003, 08:29
Not receiving any definiative errors just a blank output.
That's quite correct. This script doesn't generate any output. Instead, you can query its class variables to retrieve all the info you need for your custom display script. In the most primitive case you can chose to simply dump all the info as i had the script do in the past

Also, When I use the PHP script IIS prompts for a password. If i replace the php with a standard html the URL can be accessed without authentication...
Sounds like a configuration problem. Makes me glad i'm using Linux and Apache.

UDG-BaZ
09-07-2003, 18:13
Brain,

Thanks for that info.

Now i'm not trying to be lazy (this purely due to a lack of resources) Is anyone aware of a display script that could be plugged into vbulletin? or just an output script (display)

Obviously I am very new to PHP so I appologize for the questions.

I am running MySQL aswell, is a database required for the display? I guess in short I am wondering if someone would be goodly enough to explain or point me in a direction that puts this all together to a final product.

Again thanks in advance!

BaZ

Brain
09-07-2003, 20:37
No, you don't need MySQL for this one. The results are queried live.
A primitive dumping script would look like this:
:p

UDG-BaZ
09-07-2003, 21:27
Again thank you!

Now, at the risk of being annoying (please tell me if my questions begin to get on your nerves ;) )

How can I resolve this error?

Fatal error: Failed opening required 'ts2info.php' (include_path='.;c:\php4\pear') in C:\TS\tsoutput.php on line 3

Both PHP Documents reside in the same folder C:\TS

tsinfo.php and tsoutput.php

Which document needs to be default and are my values correct? (I did not make any changes to the document)

?php
// retrieve server info
require("ts2info.php");
$tss2info->getInfo();
$tss2info->userName="Guest";

Again Thank You,

Brain
10-07-2003, 10:46
Learning to read error messages gives you a decisive advantage over your peer PHP programmers... ;-)

Error message says: "i want ts2info.php"
You have: tsinfo.php

Conclusion: either change require("ts2info.php"); to require("tsinfo.php"); or rename your tsinfo.php to ts2info.php

UDG-WitCh-Fire
10-07-2003, 19:04
Brain: I aint knockin your efforts or nuthing.....but i do belive you forgot to mention PEAR is required to be installed. Ive tried my hand at installing PEAR 4 Windoz/Apache2 but to no avail, as i am a beginner to all this (like BaZ ;)) Please...correct me if im wrong.

PS. Is there any other basic script that is PLAIN php that you could give us? It would be greatly appreciated as were having trouble getting this to work at all ;). Thanks for your efforts.

Brain
10-07-2003, 21:04
i'm not aware of using any PEAR components. Can you give me an example?

UDG-WitCh-Fire
10-07-2003, 21:59
As this states.....

"Fatal error: Failed opening required 'ts2info.php' (include_path='.;c:\php4\pear') in C:\TS\tsoutput.php on line 3"

that would be indicating thats its missing an Include path?...no?
Perhaps i am confused.... :-/ buuuut......since tsoutput.php SHOULD be finding the Script (tsinfo.php) that RETREIVEs the info from the teamspeak Server and making it veiwable..correct? but its not doing that so i thought it might have had sumthing to do with Webserver Settings. ?

Tornado
11-07-2003, 07:58
I have been trying to get these scripts to work for my GR clan, and I have had no luck. I have not yet gotten an error, but when I attempt to run the script it just kinda stops and laughs at me. No idea what is wrong. Any help you can give would be greatly appreciated. I have posted the 2 scripts below.

This one should make the table page with all the info I think:
<?php
// retrieve server info
require("ts2.php");
$tss2info->getInfo();

// display channel list
echo "<h3>Channel List</h3>";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><thead align=\"center\"><th>Channel ID</th><th>Parent</th><th>Channel name</th><th>Default?</th><th>Topic</th><th>Players</th><th>Codec</th></thead>\n";
$counter = 0;
foreach($ts2->channelList as $channelInfo) {
// default channel?
if($channelInfo[isdefault] == 1) {
$channelname = "<b>".$channelInfo[channelname]."</b>";
} else {
$channelname = $channelInfo[channelname];
}// end if

// determine codec (verbose)
$codec = $tss2info->getVerboseCodec($channelInfo[codec]);

// default?
if($channelInfo[isdefault] == "1") $isDefault = "yes"; else $isDefault = "no";

echo ("<tr align=\"center\" valign=\"top\"><td>".$channelInfo[channelid]."</td><td>".$channelInfo[parent]."</td><td>".$channelname."</td><td>".$isDefault."</td><td>".$channelInfo[topic]."</td><td>".$channelInfo[currentplayers]."/".$channelInfo[maxplayers]."</td><td>".$codec."</td></tr>\n");
$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"7\" align=\"CENTER\">No channels</td></tr>\n");
echo ("</table>\n</div>\n");


echo "<h3>Player List</h3>";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><thead align=\"center\"><th>Player ID</th><th>Channel</th><th>Player Name</th><th>Received Packets</th><th>Received Bytes</th><th>Sent Packets</th><th>Sent Bytes</th><th>Total Time</th><th>Idle Time</th>";
$counter = 0;
foreach($ts2->playerList as $playerInfo) {
// calculate times
$totaltime = date("H:i:s", mktime(floor($playerInfo[totaltime] / 3600), floor(($playerInfo[totaltime] % 3600) / 60), $playerInfo[totaltime] % 60));
$idletime = date("H:i:s", mktime(floor($playerInfo[idletime] / 3600), floor(($playerInfo[idletime] % 3600) / 60), $playerInfo[idletime] % 60));
echo("<tr align=\"center\" valign=\"top\"><td>".$playerInfo[playerid]."</td><td>".$playerInfo[channelid]."</td><td>".$playerInfo[playername]."</td><td>".$playerInfo[receivedpackets]."</td><td>".$playerInfo[receivedbytes]."</td><td>".$playerInfo[sentpackets]."</td><td>".$playerInfo[sentbytes]."</td><td>".$totaltime."</td><td>".$idletime."</td></tr>");

$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"9\" align=\"CENTER\">No channels</td></tr>\n");
echo ("</table>\n</div>\n");
?>

The other script is on my next post...

Tornado
11-07-2003, 07:59
And this one is how it hits the TS2 server:
<?php
class tss2info {

// **** settings - to be edited before first use ****
var $serverURL = "69.12.31.35"; // will be used for the connect link, don't use localhost here
var $serverAddress = "69.12.31.35"; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767
// **** end of settings ****

//internal
var $socket;

// external
var $serverStatus = "offline";
var $playerList = array();
var $channelList = array();


// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 0;
while($attempts < 3 and !$socket) {
@$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
$this->errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}// end if
}// end while
return false;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// answer OK?
function getOK($socket) {
$result = fread($socket, 2);
fgets($socket, 128);
return($result == "OK");
}// end function getOK(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)

// 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;
}// end if
}// end function getNext($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 "";
}// end if
}// end function chopNext($evalString)

// strips the quotes around a string
function stripQuotes($evalString) {
if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);

return $evalString;
}// end function stripQuotes($evalString)

// returns the codec name
function getVerboseCodec($codec) {
if($codec == 0) {
$codec = "CELP 5.1 Kbit";
} elseif($codec == 1) {
$codec = "CELP 6.3 Kbit";
} elseif($codec == 2) {
$codec = "GSM 14.8 Kbit";
} elseif($codec == 3) {
$codec = "GSM 16.4 Kbit";
} elseif($codec == 4) {
$codec = "CELP Windows 5.2 Kbit";
} elseif($codec == 5) {
$codec = "Speex 3.4 Kbit";
} elseif($codec == 6) {
$codec = "Speex 5.2 Kbit";
} elseif($codec == 7) {
$codec = "Speex 7.2 Kbit";
} elseif($codec == 8) {
$codec = "Speex 9.3 Kbit";
} elseif($codec == 9) {
$codec = "Speex 12.3 Kbit";
} elseif($codec == 10) {
$codec = "Speex 16.3 Kbit";
} elseif($codec == 11) {
$codec = "Speex 19.5 Kbit";
} elseif($codec == 12) {
$codec = "Speex 25.9 Kbit";
} else {
$codec = "unknown (".$codec.")";
}// end if
return $codec;
}// end function getVerboseCodec($codec);

function getInfo() {
// ---=== main program ===---

// establish connection to teamspeak server
$this->socket = $this->getSocket($this->serverAddress, $this->serverQueryPort, $errno, $errstr, 0.3);
if($this->socket == false) {
return;
}// end if
$this->serverStatus = "online";

// select the one and only running server on port 8767
$this->sendQuery($this->socket, "sel ".$this->serverUDPPort);

// retrieve answer "OK"
if(!$this->getOK($this->socket)) {
echo "Server didn't answer &quot;OK&quot; after last command. Aborting.";
return;
}// end if

// retrieve player list
$this->sendQuery($this->socket,"pl");

// read player info
$this->playerList = array();
do {
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername));
}// end if
} while($playerid != "OK");

// retrieve channel list
$this->sendQuery($this->socket,"cl");

// read channel info
$this->channelList = array();
do {
$channelinfo = "";
do {
$input = fread($this->socket, 1);
if($input != "\n" && $input != "\r") $channelinfo .= $input;
} while($input != "\n");

$channelid = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$codec = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$parent = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$maxplayers = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$channelname = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$topic = $this->getNext($channelinfo);

if($channelid != "OK") {
if($isdefault == "Default") $isdefault = 1; else $isdefault = 0;

// determine number of players in channel
$playercount = 0;
foreach($this->playerList as $playerInfo) {
if($playerInfo[channelid] == $channelid) $playercount++;
}// end foreach

$this->channelList[$channelid] = array("channelid" => $channelid,
"codec" => $codec,
"parent" => $parent,
"maxplayers" => $maxplayers,
"channelname" => $this->stripQuotes($channelname),
"isdefault" => $isdefault,
"topic" => $this->stripQuotes($topic),
"currentplayers" => $playercount);
}// end if
} while($channelid != "OK");

// close connection to teamspeak server
$this->closeSocket($this->socket);

}// end getInfo()
}// class tss2info

$tss2info = new tss2info;
?>

I dont host the server, but a member of our clan rents it from this site. www.teamspeak.org so I would imagine that the ports mentioned would work. Probably a dumb thing to assume though I know. Thanks in advance for any help.

Steppenwolf101
11-07-2003, 10:02
Hi
Sorry leider ist mein Englisch nicht so gut

Das ist ein Cooler Script
aber leider habe ich ein Problem damit
Ich habe dendisplay scipt (http://web930.athen023.server4free.de/ts2/display.php) von Brain mit
<?php include("http://.... in unsere
HP (http://web930.athen023.server4free.de/) eingebaut und es geht super solange der TS Server online ist
aber sobalt der TS Server Offline ist bleibt unsere HP stehen
anscheint lauft der scipt (http://web930.athen023.server4free.de/ts2/display.php) ohne ende und gibt leider keine Meldung aus das TS Offline ist:mad:

könnte mir da jemand helfen?

THX
Steppenwolf

Brain
11-07-2003, 13:13
Witchfire:
Please read this again carefully:
Originally posted by Brain
Learning to read error messages gives you a decisive advantage over your peer PHP programmers... ;-)

Error message says: "i want ts2info.php"
You have: tsinfo.php

Conclusion: either change require("ts2info.php"); to require("tsinfo.php"); or rename your tsinfo.php to ts2info.php


Tornado:
Yes, it doesn't have any output anymore. Please read this again carefully:
Originally posted by Brain
No, you don't need MySQL for this one. The results are queried live.
A primitive dumping script would look like this:

:p


Steppenwolf:
Die Seite hängt nicht, sondern das PHP-Script wartet auf einen TCP Connection timeout. Zugegeben, ideal ist das nicht, da muß ich mir noch was einfallen lassen. Als Notlösung kannst du die Anzahl der Versuche von 3 auf 1 runterstellen. dann dauerts nicht mehr gar so lange. Ich werd Bescheid sagen wenn ich eine Idee hab. Wird wahrscheinlich darauf hinauslaufen daß ich auf 8767 UDP ein paar Datagramme schicke und schaue ob was zurückkommt. Wenn dem nicht so ist wird der Server als nichtexistent bzw. offline angesehen und es wird garnicht erst versucht Daten abzufragen.

Tornado
11-07-2003, 15:57
Brain:
I think your reply confused me more than the PHP scripts. LOL! i dont know what you are saying "yes" to and the script you told me to look at is at the top in my first post. Can you elaborate a little more for me please? I really like the script, and would love to get it up and running. Thanks.

Brain
11-07-2003, 20:45
Probably because i don't understand what your problem is. My PHP script is not programmed to laugh. Are you sure it's not your Server laughing at you? ;-)

Tornado
11-07-2003, 22:59
the problem is that when I click on the link that should display the table with all the info it does nothing. It takes a long time trying to do something, but more or less just freezes. I made a link that points to the dump file .php, because I thought that was how it woud display the results of the poll that the ts2.php file grabbed. By the way...I was not trying to be a smart allic or nothing, but servers do laugh at me often.

Brain
12-07-2003, 07:42
If the script appears to freeze that means the teamspeak server is not running or its query port is unreachable.
This is a known issue and i'm working on it.

UDG-WitCh-Fire
12-07-2003, 07:43
Pinky: What are we going to do tonight braiin?
Brain: That same thing we do every night pinky...........TRY TO TAKE OVER THE WORLD!


Anyways ive figured it out......i think..i really dont understand WHAT i did....but it works now.

UDG-WitCh-Fire
12-07-2003, 07:47
As brain has posted, but seems to be confusing us n00bs so TERRIBLY.


This script is the Basic PHP Output File that displays in your Web Browser. DO NOT modify anything in here unless u know what your doing.

Name this file anything you want.

<?php
// retrieve server info
require("ts2info.php");
$tss2info->getInfo();
$tss2info->userName="Guest";

// display channel list
echo "<h3>Channel List</h3>";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><thead align=\"center\"><th>Channel ID</th><th>Parent</th><th>Channel name</th><th>Default?</th><th>Topic</th><th>Players</th><th>Codec</th></thead>\n";
$counter = 0;
foreach($tss2info->channelList as $channelInfo) {
// default channel?
if($channelInfo[isdefault] == 1) {
$channelname = "<b>".$channelInfo[channelname]."</b>";
} else {
$channelname = $channelInfo[channelname];
}// end if

// determine codec (verbose)
$codec = $tss2info->getVerboseCodec($channelInfo[codec]);

// default?
if($channelInfo[isdefault] == "1") $isDefault = "yes"; else $isDefault = "no";

echo ("<tr align=\"center\" valign=\"top\"><td>".$channelInfo[channelid]."</td><td>".$channelInfo[parent]."</td><td>".$channelname."</td><td>".$isDefault."</td><td>".$channelInfo[topic]."</td><td>".$channelInfo[currentplayers]."/".$channelInfo[maxplayers]."</td><td>".$codec."</td></tr>\n");
$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"7\" align=\"CENTER\">No channels</td></tr>\n");
echo ("</table>\n</div>\n");


echo "<h3>Player List</h3>";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><thead align=\"center\"><th>Player ID</th><th>Channel</th><th>Player Name</th><th>Received Packets</th><th>Received Bytes</th><th>Sent Packets</th><th>Sent Bytes</th><th>Total Time</th><th>Idle Time</th>";
$counter = 0;
foreach($tss2info->playerList as $playerInfo) {
// calculate times
$totaltime = date("H:i:s", mktime(floor($playerInfo[totaltime] / 3600), floor(($playerInfo[totaltime] % 3600) / 60), $playerInfo[totaltime] % 60));
$idletime = date("H:i:s", mktime(floor($playerInfo[idletime] / 3600), floor(($playerInfo[idletime] % 3600) / 60), $playerInfo[idletime] % 60));
echo("<tr align=\"center\" valign=\"top\"><td>".$playerInfo[playerid]."</td><td>".$playerInfo[channelid]."</td><td>".$playerInfo[playername]."</td><td>".$playerInfo[receivedpackets]."</td><td>".$playerInfo[receivedbytes]."</td><td>".$playerInfo[sentpackets]."</td><td>".$playerInfo[sentbytes]."</td><td>".$totaltime."</td><td>".$idletime."</td></tr>");

$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"9\" align=\"CENTER\">No channels</td></tr>\n");
echo ("</table>\n</div>\n");
?>

UDG-WitCh-Fire
12-07-2003, 07:52
This is the file that will retrieve the ACTUAL Raw data from the TCPQuert port of TeamSpeak 2.


Name this file ts2info.php. DO NOT modify this unless you know what your doing!

<?php
class tss2info {
// ts2info.php
// (c) 2003 by Christian Müller
// non-commercial use approved, commercial users please contact me at mueller@fmi.uni-passau.de
// i give no guarantees whatsoever about the correct functioning of this script
// use at your own risk
// date: 20/06/03, 23:28

// **** settings - to be edited before first use ****
var $serverURL = "xxx.xxx.xxx.xxx"; // will be used for the connect link, don't use localhost here
var $serverAddress = "your.domainname.com"; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767
// **** end of settings ****

//internal
var $socket;

// external
var $serverStatus = "offline";
var $playerList = array();
var $channelList = array();


// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 0;
while($attempts < 3 and !$socket) {
@$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
$this->errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}// end if
}// end while
return false;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// answer OK?
function getOK($socket) {
$result = fread($socket, 2);
fgets($socket, 128);
return($result == "OK");
}// end function getOK(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)

// 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;
}// end if
}// end function getNext($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 "";
}// end if
}// end function chopNext($evalString)

// strips the quotes around a string
function stripQuotes($evalString) {
if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);

return $evalString;
}// end function stripQuotes($evalString)

// returns the codec name
function getVerboseCodec($codec) {
if($codec == 0) {
$codec = "CELP 5.1 Kbit";
} elseif($codec == 1) {
$codec = "CELP 6.3 Kbit";
} elseif($codec == 2) {
$codec = "GSM 14.8 Kbit";
} elseif($codec == 3) {
$codec = "GSM 16.4 Kbit";
} elseif($codec == 4) {
$codec = "CELP Windows 5.2 Kbit";
} elseif($codec == 5) {
$codec = "Speex 3.4 Kbit";
} elseif($codec == 6) {
$codec = "Speex 5.2 Kbit";
} elseif($codec == 7) {
$codec = "Speex 7.2 Kbit";
} elseif($codec == 8) {
$codec = "Speex 9.3 Kbit";
} elseif($codec == 9) {
$codec = "Speex 12.3 Kbit";
} elseif($codec == 10) {
$codec = "Speex 16.3 Kbit";
} elseif($codec == 11) {
$codec = "Speex 19.5 Kbit";
} elseif($codec == 12) {
$codec = "Speex 25.9 Kbit";
} else {
$codec = "unknown (".$codec.")";
}// end if
return $codec;
}// end function getVerboseCodec($codec);

function getInfo() {
// ---=== main program ===---

// establish connection to teamspeak server
$this->socket = $this->getSocket($this->serverAddress, $this->serverQueryPort, $errno, $errstr, 0.3);
if($this->socket == false) {
return;
}// end if
$this->serverStatus = "online";

// select the one and only running server on port 8767
$this->sendQuery($this->socket, "sel ".$this->serverUDPPort);

// retrieve answer "OK"
if(!$this->getOK($this->socket)) {
echo "Server didn't answer &quot;OK&quot; after last command. Aborting.";
return;
}// end if

// retrieve player list
$this->sendQuery($this->socket,"pl");

// read player info
$this->playerList = array();
do {
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername));
}// end if
} while($playerid != "OK");

// retrieve channel list
$this->sendQuery($this->socket,"cl");

// read channel info
$this->channelList = array();
do {
$channelinfo = "";
do {
$input = fread($this->socket, 1);
if($input != "\n" && $input != "\r") $channelinfo .= $input;
} while($input != "\n");

$channelid = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$codec = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$parent = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$maxplayers = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$channelname = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$topic = $this->getNext($channelinfo);

if($channelid != "OK") {
if($isdefault == "Default") $isdefault = 1; else $isdefault = 0;

// determine number of players in channel
$playercount = 0;
foreach($this->playerList as $playerInfo) {
if($playerInfo[channelid] == $channelid) $playercount++;
}// end foreach

$this->channelList[$channelid] = array("channelid" => $channelid,
"codec" => $codec,
"parent" => $parent,
"maxplayers" => $maxplayers,
"channelname" => $this->stripQuotes($channelname),
"isdefault" => $isdefault,
"topic" => $this->stripQuotes($topic),
"currentplayers" => $playercount);
}// end if
} while($channelid != "OK");

// close connection to teamspeak server
$this->closeSocket($this->socket);

}// end getInfo()
}// class tss2info

$tss2info = new tss2info;
?>

UDG-BaZ
12-07-2003, 19:06
Good clean explination!

BaZ

InvictuZ
15-07-2003, 06:23
Heres one for you guys. My teams tags are >V<PlayerNameHere

However < = the begining of html code. Is there anyway that someone could make a filter that replaces > & < with their respective html code to make them appear as text rather then code? Any help would be much appreciated, as I don't know an ounce of PHP.

Thanks for your help, and nice script brain! 8)

Brain
15-07-2003, 08:28
Benutze htmlspecialchars vor der Ausgabe: -> http://de.php.net/manual/en/function.htmlspecialchars.php

zoomzoom
17-07-2003, 13:03
Hallo mein englisch ist auch nicht so prima.zur Verständlichkeit schreib ich lieber auf deutsch....

@brain:
ne kurze Frage so wie ich die Scripte sehe , läuft das nur wenn ich auf unserem Server ( wo die Datei liegt ) den Teamspeak Server laufen habe.

Der TS Server hat folgende Daten:
Server:
LAN-4-All Teamspeak Server

Server IP:
217.172.181.134:8767

Version:
2.0.19.40

Platform:
Linux

was muss ich nun eintragen das die php seite mir von diesem Server anzeigt ob online oder nicht.
Ich muss zugeben, nach jetzt 3 stundigen Versuchen weiss ich mir nicht mehr zu helfen.Eigentlich wollte ich nur ein Script das anzeigt wer online ist auf dem TS Server und ob der Server überhaupt "on" ist .kannst du mir kurz helfen dabei???

zoomzoom

Brain
31-07-2003, 05:48
ne kurze Frage so wie ich die Scripte sehe , läuft das nur wenn ich auf unserem Server ( wo die Datei liegt ) den Teamspeak Server laufen habe.
Korrekt. Es spielt allerdings keine Rolle ob der Teamspeak Server auf derselben physikalischen Maschine läuft oder nicht - es muß nur der Query-Port frei sein.

was muss ich nun eintragen das die php seite mir von diesem Server anzeigt ob online oder nicht.
Ich muss zugeben, nach jetzt 3 stundigen Versuchen weiss ich mir nicht mehr zu helfen.Eigentlich wollte ich nur ein Script das anzeigt wer online ist auf dem TS Server und ob der Server überhaupt "on" ist .kannst du mir kurz helfen dabei???
Das ist alles schön dokumentiert...
var $serverURL = "xxx.xxx.xxx.xxx"; // will be used for the connect link, don't use localhost here
var $serverAddress = "your.domainname.com"; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767
Auf Deutsch:
$serverURL ist die URL des Teamspeak Servers. Diese Variable wird benutzt um die Links zum Verbinden zu erzeugen.
$serverAddress ist die Adresse des Teamspeak Servers. Wenn Teamspeak Server und Webserver die gleiche physikalische Maschine sind empfiehlt es sich dort "localhost" bzw. "127.0.0.1" einzutragen, ansonsten eben die IP-Adresse.
$serverQueryPort ist der Port der normalerweise für Statusabfragen benutzt wird, wie der Name schon sagt. Standardmäßig ist das 51234. Muß frei sein.
$serverUDPPort ist der Port auf den der Teamspeak Client verbindet. Der muß sowieso frei sein, wird allerdings nur zur Auswahl des Teamspeak Servers verwendet, da mehrere virtuelle Server auf einer IP unterstützt werden und irgendwie muß man sie ja unterscheiden, nicht wahr?

Brain
31-07-2003, 05:50
As promised i fixed the "Script hangs if server is not running" bug. A minor mixup in the connection handling, sorry.

The current version can be found as always on :p

Enjoy!

Gurberly
01-09-2003, 16:22
Hi

We have the basic script working fine showing who is online and what channel etc and are very pleased with it - thanks to all who put the time and effort into developing it :)

What we are trying to do is create a simple web login to the page. Literally all we want is a simple form so a user can put in their username and the server password and click submit.

Does anyone have a simple (and I mean simple as I really don't know html/php :confused: ) script that we could use to connect people to the TS server from the web page?

G

Brain
01-09-2003, 17:21
:p

... now comes whatever you want ...

:p

... again stuff you want ...


now you have the variables $ts2pass, $ts2nick and $ts2login that you can use in the query script to build your teamspeak links.

P.S.: Cookie should be set before any output is sent, that's why the first block should be at the very beginning of the page.

P.S.S.: A working example can be :p

Gurberly
01-09-2003, 19:48
Wow... many thanks :)

I'll give that a go first thing tomorrow. Many thanks for taking the time to respond. It really is much appreciated.

Thanks

G

Mobious
20-09-2003, 03:24
Thanks for the new script..

Question

on my server the script cuts some of the first letters of of the names of the users and channels..

check it out here.

vfa25radio.no-ip.com (http://vfa25radio.no-ip.com)

How do I fix this.. Thanks!

Brain
20-09-2003, 10:03
Hmm... i see what you mean. I don't have that error, but i've eliminated a potential problem in the code. If you want to give it a try you can get it :p

Please make sure you use the latest release of TS2 server. I don't know if it will work with older versions. I think it would, but i've not tested backwards compatibility.

Mobious
20-09-2003, 16:54
You know what brain.. Come to think about it.. The VFA-25 TS server is an older ts server version.. I up date it and give it a spin..

Ñèø ¤†ëƒ¤
20-09-2003, 19:18
Hey! Great job on that code. I have a quick question. I looked around for anwser but couldn't find it. Is there any way to show how many people in total are in the server and not just in a specific chanel?

Brain
20-09-2003, 22:05
Of course. Iterate over the channel list. Sum up the number of people. :)

Mobious
20-09-2003, 23:00
That was it brain.. My TS server needed to be updated..

Thanks again

DaJoker
13-11-2003, 21:02
Ich habe das online display script in mein vwar eingebunden und bin sehr begeistert davon!

Anzuschauen hier: http://iog.clanintern.de/vwar/ts.php

Nun habe ich jedoch zwei Fragen/Probleme:

1. Wird der player-Name nur bis zum ersten Leerzeichen angezeigt. Kann man das irgendwie ändern?
2. In der ersten Tabelle wird angezeigt, in welchem channel der einzelne player ist. Allerdings wird hier nur die channel-id angezeigt. Kann man stattdessen hier den channel-Namen einbauen?


I have build up the online display script in my vwar und I am very happy about it.

Look here: http://iog.clanintern.de/vwar/ts.php

But there are still two problems/questions:

1. The player-name is only shown up to the first space, can I fix it?
2. In the first table is shown, in which channel the player is. But there is only shown the channel-id. Is it possible to show the channel-name?

Mick
14-11-2003, 01:35
Brain..

Well at first I couldn't get it working from the codes posted here but I finally figured out the problems on my server... The link's to the latest source seem to be not working could you repost new links to make sure we have your latest work?


Great work!

Mick

d4rkfight3r
22-11-2003, 11:32
Originally posted by UDG-WitCh-Fire
As brain has posted, but seems to be confusing us n00bs so TERRIBLY.


This script is the Basic PHP Output File that displays in your Web Browser. DO NOT modify anything in here unless u know what your doing.

Name this file anything you want.

<?php
// retrieve server info
require("ts2info.php");
$tss2info->getInfo();
$tss2info->userName="Guest";

// display channel list
echo "<h3>Channel List</h3>";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><thead align=\"center\"><th>Channel ID</th><th>Parent</th><th>Channel name</th><th>Default?</th><th>Topic</th><th>Players</th><th>Codec</th></thead>\n";
$counter = 0;
foreach($tss2info->channelList as $channelInfo) {
// default channel?
if($channelInfo[isdefault] == 1) {
$channelname = "<b>".$channelInfo[channelname]."</b>";
} else {
$channelname = $channelInfo[channelname];
}// end if

// determine codec (verbose)
$codec = $tss2info->getVerboseCodec($channelInfo[codec]);

// default?
if($channelInfo[isdefault] == "1") $isDefault = "yes"; else $isDefault = "no";

echo ("<tr align=\"center\" valign=\"top\"><td>".$channelInfo[channelid]."</td><td>".$channelInfo[parent]."</td><td>".$channelname."</td><td>".$isDefault."</td><td>".$channelInfo[topic]."</td><td>".$channelInfo[currentplayers]."/".$channelInfo[maxplayers]."</td><td>".$codec."</td></tr>\n");
$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"7\" align=\"CENTER\">No channels</td></tr>\n");
echo ("</table>\n</div>\n");


echo "<h3>Player List</h3>";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><thead align=\"center\"><th>Player ID</th><th>Channel</th><th>Player Name</th><th>Received Packets</th><th>Received Bytes</th><th>Sent Packets</th><th>Sent Bytes</th><th>Total Time</th><th>Idle Time</th>";
$counter = 0;
foreach($tss2info->playerList as $playerInfo) {
// calculate times
$totaltime = date("H:i:s", mktime(floor($playerInfo[totaltime] / 3600), floor(($playerInfo[totaltime] % 3600) / 60), $playerInfo[totaltime] % 60));
$idletime = date("H:i:s", mktime(floor($playerInfo[idletime] / 3600), floor(($playerInfo[idletime] % 3600) / 60), $playerInfo[idletime] % 60));
echo("<tr align=\"center\" valign=\"top\"><td>".$playerInfo[playerid]."</td><td>".$playerInfo[channelid]."</td><td>".$playerInfo[playername]."</td><td>".$playerInfo[receivedpackets]."</td><td>".$playerInfo[receivedbytes]."</td><td>".$playerInfo[sentpackets]."</td><td>".$playerInfo[sentbytes]."</td><td>".$totaltime."</td><td>".$idletime."</td></tr>");

$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"9\" align=\"CENTER\">No channels</td></tr>\n");
echo ("</table>\n</div>\n");
?>


the whole script (both files) is not working i always get :
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /var/www/html/ts2info.php on line 137

Fatal error: Call to a member function on a non-object in /var/www/html/ts.php on line 4

and : can someone post a running script ? no script is working with my linux apache in this tread :D

my system is useing : Apache/2.0.40 (Red Hat Linux)

PapsW.
23-11-2003, 14:39
Hello d4rkfight3r,

I have the same problem.

Go to the file ts2info.php.

Search:
echo "Server didn't answer "OK" after last command. Aborting.";

replace it with:
echo "Server didn't answer OK after last command. Aborting.";

Now it is work.

Greeting
PapsW.

Ps. Sorry for my english.

PapsW.
23-11-2003, 20:17
Halo,

Entschuldigung für mein Doppelposting.

Ich habe folgendes Problem.

Ich möchte die Onlineanzeige in mein Board einbauen.

Ich habe den Script genommen und eingebaut.
Es klappt auch soweit nur wenn ich GZip einschalte geht es nicht.

Wie kann ich die Datei ts2info.php so anpassen das sie unter GZip läuft.

Gruß
PapsW.

commit
25-11-2003, 10:13
Quick question.
The php code returns as Player Name the Nick Name of the player.
Would it be possible to return the registered login of the player?

Dummer Sack
25-11-2003, 14:24
The TCPQueryPort command dbuserlist gives you a list of all registred users.
But I don't know how to match them to the player list.

So the answer is no, I guess.

EDIT: Forget the above bullshit. pl also returns the loginname of a user as the last entry. So it is easy possible. You even do not need the dbuserlist command.

Dummer Sack
25-11-2003, 15:01
Sorry for the double post.

I just took a look at the code. Just change this:
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername));

To:
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername, $playerlogin) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername),
"playerlogin" => $this->stripQuotes($playerlogin));

After this you can do something like that:
foreach($tss2info->playerList as $playerInfo) {
// calculate times
$totaltime = date("H:i:s", mktime(floor($playerInfo[totaltime] / 3600), floor(($playerInfo[totaltime] % 3600) / 60), $playerInfo[totaltime] % 60));
$idletime = date("H:i:s", mktime(floor($playerInfo[idletime] / 3600), floor(($playerInfo[idletime] % 3600) / 60), $playerInfo[idletime] % 60));
echo("<tr align=\"center\" valign=\"top\"><td>".$playerInfo[playerid]."</td><td>".$playerInfo[channelid]."</td><td>");
if(!empty($playerInfo[playerlogin]) { echo($playerInfo[playerlogin]); } else { echo($playerInfo[playername]); }
echo("</td><td>".$playerInfo[receivedpackets]."</td><td>".$playerInfo[receivedbytes]."</td><td>".$playerInfo[sentpackets]."</td><td>".$playerInfo[sentbytes]."</td><td>".$totaltime."</td><td>".$idletime."</td></tr>");
$counter++;
}// end foreach

PS: This is untested. I just wote it here on the fly. Also I am not sure if that works on server 2.0.19.40. It should work on server 2.0.19.46.

Russ-LG
27-11-2003, 15:47
Brain can you please post the latest source here on the forums. I tried going to the previous links but found that you (apparently) no longer have that domain pointing to your server. I got the previous ones working but i'de like to get the latest from you :D

Thanks man,
Russ

Maelstrom
28-11-2003, 13:26
Hi all, I am new to TS, I have my server up and running and can connect to it fine from the client. I tried to implement the script via the 2 php script pages that were listed previously. I have changed the information for the IP address, URL of my server. I left the port information default when I installed. However, when I run the script I get the following error:
Fatal error: Maximum execution time of 30 seconds exceeded in ts2info.php on line 31

var $serverURL = "69.44.59.95"; // will be used for the connect link, don't use localhost here
var $serverAddress = "lowgrav3.game-host.org"; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767

I have verified that I can connect to 51234 via Telnet and got a "[TS]" back. I don't know what the problem is.

This script is being run on a different server so it is a remote connection.

Now when I run this on the server it sort of works, but I get a log of the following:
Notice: Undefined variable: errno in c:\inetpub\wwwroot\ts2info.php on line 126

Notice: Undefined variable: errstr in c:\inetpub\wwwroot\ts2info.php on line 126

Notice: Undefined variable: socket in c:\inetpub\wwwroot\ts2info.php on line 30

Notice: Undefined variable: isdefault in c:\inetpub\wwwroot\ts2info.php on line 193


Any ideas?

fredice
09-12-2003, 22:33
Originally posted by Brain
As promised i fixed the "Script hangs if server is not running" bug. A minor mixup in the connection handling, sorry.

The current version can be found as always on http://christian-mueller.homeip.net/ts2/ts2info.source

Enjoy!

Can someone post the script that fixed this problem when server is not running?
Thanks for all your works :))

WL-ScorPioN
18-12-2003, 09:26
Hi there, when your link is online again :confused:

Wolpe
24-12-2003, 04:19
Yeah it works !!

THX !!

I don't need so many Infos.
So i modified the basic PHP File.
But how can i display th channelname in playerlist ?
www.con.ipme.de



<?php
// retrieve server info
require("ts2info.php");
$tss2info->getInfo();
$tss2info->userName="Guest";

echo "<table border=\"1\" cellspacing=\"2\" cellpadding=\"5\" bordercolor=\"#000000\"><thead align=\"center\"><th>User ID</th><th>Channel</th><th>User Name</th><th>Total Time</th>";
$counter = 0;
foreach($tss2info->playerList as $playerInfo) {
// calculate times
$totaltime = date("H:i:s", mktime(floor($playerInfo[totaltime] / 3600), floor(($playerInfo[totaltime] % 3600) / 60), $playerInfo[totaltime] % 60));
$idletime = date("H:i:s", mktime(floor($playerInfo[idletime] / 3600), floor(($playerInfo[idletime] % 3600) / 60), $playerInfo[idletime] % 60));

if($counter <> 0) echo("<tr align=\"center\" valign=\"top\"><td>".$playerInfo[playerid]."</td><td>".$playerInfo[channelid]."</td><td>".$playerInfo[playername]."</td><td>".$totaltime."</td></tr>");

$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"9\" align=\"CENTER\">No channels</td></tr>\n");
$counter--;
echo ("<tr><td colspan=\"9\" align=\"CENTER\"><h3>$counter User online</h3></td></tr>\n");
echo ("</table>\n</div>\n");
?>

Deckard
24-12-2003, 06:13
In the Post from UDG-WitCh-Fire concerning ts2info.php:// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 0;
while($attempts < 3 and !$socket) {
@$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
$this->errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}// end if
}// end while
return false;
}// end function getSocket(...)I cannot see where the variable attempts is increase and apparently that make it hang when the server is offline.. So i added $attempts++; just after the while, which corrected the problem.
other than that it work just fine for us www.mortsvivants.com..

aegis123
28-12-2003, 23:05
I cant get the php file from http://christian-mueller.homeip.net/ts2/ts2info.source .
could somebody mail it to me orsomething or put is on a different host so I can download it

Wolpe
29-12-2003, 00:02
Use this Link: http://con.dyndns.info/seiten/downloads/files/teamspeak/ts2info.zip to download ts2info.php


www.con.ipme.de !! Play Clusterball !!

_____________________________________________

Change the $serverURL and $serverAdress !!
_____________________________________________


<?php
class tss2info {
// ts2info.php
// (c) 2003 by Christian Müller
// non-commercial use approved, commercial users please contact me at mueller@fmi.uni-passau.de
// i give no guarantees whatsoever about the correct functioning of this script
// use at your own risk
// date: 20/06/03, 23:28

// **** settings - to be edited before first use ****
var $serverURL = "192.168.10.3 "; // will be used for the connect link, don't use localhost here
var $serverAddress = "192.168.10.3 "; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767
// **** end of settings ****

//internal
var $socket;

// external
var $serverStatus = "offline";
var $playerList = array();
var $channelList = array();


// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 0;
while($attempts < 3 and !$socket) {
$attempts++;
@$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
$this->errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}// end if
}// end while
return false;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// answer OK?
function getOK($socket) {
$result = fread($socket, 2);
fgets($socket, 128);
return($result == "OK");
}// end function getOK(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)

// 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;
}// end if
}// end function getNext($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 "";
}// end if
}// end function chopNext($evalString)

// strips the quotes around a string
function stripQuotes($evalString) {
if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);

return $evalString;
}// end function stripQuotes($evalString)

// returns the codec name
function getVerboseCodec($codec) {
if($codec == 0) {
$codec = "CELP 5.1 Kbit";
} elseif($codec == 1) {
$codec = "CELP 6.3 Kbit";
} elseif($codec == 2) {
$codec = "GSM 14.8 Kbit";
} elseif($codec == 3) {
$codec = "GSM 16.4 Kbit";
} elseif($codec == 4) {
$codec = "CELP Windows 5.2 Kbit";
} elseif($codec == 5) {
$codec = "Speex 3.4 Kbit";
} elseif($codec == 6) {
$codec = "Speex 5.2 Kbit";
} elseif($codec == 7) {
$codec = "Speex 7.2 Kbit";
} elseif($codec == 8) {
$codec = "Speex 9.3 Kbit";
} elseif($codec == 9) {
$codec = "Speex 12.3 Kbit";
} elseif($codec == 10) {
$codec = "Speex 16.3 Kbit";
} elseif($codec == 11) {
$codec = "Speex 19.5 Kbit";
} elseif($codec == 12) {
$codec = "Speex 25.9 Kbit";
} else {
$codec = "unknown (".$codec.")";
}// end if
return $codec;
}// end function getVerboseCodec($codec);

function getInfo() {
// ---=== main program ===---

// establish connection to teamspeak server
$this->socket = $this->getSocket($this->serverAddress, $this->serverQueryPort, $errno, $errstr, 0.3);
if($this->socket == false) {
return;
}// end if
$this->serverStatus = "online";

// select the one and only running server on port 8767
$this->sendQuery($this->socket, "sel ".$this->serverUDPPort);

// retrieve answer "OK"
if(!$this->getOK($this->socket)) {
echo "Server didn't answer OK after last command. Aborting.";
return;
}// end if

// retrieve player list
$this->sendQuery($this->socket,"pl");

// read player info
$this->playerList = array();
do {
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername, $playerlogin) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername),
"playerlogin" => $this->stripQuotes($playerlogin));
}// end if
} while($playerid != "OK");

// retrieve channel list
$this->sendQuery($this->socket,"cl");

// read channel info
$this->channelList = array();
do {
$channelinfo = "";
do {
$input = fread($this->socket, 1);
if($input != "\n" && $input != "\r") $channelinfo .= $input;
} while($input != "\n");

$channelid = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$codec = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$parent = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$maxplayers = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$channelname = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$topic = $this->getNext($channelinfo);

if($channelid != "OK") {
if($isdefault == "Default") $isdefault = 1; else $isdefault = 0;

// determine number of players in channel
$playercount = 0;
foreach($this->playerList as $playerInfo) {
if($playerInfo[channelid] == $channelid) $playercount++;
}// end foreach

$this->channelList[$channelid] = array("channelid" => $channelid,
"codec" => $codec,
"parent" => $parent,
"maxplayers" => $maxplayers,
"channelname" => $this->stripQuotes($channelname),
"isdefault" => $isdefault,
"topic" => $this->stripQuotes($topic),
"currentplayers" => $playercount);
}// end if
} while($channelid != "OK");

// close connection to teamspeak server
$this->closeSocket($this->socket);

}// end getInfo()
}// class tss2info

$tss2info = new tss2info;
?>

Deckard
29-12-2003, 00:08
This should stop it to hang when the server is offline:

Change the $serverURL and $serverAdress !!


<?php
class tss2info {
// ts2info.php
// (c) 2003 by Christian Müller
// non-commercial use approved, commercial users please contact me at mueller@fmi.uni-passau.de
// i give no guarantees whatsoever about the correct functioning of this script
// use at your own risk
// date: 20/06/03, 23:28

// **** settings - to be edited before first use ****
var $serverURL = "192.168.10.3"; // will be used for the connect link, don't use localhost here
var $serverAddress = "192.168.10.3"; // can be ip address or url
var $serverQueryPort = 51234; // default 51234, must be accessible and usable. check server.ini
var $serverUDPPort = 8767; // default 8767
// **** end of settings ****

//internal
var $socket;

// external
var $serverStatus = "offline";
var $playerList = array();
var $channelList = array();


// opens a connection to the teamspeak server
function getSocket($host, $port, $errno, $errstr, $timeout) {
unset($socket);
$attempts = 0;
while($attempts < 3 and !$socket) {
$attempts++;
@$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
$this->errno = $errno;
$this->errstr = $errstr;
if($socket and fread($socket, 4) == "[TS]") {
fgets($socket, 128);
return $socket;
}// end if
}// end while
return false;
}// end function getSocket(...)

// sends a query to the teamspeak server
function sendQuery($socket, $query) {
fputs($socket, $query."\n");
}// end function sendQuery(...)

// answer OK?
function getOK($socket) {
$result = fread($socket, 2);
fgets($socket, 128);
return($result == "OK");
}// end function getOK(...)

// closes the connection to the teamspeak server
function closeSocket($socket) {
fputs($socket, "quit");
fclose($socket);
}// end function closeSocket(...)

// 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;
}// end if
}// end function getNext($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 "";
}// end if
}// end function chopNext($evalString)

// strips the quotes around a string
function stripQuotes($evalString) {
if(strpos($evalString, '"') == 0) $evalString = substr($evalString, 1, strlen($evalString) - 1);
if(strrpos($evalString, '"') == strlen($evalString) - 1) $evalString = substr($evalString, 0, strlen($evalString) - 1);

return $evalString;
}// end function stripQuotes($evalString)

// returns the codec name
function getVerboseCodec($codec) {
if($codec == 0) {
$codec = "CELP 5.1 Kbit";
} elseif($codec == 1) {
$codec = "CELP 6.3 Kbit";
} elseif($codec == 2) {
$codec = "GSM 14.8 Kbit";
} elseif($codec == 3) {
$codec = "GSM 16.4 Kbit";
} elseif($codec == 4) {
$codec = "CELP Windows 5.2 Kbit";
} elseif($codec == 5) {
$codec = "Speex 3.4 Kbit";
} elseif($codec == 6) {
$codec = "Speex 5.2 Kbit";
} elseif($codec == 7) {
$codec = "Speex 7.2 Kbit";
} elseif($codec == 8) {
$codec = "Speex 9.3 Kbit";
} elseif($codec == 9) {
$codec = "Speex 12.3 Kbit";
} elseif($codec == 10) {
$codec = "Speex 16.3 Kbit";
} elseif($codec == 11) {
$codec = "Speex 19.5 Kbit";
} elseif($codec == 12) {
$codec = "Speex 25.9 Kbit";
} else {
$codec = "unknown (".$codec.")";
}// end if
return $codec;
}// end function getVerboseCodec($codec);

function getInfo() {
// ---=== main program ===---

// establish connection to teamspeak server
$this->socket = $this->getSocket($this->serverAddress, $this->serverQueryPort, $errno, $errstr, 0.3);
if($this->socket == false) {
return;
}// end if
$this->serverStatus = "online";

// select the one and only running server on port 8767
$this->sendQuery($this->socket, "sel ".$this->serverUDPPort);

// retrieve answer "OK"
if(!$this->getOK($this->socket)) {
echo "Server didn't answer OK after last command. Aborting.";
return;
}// end if

// retrieve player list
$this->sendQuery($this->socket,"pl");

// read player info
$this->playerList = array();
do {
$playerinfo = fscanf($this->socket, "%s %d %d %d %d %d %d %d %d %d %d %d %d %s %s %s");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $d, $d, $totaltime, $idletime, $d, $d, $d, $s, $playername, $playerlogin) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"totaltime" => $totaltime,
"idletime" => $idletime,
"playername" => $this->stripQuotes($playername),
"playerlogin" => $this->stripQuotes($playerlogin));
}// end if
} while($playerid != "OK");

// retrieve channel list
$this->sendQuery($this->socket,"cl");

// read channel info
$this->channelList = array();
do {
$channelinfo = "";
do {
$input = fread($this->socket, 1);
if($input != "\n" && $input != "\r") $channelinfo .= $input;
} while($input != "\n");

$channelid = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$codec = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$parent = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$maxplayers = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$channelname = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$d = $this->getNext($channelinfo);
$channelinfo = $this->chopNext($channelinfo);
$topic = $this->getNext($channelinfo);

if($channelid != "OK") {
if($isdefault == "Default") $isdefault = 1; else $isdefault = 0;

// determine number of players in channel
$playercount = 0;
foreach($this->playerList as $playerInfo) {
if($playerInfo[channelid] == $channelid) $playercount++;
}// end foreach

$this->channelList[$channelid] = array("channelid" => $channelid,
"codec" => $codec,
"parent" => $parent,
"maxplayers" => $maxplayers,
"channelname" => $this->stripQuotes($channelname),
"isdefault" => $isdefault,
"topic" => $this->stripQuotes($topic),
"currentplayers" => $playercount);
}// end if
} while($channelid != "OK");

// close connection to teamspeak server
$this->closeSocket($this->socket);

}// end getInfo()
}// class tss2info

$tss2info = new tss2info;
?>

Wolpe
29-12-2003, 00:34
THX

O.K i did the change !

Croatia [ICL]
29-12-2003, 20:22
I dont quite know what TS URL is?
But anyway i uploaded script:
http://www.adriatic-properties.com/pstnuke/test/ts2info.php
Blank page?
Anyway
TS2 IP: 209.120.238.85:8767
:)

Deckard
29-12-2003, 20:29
Originally posted by Croatia [ICL]
I dont quite know what TS URL is?
But anyway i uploaded script:
http://www.adriatic-properties.com/pstnuke/test/ts2info.php
Blank page?
Anyway
TS2 IP: 209.120.238.85:8767
:)

For the TS URL, if the TS server is running on the same computer at the HTTP Server it should be 127.0.0.1. If it's running on another computer just use the TS IP 209.120.238.85, but make sure the ports are open if you use a Firewall.

You need more than TS2Info.php to make it work.
TS2Info is a script to get all the data, but doesn't deal with the display... For that you need another script posted earlier on (it include TS2info.php).

Wolpe
29-12-2003, 20:54
Here is a Link to 3 Example Scripts:

http://con.dyndns.info/seiten/downloads/files/teamspeak/online.zip

Croatia [ICL]
29-12-2003, 21:03
Thanks, i am gonna edit those script to create one that i like:D

scab
29-12-2003, 23:53
Is there any way to pull player info for just certain channels?

I ask cause I use a semi-private/public TS server with like 287 channels.

I would just like to display my main channel and sub-channels.

thanks in advance if anyone can help out.

Deckard
30-12-2003, 00:58
This should do it (using T2INfo.php and making the changes for your server IP).

Just change the "What_Ever_You_Feel_Like" to your Channel Name (Line 6 of the code).


<?php
// retrieve server info
require("TSInfo.php");
$tss2info->getInfo();
$tss2info->userName="Guest";
$Your_Channel_Name = "What_Ever_You_Feel_Like";

// display channel list
echo " <TABLE BORDER=2 WIDTH=\"130\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDERCOLOR=\"BLACK\">\n";
echo " <TR><TD ALIGN=\"CENTER\"><FONT FACE=\"Verdana,Arial\" SIZE=\"2\" COLOR=\"WHITE\"><B>TeamSpeak</B></FONT></TD></TR>\n";
$counter = 0;
foreach($tss2info->channelList as $channelInfo) {
$channelname = $channelInfo[channelname];

// determine codec (verbose)
$codec = $tss2info->getVerboseCodec($channelInfo[codec]);

// default?
if($channelInfo[isdefault] == "1") $isDefault = "yes"; else $isDefault = "no";

if ($channelInfo[channelid] != "id") {
if ($channelname == $Your_Channel_Name) {
echo ("<tr align=\"center\" valign=\"top\"><td><I><FONT COLOR=\"#424274\">".$channelname."</FONT></I></td></tr>\n");
$counter_player = 0;
foreach($tss2info->playerList as $playerInfo) {
if ($playerInfo[channelid] == $channelInfo[channelid]) {
echo("<tr align=\"center\" valign=\"top\"><td><B>".$playerInfo[playername]."<B></td></tr>\n");
$counter_player++;
}
}
}
if($counter_player == 0) echo ("<tr><td colspan=\"7\" align=\"CENTER\">Nobody</td></tr>\n");
}
$counter++;
}// end foreach

if ($counter == 0) echo ("<tr><td colspan=\"7\" align=\"CENTER\">Offline</td></tr>\n");

echo ("</table>\n</div>\n");
?>

aegis123
30-12-2003, 18:44
k I downloaded that online zip with the 3 scripts and the ts2info.php script but how do I inplement them in my website

Brain
05-01-2004, 15:38
Hello all, it's been some time. I've been very ill and i'm slowly getting better. Unfortunately i had to shut down my private web server because it was what has slowly poisoned me over the last two years. I can now move and type again without pain and i'm in the process of setting up a rental server with a new domain, :p
I don't know when it will be finished, but i'll keep you informed. I'm going to give the whole info script a complete do-over, so stay tuned :-)

Cheers,
Brain

Dummer Sack
05-01-2004, 18:10
While you are at it, use somthing else than fscaf.
This is not working when users have spaces in their names.
And you can add the last parameter which is the registred user name.

Deckard
05-01-2004, 18:11
Take care Brain and get well mate.

SatanClaus
05-01-2004, 18:20
yupp... heads up and our best wishes...

get better soon ;)

cu
SatanClaus in place of the TS-Team

CyberWolf
05-01-2004, 22:06
Hello,

Have you all seen on a Linux server hosting the scripts when this script is running that users that have "space's" in there names only get displayed with the 1st part of there name?

User Jimbo Tomson Slim would show up as just Jimbo

cluteman
07-01-2004, 01:29
Originally posted by Wolpe
[B]Yeah it works !!

THX !!

I don't need so many Infos.
So i modified the basic PHP File.
But how can i display th channelname in playerlist ?
www.con.ipme.de

I wanted the channelname in the playerlist as well, so I played around with the code a bit (still a bit of a php newb), and managed to get it working.

Edited online3.php file: <p><?php
// retrieve server info
require("ts2info.php");
$tss2info->getInfo();
$tss2info->userName="Guest";

echo "<table border=\"1\" cellspacing=\"2\" cellpadding=\"5\" bordercolor=\"#000000\"><thead align=\"center\"><th>User ID</th><th>Channel</th><th>User Name</th><th>Status</th><th>Total Time</th>";
$counter = 0;

foreach($tss2info->channelList as $channelInfo) {
// default channel?
if($channelInfo[isdefault] == 1) {
$channelname = "<b>".$channelInfo[channelname]."</b>";
} else {
$channelname = $channelInfo[channelname];
}// end if
$channelarray[$channelInfo[channelid]] = $channelname;
}// end foreach

foreach($tss2info->playerList as $playerInfo) {
// calculate times
$totaltime = date("H:i:s", mktime(floor($playerInfo[totaltime] / 3600), floor(($playerInfo[totaltime] % 3600) / 60), $playerInfo[totaltime] % 60));
$idletime = date("H:i:s", mktime(floor($playerInfo[idletime] / 3600), floor(($playerInfo[idletime] % 3600) / 60), $playerInfo[idletime] % 60));
if(!empty($playerInfo[playerlogin])) $playerInfo[playerlogin] ="registered" ; else $playerInfo[playerlogin] ="unregistered";
if($counter <> 0) echo("<tr align=\"center\" valign=\"top\"><td>".$playerInfo[playerid]."</td><td>".$channelarray[$playerInfo[channelid]]."</td><td>".$playerInfo[playername]."</td><td>".$playerInfo[playerlogin]."</td><td>".$totaltime."</td></tr>");

$counter++;
}// end foreach
if($counter == 0) echo ("<tr><td colspan=\"9\" align=\"CENTER\">No channels</td></tr>\n");
$counter--;
echo ("<tr><td colspan=\"9\" align=\"CENTER\"><h3>$counter User online</h3></td></tr>\n");
echo ("</table>\n</div>\n");
?></p>

The only thing I'm having trouble with is I have two channels showing up as default.. and it doesn't change even if I set another channel as default. Anyone else get this? Any way to fix it?

Deckard
08-01-2004, 02:36
Maybe a check on the channelname to get rid of the unnecessary channel ;) if ($channelInfo[channelname] == "The_Channel_You_Want_To_Keep") {...Or if you want to keep more than one:if (($channelInfo[channelname] == "The_First_Channel_You_Want_To_Keep") && ($channelInfo[channelname] == "The_second_Channel_You_Want_To_Keep")){...

jluerken
09-01-2004, 13:55
Can someone post a downloadable attachment here?

The thread is quite long and there are several changes made.

A simply package with the standard functionality would be fine.

Deckard
09-01-2004, 16:56
Can't you spend 5 seconds to check the previous post? A Post on the previous already contain a link to download the scripts.

You can get some HERE (http://www.MortsVivants.com/Downloads/TeamSpeak.zip)

Wolpe
13-01-2004, 02:24
Yeah !!

Thre're cool scripts.

I modified it for me.
To provide confusion with the other Scrip's i only place a Link to see what i do with those.

http://www.con.ipme.de/seiten/teamspeak/online.php

Who want's to see the Script's can Mail to clusterfun@t-online.de

Dummer Sack
13-01-2004, 16:27
@Brain: Minimaler Fehler in ts2dump.php. Drei </div> tags ohne <div>.

CyberWolf
14-01-2004, 06:37
Any way to get the total number of users online?

Have a output like..

1 User(s) Online

Dummer Sack
14-01-2004, 13:07
Just take the count() of the users array.

CyberWolf
14-01-2004, 15:07
;) I do not know anything about programing, wish I had the time to learn...could you give me a example?

Originally posted by Dummer Sack
Just take the count() of the users array.