Codeschnipsel - TS2 Viewer Generator by Micha


Hallo, heute will ich euch Zeigen, wie man einen Teamspeak 2 Viewer generiert!
Ich habe bereits einen generierten Code zusammengestellt.

 

1. Die Show Viewer Datei:

 

PHP Code:  Bitte in dieser Datei nur den Style ändern!

Code:
<?php // Hier könnt ihr den Pfad der Configdatei beliebig verändern. require("config.php"); $tss2info->getInfo(); $tss2info->userName="User"; // Gebt hier den Namen ein, den der User beim Connecten zugeteilt bekommt. ?> <html> <head> <title><?php echo $tss2info->sitetitle;?></title> <style type="text/css"> <!-- body { background-color: #FFFFFF; //Hintergrundfarbe margin: 1px; font-family: Verdana; font-size: 9px; SCROLLBAR-base-COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #000000; } td.refresh { font-family: Verdana; font-size: 9px; color: #000000; } a.channellink:link, a.channellink:hover, a.channellink:visited, a.channellink:active { text-decoration: none; font: font-family: Verdana; font-size: 9px; color: #000000; } a.refreshlink:link, a.refreshlink:hover, a.refreshlink:visited, a.refreshlink:active { text-decoration: none; font-family: Verdana; font-size: 9px; color: #000000; } td.teamspeak { font: font-family: Verdana; font-size: 9px; color: #000000; } td.channel { font: font-family: Verdana; font-size: 9px; color: #000000; } td.player { font-family: Verdana,Arial; font-size: 9px; color: #000000; } td.offline { font: font-family: Verdana; font-size: 9px; color: #000000; } //.Stil1 {font-size: 10px} .Stil2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;} --> </style> <?php if (isset($HTTP_GET_VARS["auto"])) { $auto = $HTTP_GET_VARS["auto"]; } else { $auto = 0; } if ($auto==1) { echo '<meta http-equiv="refresh" content="'.$tss2info->refreshtime.'" URL='.$PHP_SELF.'?auto=1">'; } ?> </head> <body class="channel Stil2"> <?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"; if ($auto==1) { echo ""; } else { echo ""; } 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=\"33\"><img src=\"images/teamspeak.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td><td class=\"teamspeak\">Teamspeak² Viewer</td>n"; echo "</tr>n"; echo "</table>n"; //---> TeamSpeak <---\ Ende   $result = getSubChannel();   //------------------------------------------------------------------------------------------------- //---> OFFLINE <---\ if ($result != "") { echo $result; } else { 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\"><i>Teamspeak is down!</i></td></tr>n"); echo ("</table>n"); echo ("</td>n"); echo ("</tr>n"); }   //---> OFFLINE <---\ //------------------------------------------------------------------------------------------------- echo ("</table>n"); ?> </body> </html> <?php   function getPlayer($chanelID, $channelID, $SubCounter) { global $tss2info; //$channelInfo = $tss2info->channelList[$chanelID]; $player = "";   foreach($tss2info->playerList as $playerInfo) { if ($playerInfo[channelid] == $channelID) {   //------------------------------------------------------------------------------------------------- $player .= ("<tr>n"); $player .= ("<td>n"); $player .= (" <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">n");   $width=32; $gitter=""; for ($i=0;$i<=$SubCounter;$i++) { $width+=16; $gitter .= "<img src=\"images/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\">"; }   //if ($channelInfo[parent]==-1) { $player .= (" <tr><td width=\"$width\">$gitter<img src=\"images/gitter2.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"images/".$playerInfo[attribute]."\" width=\"16\"height=\"16\" border=\"0\" alt=\"Time [online: ".$playerInfo[totaltime]." | idle: ".$playerInfo[idletime]."] Ping:".$playerInfo[pingtime]."ms\"></td><td class=\"player\" title=\"Time [online: ".$playerInfo[totaltime]." | idle:".$playerInfo[idletime]."] Ping:".$playerInfo[pingtime]."ms\"> ".$playerInfo[playername]." ".$playerInfo[flags]."</td></tr>n"); //} else { // $player .= (" <tr><td width=\"64\"><img src=\"images/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"images/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"images/gitter2.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"images/".$playerInfo[attribute]."\" width=\"16\"height=\"16\" border=\"0\" alt=\"Time [online: ".$playerInfo[totaltime]." | idle: ".$playerInfo[idletime]."] Ping:".$playerInfo[pingtime]."ms\"></td><td class=\"player\" title=\"Time [online: ".$playerInfo[totaltime]." | idle:".$playerInfo[idletime]."] Ping:".$playerInfo[pingtime]."ms\"> ".$playerInfo[playername]." ".$playerInfo[flags]."</td></tr>n"); //} $player .= (" </table>n"); $player .= ("</td>n"); $player .= ("</tr>n"); //---> Player <---\ Ende //------------------------------------------------------------------------------------------------- } } return $player; }   function getSubChannel($chanelID=-1,$SubCounter=0) { global $tss2info; $SubChannel = ""; if ($chanelID==-1) $SubCounter=0; else $SubCounter++; foreach($tss2info->channelList as $channelInfo) {   $channelname = $channelInfo[channelname]; // determine codec (verbose) $codec = $tss2info->getVerboseCodec($channelInfo[codec]);   if ($channelInfo[parent]==$chanelID) { $SubChannel .= ("<tr>n"); $SubChannel .= ("<td>n"); //------------------------------------------------------------------------------------------------- //---> Channel <---\ Anfang $SubChannel .= (" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">n"); $SubChannel .= (" <tr>n");   $width=32; $gitter=""; for ($i=1;$i<=$SubCounter;$i++) { $width+=16; $gitter .= "<img src=\"images/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\">"; }   $SubChannel .= (" <td width=\"$width\">$gitter<img width=\"16\"height=\"16\" src=\"images/gitter2.gif\" border=\"0\" alt=\"\"><img src=\"images/channel.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td>"); $SubChannel .= (" <td class=\"channel\"> <a class=\"channellink\" href=\"teamspeak://".$tss2info->serverAddress.":".$tss2info->serverUDPPort."/?channel=".$channelname."?nickname=User.?password=".$tss2info->serverPasswort."\" title=\"".$channelInfo[topic]."\">".$channelname."</a></td>n");   if ($SubCounter==0) $SubChannel .= (" <td class=\"player\"> ".$channelInfo[attribute]."</td>n");   $SubChannel .= (" </tr>n"); $SubChannel .= (" </table>n"); //---> Channel <---\ Ende //------------------------------------------------------------------------------------------------- $SubChannel .= ("</td>n"); $SubChannel .= ("</tr>n");   if ($SubChannel!="") $SubChannel .= getSubChannel($channelInfo[channelid],$SubCounter); //Rekusiver Aufruf!!   $SubChannel .= getPlayer($channelInfo[channelid],$channelInfo[channelid],$SubCounter); //User einfügen } } return $SubChannel; } echo ("<table>n"); echo ("<tr>n"); echo ("<td class=\"player\">n"); echo ("</td>n"); echo ("</tr>n"); echo ("</table>n");   ?>

Hinweis:

Diesen Code könnt ihr in eurem Design der Website einfügen. Macht es am besten in einer Tabelle.
Ihr könnt auch, wenn ihr den Viewer extern ohne Design anzeigen möchtet, dies natürlich auch tun.
Speichert dazu diese Datei einfach so: index.php

 

2. legt jetzt die Config.php an:

2.1 Legt zunächst euch eine neue Datei: config.php an.

 

PHP Code:  Bitte in dieser Datei nichts verändern!!!

Code:
<?php class tss2info {   // START OF CONFIG - NICHTS MEHR AENDERN!   var $serverAddress; var $serverQueryPort; var $serverUDPPort;   function tss2info($ip, $tcp, $udp) { $this->serverAddress = $ip; $this->serverQueryPort = $tcp; $this->serverUDPPort = $udp; }   // END OF CONFIG ---------------------------------   // Hier koennt ihr die refresh und Viewerbreite sowie den Namen des Viewer editieren var $refreshtime = 30; var $tabellenbreite = 250; var $sitetitle = "Ts² View";   // AB HIER NICHTS MEHR AENDERN! //internal var $socket; var $userdata;   // external var $serverStatus = "Down"; var $playerList = array(); var $channelList = array();       // 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() { $this->playerList = $this->getUserInfo($this->serverAddress, $this->serverQueryPort, $this->serverUDPPort); $this->channelList = $this->getChannelInfo($this->serverAddress, $this->serverQueryPort, $this->serverUDPPort); } // end getInfo()   function getChannelInfo($server_ip, $server_query, $server_port) { $channelList = array(); $cmd = "cl $server_portnquitn";   $connection = fsockopen ("$server_ip", $server_query, &$errno, &$errstr, 1); if (!$connection) { echo "Cannot connect: ($errno)-$errstr<br>"; } else { $error = fputs($connection,$cmd, strlen($cmd)); if (!$error) { echo "Cannot read Data!<br>"; } else {   while($channeldata = fgets($connection, 4096)) { $channeldata = explode(" ", $channeldata); $channeldata0 = trim($channeldata[0]); // number $channeldata1 = trim($channeldata[1]); // codec $channeldata2 = trim($channeldata[2]); // parent $channeldata3 = trim($channeldata[3]); // order $channeldata4 = trim($channeldata[4]); // maxuser   $channeldata5 = trim("$channeldata[5]"); $channeldata5 = substr("$channeldata5", 1); $channeldata5 = substr("$channeldata5", 0, -1); $channeldata5 = addslashes("$channeldata5"); // name $channeldata5 = htmlentities("$channeldata5"); // $channeldata5 = addslashes(trim($channeldata[5])); // name   $channeldata6 = trim($channeldata[6]); // channel flags $channeldata7 = trim($channeldata[7]); // priv/pub   $channeldata8 = trim("$channeldata[8]"); $channeldata8 = substr("$channeldata8", 1); $channeldata8 = substr("$channeldata8", 0, -1); $channeldata8 = addslashes(htmlspecialchars("$channeldata8")); // topic // $channeldata8 = addslashes(htmlspecialchars(trim($channeldata[8]))); // topic   $channelid = $channeldata0; if ($channelid > 0) { $channelList[$channelid] = array( "channelid" => $channelid, "codec" => $channeldata1, "parent" => $channeldata2, "order" => $channeldata3, "maxplayers" => $channeldata4, "channelname" => $channeldata5, "attribute" => $this->get_channel_flags($channeldata6), "isdefault" => 0, "topic" => $channeldata8); } } } fclose($connection); }     function cmp ($a, $b) { if ($a["order"] == $b["order"]) { return ($a["channelid"] < $b["channelid"]) ? -1 : 1; }//return 0; return ($a["order"] < $b["order"]) ? -1 : 1; } usort($channelList, "cmp");     return $channelList; }   function getUserInfo($server_ip, $server_query, $server_port) { $playerList = array(); $cmd = "pl $server_portnquitn";   $connection = fsockopen ("$server_ip", $server_query, &$errno, &$errstr, 1); if (!$connection) { echo "Cannot connect: ($errno)-$errstr<br>"; } else { fputs($connection,$cmd, strlen($cmd)); while($userdata = fgets($connection, 4096)) { $userdata = explode(" ", $userdata); $userdata0 = trim($userdata[0]); // pl_id $userdata1 = trim($userdata[1]); // pl_channelid $userdata2 = trim($userdata[2]); // pl_pktssend $userdata3 = trim($userdata[3]); // pl_bytessend $userdata4 = trim($userdata[4]); // pl_pktsrecv $userdata5 = trim($userdata[5]); // pl_bytesrecv $userdata6 = trim($userdata[6]); // pl_pktloss $userdata7 = trim($userdata[7]); // pl_ping $userdata8 = trim($userdata[8]); // pl_logintime $userdata9 = trim($userdata[9]); // pl_idletime $userdata10 = trim($userdata[10]); // pl_channelprivileges $userdata11 = trim($userdata[11]); // pl_playerprivileges $userdata12 = trim($userdata[12]); // pl_playerflags $userdata13 = trim($userdata[13]); // pl_ipaddress   $userdata14 = trim("$userdata[14]"); $userdata14 = substr("$userdata14", 1); $userdata14 = substr("$userdata14", 0, -1); $userdata14 = addslashes("$userdata14"); $userdata14 = htmlentities("$userdata14"); // pl_nickname // $userdata14 = addslashes(trim($userdata[14])); // pl_nickname   $userdata15 = trim("$userdata[15]"); $userdata15 = substr("$userdata15", 1); $userdata15 = substr("$userdata15", 0, -1); $userdata15 = addslashes("$userdata15"); // pl_loginname // $userdata15 = addslashes(trim($userdata[15])); // pl_loginname   $playerid = $userdata0;   $playerList[$playerid] = array( "playerid" => $playerid, "channelid" => $userdata1, "receivedpackets" => $userdata4, "receivedbytes" => $userdata5, "sentpackets" => $userdata2, "sentbytes" => $userdata3, "paketlost" => $userdata6 / 100, "pingtime" => $userdata7, "totaltime" => $this->setTimeString($userdata8), "idletime" => $this->setTimeString($userdata9), "privileg" => $userdata10, "userstatus" => $userdata11, "attribute" => $this->getUserStatusBild($userdata12), "flags" => $this->get_player_flags($userdata11,$userdata10), "s" => $userdata13, "playername" => $userdata14); } fclose($connection); } return $playerList; }   function get_player_flags($num1,$num2) { if ($num1 == '13') { $plpriv = "(R SA"; } else if ($num1 == '5') { $plpriv = "(R SA"; } else if ($num1 == '4') { $plpriv = "(R"; } else if ($num1 < '4') { $plpriv = "(U"; } if ($num2 == '1') { $clpriv = " CA)"; } else { $clpriv = ")"; } return $plpriv.$clpriv; }   function get_channel_flags($num) { // (RMPSD) (0 2 4 6 8 16) if ($num == '30') { $clflag = "(RMPSD)"; } else if ($num == '28') { $clflag = "(RPSD)"; } else if ($num == '26') { $clflag = "(RMSD)"; } else if ($num == '24') { $clflag = "(RSD)"; } else if ($num == '22') { $clflag = "(RMPD)"; } else if ($num == '20') { $clflag = "(RPD)"; } else if ($num == '18') { $clflag = "(RMD)"; } else if ($num == '16') { $clflag = "(RD)"; } else if ($num == '15') { $clflag = "(UMPS)"; } else if ($num == '14') { $clflag = "(RMPS)"; } else if ($num == '13') { $clflag = "(UPS)"; } else if ($num == '12') { $clflag = "(RPS)"; } else if ($cldata[9] == '11') { $clflag = "(UMS)"; } else if ($num == '10') { $clflag = "(RMS)"; } else if ($num == '9') { $clflag = "(US)"; } else if ($num == '8') { $clflag = "(RS)"; } else if ($num == '7') { $clflag = "(UMP)"; } else if ($num == '6') { $clflag = "(RMP)"; } else if ($num == '5') { $clflag = "(UP)"; } else if ($num == '4') { $clflag = "(RP)"; } else if ($num == '3') { $clflag = "(UM)"; } else if ($num == '2') { $clflag = "(RM)"; } else if ($num == '1') { $clflag = "(U)"; } else if ($num == '0') { $clflag = "(R)"; } else { $clflag = ""; } return $clflag; }   function getUserStatusBild($attribut) { //------------------------------------------------------------------------------------------------- //--- UserStatusBild --\ $playergif = "player.gif"; if ($attribut == "0") $playergif = "player.gif"; if (($attribut == "8") or ($attribut == "9") or ($attribut == "12") or ($attribut == "13") or ($attribut == "24") or ($attribut == "25") or ($attribut == "28") or ($attribut == "29") or ($attribut == "40") or ($attribut == "41") or ($attribut == "44") or ($attribut == "45") or ($attribut == "56") or ($attribut == "57")) $playergif = "away.gif"; if (($attribut == "16") or ($attribut == "17") or ($attribut == "20") or ($attribut == "21")) $playergif = "mutemicro.gif"; if (($attribut == "32") or ($attribut == "33") or ($attribut == "36") or ($attribut == "37") or ($attribut == "48") or ($attribut == "49") or ($attribut == "52") or ($attribut == "53")) $playergif = "mutespeakers.gif"; if ($attribut == "4") $playergif = "player.gif"; if (($attribut == "1") or ($attribut == "5")) $playergif = "channelcommander.gif"; if ($attribut >= "64") $playergif = "record.gif"; //--- UserStatusBild --\ //------------------------------------------------------------------------------------------------- return $playergif; } function setTimeString($time) { $timestring = "0 Sekunden"; if ($time < 60 ) { $timestring = strftime("%S Sekunden", $time); } else { if ($time >= 3600 ) { $timestring = strftime("%H:%M:%S Stunden", $time - 3600); } else { $timestring = strftime("%M:%S Minuten", $time); } } return htmlentities("$timestring"); }   } $tss2info = new tss2info($_REQUEST["ip"], $_REQUEST["tcp"], $_REQUEST["udp"]); ?>

 

3. GET Forumlar für das Generieren erstellen:

3.1 Erstellt euch eine Leere php oder html Seite.
3.2 Nun legt ihr 3 Textfelder an. Die nennt ihr so:

Eingabefeld IP Adresse: ip
Eingabefeld TCP Port: tcp
Eingabefeld UDP Port: upd

 

3.3 Füge nun den Button OK hinzu.
3.4 Die Aktion des Button ist: GET und soll mit der index.php verknüpft werden.

3.5 Speichert diese Datei in: index.html

 

4. Viewer Images:

4.1 Hier ist der Downloadlink der images: http://www.pa-s.de/php/codeschnipsel/tsicons.zip
4.2 Downloadet euch die Icons und legt im Ordner den Ordner: images an.

 

Fertig! Alles speichern, hochladen, Ts2 Generieren und freuen!
Bei Fragen ins Forum posten !

 

Gruß Micha

 

Beachten Sie: Wir übernehmen keinerlei Haftung für irgendwelche Schäden, Ausfälle oder sonstigen Geschehnissen.
Alle Angaben sind ohne Gewähr, Sie handeln auf eigenes Risiko!
Alle genannten Soft- und Hardwarebezeichnungen sowie Markennamen sind Eigentum ihrer jeweiligen Inhaber und unterliegen im Allgemeinen warenzeichen-, marken- oder patentrechtlichem Schutz.
Alle Rechte vorbehalten