Client Online / Offline in teamspeak server

niks

Member
Jan 30, 2017
40
5
40
Could anyone help me please..
I need a php script where I put a person's Unique ID or dbid doesn't matter to see whether they are online at the current time or not.
Thank you !
 

niks

Member
Jan 30, 2017
40
5
40
Do you want to see if the client is online without the page reloading? It would need JQuery for that.
Otherwise it will reload the page and then show if the client is online.

Copied from shoutbox --
Thanks man, appreciated. But why I asked is because all I have found is only foreach client.. I want to look for specific client's by unique id (uuid) or dbid

I am not good at PHP at all.. I've tried putting things like this together

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

$user = $ts3->clientGetByUid("bWvZD4osfd/c1sN4YHTz8ApoJE=");
    if($user["client_type"]) continue;
    echo "<strong><a style='color:#19D119;'>" . $user . "</strong> - Online on TeamSpeak" . "</a><br>" ;
  }

?>
But ended up only with failures

Thank you for helping.
 
Last edited:

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Okay I see

This will work
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3 = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
try{
$client = $ts3->clientGetByUid("GV1o/OG88OpRoTwTq4HOA3BCEic=");

//If no error occured echo online, means client is online
echo "online";

}
catch(TeamSpeak3_Exception $error)
{
  //Check if error is invalidID and echo offline, means offline or wrong uid
  if($error->getCode() == 512){
      die("offline");
  }
  // print the error message returned by the server
  echo "Error " . $error->getCode() . ": " . $error->getMessage();
}
If you want to interact with the client, for example give them a group even when they are offline, use this:
PHP:
$uid = "GV1o/OG88OpRoTwTq4HOA3BCEic=";
$dbid = $ts3->clientFindDb($uid, true)[0];
$ts3->serverGroupClientAdd(21, $dbid);
This would add the client with the uid GV1o/OG88OpRoTwTq4HOA3BCEic= to the group with ID 21 even if they are offline.

What exactly do you want to do? Maybe I can help a bit more.
 

niks

Member
Jan 30, 2017
40
5
40
<?php require_once("libraries/TeamSpeak3/TeamSpeak3.php"); $ts3 = TeamSpeak3::factory("serverquery://serveradmin:p[email protected]:10011/?server_port=9987"); try{ $client = $ts3->clientGetByUid("GV1o/OG88OpRoTwTq4HOA3BCEic="); //If no error occured echo online, means client is online echo "online"; } catch(TeamSpeak3_Exception $error) { //Check if error is invalidID if($error->getCode() == 512){ echo "offline"; die(); } // print the error message returned by the server echo "Error " . $error->getCode() . ": " . $error->getMessage(); }

That would be perfect for what I needed, but I don't know why .. it is displaying a HTTP ERROR 500 being alone without any other piece of code.
 

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
I added simple html form to check uids with @Kieran php code

PHP:
<?php
if(isset($_POST['submit']))
{
    $filename = 'TeamSpeak3/TeamSpeak3.php';

    if (file_exists($filename))
    {
        require_once("TeamSpeak3/TeamSpeak3.php");
    }
    else
    {
        die ("The file $filename does not exist");

    }

    $login_name = 'serveradmin';      //query login info
    $login_password = '7mJEDtKf';     // =||=
    $ip = 'localhost';                //ex. 127.0.0.1/ 254.13.121.12
    $query_port = '10011';              //default 10011
    $virtualserver_port = '9987';     //default 9987

    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."/?server_port=".$virtualserver_port."&nickname=R4P3&blocking=0");


    $uid = $_POST['uid'];

    try{

        $client = $ts3_VirtualServer->clientGetByUid($uid);

        //If no error occured echo online, means client is online
        echo "online";

        }
        catch(TeamSpeak3_Exception $error)
        {
          //Check if error is invalidID
          if($error->getCode() == 512){
              echo "offline";
              die();
          }
          // print the error message returned by the server
          echo "Error " . $error->getCode() . ": " . $error->getMessage();
        }

}


?>

<!DOCTYPE html>
<html>
<head>
    <title>ID FINDER</title>
</head>
<body>
    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
        <input placeholder="Post your uid" type="text" name="uid" /><br>
        <button type="submit" name="submit"><strong>Search</strong></button>
    </form>
</body>
</html>
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
That would be perfect for what I needed, but I don't know why .. it is displaying a HTTP ERROR 500 being alone without any other piece of code.
Look in your error log. Maybe the path to the teamspeak framework is wrong?
What webserver are you running? If it's apache, look at the last few lines of /var/log/apache2/error.log
 

niks

Member
Jan 30, 2017
40
5
40
Code:
[Sat Dec 09 22:57:58.372714 2017] [:error] [pid 3732] [client 162.158.79.165:34659] PHP Fatal error:  Uncaught TeamSpeak3_Adapter_ServerQuery_Exception: connection failed, you are banned (you may retry in 161 seconds) in /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php:319\nStack trace:\n#0 /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php(91): TeamSpeak3_Adapter_ServerQuery_Reply->fetchError(Object(TeamSpeak3_Helper_String))\n#1 /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery.php(141): TeamSpeak3_Adapter_ServerQuery_Reply->__construct(Array, 'login client_lo...', Object(TeamSpeak3_Node_Host), true)\n#2 /var/www/html/n/libraries/TeamSpeak3/Node/Abstract.php(73): TeamSpeak3_Adapter_ServerQuery->request('login client_lo...', true)\n#3 /var/www/html/n/libraries/TeamSpeak3/Node/Abstract.php(97): TeamSpeak3_Node_Abstract->request('login client_lo...')\n#4 /var/www/html/n/libraries/TeamSpeak3/Node/Host.php(839): TeamSpeak3_Node_Abstract->execute('login', Array)\n#5 /var/www/html/n/libraries/TeamSpeak3/TeamSpeak3.php(328): TeamSpeak3_Node_Host->login(Object(TeamSpeak3_Helper_Stri in /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php on line 319
[Sat Dec 09 22:58:04.323579 2017] [:error] [pid 3741] [client 141.101.107.172:12369] PHP Fatal error:  Uncaught TeamSpeak3_Adapter_ServerQuery_Exception: connection failed, you are banned (you may retry in 155 seconds) in /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php:319\nStack trace:\n#0 /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php(91): TeamSpeak3_Adapter_ServerQuery_Reply->fetchError(Object(TeamSpeak3_Helper_String))\n#1 /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery.php(141): TeamSpeak3_Adapter_ServerQuery_Reply->__construct(Array, 'login client_lo...', Object(TeamSpeak3_Node_Host), true)\n#2 /var/www/html/n/libraries/TeamSpeak3/Node/Abstract.php(73): TeamSpeak3_Adapter_ServerQuery->request('login client_lo...', true)\n#3 /var/www/html/n/libraries/TeamSpeak3/Node/Abstract.php(97): TeamSpeak3_Node_Abstract->request('login client_lo...')\n#4 /var/www/html/n/libraries/TeamSpeak3/Node/Host.php(839): TeamSpeak3_Node_Abstract->execute('login', Array)\n#5 /var/www/html/n/libraries/TeamSpeak3/TeamSpeak3.php(328): TeamSpeak3_Node_Host->login(Object(TeamSpeak3_Helper_Stri in /var/www/html/n/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php on line 319, referer: http://maxskill.eu/n/test.php

Oh I see, the host ip was not in the whitelist for some reason.
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Oh yea try putting the
PHP:
$ts3 = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
inside the "try". Then it would echo "error you are banned retry in.."
 

niks

Member
Jan 30, 2017
40
5
40
Oh yea try putting the
PHP:
$ts3 = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
inside the "try". Then it would echo "error you are banned retry in.."

Thank you so much to the both of you..
Greatly Appreciated.. Is there any way I can add reputation or something like that to show my gratitude?

I added simple html form to check uids with @Kieran php code



PHP:
<?php
if(isset($_POST['submit']))
{
    $filename = 'TeamSpeak3/TeamSpeak3.php';

    if (file_exists($filename))
    {
        require_once("TeamSpeak3/TeamSpeak3.php");
    }
    else
    {
        die ("The file $filename does not exist");

    }

    $login_name = 'serveradmin';      //query login info
    $login_password = '7mJEDtKf';     // =||=
    $ip = 'localhost';                //ex. 127.0.0.1/ 254.13.121.12
    $query_port = '10011';              //default 10011
    $virtualserver_port = '9987';     //default 9987

    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."/?server_port=".$virtualserver_port."&nickname=R4P3&blocking=0");


    $uid = $_POST['uid'];

    try{

        $client = $ts3_VirtualServer->clientGetByUid($uid);

        //If no error occured echo online, means client is online
        echo "online";

        }
        catch(TeamSpeak3_Exception $error)
        {
          //Check if error is invalidID
          if($error->getCode() == 512){
              echo "offline";
              die();
          }
          // print the error message returned by the server
          echo "Error " . $error->getCode() . ": " . $error->getMessage();
        }

}


?>

<!DOCTYPE html>
<html>
<head>
    <title>ID FINDER</title>
</head>
<body>
    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
        <input placeholder="Post your uid" type="text" name="uid" /><br>
        <button type="submit" name="submit"><strong>Search</strong></button>
    </form>
</body>
</html>
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Thank you so much to the both of you..
Greatly Appreciated.. Is there any way I can add reputation or something like that to show my gratitude?
Liking the most helping posts is enough :3
No problem ^^
 
Top