I have a Question !♥

Mar 20, 2016
39
4
43
Hello everyone, I am a small programmer in PHP
I want to help everyone that it is extracted UUID + CLIENT NAME from IP
How ? How?

Sorry But my language the english is bad xD
♥ Thank You ♥
 

Alligatoras

Administrator
Mar 31, 2016
2,570
12
2,857
381
You mean to recognize client automatically, without put UUID or nickname
What he actually needs it to add to his website a box that says: Welcome (TeamspeakUser) and the Teamspeak User will be changed with the user's name based his IP Address!
 
U

User_13254

PHP:
$user = 'serveradmin';
$password = '12345';
$ip_query = '127.0.0.1';
$port = '9987';

try {
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://$user:$password@$ip_query/?server_port=$port&nickname=GetNameByIP");

foreach ($ts3_VirtualServer->clientList() as $cl) {
                if ($cl->client_type) continue;
                if ($cl->getProperty('connection_client_ip') == $_SERVER['REMOTE_ADDR']) {
                        $result[] = $cl->client_nickname;
                        $uid = $cl->client_unique_identifier;
                }
        }
}
catch (Exception $e) {
        echo "<p class='error'><b>Error " . $e->getCode() . ":</b> " . $e->getMessage() . "</p>";
        die;
}


if ($result == "" ) {
exit;
}

echo "Welcome To Our Server" . implode(', ', $result) . "<br>";
echo "Your ID: " . $uid;
 
Last edited by a moderator:

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Here ya go:
PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://USERNAME:PASSWORD@IPADDRESS:10011/?server_port=9987");
$clientip = $_SERVER['REMOTE_ADDR'];
$nickname = array();
$uid = array();
foreach($ts3_VirtualServer->clientListDb() as $Client)
{
    if($Client['client_lastip'] == $clientip)
    {
        $nickname[] = $Client['client_nickname'];
        $uid[] = $Client['client_unique_identifier'];
    }
 

}

if($nickname[0] == "") { $nickname[0] = "New member"; $uid[0] = "New meber"; }

echo "Name: " . $nickname[0];
echo "<br/>";
echo "UID: " . $uid[0];
It prints first connected client with that ip.
 
Last edited:
Mar 20, 2016
39
4
43
Here ya go:
PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://USERNAME:PASSWORD@IPADDRESS:10011/?server_port=9987");
$clientip = $_SERVER['REMOTE_ADDR'];
$nickname = array();
$uid = array();
foreach($ts3_VirtualServer->clientListDb() as $Client)
{
    if($Client['client_lastip'] == $clientip)
    {
        $nickname[] = $Client['client_nickname'];
        $uid[] = $Client['client_unique_identifier'];
    }
  

}

echo "Name: " . $nickname[0];
echo "<br/>";
echo "UID: " . $uid[0];
It prints first connected client with that ip.
Tell me

Notice: Undefined offset: 0 in D:\My-Servers\xampp\htdocs\SkyLayerBots\inc\source.php on line 21
Name:

Notice: Undefined offset: 0 in D:\My-Servers\xampp\htdocs\SkyLayerBots\inc\source.php on line 23
UID:
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
That means nobody matches the ip.

EDIT: Slightly edited the script (if nobody matches with any ip, it will print New member)
 
Last edited:

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
I'll take a look at it tomorrow.

EDIT: Still didn't figure hw to do it :D
 
Last edited:

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
Hello everyone, I am a small programmer in PHP
I want to help everyone that it is extracted UUID + CLIENT NAME from IP
How ? How?
Sorry But my language the english is bad xD
♥ Thank You ♥


Get IP.
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;
    }
Get UID:
PHP:
    $connect = "serverquery://".$USER_QUERY.":".$PASS_QUERY."@".$HOST_QUERY.":".$PORT_QUERY."/?server_port=".$SERVER_PORT."";
    $ts3 = TeamSpeak3::factory($connect);
    $FLAG = false;
   
    foreach ($ts3->clientList(array('client_type' => '0', 'connection_client_ip' => getClientIp())) as $client) {
        $clientuid = $client->client_unique_identifier;
        $client_nickname = $client->client_nickname;
        $client_clid = $client->clid;
        $FLAG = true;
        break;
    }
    if (!$FLAG){
        echo "<p><b>You are not conected To TS3 SErver.</b></p><br/>";
        header("refresh: 10; url = ./");
        die; 
    }
 
Mar 20, 2016
39
4
43
Get IP.
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;
    }
Get UID:
PHP:
    $connect = "serverquery://".$USER_QUERY.":".$PASS_QUERY."@".$HOST_QUERY.":".$PORT_QUERY."/?server_port=".$SERVER_PORT."";
    $ts3 = TeamSpeak3::factory($connect);
    $FLAG = false;
  
    foreach ($ts3->clientList(array('client_type' => '0', 'connection_client_ip' => getClientIp())) as $client) {
        $clientuid = $client->client_unique_identifier;
        $client_nickname = $client->client_nickname;
        $client_clid = $client->clid;
        $FLAG = true;
        break;
    }
    if (!$FLAG){
        echo "<p><b>You are not conected To TS3 SErver.</b></p><br/>";
        header("refresh: 10; url = ./");
        die;
    }
thank you ♥
 
Top