Hallo ich möchte einen Teamspeak Viewer so umprogramieren das ich die TS Server Daten per URL angeben kann.
Also so:
Ich habe es schon mit get probirt aber leider kommt immer dieser fehler.
Klick
Ich habe unten den code eingefügt kann mir einer sagen wo der fehler ist und wie ich ihn beheben kann?.
PHPScript Code:
MFG Space24
P.S : Habe das komplette Script aneinander gehangen weil es sonst gar nicht funktionirt.
Also so:
Code:
TS_start.php?serverAddress=space-server.org&serverQueryPort=7394&serverUDPPort=9393
Code:
Parse error: parse error, expecting `','' or `';'' in /var/www/vhosts/space-server.org/httpdocs/ts/TS_start.php on line 8
Klick
Ich habe unten den code eingefügt kann mir einer sagen wo der fehler ist und wie ich ihn beheben kann?.
PHPScript Code:
Code:
<body>
<?php
class tss2info {
var $sitetitle = "Teamspeak Viewer 1.1"; // SeitenTitle und Scriptversion
var $_GET['serverAddress']; // Hier die TeamSpeak IP Adresse eintragen !!wichtig!! (Beispiel: 192.168.7.1)
var $_GET['serverQueryPort']; // TeamSpeak QueryPort.. Schau in die server.ini von TeamSpeak (Standard 51234)
var $_GET['serverUDPPort']; // UDP Port für Teamspeak der auch hinter der IP Adresse genutzt wird (Standard 8767)
var $tabellenbreite = "150"; // Mindestbreite der Teamspeaktabelle (die einbindung mit einem IFRAME sollte 20px mehr betragen)
var $refreshtime = "10"; // Zeit in Sekunden nach der die Anzeige aktualisiert wird, wenn "auto on" aktiv ist
var $serverPasswort = ""; // Serverpasswort das bei Serversettings eingestellt wird (wenn kein Passwort erteilt, dann leer lassen)
// (Passwort wird meistens bei Clanservern gebraucht)
// **** end of SETTINGS ****
/* Ab hier darf >>> KEIN <<< Text mehr geändert werden */
//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 = 1;
while($attempts <= "1" and !$this->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 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, "", "", 0.3);
if($this->socket == false) {
return;
echo ("No Server");
} else {
$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");
list($playerid, $channelid, $receivedpackets, $receivedbytes, $sentpackets, $sentbytes, $paketlost, $pingtime, $totaltime, $idletime, $privileg, $userstatus, $attribute, $s, $playername) = $playerinfo;
if($playerid != "OK") {
$this->playerList[$playerid] = array("playerid" => $playerid,
"channelid" => $channelid,
"receivedpackets" => $receivedpackets,
"receivedbytes" => $receivedbytes,
"sentpackets" => $sentpackets,
"sentbytes" => $sentbytes,
"paketlost" => $paketlost / 100,
"pingtime" => $pingtime,
"totaltime" => $totaltime,
"idletime" => $idletime,
"privileg" => $privileg,
"userstatus" => $userstatus,
"attribute" => $attribute,
"s" => $s,
"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;
?>
<?php
$tss2info->getInfo();
$tss2info->userName="Guest";
?>
<html>
<head>
<title><?php echo $tss2info->sitetitle;?></title>
<style type="text/css">
<!--
body {
background-color: #A3A3CB;
margin: 1px;
font-family: Arial;
font-size: 10px;
scrollbar-base-color: #A3A3CB;
}
td.refresh {
font-family: Verdana,Arial;
font-size: 9px;
color: #424274;
}
a.channellink:link,
a.channellink:hover,
a.channellink:visited,
a.channellink:active {
text-decoration: none;
font: bold
font-family: Verdana, Arial;
font-size: 11px;
color: #424274;
}
a.refreshlink:link,
a.refreshlink:hover,
a.refreshlink:visited,
a.refreshlink:active {
text-decoration: none;
font-family: Verdana, Arial;
font-size: 9px;
color: #424274;
}
td.teamspeak {
font: bold
font-family: Verdana,Arial;
font-size: 13px;
color: #424274;
}
td.channel {
font: bold
font-family: Verdana, Arial;
font-size: 11px;
color: #424274;
}
td.player {
font-family: Verdana,Arial;
font-size: 9px;
color: #424274;
}
td.offline {
font: bold
font-family: Verdana,Arial;
font-size: 11px;
color: #FF0000;
}
//-->
</style>
</head>
<body>
<?php
// display channel list
echo "<table border=\"0\" width=\"".$tss2info->tabellenbreite."\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td>\n";
//-------------------------------------------------------------------------------------------------
//---> Refresh <---\\ Anfang
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"16\"><img src=\"TeamSpeak/refresh.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td><td class=\"refresh\"><a class=\"refreshlink\" href=\"TS_start.php\" target=\"_self\">refresh</a></td><td class=\"refresh\" align=\"right\"><a class=\"refreshlink\" href=\"TS_auto.php\" target=\"_self\">auto on</a></td></tr>\n";
echo "</tr>\n";
echo "</table>\n";
//---> Refresh <---\\ Ende
//-------------------------------------------------------------------------------------------------
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
//-------------------------------------------------------------------------------------------------
//---> TeamSpeak <---\\ Anfang
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"16\"><img src=\"TeamSpeak/teamspeak.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td><td class=\"teamspeak\"> TeamSpeak</td>\n";
echo "</tr>\n";
echo "</table>\n";
//---> TeamSpeak <---\\ Ende
//-------------------------------------------------------------------------------------------------
echo "</td>\n";
echo "</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") {
echo ("<tr>\n");
echo ("<td>\n");
//-------------------------------------------------------------------------------------------------
//---> Channel <---\\ Anfang
echo (" <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n");
echo (" <tr>\n");
echo (" <td width=\"32\"><img width=\"16\"height=\"16\" src=\"TeamSpeak/gitter2.gif\" border=\"0\" alt=\"\"><img src=\"TeamSpeak/channel.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td><td class=\"channel\"> <a class=\"channellink\" href=\"teamspeak://".$tss2info->serverAddress.":".$tss2info->serverUDPPort."/?channel=".$channelname."?password=".$tss2info->serverPasswort."\" title=\"".$channelInfo['topic']."\">".$channelname."</a> (".$channelInfo['currentplayers']."/".$channelInfo['maxplayers'].")</td>\n");
echo (" </tr>\n");
echo (" </table>\n");
//---> Channel <---\\ Ende
//-------------------------------------------------------------------------------------------------
echo ("</td>\n");
echo ("</tr>\n");
$counter_player = 0;
foreach($tss2info->playerList as $playerInfo) {
if ($playerInfo['channelid'] == $channelInfo['channelid']) {
//-------------------------------------------------------------------------------------------------
//--- UserStatusBild --\\
if ($playerInfo['attribute'] == "0") $playergif = "player.gif";
if (($playerInfo['attribute'] == "8") or
($playerInfo['attribute'] == "9") or
($playerInfo['attribute'] == "12") or
($playerInfo['attribute'] == "13") or
($playerInfo['attribute'] == "24") or
($playerInfo['attribute'] == "25") or
($playerInfo['attribute'] == "28") or
($playerInfo['attribute'] == "29") or
($playerInfo['attribute'] == "40") or
($playerInfo['attribute'] == "41") or
($playerInfo['attribute'] == "44") or
($playerInfo['attribute'] == "45") or
($playerInfo['attribute'] == "56") or
($playerInfo['attribute'] == "57")) $playergif = "away.gif";
if (($playerInfo['attribute'] == "16") or
($playerInfo['attribute'] == "17") or
($playerInfo['attribute'] == "20") or
($playerInfo['attribute'] == "21")) $playergif = "mutemicro.gif";
if (($playerInfo['attribute'] == "32") or
($playerInfo['attribute'] == "33") or
($playerInfo['attribute'] == "36") or
($playerInfo['attribute'] == "37") or
($playerInfo['attribute'] == "48") or
($playerInfo['attribute'] == "49") or
($playerInfo['attribute'] == "52") or
($playerInfo['attribute'] == "53")) $playergif = "mutespeakers.gif";
if ($playerInfo['attribute'] == "4") $playergif = "player.gif";
if (($playerInfo['attribute'] == "1") or
($playerInfo['attribute'] == "5")) $playergif = "channelcommander.gif";
//--- UserStatusBild --\\
//-------------------------------------------------------------------------------------------------
//--- UserRechte ---\\
if ($playerInfo['userstatus'] < "4") { $playerstatus = "U"; } // Unregistriert
if ($playerInfo['userstatus'] == "4") { $playerstatus = "R"; } // Registriert
if ($playerInfo['userstatus'] == "5") { $playerstatus = "R SA"; } // Serveradmin
//--- UserRechte ---\\
//-------------------------------------------------------------------------------------------------
//--- Privilegien ---\\
if ($playerInfo['privileg'] == "0") { $privileg = ""; } // nix
if ($playerInfo['privileg'] == "1") { $privileg = " CA"; } // Channeladmin
//--- Privilegien ---\\
//-------------------------------------------------------------------------------------------------
//--- Online Seit ---\\
if ($playerInfo['totaltime'] < 60 ) {
$playertotaltime = strftime("%S Sekunden", $playerInfo['totaltime']);
} else {
if ($playerInfo['totaltime'] >= 3600 ) {
$playertotaltime = strftime("%H:%M:%S Stunden", $playerInfo['totaltime'] - 3600);
} else {
$playertotaltime = strftime("%M:%S Minuten", $playerInfo['totaltime']);
}
}
//--- Online Seit ---\\
//-------------------------------------------------------------------------------------------------
//--- Idle Seit ---\\
if ($playerInfo['idletime'] < 60 ) {
$playeridletime = strftime("%S Sekunden", $playerInfo['idletime']);
} else {
if ($playerInfo['idletime'] >= 3600 ) {
$playeridletime = strftime("%H:%M:%S Stunden", $playerInfo['idletime'] - 3600);
} else {
$playeridletime = strftime("%M:%S Minuten", $playerInfo['idletime']);
}
}
//--- Idle Seit ---\\
//-------------------------------------------------------------------------------------------------
//---> Player <---\\ Anfang
echo ("<tr>\n");
echo ("<td>\n");
echo (" <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n");
echo (" <tr><td width=\"48\"><img src=\"TeamSpeak/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"TeamSpeak/gitter2.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"TeamSpeak/".$playergif."\" width=\"16\"height=\"16\" border=\"0\" alt=\"Time [online:".$playertotaltime." | idle:".$playeridletime."] Ping:".$playerInfo['pingtime']."ms\"></td><td class=\"player\" title=\"Time [online:".$playertotaltime." | idle:".$playeridletime."] Ping:".$playerInfo['pingtime']."ms\"> ".$playerInfo['playername']." (".$playerstatus."".$privileg.")</td></tr>\n");
echo (" </table>\n");
echo ("</td>\n");
echo ("</tr>\n");
//---> Player <---\\ Ende
//-------------------------------------------------------------------------------------------------
$counter_player++;
}
}
}
$counter++;
}// end foreach
//-------------------------------------------------------------------------------------------------
//---> OFFLINE <---\\
if ($counter == 0) {
echo ("<tr>\n");
echo ("<td>\n");
echo (" <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n");
echo (" <tr><td class=\"offline\" width=\"110\"align=\"center\" colspan=\"2\"><b>Offline</b></td></tr>\n");
echo (" </table>\n");
echo ("</td>\n");
echo ("</tr>\n");
}
//---> OFFLINE <---\\
//-------------------------------------------------------------------------------------------------
echo ("<tr>\n");
echo ("<td class=\"player\">\n<br>");
echo ($tss2info->sitetitle."<br>\n");
echo ("created by <a href=\"http://www.php-gfx.net\" target=\"_blank\">Dooki</a><br>\n");
echo ("</td>\n");
echo ("</tr>\n");
echo ("</table>\n");
?>
</body>
</html>
MFG Space24
P.S : Habe das komplette Script aneinander gehangen weil es sonst gar nicht funktionirt.
Zuletzt bearbeitet: