TSTime and TSTimeBig

Agusanz

Active Member
Jul 18, 2015
239
148
88
Please, read pages 1,2 and 3.. if you're trying to setup this on linux/windows i bet u can solve your problem reading those pages.

Hello r4p3..

I use this as a CRON each 1 minute, i know this is pretty easy to script, but most of those scripts are on a loop and that doesn't work that well if your server is getting attacked or experimenting random timeouts, which leads to random errors.

Both bots will use YYYY MM DD HH MM format, (i'm from Argentina, so that's what i use..) if you want to change that you can change that to YYYY DD MM HH MM

It will detect how many slots are available on your server. (Reserved slots doesn't count as available, you can change that changing this line:
$slotsAvailable = $maxSlots - $slotsReserved;
to this
$slotsAvailable = $maxSlots;
otherwise just replace where i use $slotsAvailable to $maxSlots and done.

The time is displayed as 24 hours format, you can change that using lowecase H here
Code:
$realTime = date('[Y-m-d] - [h:i]',$unixTime);
  if($BotChannelTime["channel_name"] != "[cspacer0] {$realTime}")

Yes, i know, the bot itself will count as an user online, but you can reverse that using this below "$slotsAvailable = $maxSlots - $slotsReserved;"
Code:
$clientsOnline = $clientsOnline -1

TSTime

207bdbe51a.png

It's a date spacer and a 2nd spacer with the number of online clients/available slots.
GitHub
Code:
<?php

require_once("TeamSpeak3/TeamSpeak3.php");
date_default_timezone_set('America/Argentina/Buenos_Aires');
TeamSpeak3::init();

$user = "serveradmin";
$pass = "mc4zYL9G";
$serverIP = "127.0.0.1";
$botTimeChannel = 2;
$botUsersChannel = 3;
$nickname = "TimeBot";

try
{
   $ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987&blocking=0&nickname={$nickname}");

  $BotChannelTime = $ts3->channelGetById($botTimeChannel);
  $BotChannelUsuarios = $ts3->channelGetById($botUsersChannel);

  $unixTime = time();
   $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Connected\n";

   $unixTime = time();
  $realTime = date('[Y-m-d] - [H:i]',$unixTime);
  if($BotChannelTime["channel_name"] != "[cspacer0] {$realTime}")
  {
  $BotChannelTime["channel_name"] = "[cspacer0] {$realTime}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Time updated\n";
  }

  $serverInfo = $ts3->getInfo();
  $maxSlots = $serverInfo["virtualserver_maxclients"];
  $clientsOnline = $serverInfo["virtualserver_clientsonline"];
  $slotsReserved = $serverInfo["virtualserver_reserved_slots"];
  $slotsAvailable = $maxSlots - $slotsReserved;

  if($BotChannelUsuarios["channel_name"] != "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}")
  {
  $BotChannelUsuarios["channel_name"] = "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Users online updated\n";
  }

  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  die($realTime."\t[INFO] Finished.\n");
}
catch(Exception $e)
{
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo "Failed\n";
  die($realTime."\t[ERROR]  " . $e->getMessage() . "\n". $e->getTraceAsString() ."\n");
}

TSTimeBig
0753e477c9.png

It's a 4 spacer clock and a 5th spacer with the online clients/available slots.
GitHub
Code:
<?php

require_once("TeamSpeak3/TeamSpeak3.php");
date_default_timezone_set('America/Argentina/Buenos_Aires');
TeamSpeak3::init();

$user = "serveradmin";
$pass = "mc4zYL9G";
$serverIP = "127.0.0.1";
$botTime1Channel = 2;
$botTime2Channel = 3;
$botTime3Channel = 4;
$botTime4Channel = 5;
$botUsersChannel = 6;
$nickname = "TimeBot";

try
{
   $ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987&blocking=0&nickname={$nickname}");

  $BotChannelTime1 = $ts3->channelGetById($botTime1Channel);
  $BotChannelTime2 = $ts3->channelGetById($botTime2Channel);
  $BotChannelTime3 = $ts3->channelGetById($botTime3Channel);
  $BotChannelTime4 = $ts3->channelGetById($botTime4Channel);
  $BotChannelUsuarios = $ts3->channelGetById($botUsersChannel);

  $unixTime = time();
   $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Connected\n";

  $line1[0] = "▄▀▀▀▄";
  $line2[0] = "█───█";
  $line3[0] = "█───█";
  $line4[0] = "▀▄▄▄▀";

  $line1[1] = "─▄█";
  $line2[1] = "▀─█";
  $line3[1] = "──█";
  $line4[1] = "──█";

  $line1[2] = "▄▀▀▀▄";
  $line2[2] = "───▄▀";
  $line3[2] = "─▄▀──";
  $line4[2] = "█▄▄▄▄";

  $line1[3] = "▄▀▀▀▄";
  $line2[3] = "──▄▄█";
  $line3[3] = "────█";
  $line4[3] = "▀▄▄▄▀";

  $line1[4] = "───▄█─";
  $line2[4] = "─▄▀─█─";
  $line3[4] = "█▄▄▄█▄";
  $line4[4] = "────█─";

  $line1[5] = "█▀▀▀▀";
  $line2[5] = "█▄▄▄─";
  $line3[5] = "────█";
  $line4[5] = "▀▄▄▄▀";

  $line1[6] = "▄▀▀▀▄";
  $line2[6] = "█▄▄▄─";
  $line3[6] = "█───█";
  $line4[6] = "▀▄▄▄▀";

  $line1[7] = "▀▀▀▀█";
  $line2[7] = "────█";
  $line3[7] = "──▄▀─";
  $line4[7] = "─█───";

  $line1[8] = "▄▀▀▀▄";
  $line2[8] = "▀▄▄▄▀";
  $line3[8] = "█───█";
  $line4[8] = "▀▄▄▄▀";

  $line1[9] = "▄▀▀▀▄";
  $line2[9] = "▀▄▄▄▀";
  $line3[9] = "────█";
  $line4[9] = "▀▄▄▄▀";

  $time = date('H:i', time());
  $time_explode = explode(':', date('H:i') );
  $time_H = str_split($time_explode[0],1);
  $time_H1 = $time_H[0];
  $time_H2 = $time_H[1];
  $time_M = str_split($time_explode[1],1);
  $time_M1 = $time_M[0];
  $time_M2 = $time_M[1];

  $channel_time1 =  "[cspacer]".$line1[$time_H1]."─".$line1[$time_H2]."─────".$line1[$time_M1]."─".$line1[$time_M2];
  $channel_time2 =  "[cspacer]".$line2[$time_H1]."─".$line2[$time_H2]."──▀──".$line2[$time_M1]."─".$line2[$time_M2];
  $channel_time3 =  "[cspacer]".$line3[$time_H1]."─".$line3[$time_H2]."──▄──".$line3[$time_M1]."─".$line3[$time_M2];
  $channel_time4 =  "[cspacer]".$line4[$time_H1]."─".$line4[$time_H2]."─────".$line4[$time_M1]."─".$line4[$time_M2];

  if($BotChannelTime1["channel_name"] != $channel_time1)
  {
  $BotChannelTime1["channel_name"] = $channel_time1;
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] BotChannelTime1 updated\n";
  }

  if($BotChannelTime2["channel_name"] != $channel_time2)
  {
  $BotChannelTime2["channel_name"] = $channel_time2;
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] BotChannelTime2 updated\n";
  }

  if($BotChannelTime3["channel_name"] != $channel_time3)
  {
  $BotChannelTime3["channel_name"] = $channel_time3;
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] BotChannelTime3 updated\n";
  }

  if($BotChannelTime4["channel_name"] != $channel_time4)
  {
  $BotChannelTime4["channel_name"] = $channel_time4;$unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] BotChannelTime4 updated\n";
  }
  sleep(2);

  $serverInfo = $ts3->getInfo();
  $maxSlots = $serverInfo["virtualserver_maxclients"];
  $clientsOnline = $serverInfo["virtualserver_clientsonline"];
  $slotsReserved = $serverInfo["virtualserver_reserved_slots"];
  $slotsAvailable = $maxSlots - $slotsReserved;

  if($BotChannelUsuarios["channel_name"] != "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}")
  {
  $BotChannelUsuarios["channel_name"] = "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Users online updated\n";
  }

  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  die($realTime."\t[INFO] Finished.\n");
}
catch(Exception $e)
{
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo "Failed\n";
  die($realTime."\t[ERROR]  " . $e->getMessage() . "\n". $e->getTraceAsString() ."\n");
}

Have fun..
-Agusanz
 
Last edited:

Agusanz

Active Member
Jul 18, 2015
239
148
88
In order to run this you need to download TeamSpeak php framework: https://www.planetteamspeak.com/downloads/
Or you can git clone or download the zip file from my github repository
https://github.com/Agusanz/TSTime
https://github.com/Agusanz/TSTimeBig

if you already have all that stuff, you can run it with
php -f TSTime.php and php -f TSTimeBig.php

If you want to setup a cron for this just add this to crontab -e
*/1 * * * * php -f /home/agusanz/TSTime/TSTime.php > /dev/null
*/1 * * * * php -f /home/agusanz/TSTimeBig/TSTimeBig.php > /dev/null


Otherwise u can create a bash file inside of that folder and use
*/1 * * * * /home/agusanz/TSTime/./TSTime.sh > /dev/null
Code:
#!/bin/bash
TSTime=`ps ax | grep TSTime.php | grep -v grep | wc -l`
if [ $TSTime -eq 1 ]
then
  exit
else
  cd /home/agusanz/TSTime;
  nohup php -f TSTime.php &> TSTime.log
fi

*/1 * * * * /home/agusanz/TSTimeBig/./TSTimeBig.sh > /dev/null
Code:
#!/bin/bash
TSTimeBig=`ps ax | grep TSTimeBig.php | grep -v grep | wc -l`
if [ $TSTimeBig -eq 1 ]
then
  exit
else
  cd /home/agusanz/TSTimeBig;
  nohup php -f TSTimeBig.php &> TSTimeBig.log
fi
 
Last edited:

Skav

Member
Mar 2, 2016
20
2
38
Hello Agusanz, thanks for your works ! :)
But i don't understand how can i run it on my own TS3 server (Windows host)..
Can you explain me please ?
 

Agusanz

Active Member
Jul 18, 2015
239
148
88
Hello Agusanz, thanks for your works ! :)
But i don't understand how can i run it on my own TS3 server (Windows host)..
Can you explain me please ?
You need to install php on windows, and execute this script with php -f TSTime.php and php -f TSTimeBig.php. How to: http://php.net/manual/en/install.windows.commandline.php

I keep running that command (php scriptname.php) each 1 minute with crontab on linux, but you can get the same result on windows with Task scheduler: https://technet.microsoft.com/en-us/library/bb726974.aspx

It has been already explained how to do it on stackoverflow:
1#: http://stackoverflow.com/questions/4701861/how-do-i-run-a-php-script-using-windows-schedule-task
2#: http://stackoverflow.com/questions/21236309/wamp-do-a-php-task-every-1-minute
 
Last edited:

Skav

Member
Mar 2, 2016
20
2
38
You need to install php on windows, and execute this script with php -f TSTime.php and php -f TSTimeBig.php. How to: http://php.net/manual/en/install.windows.commandline.php

I keep running that command (php scriptname.php) each 1 minute with crontab on linux, but you can get the same result on windows with Task scheduler: https://technet.microsoft.com/en-us/library/bb726974.aspx

It has been already explained how to do it on stackoverflow:
1#: http://stackoverflow.com/questions/4701861/how-do-i-run-a-php-script-using-windows-schedule-task
2#: http://stackoverflow.com/questions/21236309/wamp-do-a-php-task-every-1-minute
Ok thank you very much, work succefullfor the small version but for the big display version, i get this error:
423076Capture.jpg


Edit: And its possible to modify the position of the clock & user number on the TS ?
 
Last edited:

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
Ok thank you very much, work succefullfor the small version but for the big display version, i get this error:
423076Capture.jpg


Edit: And its possible to modify the position of the clock & user number on the TS ?

Post Seccion of config.
 

Skav

Member
Mar 2, 2016
20
2
38
Post Seccion of config.
What ?
You want dxdiag ?
For the PHP folder, i have move it in the C:

Edit: I can come on your TS or you can come on my own if you have free time for that..

Edit 2: With the great help of EscuderoKevin, we have succefully setup the small version of your tool ! :D
 
Last edited:

Agusanz

Active Member
Jul 18, 2015
239
148
88
Ok thank you very much, work succefullfor the small version but for the big display version, i get this error:
423076Capture.jpg


Edit: And its possible to modify the position of the clock & user number on the TS ?

Edit ur config variables, that error it's because the channelid number 2 doesn't exist.

Yes, you can change the position of the clock as you want, you need to change the config channel variables to achieve that.. i used 2,3,4,5,6 as an example..

Feel free to pm me if you need more help
 

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
Edit ur config variables, that error it's because the channelid number 2 doesn't exist.

Yes, you can change the position of the clock as you want, you need to change the config channel variables to achieve that.. i used 2,3,4,5,6 as an example..

Feel free to pm me if you need more help


I Help it! -.- (Teamwiever).
 

Skav

Member
Mar 2, 2016
20
2
38
Edit ur config variables, that error it's because the channelid number 2 doesn't exist.

Yes, you can change the position of the clock as you want, you need to change the config channel variables to achieve that.. i used 2,3,4,5,6 as an example..

Feel free to pm me if you need more help
Yes thanks for your informations, but now the time is not corect, its two hours late, I think the problem come from the following line:
$realTime = date('[Y-m-d] [H:i:s]',$unixTime);

For exemple, when in France there is 10 hours and 10 minutes oclock, on my TS i have 8 hours and 10 minutes..
Edit: i have found this but i don't know if i can apply it and how apply on your files:
http://php.net/manual/fr/function.date-default-timezone-set.php
And second little problem, i have edit the permissions of the bof user name but it won't hide the channel edit..

Edit 2: Ok, i have find a solution for the problem of time, add following command:
date_default_timezone_set('Region/City');
Copy & past it just after:
<?php
require_once("TeamSpeak3/TeamSpeak3.php");
Replace Region and City with yours: http://php.net/manual/en/timezones.php
 
Last edited:

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
Yes thanks for your informations, but now the time is not corect, its two hours late, I think the problem come from the following line:
$realTime = date('[Y-m-d] [H:i:s]',$unixTime);

For exemple, when in France there is 10 hours and 10 minutes oclock, on my TS i have 8 hours and 10 minutes..
Edit: i have found this but i don't know if i can apply it and how apply on your files:
http://php.net/manual/fr/function.date-default-timezone-set.php
And second little problem, i have edit the permissions of the bof user name but it won't hide the channel edit..

Edit 2: Ok, i have find a solution for the problem of time, add following command:
date_default_timezone_set('Region/City');
Copy & past it just after:
<?php
require_once("TeamSpeak3/TeamSpeak3.php");
Replace Region and City with yours: http://php.net/manual/en/timezones.php


i told you put

date_default_timezone_set('Region/City');

in second line.
 
Top