PDA

View Full Version : Userliste als html mit *nix/bsd


MagicMad
09-11-2002, 20:17
well, since my TS Server somehow doesnt post anything to my webpost2 script here a small solution for a Userlist at least.

The following shell script saved as tsstatus.cgi in your webserver“s cgi-bin folder should do the trick: (if u have netcat installed, but who hasnt ?!?)

#!/bin/sh

#
# Teamspeak 2 - CGI Username Query
#
# (c) Martin Hauck 2002
#

PLY=`{ echo "sel 8767"; echo "pl 8767"; echo "quit"; } | /usr/local/bin/netcat localhost 51234`
COUNT=3

echo "Content-Type: text/html; charset=iso-8859-1"
echo "Cache-control: no-store" # HTTP/1.1 (or no-cache?)
echo "Pragma: no-cache" # HTTP/1.0
echo "Expires: `date -Ru`" # Expires now!
echo "Refresh: 30"
echo

echo "<html><head>"
echo "<LINK REL=STYLESHEET TYPE=\"text/css\" HREF=\"main.css\">"
echo "<title>Teamspeak Users</title></head>"
echo "<body bgcolor=\"#ffffff\" text=\"BLACK\" background=\"Background.jpg\">"

echo "<div align=\"center\">"
echo "<table border="1">"

if [ "$(echo $PLY | cut -d" " -f$COUNT)" = "OK" ]
then

echo "</table>"
echo "<br><br><small>no one connected..</small>"
echo "</body></html>"
exit 0

else

COUNT=`expr "$COUNT" + 1`

while [ "$(echo $(echo $PLY | cut -d"." -f$COUNT) | cut -d" " -f2)" != "OK" ]
do
echo "<tr><td>$(echo $(echo $PLY | cut -d"." -f$COUNT) | cut -d" " -f2)</td></tr>"
COUNT=`expr "$COUNT" + 3`
done

fi

echo "</table>"
echo "</div>"
echo "<br><small>userlisting v0.9<br>(c)Mad 2002</small>"
echo "</body></html>"
exit 0


CONFIGURE:
Just use your serveradress and queryport and maybe the server udpport used for the pl command.

So it has nothing to do with the webpost feature of the server; in fact it does directly query the server everytime its hit, so you have always the correct data shown up.

See it in Action here (http://tss.darktech.org).
I display the cgi in an IFRAME under the left menue.

jvhaarst
10-11-2002, 14:21
The pl 8767 isn't needed after a sel 8767...

For the rest :
I'm impressed by the easy solution. I was using difficult telnet parsing, this is a lot easier.
I think I'll rewrite my script to use netcat.