mbutschek
19-01-2004, 15:19
(english text see inside the script!)
Hier ein kleines Script, um einen registrierten User, der gerade online ist, zum SA zu ernennen. Hintergrund ist folgender: Oft will man auf seinem eigenen Server nicht als SA sein, da die Leute gleich mit 100 Fragen losstürmen. Doch bleibt man "anonmy" als normaler User und braucht man dann mal SA-Status, muß man neu connecten.
Mit diesem Script ist es möglich, den eigenen Login-Namen (nicht NICK!) jederzeit per Tastendruck zum SA zu machen. Das geht dank PHP4 sowohl von der Linuux Shell aus wie auch über eine Webseite. Das Script hat KEINE Fehlerprüfung, also nicht 100% sauber. Das Script ist frei von copyright und darf von jedermann benutzt werden. Für Funktionsweise, rechtliche Hinweise, etc bitte den Text im Script lesen.
#! /usr/bin/php4 -q
<?
# Settings
$TCPSERVER="localhost"; # Name or IP of the server
$TCPPORT=51234; # Port of the tcpquery
$TSPORT=8767; # Port of the TS server
$SULOGIN="superadmin"; # Name of the super admin
$SUPASSWORD="mypassword"; # Password of the super admin
$SALOGIN="mike"; # Name which uses SA to log on
#
# Often SA want to talk on their server without SA status (too
# many questions from player) but if they need SA, they have to
# reconnect.
#
# This script is connection to a TeamSpeak TCPQUERY server,
# searches for Player with a given login and grant them SA
# privileges.
#
# So you can stay regular registeres user and make yourself
# SA when you need it. This script will not remove SA, cause
# you can do it yourself, when you are SA.
#
# This script is public domain, no rights reserver, no copy-
# right, so you can use, give to others or change the script
# just as you like. But please be fair and upload better
# versions of this script to the TeamSpeak forum, so all
# users can use it, too.
#
# The script is using PHP4 (script is not compatible with PHP3!),
# you can run it as a linux shellscript (chmod 700, your password
# is stored there!) or on a webserver with PHP support.
#
# btw: Line 1 and 5-10 must me edited! Insert correct path of
# the php interpreter and your server and login informations.
#
# Other thing: This script has NO ERROR VERIFYING! If the
# server answers in a not expected way, the script will fail!
#
# I give NO guaranty for functionality damage by this script.
# You can use is or let it be. It work's at my TS-server in
# version 2.0.19.40, I don't know what other versions do, but
# you can test it yourself and alter the script if you need.
#
# I give actually no support to that or other scripts, but
# if you have a question, you can try emailing me. But please
# no questions like "how do i install". Learn yourself that.
# Michael Butschek <tss@butschek.de>
#
# FUNCTION TO READ DATA FROM SERVER
function tcpquery($data)
# Send a string $data to the server and read
# answer from the server (including echo and
# ok or error at the end!
{
global $handle;
fputs($handle, $data."\n");
$data="";
$newdata=" ";
while ($newdata!="")
{
$newdata="";
$newdata=fgets($handle,1024);
$data.=$newdata;
}
return $data;
}
# Open the connection to the server.
# Connect timeout is 5 seconds
$handle=fsockopen($TCPSERVER, $TCPPORT, $errno, $errstr, 5);
if (!$handle)
die ("Verbindungsaufbau fehlgeschlagen:\n($errno) $errstr");
socket_set_blocking($handle, 0);
# Send empty string to clear the buffer (welcome-message)
tcpquery("");
# Select server port
tcpquery("sel $TSPORT\n");
# Login as superadmin
# Hint: If you want to use this script NOT as superadmin
# but as regular admin of a server, use "login" instread
# of "slogin"
tcpquery("slogin $SULOGIN $SUPASSWORD\n");
# Read the playerlist
$PLAYERDATA=tcpquery("pl\n");
# Alter string output to array,
# each line will be an element of the array
$PLAYERDATA=explode("\n", $PLAYERDATA);
# Repeat for every element in array (=every line)...
while(list($KEY, $LINE)=each ($PLAYERDATA))
{
# Alter Line-String to Array (TAB-Seperared)
$LINEARRAY=explode("\t", trim($LINE));
# check if element 15 (login) is same as $SALOGIN
if ($LINEARRAY[15]=="\"$SALOGIN\"")
{
# If true, then give this player (p_id = element 0)
# admin permissions.
tcpquery("sppriv $LINEARRAY[0] privilege_serveradmin 1\n");
# Type action on screen
echo("User $LINEARRAY[14] granted SA privileges");
}
}
# Send quit to the server (leave tcpquery)
tcpquery("quit\n");
# Close server connection
fclose($handle);
# Just give out one more enter
# (looks better in shell, I think)
echo "\n";
?>
Hier ein kleines Script, um einen registrierten User, der gerade online ist, zum SA zu ernennen. Hintergrund ist folgender: Oft will man auf seinem eigenen Server nicht als SA sein, da die Leute gleich mit 100 Fragen losstürmen. Doch bleibt man "anonmy" als normaler User und braucht man dann mal SA-Status, muß man neu connecten.
Mit diesem Script ist es möglich, den eigenen Login-Namen (nicht NICK!) jederzeit per Tastendruck zum SA zu machen. Das geht dank PHP4 sowohl von der Linuux Shell aus wie auch über eine Webseite. Das Script hat KEINE Fehlerprüfung, also nicht 100% sauber. Das Script ist frei von copyright und darf von jedermann benutzt werden. Für Funktionsweise, rechtliche Hinweise, etc bitte den Text im Script lesen.
#! /usr/bin/php4 -q
<?
# Settings
$TCPSERVER="localhost"; # Name or IP of the server
$TCPPORT=51234; # Port of the tcpquery
$TSPORT=8767; # Port of the TS server
$SULOGIN="superadmin"; # Name of the super admin
$SUPASSWORD="mypassword"; # Password of the super admin
$SALOGIN="mike"; # Name which uses SA to log on
#
# Often SA want to talk on their server without SA status (too
# many questions from player) but if they need SA, they have to
# reconnect.
#
# This script is connection to a TeamSpeak TCPQUERY server,
# searches for Player with a given login and grant them SA
# privileges.
#
# So you can stay regular registeres user and make yourself
# SA when you need it. This script will not remove SA, cause
# you can do it yourself, when you are SA.
#
# This script is public domain, no rights reserver, no copy-
# right, so you can use, give to others or change the script
# just as you like. But please be fair and upload better
# versions of this script to the TeamSpeak forum, so all
# users can use it, too.
#
# The script is using PHP4 (script is not compatible with PHP3!),
# you can run it as a linux shellscript (chmod 700, your password
# is stored there!) or on a webserver with PHP support.
#
# btw: Line 1 and 5-10 must me edited! Insert correct path of
# the php interpreter and your server and login informations.
#
# Other thing: This script has NO ERROR VERIFYING! If the
# server answers in a not expected way, the script will fail!
#
# I give NO guaranty for functionality damage by this script.
# You can use is or let it be. It work's at my TS-server in
# version 2.0.19.40, I don't know what other versions do, but
# you can test it yourself and alter the script if you need.
#
# I give actually no support to that or other scripts, but
# if you have a question, you can try emailing me. But please
# no questions like "how do i install". Learn yourself that.
# Michael Butschek <tss@butschek.de>
#
# FUNCTION TO READ DATA FROM SERVER
function tcpquery($data)
# Send a string $data to the server and read
# answer from the server (including echo and
# ok or error at the end!
{
global $handle;
fputs($handle, $data."\n");
$data="";
$newdata=" ";
while ($newdata!="")
{
$newdata="";
$newdata=fgets($handle,1024);
$data.=$newdata;
}
return $data;
}
# Open the connection to the server.
# Connect timeout is 5 seconds
$handle=fsockopen($TCPSERVER, $TCPPORT, $errno, $errstr, 5);
if (!$handle)
die ("Verbindungsaufbau fehlgeschlagen:\n($errno) $errstr");
socket_set_blocking($handle, 0);
# Send empty string to clear the buffer (welcome-message)
tcpquery("");
# Select server port
tcpquery("sel $TSPORT\n");
# Login as superadmin
# Hint: If you want to use this script NOT as superadmin
# but as regular admin of a server, use "login" instread
# of "slogin"
tcpquery("slogin $SULOGIN $SUPASSWORD\n");
# Read the playerlist
$PLAYERDATA=tcpquery("pl\n");
# Alter string output to array,
# each line will be an element of the array
$PLAYERDATA=explode("\n", $PLAYERDATA);
# Repeat for every element in array (=every line)...
while(list($KEY, $LINE)=each ($PLAYERDATA))
{
# Alter Line-String to Array (TAB-Seperared)
$LINEARRAY=explode("\t", trim($LINE));
# check if element 15 (login) is same as $SALOGIN
if ($LINEARRAY[15]=="\"$SALOGIN\"")
{
# If true, then give this player (p_id = element 0)
# admin permissions.
tcpquery("sppriv $LINEARRAY[0] privilege_serveradmin 1\n");
# Type action on screen
echo("User $LINEARRAY[14] granted SA privileges");
}
}
# Send quit to the server (leave tcpquery)
tcpquery("quit\n");
# Close server connection
fclose($handle);
# Just give out one more enter
# (looks better in shell, I think)
echo "\n";
?>