Results 1 to 15 of 22
-
12-01-2010, 13:09 #1
-= TeamSpeak Lover =-
- Join Date
- Jan 2010
- Location
- Duesseldorf, Germany
- Posts
- 33
Script for displaying actualy valied token
You can implement this script in a resticted area of your Homepage and your users will see all valied tokens. New generated tokens will be displayed automatically and used tokens will disappear automaticaly too.
You have to fill some variables at the beginning and you can change the outfit of the output at the end.
I hope this will be usefull for some of you.PHP Code:<?php
/*
This script will connect to a TS3-Server via query-port and display
all actualy valied tokens for a desired servergroup.
Written by Nils Cibula
Dieses Script verbindet über den Query-Port zu einem TS3-Server und zeigt alle
aktuell verfügbaren Tokens für eine ausgewählte Gruppe an
Geschrieben von Nils Cibula
*/
// Fill in connection-information for your TS3-Server
// Ab hier die nötigen Informationen deines TS3-Servers eintragen
// IP-Adress of the TS3-Server
// IP-Adresse des TS3-Servers
$ip = 'xx.xx.xx.xx';
// query-port of the TS3-Server (default: 10011)
// Query-Port des TS3-Servers (Standard: 10011)
$t_port = '10011';
// ID of the virtual server
// Server-ID des virtuellen Servers
$sid = '1';
// Login-name for query
// Login-Name zur Abfrage
$Login_Name = 'serveradmin';
// password for query-user
// Passwort zur Abfrage
$Login_pwd = '********';
// ID of the group tokens will be displayed from
// ID der Gruppe dessen Tokens angezeigt werden sollen
$Group_id = '7';
// Don't change anything from here on (Except you are knowing what you are doing)!
// Ab hier keine Änderungen mehr vornehmen (außer du weist was du tust)!
// ------------------------------------------------------------------------------------------------------------
$error = array();
function sendCmd($fp, $cmd){
$msg = '';
fputs($fp, $cmd);
while(strpos($msg, 'msg=') === false){
$msg .= fread($fp, 8096);
}
if(!strpos($msg, 'msg=ok')){
return false;
}else{
return $msg;
}
}
error_reporting(E_ALL);
$i = 0;
$fp = @fsockopen($ip, $t_port, $errno, $errstr, 2);
if($fp){
$cmd = "use sid=".$sid."\n";
if(!($select = sendCmd($fp, $cmd))){
echo ("Auf Server 1 geschaltet");
$error[] = 'Wrong Server ID';
}
$cmd="login $Login_Name $Login_pwd\n";
if(!($sinfo = sendCmd($fp, $cmd))){
$error[] = 'Login Denied';
}
$cmd="tokenlist\n";
if(!($tokens = sendCmd($fp, $cmd))){
$error[] = 'no tokens availible';
}else{
$zeichen = explode('|',$tokens);
foreach ($zeichen as &$token) {
$token = explode(' ',$token);
if ($token[2]=='token_id1='.$Group_id){
$ausgabe = explode('=',$token[0]);
$FMToken[$i] = $ausgabe[1];
$i++;
}
}
}
}else{
$error[] = 'Can not connect to the server';
}
// here is the loop for the output. Add HTML-Code if you want a nice result
// Hier ist die Schleife für die Ausgabe. Fürge HTML-code hinzu, wenn du eine schönere Ausgabe wünscht.
foreach ($FMToken as &$AToken){
echo (stripcslashes($AToken)."<br><br>");
}
?>
-
12-01-2010, 14:08 #2
-= TeamSpeak User =-
- Join Date
- Jan 2010
- Location
- Germany
- Posts
- 3
This is very nice, great work!
Must i use the serveradmin logindate, i think this is a high risk.
-
12-01-2010, 14:22 #3
-= TeamSpeak Lover =-
- Join Date
- Jan 2010
- Location
- Duesseldorf, Germany
- Posts
- 33
Hello,
I'm happy that you enjoy my script. At the Moment I don't have another solution but using the serveradmin.
Knowing the risk I've opend another thread yesterday (http://forum.teamspeak.com/showthread.php?t=49680), but it seems to be impossible otherwise.
If anyone finds a better way I will be very happy and change my script then.
-
13-01-2010, 19:19 #4
Notice: Undefined variable: FMToken in F:\XAMPP\HS_Uncut_XAMPP_Paket\xampp\htdocs\afk\tes t.php on line 99
Warning: Invalid argument supplied for foreach() in F:\XAMPP\HS_Uncut_XAMPP_Paket\xampp\htdocs\afk\tes t.php on line 99
Sourcecode:
PHP Code:foreach ($FMToken as &$AToken){
echo (stripcslashes($AToken)."<br><br>");
}
-
15-01-2010, 13:54 #5
-= TeamSpeak Lover =-
- Join Date
- Jan 2010
- Location
- Duesseldorf, Germany
- Posts
- 33
I tested the script again and it works fine for me.
But checking the code again I noticed, that I forgot to carry a about the situation, that there are no tokens availible. May be this is your situation.
I will try it later today an post an update of my script if nessesary.
Meanwhile you can try, wether there are actually tokens for the configured group or not. If not please generate one and try again.
-
15-01-2010, 18:52 #6
-= TeamSpeak User =-
- Join Date
- Dec 2009
- Location
- Germany
- Posts
- 26
On my site running the script
-
15-01-2010, 19:09 #7
-= TeamSpeak Lover =-
- Join Date
- Jan 2010
- Location
- Duesseldorf, Germany
- Posts
- 33
I have tested the script and got no errors. If there are no tokens availible, I got no output.
But I improved my script with some new features:
Now you can decide what the script will do, when no tokens are availible. You can let it generate a new token and dislplay it, or you can display a message instead.PHP Code:<?php
/*
This script will connect to a TS3-Server via query-port and display
all actualy valied tokens for a desired servergroup.
Written by Nils Cibula
Dieses Script verbindet über den Query-Port zu einem TS3-Server und zeigt alle
aktuell verfügbaren Tokens für eine ausgewählte Gruppe an
Geschrieben von Nils Cibula
*/
// Fill in connection-information for your TS3-Server
// Ab hier die nötigen Informationen deines TS3-Servers eintragen
// IP-Adress of the TS3-Server
// IP-Adresse des TS3-Servers
$ip = 'XX.XX.XX.XX';
// query-port of the TS3-Server (default: 10011)
// Query-Port des TS3-Servers (Standard: 10011)
$t_port = '10011';
// ID of the virtual server
// Server-ID des virtuellen Servers
$sid = '1';
// Login-name for query
// Login-Name zur Abfrage
$Login_Name = 'serveradmin';
// password for query-user
// Passwort zur Abfrage
$Login_pwd = '********';
// ID of the group tokens will be displayed from
// ID der Gruppe dessen Tokens angezeigt werden sollen
$Group_id = '7';
// Message if there are no tokens availible
// Nachrit wenn keine Tokens verfügbar sind
$NoTokens = 'No Tokens generated, please see your serveradministrator!';
// Generate a Token if there is none (0=No, display message instead | 1=Yes
// Neues Token erstellen falls keines verfügbar (0 = Nein, zeige die Meldung stattdessen | 1 = Yes)
$GenerateToken = '1';
// Here you can enter Text to be displayed before and after each token
// (e.g. before="<li>" and after = "</li>" to display Tokens in an unordered list)
// Hier kann Text festgelegt werden, der vor und nach jedem Token ausgegeben wird
// (z.B. vorher="<li>" und nachher = "</li>" um die Tokens in einer Liste auszugeben
$TextBefore = '';
$TextAfter = '<br /><br />';
// Don't change anything from here on (Except you are knowing what you are doing)!
// Ab hier keine Änderungen mehr vornehmen (außer du weist was du tust)!
// ------------------------------------------------------------------------------------------------------------
$error = array();
function sendCmd($fp, $cmd){
$msg = '';
fputs($fp, $cmd);
while(strpos($msg, 'msg=') === false){
$msg .= fread($fp, 8096);
}
if(!strpos($msg, 'msg=ok')){
return false;
}else{
return $msg;
}
}
function readToken ($fp){
global $Group_id;
global $NoTokens;
$FMToken[0] = $NoTokens;
$cmd="tokenlist\n";
$i=0;
if(!($tokens = sendCmd($fp, $cmd))){
$error[] = 'no tokens availible';
}else{
$zeichen = explode('|',$tokens);
foreach ($zeichen as &$token) {
$token = explode(' ',$token);
if ($token[2]=='token_id1='.$Group_id){
$ausgabe = explode('=',$token[0]);
$FMToken[$i] = stripcslashes($ausgabe[1]);
$i++;
}
}
}
return $FMToken;
}
function makeToken ($fp){
global $Group_id;
$cmd="tokenadd tokentype=0 tokenid1=".$Group_id." tokenid2=0\n";
$newToken=sendCmd($fp, $cmd);
return $newToken;
}
error_reporting(E_ALL);
$fp = @fsockopen($ip, $t_port, $errno, $errstr, 2);
if($fp){
$cmd = "use sid=".$sid."\n";
if(!($select = sendCmd($fp, $cmd))){
echo ("Auf Server 1 geschaltet");
$error[] = 'Wrong Server ID';
}
$cmd="login $Login_Name $Login_pwd\n";
if(!($sinfo = sendCmd($fp, $cmd))){
$error[] = 'Login Denied';
}
$FMToken = readToken($fp);
if ($FMToken[0] === $NoTokens){
if ($GenerateToken === '1'){
$NewToken = makeToken($fp);
$FMToken = readToken($fp);
}
}
}else{
$error[] = 'Can not connect to the server';
}
// here is the loop for the output. Add HTML-Code if you want a nice result
// Hier ist die Schleife für die Ausgabe. Fürge HTML-code hinzu, wenn du eine schönere Ausgabe wünscht.
foreach ($FMToken as $AToken){
echo $TextBefore.($AToken).$TextAfter;
}
?>
Further you can define strings to be outputtet before and after each token.
Please report, wether this version works.Last edited by Harry.Fox; 15-01-2010 at 22:08.
-
15-01-2010, 22:14 #8
-= TeamSpeak Lover =-
- Join Date
- Jan 2010
- Location
- Duesseldorf, Germany
- Posts
- 33
I've found a littel mistake in the script above and corrected it.
If you've copied the code bevore this post please copy it again!
Best regards
Harry.Fox
P.S.: I wold be happy about some feedback
-
16-01-2010, 15:00 #9
-= TeamSpeak User =-
- Join Date
- Dec 2009
- Location
- Germany
- Posts
- 26
It works well
-
16-01-2010, 22:18 #10
-= TeamSpeak User =-
- Join Date
- Jan 2010
- Location
- Switzerland
- Posts
- 10
Thanks. I could have written it myself, but this way I easily saved an hour. You're the best!
-
16-01-2010, 22:26 #11
-= TeamSpeak Fanatic =-
- Join Date
- Jan 2010
- Location
- Secret Base in Arctic Region
- Posts
- 1,187
If the server is running with MySQL you could do some queries on the "tokens" table directly instead of using the server-query function.
-
16-01-2010, 22:55 #12
ill test it if im at home, maybe i got the "bug" because i allready got the beta13 for testing, and on beta13, the tokes got other stuff. PM me to get more infos about it. btw on pm you can speak german with me.
greetz
Cobra
-
18-01-2010, 18:17 #13
-= TeamSpeak User =-
- Join Date
- Dec 2009
- Location
- Germany
- Posts
- 26
no works with new Beta15 Server
-
19-01-2010, 05:35 #14
-= TeamSpeak User =-
- Join Date
- Jan 2010
- Location
- uk
- Posts
- 4
From ur first script i get:
Notice: Undefined variable: FMToken in /home/alpha10/public_html/ts3php.php on line 99
Warning: Invalid argument supplied for foreach() in /home/alpha10/public_html/ts3php.php on line 99
Also get same for the 2nd script (line 127 then i think)
Could i ask, are you running this from the host or remotely?
-
19-01-2010, 12:36 #15
-= TeamSpeak Lover =-
- Join Date
- Apr 2007
- Location
- Germany
- Posts
- 98
This error is shown if you use "localhost" or equivalent terms (like 127.0.0.1) instead of your external IP!
@author:
You should add a exception for this case
You should also fix the exception thrown for "No connection" because there is no error shown at the moment.
And you should declare all variables at the beginning of the script to avoid errors.
Maybe you want to use this version instead:
Fixed the most epic english-fails I noticedPHP Code:<?php
/*
This script will connect to a TS3-Server via query-port and display
all actualy valied tokens for a desired servergroup.
Written by Nils Cibula
Dieses Script verbindet über den Query-Port zu einem TS3-Server und zeigt alle
aktuell verfügbaren Tokens für eine ausgewählte Gruppe an
Geschrieben von Nils Cibula
*/
// Fill in connection-information for your TS3-Server
// Ab hier die nötigen Informationen deines TS3-Servers eintragen
// IP-Adress of the TS3-Server (NOT localhost or 127.0.0.1)
// IP-Adresse des TS3-Servers (NICHT localhost or 127.0.0.1)
$ip = '';
// query-port of the TS3-Server (default: 10011)
// Query-Port des TS3-Servers (Standard: 10011)
$t_port = '10011';
// ID of the virtual server
// Server-ID des virtuellen Servers
$sid = '1';
// Login-name for query
// Login-Name zur Abfrage
$Login_Name = 'serveradmin';
// password for query-user
// Passwort zur Abfrage
$Login_pwd = '*********';
// ID of the group tokens will be displayed from
// ID der Gruppe dessen Tokens angezeigt werden sollen
$Group_id = '7';
// Message if there are no tokens available
// Nachrit wenn keine Tokens verfügbar sind
$NoTokens = 'No tokens available, please contact your serveradministrator!';
// Generate a Token if there is none (0=No, display message instead | 1=Yes
// Neues Token erstellen falls keines verfügbar (0 = Nein, zeige die Meldung stattdessen | 1 = Yes)
$GenerateToken = false;
// Here you can enter Text to be displayed before and after each token
// (e.g. before="<li>" and after = "</li>" to display Tokens in an unordered list)
// Hier kann Text festgelegt werden, der vor und nach jedem Token ausgegeben wird
// (z.B. vorher="<li>" und nachher = "</li>" um die Tokens in einer Liste auszugeben
$TextBefore = '';
$TextAfter = '<br /><br />';
// Here you are able to activate the debug-mode (true / false)
// Hier kannst du den Debugmodus aktiveren (true = an / false = aus)
$debug = true;
// Don't change anything from here on (Except you know what you are doing)!
// Ab hier keine Änderungen mehr vornehmen (außer du weist was du tust)!
// ------------------------------------------------------------------------------------------------------------
$error = array();
$FMToken = array();
function sendCmd($fp, $cmd){
$msg = '';
fputs($fp, $cmd);
while(strpos($msg, 'msg=') === false){
$msg .= fread($fp, 8096);
}
if(!strpos($msg, 'msg=ok')){
return false;
}else{
return $msg;
}
}
function readToken ($fp){
global $Group_id;
global $NoTokens;
$FMToken[0] = $NoTokens;
$cmd="tokenlist\n";
$i=0;
if(!($tokens = sendCmd($fp, $cmd))){
$error[] = 'no tokens availible';
}else{
$zeichen = explode('|',$tokens);
foreach ($zeichen as &$token) {
$token = explode(' ',$token);
if ($token[2]=='token_id1='.$Group_id){
$ausgabe = explode('=',$token[0]);
$FMToken[$i] = stripcslashes($ausgabe[1]);
$i++;
}
}
}
return $FMToken;
}
function makeToken ($fp){
global $Group_id;
$cmd="tokenadd tokentype=0 tokenid1=".$Group_id." tokenid2=0\n";
$newToken=sendCmd($fp, $cmd);
return $newToken;
}
error_reporting(E_ALL);
If ($ip === "127.0.0.1" || $ip === "localhost") {
$error[] = 'Connection failed! Use your external IP, <b>NOT</b> "localhost" or "127.0.0.1"!';
} else {
$fp = @fsockopen($ip, $t_port, $errno, $errstr, 2);
if($fp){
$cmd = "use sid=".$sid."\n";
if(!($select = sendCmd($fp, $cmd))){
echo ("Auf Server 1 geschaltet");
$error[] = 'Wrong Server ID';
}
$cmd="login $Login_Name $Login_pwd\n";
if(!($sinfo = sendCmd($fp, $cmd))){
$error[] = 'Login Denied';
}
$FMToken = readToken($fp);
if ($FMToken[0] === $NoTokens){
if ($GenerateToken){
$NewToken = makeToken($fp);
$FMToken = readToken($fp);
}
}
}else{
$error[] = 'Can not connect to the server';
}
}
// here is the loop for the output. Add HTML-Code if you want a nice result
// Hier ist die Schleife für die Ausgabe. Fürge HTML-code hinzu, wenn du eine schönere Ausgabe wünscht.
If ($debug) {
echo "<b>Debug Mode activated!</b><br>The following errors where thrown:<br><font color='red'>";
foreach ($error as $aerror){
echo $aerror."<br>";
}
echo "</font><br><br>";
} else {
foreach ($FMToken as $AToken){
echo $TextBefore.($AToken).$TextAfter;
}
}
?>
Fixed some typos, added additional checks and added $FMToken to $error (beginning). Feel free to use it...
Use your external IP, not with 127.0.0.1 or anthing like that.
I think it can be also run remotely but I don't promise anything
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Linux server startup script!
By mancert in forum Linux / FreeBSDReplies: 159Last Post: 24-09-2011, 16:51 -
New Teamspeak Query script for php: Teamspeak Display
By MrGuide@NL in forum [TeamSpeak 2] Addons & ScriptsReplies: 347Last Post: 06-08-2010, 17:17 -
Create token by php script and mysql
By Wikibear in forum Permission SystemReplies: 6Last Post: 28-12-2009, 19:31 -
[BUG-Feedback] About Token
By Blutgerinsel in forum Server SupportReplies: 0Last Post: 26-12-2009, 14:28 -
Bug? Token System
By Gubi1990 in forum Bug ReportsReplies: 4Last Post: 21-12-2009, 22:36


Reply With Quote

