<?



// Verbindung herstellen

$connection fsockopen($config_sec["tsip"], "51234");

if (
$connection == FALSE) { echo "Verbindung zum Teamspeak Server fehlgeschlagen.<br />"; }
// Server wählen
else {


fputs($connection"SEL ".$config_sec["tsport"]."\r\n");

// Playerlist

fputs($connection"pl\r\n");

if (
fgets($connection) != "[TS]\r\n") { echo "Keinen Teamspeak Server auf diesem Port gefunden.<br />"; }
else {

fgets($connection); // Erstes OK

if (fgets($connection) == "OK\r\n") {} // Wenn darauf zweites OK => keine Benutzer auf TS
else {

$tsusers = array();
    while(
$p_id != "OK\r\n") {
      list(
$p_id$c_id$ps$bs$pr$br$pl$ping$logintime$idletime$cprivs$pprivs$pflags$ip$nick$loginname) = explode("    ",fgets($connection));
      echo 
$nick '<br>';
              if (
is_numeric($p_id)) {
        
$privs "[";
        if (
$cprivs == 1) { $privs .= "CA "; }
        elseif (
$cprivs == 2) { $privs .= "O "; }
        elseif (
$cprivs == 4) { $privs .= "V "; }
        elseif (
$cprivs == 8) { $privs .= "AO "; }
        elseif (
$cprivs == 16) { $privs .= "AV "; }
        
        if (
$pprivs == 1) { $privs .= "SA"; }
        elseif (
$pprivs == 4) { $privs .= "R"; }
        elseif (
$pprivs == 5) { $privs .= "R SA"; }
        else { 
$privs .= "U"; }
        
        
$flags "normal";
        if (
$pflags >= 1) { $flags "chan_commander"; }
        if (
$pflags >= 4) { $flags "block_whisper"; }
        if (
$pflags >= 8) { $flags "away"; }
        if (
$pflags >= 16) { $flags "mute_mic"; }
        if (
$pflags >= 32) { $flags "mute_speakers"; }

        
$privs rtrim($privs)."]";
                
$push = array('name'=>"<img src='ts_images/".$flags.".gif' alt='' /> ".str_replace("\"","",$nick),'privs'=>$privs);  
                
array_push($tsusers,$push);
                }
    }

/*
        p_id    is the player ID, needed for many other commands to manipulate
                a player.
        c_id    is the channel ID of the channel the player is currently in.
        ps      is the amount of packets this user has sent to the server
        bs      is the amount of bytes this user has sent to the server
        pr      is the amount of packets this user has recieved from the
                server
        br      is the amount of bytes this user has recieved from the server
        pl      is the amount of lost packets the user-server connection
                produced
        ping    is the latency time from user to server, in milliseconds
        logintime       is the time in seconds since this user connected to
                        the server
        idletime        is the time in seconds since the last user interaction
                        with the server
        cprivs  a value determining the current channel privileges, add up
                until you get the value from this table:
                CA:     1
                O:      2
                V:      4
                AO:     8
                AV:     16
        pprivs  a value determining the current player privileges, add up until
                you get the value from this table:
                SA:                     1
                Allow_Registration:     2
                Registered:             4
                Internal Use:           8
                Stickey:                16
        pflags  a value determining the current player flags, add up until you
                get the value from this table:
                Channel Commander:      1
                Voice Request:          2
                Doesnt Accept Whispers: 4
                Away:                   8
                Microphone Muted:       16
                Sound Muted:            32
                Recording:              64
        ip      is the IP of this player
        nick    is the nickname the player has selected
        loginname   is the name of the account the user has logged in with
*/

}
// Verbindung beenden
fclose($connection);

}
}
?>