Advertisement
Guest User

Untitled

a guest
May 22nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.01 KB | None | 0 0
  1. <?php
  2. /*-------SETTINGS-------*/ //PLEASE EDIT THIS PART
  3. $ts3_ip = '127.0.0.1';
  4. $ts3_queryport = 10011;
  5. $ts3_user = 'serveradmin';
  6. $ts3_pass = 'password';
  7. $ts3_port = 9987;
  8. /*----------------------*/
  9.  
  10. #Include ts3admin.class.php
  11. require("ts3admin.class.php");
  12.  
  13. #build a new ts3admin object
  14. $tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);
  15.  
  16. function is_multi($array) { return (count($array) != count($array, 1)); }
  17. function is_assoc($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); }
  18. function array2table($array) {
  19.     $html = '';
  20.  
  21.     if(is_multi($array)) {
  22.         $html .= '<table cellpadding="5" cellspacing="1" bgcolor="black" align="center"><tr>';
  23.  
  24.         foreach($array as $array2) {
  25.             foreach($array2 as $key => $value) {
  26.                 $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">&nbsp;&nbsp;&nbsp;'.htmlspecialchars($key).'&nbsp;&nbsp;&nbsp;</td>';
  27.             }
  28.             break;
  29.         }
  30.  
  31.         $html .= '</tr>';
  32.  
  33.         foreach($array as $array2) {
  34.             $html .= '<tr>';
  35.             foreach($array2 as $key => $value) {
  36.                 $html .= '<td bgcolor="#ffffff" align="center">&nbsp;&nbsp;&nbsp;'.htmlspecialchars($value).'&nbsp;&nbsp;&nbsp;</td>';
  37.             }
  38.             $html .= '</tr>';
  39.         }
  40.     }else{
  41.         $html .= '<table cellpadding="5" cellspacing="1" bgcolor="black" align="center" width="';
  42.  
  43.         if(is_assoc($array)) {
  44.             $html .= '400px">';
  45.             $html .= '<tr>';
  46.             $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">Key</td>';
  47.             $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">Value</td>';
  48.             $html .= '</tr>';
  49.  
  50.             foreach($array as $key => $value) {
  51.                 $html .= '<tr>';
  52.                 $html .= '<td bgcolor="#ffffff" align="center">'.htmlspecialchars($key).'</td>';
  53.                 $html .= '<td bgcolor="#ffffff" align="center">'.htmlspecialchars($value).'</td>';
  54.                 $html .= '</tr>';
  55.             }
  56.         }else{
  57.             $html .= '200px">';
  58.             $html .= '<tr>';
  59.             $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">Value</td>';
  60.             $html .= '</tr>';
  61.  
  62.             foreach($array as $value) {
  63.                 $html .= '<tr>';
  64.                 $html .= '<td bgcolor="#ffffff" align="center">'.htmlspecialchars($value).'</td>';
  65.                 $html .= '</tr>';
  66.             }
  67.         }
  68.     }
  69.     return $html;
  70. }
  71. $html = '';
  72.  
  73. if($tsAdmin->getElement('success', $tsAdmin->connect()))
  74. {
  75.     #login as serveradmin
  76.     $tsAdmin->login($ts3_user, $ts3_pass);
  77.     #select teamspeakserver
  78.     $tsAdmin->selectServer($ts3_port);
  79.     $customFieldSet = array();
  80.     $output = $tsAdmin->tokenAdd('0','7','0','registrationtoken',$customFieldSet);
  81.     $html = array2table($output['data']);
  82.  
  83. }
  84. else
  85. {
  86.     echo 'Connection could not be established.';
  87. }
  88.  
  89. /**
  90.  * This code retuns all errors from the debugLog
  91.  */
  92. if(count($tsAdmin->getDebugLog()) > 0) {
  93.     foreach($tsAdmin->getDebugLog() as $logEntry) {
  94.         echo '<script>alert("'.$logEntry.'");</script>';
  95.     }
  96. }
  97. echo "Okay, let's create a token for you.";
  98. echo '<br/><br/>';
  99. ?>
  100. <html>
  101.     <head>
  102.    
  103.     </head>
  104.     <body bgcolor="#B1BDA6">
  105.         <br><br>
  106.         <h1 align="center">Returnvalues:</h1>
  107.         <br><br>
  108.         <?php echo $html; ?>
  109.     </body>
  110. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement