Forum

Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    5

    Question Get a list of clients of specific group currently connected to a ts3 server

    Hello All!

    I'm looking for some help regarding php script.
    I tested the TS3 PHP Framework and I have a question?

    How to get client list of specific group(s) connected to server?
    What code should I use to make opportunity of doing this?

    Can anybody help me with this issue?

    Code:
    <?php
    
    /**
     * @file
     * TeamSpeak 3 PHP Framework Example
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program. If not, see <http://www.gnu.org/licenses/>.
     *
     * @author    Sven 'ScP' Paulsen
     * @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
     */
    
    try
    {
      /* connect to server, login and get TeamSpeak3_Node_Host object by URI */
      $ts3_ServerInstance = TeamSpeak3::factory("serverquery://" . $cfg["user"] . ":" . $cfg["pass"] . "@" . $cfg["host"] . ":" . $cfg["query"] . "/");
    
      /* access server instance address using __toString() */
      echo "<h1>Client List - " . $ts3_ServerInstance . "</h1>\n";
    
      /* display server select form */
      $selected_sid = form_server_selector($ts3_ServerInstance->serverList());
    
      /* get TeamSpeak3_Node_Server object by ID */
      $ts3_VirtualServer = $ts3_ServerInstance->serverGetById($selected_sid);
    
      /* walk through list of clients */
      echo "<table class=\"list\">\n";
      echo "<tr>\n" .
           "  <th>ID</th>\n" .
           "  <th>Nickname</th>\n" .
           "  <th>Unique Identifier</th>\n" .
           "  <th>Status</th>\n" .
           "  <th>Platform</th>\n" .
           "  <th>Version</th>\n" .
           "</tr>\n";
      foreach($ts3_VirtualServer->clientList() as $client)
      {
        echo "<tr>\n" .
             "  <td>" . $client->getId() . "</td>\n" .
             "  <td><a href=\"?page=clientinfo&amp;server=" . $ts3_VirtualServer->getId() . "&amp;client=" . $client->getId() . "\">" . htmlspecialchars($client) . "</a></td>\n" .
             "  <td>" . $client["client_unique_identifier"] . "</td>\n" .
             "  <td><img src=\"../images/viewer/" . $client->getIcon() . ".png\" alt=\"\" /></td>\n" .
             "  <td>" . $client["client_platform"] . "</td>\n" .
             "  <td>" . $client["client_version"] . "</td>\n" .
             "</tr>\n";
      }
      echo "</table>\n";
    
      /* display runtime from adapter profiler */
      echo "<p>Executed " . $ts3_ServerInstance->getAdapter()->getQueryCount() . " queries in " . $ts3_ServerInstance->getAdapter()->getQueryRuntime() . " seconds</p>\n";
    }
    catch(Exception $e)
    {
      /* catch exceptions and display error message if anything went wrong */
      echo "<span class='error'><b>Error " . $e->getCode() . ":</b> " . $e->getMessage() . "</span>\n";
    }

  2. #2
    Join Date
    July 2006
    Posts
    1,600
    You want to list all groups in which at least one member client is connected to the server?
    So basically, say, we have 3 serveradmins and 2 guests but no normal users connected; your list would look like this:
    Code:
    serveradmin
    guest
    OR

    do you want to specify a (or more) groups which member clients (currently online) will be displayed.
    same example as above but you want to list only serveradmins which would result in
    Code:
    Admin1
    Admin2
    Admin3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: November 14th, 2014, 07:31 PM
  2. Replies: 0
    Last Post: February 26th, 2013, 08:51 AM
  3. Replies: 3
    Last Post: January 3rd, 2013, 10:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •