Server Kick Help

lundi 14 septembre 2015

I am trying to kick someone from my server where the username does not match my SQL below is the code that I have written, assigning the server group works but thats it... if I have posted this in the wrong section please move accordingly
PHP Code:

<?php // load framework files
require_once("ts3/libraries/TeamSpeak3/TeamSpeak3.php");
require_once(
"extra/common.php");

    
error_reporting(E_ALL);
    
    try
    {
            
$ts3_VirtualServer = TeamSpeak3::factory($serverinfo);

            foreach(
$ts3_VirtualServer->clientList()as $ts3_Client)
            {
                    if(
$ts3_Client['client_type']) continue;
                    
$query = "
                        SELECT
                        username
                        FROM users
                        WHERE username = username
                    "
;
                    try
                    {
                        
$stmt = $db->prepare($query);
                        
$result = $stmt->execute();
                    }
                    catch(
PDOException $ex)
                    {
                        die(
"Failed to run query: " . $ex->getMessage());
                    }
                    
$rows = $stmt->fetchall();
                    
                    foreach(
$rows as $row)
                    {
                        
$driver = $ts3_Client['client_nickname'];
                        if(
$driver == $row['username'])
                        {
                            
$array = $ts3_VirtualServer->execute("servergroupclientlist", array("sgid" => 13, "-names"))->toAssocArray("cldbid");
                            if(
in_array($driver, $array) == true) continue;
                            
$continue = true;
                            foreach(
explode(",", $ts3_Client["client_servergroups"]) as $sgid)
                            {
                                if(
$sgid == 13) $continue = false;
                            }
                            if(
$continue == false) continue;
                            
$ts3_VirtualServer->clientListReset();
                            
$ts3_VirtualServer->serverGroupClientAdd("13", $ts3_Client["client_database_id"]);
                            echo (
"Set User as Verified");
                        }
                        elseif(
$driver !== $row['username'])
                        {
                            
$ts3_VirtualServer->clientGetByName("INSERT NAME HERE")->kick(TeamSpeak3::KICK_SERVER,  "Name must match website!");
                        }
                        else continue;
                        
                    }
            
sleep(1);
            }
    }
    catch(
TeamSpeak3_Exception $e)
    {
    echo 
"Error " . $e->getCode() . ": " . $e->getMessage();
    }
    
//echo ("Nice Try");
    
echo ("Set User for Verified");
    
//header("Location: index.php"); 
            
exit;

Server Kick Help

0 commentaires:

Enregistrer un commentaire