Autodelete Teamspeak Server

willy

Member
May 4, 2016
32
5
40
Name of the script: Teamspeak 3 auto delete
Functions of the script: Delete unused Teamspeak 3 server
Why do you want it: Because i want to give free Teamspeak server, but I don't want to be cluttered with unused servers
Screenshots: /
Orginal source (if any): /
Other notes:

Hello !
I need a script (with cron for exemple) who check the activities on all teamspeak servers of an instance.
And for exemple, if the server is unused during x days, he will be deleted automatically...
I tried to find a script like this but nothing already exist...
Any help ?
Thank you !
 
Last edited:

Jackbox

Active Member
Jan 2, 2016
197
96
74
That is good!! Now all you need is to setup a task/cron which checks the last time a user was connected. If it has been more than X time, delete. It should involve some simple modification of code.

I encourage anyone that wants to make this happen to begin practice software development. I understand not everyone may want to be a software engineer, but how do you think things get made? By people, just like you. I would volunteer and help to make this, but I'm in bed on my phone and dead tired.

If you can not find something and you want it, there is the option to fork another project like the one you have and adjust the project so it works exactly how you want or you can start from scratch or with a framework. You have many options. Lastly, you can beg for someone else to do it for you. :)
 

willy

Member
May 4, 2016
32
5
40
Or simply rename the names of the servers, and if it does not change them, deleted the server after x days.
It's a solution for no first connection on the server. But if user change the name the first time, and he never come back ? The server stay online...
I think the script is simple to write for a developper, (if last connect >= x days -> delete server). Then just create a cron task every hour to run the script...
 

freets3.ovh

Active Member
Sep 19, 2015
150
105
85
It's a solution for no first connection on the server. But if user change the name the first time, and he never come back ? The server stay online...
I think the script is simple to write for a developper, (if last connect >= x days -> delete server). Then just create a cron task every hour to run the script...
Personally, I change the name of the servers every Saturday, and Monday, if it does not change, the server is automatically deleted.
 

JetFox

Active Member
Sep 25, 2015
175
76
73
Could work with this technically, just create your own database to utilize counts with..

PHP:
<?php
require_once ("Commands/libraries/TeamSpeak3/TeamSpeak3.php");
// connect to local server, authenticate and spawn an object for the server instance
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/");
// walk through list of virtual servers
foreach($ts3_ServerInstance as $ts3_VirtualServer) {
    $name = $ts3_VirtualServer["virtualserver_name"];
    $connected_clients = $ts3_VirtualServer["virtualserver_clientsonline"];
    //$port = $ts3_VirtualServer["virtualserver_port"];
    //echo $port;
    //echo $name;
    //Ehh create mysql connection and do this
if ($connected_clients == 0){
    // do mysql connection... store into database that it was noted that there was 0 people online at time of check... do a +1 on count
}
else if ($connected_clients > 0){
    //do mysql connection but reset +1 count to 0...
}

if ($name == "Delete Me")
{
    
$getlovelyid = $ts3_VirtualServer->getId();
$ts3_VirtualServer->serverStop($getlovelyid);
$ts3_VirtualServer->serverDelete($getlovelyid);
}
else{
    echo "Nothing happened for server with the name ".$name;
}
}
 

willy

Member
May 4, 2016
32
5
40
Could work with this technically, just create your own database to utilize counts with..

PHP:
<?php
require_once ("Commands/libraries/TeamSpeak3/TeamSpeak3.php");
// connect to local server, authenticate and spawn an object for the server instance
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/");
// walk through list of virtual servers
foreach($ts3_ServerInstance as $ts3_VirtualServer) {
    $name = $ts3_VirtualServer["virtualserver_name"];
    $connected_clients = $ts3_VirtualServer["virtualserver_clientsonline"];
    //$port = $ts3_VirtualServer["virtualserver_port"];
    //echo $port;
    //echo $name;
    //Ehh create mysql connection and do this
if ($connected_clients == 0){
    // do mysql connection... store into database that it was noted that there was 0 people online at time of check... do a +1 on count
}
else if ($connected_clients > 0){
    //do mysql connection but reset +1 count to 0...
}

if ($name == "Delete Me")
{
   
$getlovelyid = $ts3_VirtualServer->getId();
$ts3_VirtualServer->serverStop($getlovelyid);
$ts3_VirtualServer->serverDelete($getlovelyid);
}
else{
    echo "Nothing happened for server with the name ".$name;
}
}
Thank you for taking the time to reply.
But I have no knowledge in development... can you add the code for the mysql connection in the script please ?

Thanks a lot
 

Kleberstoff

Knowledge Seeker
VIP
Dec 29, 2015
308
214
158
even tho this thread is kinda dead, i'll post mine anyway.

index.php (Does the Stuff)


config.php


Might wanna use a Cronjob for it.
 

Kleberstoff

Knowledge Seeker
VIP
Dec 29, 2015
308
214
158
Cronjob 1Day ? or whatever i want right ?
----
HTTP ERROR 500 < do you know the problem what is it ?
Error 500 refers to a Internal Server Error on your Server(If not mistaken).
Try it to execute the php file with 'php index.php' in the same folder as the script it.
Otherwise need to find the Problem causing the 500 Error.
 
Top