Show online Teamspeak users without the client

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 “Powerful PHP Framework” from planet teamspreak. This framework enables the user to access the Teamspeak query system and do all kinds of fun stuff. The best part is, it is publicly available at Github and it is well documented.

during my search I already found a piece of code wich did almost exactly what I wanted to do, after some alterations I had the following code:

<span>
<?php
require_once("TeamSpeak3Lib/TeamSpeak3.php");

$enter = "<br>";
if (isset($_GET['TS']))
{
  $enter = "\13\10";
}

$ts3_VirtualServer = TeamSpeak3::factory("serverquery://<queryUser>:<queryPassword>@<TeamspeakIP>:<queryPort>/?server_port=<serverPort>");

$status = "offline";
$count = 0;
$max = 0;
 
try {
    $status = $ts3_VirtualServer->getProperty("virtualserver_status");
    $count = $ts3_VirtualServer->getProperty("virtualserver_clientsonline") - $ts3_VirtualServer->getProperty("virtualserver_queryclientsonline");
    $max = $ts3_VirtualServer->getProperty("virtualserver_maxclients");
}

catch (Exception $e) {
    echo "QueryError: " . $e->getCode() . ' ' . $e->getMessage() . "</div>";
}

echo "TS3 Server Status: " . $status . $enter . "Clients online: " . $count . "/" . $max ; 

echo $enter.$enter;
echo "Online clients: " . $enter;

// query clientlist from virtual server and filter by platform
$arr_ClientList = $ts3_VirtualServer->clientList();
// walk through list of clients
foreach($arr_ClientList as $ts3_Client)
{
  if ($ts3_Client["client_platform"] != "ServerQuery")
  {
    echo $ts3_Client . $enter;
  }
}
?>
</span>

The above code produces the following output in a browser:

TS3 Server Status: online
Clients online: 1/32

Online clients:
projects-42

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!

The following Rainmeter skin will show the above output in a very basic format, but it is perfect for me 🙂

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,70
AccurateText=1

[MeasureSite]
Measure=WebParser
URL=http://<url/to/your/php/page>.php?TS
RegExp=(?siU)<span>(.*)</span>
UpdateRate=30

[MeasureInnerSite]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1

[MeterShowSite]
Meter=String
MeasureName=MeasureInnerSite
Text=%1 
X=5
FontSize=11
FontColor=255,255,255,255