Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 4 of 4
  1. #1
    Join Date
    July 2015
    Posts
    5

    all users online

    How to get all users name online in PHP on my Website?

    Thanks!

  2. #2
    Join Date
    December 2009
    Location
    Germany
    Posts
    289
    connect to your query-port, normally 10011, and issue the right commands.
    If you only need the connected clients, then use "clientlist", and you only have to parse the output to get all connected clients.

    All this can be handled with a socket-connection.

  3. #3
    Join Date
    July 2015
    Posts
    5
    Maybee some example? Plz

  4. #4
    Join Date
    December 2009
    Location
    Germany
    Posts
    289
    This is the php-code, you can use for the mentioned problem. You will get an array with the following informations:
    • Client-ID [clid]
    • Channel-ID [cid]
    • Client-DBID [client_database_id]
    • Client-Nickname [client_nickname]
    • Client-Type (Normal or Query-User) [client_type]

    At the end of each line i have mentioned the field-name and the array is also indexed by the client-id.

    Code:
    <?php
    
    $sock = fsockopen("<server-ip>", 10011);
    
    sleep(1);
    $content = fread($sock, 10240);
    $content = "";
    
    fwrite($sock, "use port=<serverport>\n");
    fwrite($sock, "login <query-user> <query-pw>\n");
    fwrite($sock, "clientlist\n");
    
    sleep(1);
    $content = fread($sock, 10240);
    
    $lines = explode("\r", $content);
    
    $clients = explode("|", $lines[2]);
    
    $clientInfo = array();
    
    foreach($clients as $client) {
    	$cliententries = explode(" ", $client);
    	
    	$tmp = array();
    	foreach($cliententries as $cliententry) {
    		 $tmp[] = explode("=", $cliententry);
    	}
    	
    	$tmp2 = array();
    	foreach($tmp as $entry) {
    		$tmp2[$entry[0]] = $entry[1];
    	}
    	
    	$clientInfo[$tmp2["clid"]] = $tmp2;
    }
    
    print_r($clientInfo);
    
    fclose($sock);
    ?>

Thread Information

Users Browsing this Thread

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

Posting Permissions

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