Teamspeak³ Whitelist

PirateControl

Member
Apr 19, 2016
33
11
43
Someone have a Whitelist bot / Script?

So only my friends can connect to my server other guy will be kicked?
 

walross99

Some random Guy
Jul 29, 2016
42
14
40
Make a Guest-Servergroup without any permissions and only assign a user-group with permissions to your whitelisted people
 

chuga2

Restricted
Jul 16, 2016
175
42
61
JTS3ServerMod

use server group protection
-- add the protection for default server group in your server [exmpl : Guest]
and give to your friends another permission

so, any user will join to your server will be kicked
because the default permission is under protection
 
Last edited:

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
It would make more sense to just use a default group without permissions but this should help you.

PHP:
<?php
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

    $whitelist = array('T0jN+2Wci+sz5wfFnOVcHhRFEak=', 'L3dN+2Wci+sz3fsFnOVcHhRFCdP=');

    foreach($tsHandle->clientList(array("client_type" => 0)) as $client)
    {
        if(!in_array($client->client_unique_identifier, $whitelist))
        {
            try {
                $client->kick(TeamSpeak3::KICK_SERVER, 'You aren\'t whitelisted!');
            } catch(TeamSpeak3_Exception $e) {
                echo "Error ".$e->getCode().": ".$e->getMessage();
            }
        }
    }
 

PirateControl

Member
Apr 19, 2016
33
11
43
It would make more sense to just use a default group without permissions but this should help you.

PHP:
<?php
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

    $whitelist = array('T0jN+2Wci+sz5wfFnOVcHhRFEak=', 'L3dN+2Wci+sz3fsFnOVcHhRFCdP=');

    foreach($tsHandle->clientList(array("client_type" => 0)) as $client)
    {
        if(!in_array($client->client_unique_identifier, $whitelist))
        {
            try {
                $client->kick(TeamSpeak3::KICK_SERVER, 'You aren\'t whitelisted!');
            } catch(TeamSpeak3_Exception $e) {
                echo "Error ".$e->getCode().": ".$e->getMessage();
            }
        }
    }
Very Nice thank you :) but how can i let them check my server like every 3 sec or 5 sec now i need to refresh the webpage
Like a Startscript or so?
 
Last edited:

MarineHya

Member
Aug 27, 2017
33
17
55
Very Nice thank you :) but how can i let them check my server like every 3 sec or 5 sec now i need to refresh the webpage
Like a Startscript or so?
PHP:
<?php
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
$whitelist = array('T0jN+2Wci+sz5wfFnOVcHhRFEak=', 'L3dN+2Wci+sz3fsFnOVcHhRFCdP=');
while(1) {
    foreach($tsHandle->clientList(array("client_type" => 0)) as $client)
    {
        if(!in_array($client->client_unique_identifier, $whitelist))
        {
            try {
                $client->kick(TeamSpeak3::KICK_SERVER, 'You aren\'t whitelisted!');
            } catch(TeamSpeak3_Exception $e) {
                echo "Error ".$e->getCode().": ".$e->getMessage();
            }
        }
    }
}
?>
 

PirateControl

Member
Apr 19, 2016
33
11
43
Thanks, but it´s not working :(
Code:
Diese Seite funktioniert nicht
My IP kann diese Anfrage momentan nicht verarbeiten.

This site does not work
 
E

ewenjo

Is this what you're looking for?

PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

$tsHandle->notifyRegister("server");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", "whitelistFunction");
while(1) $tsHandle->getAdapter()->wait();

function whitelistFunction(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host)
{
    try {
       
        $whitelist = array('T0jN+2Wci+sz5wfFnOVcHhRFEak=', 'L3dN+2Wci+sz3fsFnOVcHhRFCdP=');
       
        if ($event["client_type"] == 0) {
           
            $client = $host->serverGetSelected()->clientGetById($event["clid"]);
            if(!in_array($event["client_unique_identifier"], $whitelist))
            {
                $client->kick(5, 'You aren\'t whitelisted!');
            }
        }
       
    } catch(TeamSpeak3_Exception $e) {
        echo "Error ".$e->getCode().": ".$e->getMessage();
    }
}
?>
 

PirateControl

Member
Apr 19, 2016
33
11
43
Is this what you're looking for?

PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

$tsHandle->notifyRegister("server");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", "whitelistFunction");
while(1) $tsHandle->getAdapter()->wait();

function whitelistFunction(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host)
{
    try {
     
        $whitelist = array('T0jN+2Wci+sz5wfFnOVcHhRFEak=', 'L3dN+2Wci+sz3fsFnOVcHhRFCdP=');
     
        if ($event["client_type"] == 0) {
         
            $client = $host->serverGetSelected()->clientGetById($event["clid"]);
            if(!in_array($event["client_unique_identifier"], $whitelist))
            {
                $client->kick(5, 'You aren\'t whitelisted!');
            }
        }
     
    } catch(TeamSpeak3_Exception $e) {
        echo "Error ".$e->getCode().": ".$e->getMessage();
    }
}
?>
This script has an Error

Code:
PHP Fatal error:  Uncaught TeamSpeak3_Adapter_Exception: only available in non-b                      locking mode in /opt/Whitelist/libraries/TeamSpeak3/Adapter/ServerQuery.php:158
Stack trace:
#0 /opt/Whitelist/errorscript.php(7): TeamSpeak3_Adapter_ServerQuery->wait()
#1 {main}
  thrown in /opt/Whitelist/libraries/TeamSpeak3/Adapter/ServerQuery.php on line                       158


Code:
 screen -S screen1 php YOURSCRIPT.php

Only 1 time kick, the script is starting, i got kicked but only 1 times
 
Last edited:
E

ewenjo

This script has an Error

Code:
PHP Fatal error:  Uncaught TeamSpeak3_Adapter_Exception: only available in non-b                      locking mode in /opt/Whitelist/libraries/TeamSpeak3/Adapter/ServerQuery.php:158
Stack trace:
#0 /opt/Whitelist/errorscript.php(7): TeamSpeak3_Adapter_ServerQuery->wait()
#1 {main}
  thrown in /opt/Whitelist/libraries/TeamSpeak3/Adapter/ServerQuery.php on line                       158

My bad, try changing this line from
$tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
to
$tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987&blocking=0");
 

PirateControl

Member
Apr 19, 2016
33
11
43
I got a new Problem :) afer 5 -10 min the bot will disconnect from the server anyone knows why?
 
E

ewenjo

I got a new Problem :) afer 5 -10 min the bot will disconnect from the server anyone knows why?

Im not sure, but adding a timeout function to the original script might work.
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

TeamSpeak3::init();

try
{
  TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onTimeout");
  TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", "onClientEnter");
  TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected", "onSelect");

  $tsHandle = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987&blocking=0");

  while(1) $tsHandle->getAdapter()->wait();
}
catch(Exception $e)
{
  die("[ERROR]  " . $e->getMessage() . "\n");
}


function onTimeout($seconds, TeamSpeak3_Adapter_ServerQuery $adapter)
{
  if($adapter->getQueryLastTimestamp() < time()-300)
  {
    $adapter->request("clientupdate");
  }
}


function onSelect(TeamSpeak3_Node_Host $host)
{
  $host->serverGetSelected()->notifyRegister("server");
}

function onClientEnter(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host)
{
    try {
      
        $whitelist = array('T0jN+2Wci+sz5wfFnOVcHhRFEak=', 'L3dN+2Wci+sz3fsFnOVcHhRFCdP=');
      
        if ($event["client_type"] == 0) {
          
            $client = $host->serverGetSelected()->clientGetById($event["clid"]);
            if(!in_array($event["client_unique_identifier"], $whitelist))
            {
                $client->kick(5, 'You aren\'t whitelisted!');
            }
        }
      
    } catch(TeamSpeak3_Exception $e) {
        echo "Error ".$e->getCode().": ".$e->getMessage();
    }
}
?>
 
Top