Advertisement
Guest User

TS3Admin Class Test

a guest
Aug 8th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <?php
  2.  
  3. require_once "ts3admin.class.php";
  4.  
  5. /*-------SETTINGS-------*/
  6. $ts3_ip = '127.0.0.1';
  7. $ts3_queryport = 10011;
  8. $ts3_port = 9987;
  9. $ts3_username = "serveradmin";
  10. $ts3_password = "password";
  11. $ts3_group_id    = 2;
  12. /*----------------------*/
  13.  
  14.  
  15.  
  16. echo '<table border="1"><tr><td>Username</td><td>Kanal</td><td>Status</td></tr>';
  17.  
  18.  
  19. $tsAdmin = new ts3admin("127.0.0.1", "10011");
  20.  
  21. if($tsAdmin->getElement('success', $tsAdmin->connect()))
  22. {
  23.     #login as serveradmin
  24.     $login = $tsAdmin->login($ts3_username, $ts3_password);
  25.    
  26.     if($login["success"])
  27.     {
  28.         #select teamspeakserver
  29.         $tsAdmin->selectServer($ts3_port);
  30.  
  31.         #get serverGroupClientList
  32.         $groupList = $tsAdmin->serverGroupClientList($ts3_group_id, true);
  33.  
  34.         #get ClientList
  35.         $userList = $tsAdmin->clientList("-uid -times");
  36.  
  37.         if($groupList["success"] && $userList["success"])
  38.         {
  39.  
  40.             foreach($groupList["data"] as $srow => $svalue)
  41.             {
  42.                 #check FOR EACH Group if the Member of the Group is online
  43.  
  44.                 $nick = $svalue["client_nickname"];
  45.                 $isonline = 0;
  46.  
  47.                 foreach($userList["data"] as $usrow => $usvalue)
  48.                 {
  49.                     #Check FOR EACH User who is online, if he is in the Group
  50.  
  51.                     $cldbid = $usvalue['client_database_id'];
  52.                    
  53.  
  54.                     #check wether a User is in the Group
  55.  
  56.                     if($svalue["cldbid"] == $cldbid)
  57.                     {
  58.                         $isonline = 1;
  59.                         $cid    = $usvalue['cid'];
  60.                         break;
  61.                     }
  62.                 }
  63.  
  64.                 #Is the User Online?
  65.                
  66.                 if($isonline)
  67.                 {
  68.                     $status =  '<span style="color:green;">Online</span><br /><br />';
  69.                     $channel = ($tsAdmin->channelInfo($cid)['data']['channel_name']);
  70.                 }
  71.                 else
  72.                 {
  73.                     $status = '<span style="color:red;">Offline</span><br /><br />';
  74.                     $channel = "Unavailable";
  75.                 }
  76.  
  77.  
  78.                 #Print Entry to table
  79.                 echo "  
  80.                 <tr>
  81.                 <td><p>". $nick ."<br /></td><td><small>Channel: ".$channel."<br /></small></td>
  82.                 <td>". $status ."</td>
  83.                 </tr>";
  84.             }
  85.         }
  86.         else
  87.         {
  88.             echo "Can't get Grouplist AND/OR UserList: ".$groupList["errors"][0]." / ".$userList["errors"][0];
  89.         }
  90.     }
  91.     else
  92.     {
  93.         echo "Can't Login: ".$login["errors"][0];
  94.     }
  95. }
  96. else
  97. {
  98.     echo 'Connection could not be established.';
  99. }
  100.  
  101.  
  102. echo "</table>";
  103.  
  104. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement