user in group?

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
For web u need this...

PHP:
    function getClientIp() {
        if (!empty($_SERVER['HTTP_CLIENT_IP']))
        return $_SERVER['HTTP_CLIENT_IP'];
        else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
        return $_SERVER['HTTP_X_FORWARDED_FOR'];
        else if(!empty($_SERVER['HTTP_X_FORWARDED']))
        return $_SERVER['HTTP_X_FORWARDED'];
        else if(!empty($_SERVER['HTTP_FORWARDED_FOR']))
        return $_SERVER['HTTP_FORWARDED_FOR'];
        else if(!empty($_SERVER['HTTP_FORWARDED']))
        return $_SERVER['HTTP_FORWARDED'];
        else if(!empty($_SERVER['REMOTE_ADDR']))
        return $_SERVER['REMOTE_ADDR'];
        else
        return false;
    }
   
   
    try
    {
        $connect = "serverquery://".$USER_QUERY.":".$PASS_QUERY."@".$HOST_QUERY.":".$PORT_QUERY."";
        $ts3 = TeamSpeak3::factory($connect);
        $ts3 = $ts3->serverGetById(27);
        $ts3->execute("clientupdate", array("client_nickname" => $NICK_QUERY));
       
    }
   
    catch(Exception $e) {
       
        echo "[DEBUG] Ha ocurrido un error inesperado <br>";
        echo "[DEBUG] Mensaje de error DEBUG: ".$e->getMessage()."<br>";
        echo "[DEBUG] El codigo de error fue ".$e->getCode()."<br>";
       
        if($e->getCode() == 0) {
           
            echo "Error desconocido. Metodo invalido";
        }
        else if($e->getCode() == 10060){ echo "No se pudo conectar con el servidor de teamspeak 3";}
        else if($e->getCode() == 520) { echo "Los datos de acceso query no son correctos";}
        else if($e->getCode() == 3329){ echo "La conexion fue baneada por query. Intenta mas tarde";}
    }
   
    foreach ($ts3->clientList(array('client_type' => '0', 'connection_client_ip' => getClientIp())) as $client) {
        $clientuid = $client->client_unique_identifier;
        $cliente = $ts3->clientGetByUid($clientuid);
        $nombrecliente  = $cliente['client_nickname'];
        $conectado = 1;
    }
   
   
    foreach(explode(",", $cliente["client_servergroups"]) as $sgid)
    {
        $groups[] = $sgid;
    }


$groups[] = $sgid; its array with groups...

Edit: Erros are Spanish.... in at phone.
 

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
foreach(explode(",", $cliente["client_servergroups"]) as $sgid) { $groups[] = $sgid; }
I dont understand this part. Why you take values from array and put into new array?
If you do explode on string with , delimeter you get a new array, so putting values into new array trough loop is pointless.
Change my mind. :D
 

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
I dont understand this part. Why you take values from array and put into new array?
If you do explode on string with , delimeter you get a new array, so putting values into new array trough loop is pointless.
Change my mind. :D


PHP:
 explode(",",  [/PHP ]

Groups now = 2,3,4,5,6,7,8
 
Top