PHP| Group Assignment to specify IP Address

nutellazpw

Member
Jan 9, 2019
11
6
53
Hello,
did someone know how to add to this script to ignore query users?

PHP:
<?php

/*

    Name: onClientConnect
    Author: kalle
    Version: v1.0   

    Description: This script subscribes to oncliententerview event, and fires callback on function.
                 In my function I took event invoker and his database id.
                 Later I used that dbid to find specific information about user.
                 Purpose is to assign new group if ip of invoker matches our allowed arrays.

*/

require_once('TeamSpeak3/TeamSpeak3.php');
$ts3_host = "";
$ts3_q_port = "";
$ts3_s_port = "";
$ts3_username = "";
$ts3_password = "";
$ts3_nick = "";
$selectedOnes = array(ip);
$group = '196353';
$ts3 = TeamSpeak3::factory("serverquery://$ts3_username:$ts3_password@$ts3_host:$ts3_q_port/?server_port=$ts3_s_port&blocking=0");
$ts3->selfUpdate(array('client_nickname'=> $ts3_nick));
TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onWaitTimeout");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", "onClientEnterView");
$ts3->notifyRegister("server");
while(1)
{
    $ts3->getAdapter()->wait();
}
function onWaitTimeout($time, TeamSpeak3_Adapter_Abstract $adapter)
{
    if($adapter->getQueryLastTimestamp() < time()-300)
    {
        $adapter->request('clientupdate');
    }
}
function onClientEnterView(TeamSpeak3_Adapter_ServerQuery_Event $event){
    global $group;
    global $ts3;
    global $selectedOnes;
    $userInfo = $event->getData();
    $client = $ts3->clientGetByDbId($userInfo['client_database_id']);
    $groups = array_filter(explode(',', $client->client_servergroups));
    
    if(in_array($client->connection_client_ip, $selectedOnes)){ 
        if(in_array($group, $groups, TRUE)){
            
            return;   
        }else{
            $ts3->serverGroupClientAdd($group,$userInfo['client_database_id']);
            return;
        } 
    }   
}
 

nutellazpw

Member
Jan 9, 2019
11
6
53
We fixed it , but after 5minutes bot crashed with this error:
Uncaught TeamSpeak3_Transport_Exception: connection to server '164.132.93.40:2006' lost in /home/TS3Scripts-master/TeamSpeak3/Transport/TCP.php:131
 
E

ewenjo

We fixed it , but after 5minutes bot crashed with this error:
Uncaught TeamSpeak3_Transport_Exception: connection to server '164.132.93.40:2006' lost in /home/TS3Scripts-master/TeamSpeak3/Transport/TCP.php:131
Change this line
PHP:
if($adapter->getQueryLastTimestamp() < time()-300)

to

PHP:
if($adapter->getQueryLastTimestamp() < time()-250)
 
Top