Autodelete Teamspeak Server

willy

Member
Joined
May 4, 2016
Messages
32
Reaction score
5
Points
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:

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
after using google for 2 minutes, i found this it's a german site but it provides such script.
I have not tried this, so feedback is appreciated.

 

Jackbox

Active Member
Joined
Jan 2, 2016
Messages
197
Reaction score
96
Points
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
Joined
May 4, 2016
Messages
32
Reaction score
5
Points
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
Joined
Sep 19, 2015
Messages
150
Reaction score
105
Points
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
Joined
Sep 25, 2015
Messages
175
Reaction score
76
Points
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
Joined
May 4, 2016
Messages
32
Reaction score
5
Points
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
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
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
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
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.
 

willy

Member
Joined
May 4, 2016
Messages
32
Reaction score
5
Points
40
HTTP ERROR 500 < do you know the problem what is it ?
Same here :/
What's the problem ? I have copy/paste the script and replace the server address and query password only...
 
Top