Hi everyone,
I am new to PHP and am currently trying to edit some code so that I can display the status of my TeamSpeak 3 Server on my website’s home page. After looking around online this is the code that I have chosen as it has a lot of customization options and its possibilities. However when I look at the PHP code I just have not got a clue what to do with it. I would be very grateful to receive some guidance.
Here is some information which will need to be edited/implemented into the PHP code:
Server I.P: 185.38.149.82
Server Port: 9088
Server Query Port: 10011
Show server group icons: False
Show channels even if empty: True
Kindest Regards.
<?php /** * TSStatus: Teamspeak 3 viewer for php5 * @author Sebastien Gerard * @see http://tsstatus.sebastien.me/ * @version 2013-08-31 **/ $enableGenerator = true; $absoluteDir = dirname(__FILE__) . "/"; $wwwDir = substr($_SERVER["SCRIPT_NAME"], 0, strrpos($_SERVER["SCRIPT_NAME"], "/") + 1); $host = isset($_POST["host"]) ? $_POST["host"] : ""; $qport = isset($_POST["qport"]) ? intval($_POST["qport"]) : 10011; $portOrId = isset($_POST["portOrId"]) ? intval($_POST["portOrId"]) : 1; $port = isset($_POST["port"]) ? intval($_POST["port"]) : 9088; $sid = isset($_POST["sid"]) ? intval($_POST["sid"]) : 1; $showNicknameBox = !isset($_POST["showNicknameBox"]); $timeout = isset($_POST["timeout"]) ? intval($_POST["timeout"]) : 2; $showPasswordBox = !isset($_POST["showPasswordBox"]); $serverQueryLogin = isset($_POST["serverQueryLogin"]) ? $_POST["serverQueryLogin"] : ""; $serverQueryPassword = isset($_POST["serverQueryPassword"]) ? $_POST["serverQueryPassword"] : ""; $cacheTime = isset($_POST["cacheTime"]) ? intval($_POST["cacheTime"]) : 0; $cacheFile = isset($_POST["cacheFile"]) ? $_POST["cacheFile"] : ""; $limitToChannels = isset($_POST["limitToChannels"]) ? $_POST["limitToChannels"] : ""; $hideEmptyChannels = !isset($_POST["hideEmptyChannels"]); $hideParentChannels = !isset($_POST["hideParentChannels"]); if($timeout < 1) $timeout = 0; else if($timeout > 10) $timeout = 10; $htmlCode = ' '; echo $htmlCode; $phpCode = "<?php\n"; $phpCode .= 'require_once("' . $absoluteDir . 'tsstatus.php");' . "\n"; $phpCode .= '$tsstatus = new TSStatus("' . $host . '", ' . $qport . ');' . "\n"; if($portOrId == 1) $phpCode .= '$tsstatus->useServerPort(' . $port . ');' . "\n"; if($portOrId == 2) $phpCode .= '$tsstatus->useServerId(' . $sid . ');' . "\n"; $phpCode .= '$tsstatus->imagePath = "' . $wwwDir . 'img/";' . "\n"; $phpCode .= '$tsstatus->timeout = ' . $timeout . ";\n"; if($serverQueryLogin != "") $phpCode .= '$tsstatus->setLoginPassword("'.$serverQueryLogin.'", "'.$serverQueryPassword.'");' . "\n"; if($cacheTime > 0 && $cacheFile == "") $phpCode .= '$tsstatus->setCache('.$cacheTime.');' . "\n"; if($cacheTime > 0 && $cacheFile != "") $phpCode .= '$tsstatus->setCache('.$cacheTime.', "'.$cacheFile.'");' . "\n"; if($limitToChannels != "") $phpCode .= '$tsstatus->limitToChannels('.$limitToChannels.');' . "\n"; $phpCode .= '$tsstatus->hideEmptyChannels = ' . (!$hideEmptyChannels ? "true" : "false") . "\n"; $phpCode .= '$tsstatus->hideParentChannels = ' . (!$hideParentChannels ? "true" : "false") . ";\n"; $phpCode .= '$tsstatus->showNicknameBox = ' . ($showNicknameBox ? "true" : "false") . ";\n"; $phpCode .= '$tsstatus->showPasswordBox = ' . ($showPasswordBox ? "false" : "true") . ";\n"; $phpCode .= 'echo $tsstatus->render();' . "\n?>";
?>
TSStatus generator body, table{ font-family: Verdana; font-size: 12px; } th{ text-align: right; } td{ font-style: italic; } label{ font-style: normal; } h3{ font-size: 14px; padding-bottom: 4px; border-bottom: 1px solid #aaa; } .warning{ color: red; }TSStatus generator
Host | Your Teamspeak server hostname or ip | |
---|---|---|
Query port | Server's query port, not the client port! (default 10011) | |
Server Port | /> | You must define a server port or a server id to connect to |
Server Id | /> | |
Timeout | The timeout, in seconds, for connect, read, write operations | |
ServerQuery login | [Optional] The ServerQuery login used by tsstatus | |
ServerQuery password | [Optional] The ServerQuery password | |
Cache time | [Optional] Cache datas for X seconds before updating (prevent bans from the server). 0 => disabled | |
Cache file | [Optional] The file were the datas will be stored (.../tsstatus/tsstatus.php.cache if not specified) | |
Limit to these channels | [Optional] Comma seperated list of channels ID to display. If set TSStatus will only render these channels | |
/> Hide empty channels | ||
/> Hide parents channels | To use with "Limit to these channels" and "Hide empty channels" options | |
/> Hide nickname box | ||
/> Show password box | The box will only be visible if the the server have a password | |
TSStatus result
\n"; require_once($absoluteDir . "tsstatus.php"); $tsstatus = new TSStatus($host, $qport); $tsstatus->imagePath = $wwwDir . "img/"; if($portOrId == 1) $tsstatus->useServerPort($port); if($portOrId == 2) $tsstatus->useServerId($sid): 185.38.149.82; $tsstatus->timeout = $timeout; if($serverQueryLogin != "") $tsstatus->setLoginPassword($serverQueryLogin, $serverQueryPassword); if($cacheTime > 0 && $cacheFile == "") $tsstatus->setCache($cacheTime); if($cacheTime > 0 && $cacheFile != "") $tsstatus->setCache($cacheTime, $cacheFile); if($limitToChannels != "") { $ids = explode(",", $limitToChannels); call_user_func_array(array($tsstatus, "limitToChannels"), $ids); } $tsstatus->hideEmptyChannels = !$hideEmptyChannels; $tsstatus->hideParentChannels = !$hideParentChannels; $tsstatus->showNicknameBox = $showNicknameBox; $tsstatus->showPasswordBox = !$showPasswordBox; echo $tsstatus->render(); echo "HTML code
\n"; highlight_string($htmlCode); echo "PHP code
\n"; highlight_string($phpCode); echo "Full page sample
\n"; highlight_string("\n\nTSStatus\n$htmlCode\n\n\n$phpCode\n\n"); echo 'To enable the script you have to edit tsstatusgen.php and replace $enableGenerator = false; by $enableGenerator = true; on line 10
Don\'t forget to disable this script once finished testing!