{"id":279,"date":"2018-07-19T20:46:43","date_gmt":"2018-07-19T20:46:43","guid":{"rendered":"https:\/\/projects-42.nl\/?p=279"},"modified":"2019-03-29T19:19:27","modified_gmt":"2019-03-29T19:19:27","slug":"show-online-teamspeak-users-without-the-client","status":"publish","type":"post","link":"https:\/\/projects-42.nl\/index.php\/2018\/show-online-teamspeak-users-without-the-client\/","title":{"rendered":"Show online Teamspeak users without the client"},"content":{"rendered":"<p>It might sound like a useless project, but I wanted to be able to check who was using my Teamspeak server without having to be logged on all the time.<\/p>\n<p>After a short search over the world wide web, I came across the &#8220;Powerful PHP Framework&#8221; from <a href=\"https:\/\/www.planetteamspeak.com\/\">planet teamspreak<\/a>. This framework enables the user to access the Teamspeak query system and do all kinds of fun stuff. The best part is, it is <a href=\"https:\/\/github.com\/planetteamspeak\/ts3phpframework\/releases\">publicly available at Github<\/a> and it is <a href=\"https:\/\/docs.planetteamspeak.com\/ts3\/php\/framework\/index.html\">well documented<\/a>.<\/p>\n<p>during my search I already found <a href=\"https:\/\/forum.teamspeak.com\/threads\/118734-API-Teamspeak-number-of-connected-people\">a piece of code<\/a> wich did almost exactly what I wanted to do, after some alterations I had the following code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;span&gt;\n&lt;?php\nrequire_once(\"TeamSpeak3Lib\/TeamSpeak3.php\");\n\n$enter = \"&lt;br&gt;\";\nif (isset($_GET['TS']))\n{\n  $enter = \"\\13\\10\";\n}\n\n$ts3_VirtualServer = TeamSpeak3::factory(\"serverquery:\/\/&lt;queryUser&gt;:&lt;queryPassword&gt;@&lt;TeamspeakIP&gt;:&lt;queryPort&gt;\/?server_port=&lt;serverPort&gt;\");\n\n$status = \"offline\";\n$count = 0;\n$max = 0;\n \ntry {\n    $status = $ts3_VirtualServer-&gt;getProperty(\"virtualserver_status\");\n    $count = $ts3_VirtualServer-&gt;getProperty(\"virtualserver_clientsonline\") - $ts3_VirtualServer-&gt;getProperty(\"virtualserver_queryclientsonline\");\n    $max = $ts3_VirtualServer-&gt;getProperty(\"virtualserver_maxclients\");\n}\n\ncatch (Exception $e) {\n    echo \"QueryError: \" . $e-&gt;getCode() . ' ' . $e-&gt;getMessage() . \"&lt;\/div&gt;\";\n}\n\necho \"TS3 Server Status: \" . $status . $enter . \"Clients online: \" . $count . \"\/\" . $max ; \n\necho $enter.$enter;\necho \"Online clients: \" . $enter;\n\n\/\/ query clientlist from virtual server and filter by platform\n$arr_ClientList = $ts3_VirtualServer-&gt;clientList();\n\/\/ walk through list of clients\nforeach($arr_ClientList as $ts3_Client)\n{\n  if ($ts3_Client[\"client_platform\"] != \"ServerQuery\")\n  {\n    echo $ts3_Client . $enter;\n  }\n}\n?&gt;\n&lt;\/span&gt;<\/pre>\n<p>The above code produces the following output in a browser:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">TS3 Server Status: online\nClients online: 1\/32\n\nOnline clients:\nprojects-42<\/pre>\n<p>This did not solve my problem entirely, I wanted to show the output on my desktop and opening a webbrowser and hitting F5 every few minutes is hardly ideal. Rainmeter to the rescue!<\/p>\n<p>The following Rainmeter skin will show the above output in a very basic format, but it is perfect for me \ud83d\ude42<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\">[Rainmeter]\nUpdate=1000\nAccurateText=1\nDynamicWindowSize=1\nBackgroundMode=2\nSolidColor=0,0,0,70\nAccurateText=1\n\n[MeasureSite]\nMeasure=WebParser\nURL=http:\/\/&lt;url\/to\/your\/php\/page&gt;.php?TS\nRegExp=(?siU)&lt;span&gt;(.*)&lt;\/span&gt;\nUpdateRate=30\n\n[MeasureInnerSite]\nMeasure=WebParser\nURL=[MeasureSite]\nStringIndex=1\n\n[MeterShowSite]\nMeter=String\nMeasureName=MeasureInnerSite\nText=%1 \nX=5\nFontSize=11\nFontColor=255,255,255,255\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-287\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/07\/Teamspeak-Rainmeter.png\" alt=\"\" width=\"271\" height=\"113\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It might sound like a useless project, but I wanted to be able to check who was using my Teamspeak server without having to be logged on all the time. After a short search over the world wide web, I came across the &#8220;Powerful PHP Framework&#8221; from planet teamspreak. This framework enables the user to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":280,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,17],"tags":[59,15,58,57,56],"class_list":["post-279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-projects","tag-api","tag-php","tag-planetteamspeak","tag-rainmeter","tag-teamspeak"],"_links":{"self":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":10,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"predecessor-version":[{"id":328,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/279\/revisions\/328"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/media\/280"}],"wp:attachment":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}