Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*-------SETTINGS-------*/ //PLEASE EDIT THIS PART
- $ts3_ip = '127.0.0.1';
- $ts3_queryport = 10011;
- $ts3_user = 'serveradmin';
- $ts3_pass = 'password';
- $ts3_port = 9987;
- /*----------------------*/
- #Include ts3admin.class.php
- require("ts3admin.class.php");
- #build a new ts3admin object
- $tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);
- function is_multi($array) { return (count($array) != count($array, 1)); }
- function is_assoc($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); }
- function array2table($array) {
- $html = '';
- if(is_multi($array)) {
- $html .= '<table cellpadding="5" cellspacing="1" bgcolor="black" align="center"><tr>';
- foreach($array as $array2) {
- foreach($array2 as $key => $value) {
- $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center"> '.htmlspecialchars($key).' </td>';
- }
- break;
- }
- $html .= '</tr>';
- foreach($array as $array2) {
- $html .= '<tr>';
- foreach($array2 as $key => $value) {
- $html .= '<td bgcolor="#ffffff" align="center"> '.htmlspecialchars($value).' </td>';
- }
- $html .= '</tr>';
- }
- }else{
- $html .= '<table cellpadding="5" cellspacing="1" bgcolor="black" align="center" width="';
- if(is_assoc($array)) {
- $html .= '400px">';
- $html .= '<tr>';
- $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">Key</td>';
- $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">Value</td>';
- $html .= '</tr>';
- foreach($array as $key => $value) {
- $html .= '<tr>';
- $html .= '<td bgcolor="#ffffff" align="center">'.htmlspecialchars($key).'</td>';
- $html .= '<td bgcolor="#ffffff" align="center">'.htmlspecialchars($value).'</td>';
- $html .= '</tr>';
- }
- }else{
- $html .= '200px">';
- $html .= '<tr>';
- $html .= '<td bgcolor="#c0c0c0" style="font-weight:bold" align="center">Value</td>';
- $html .= '</tr>';
- foreach($array as $value) {
- $html .= '<tr>';
- $html .= '<td bgcolor="#ffffff" align="center">'.htmlspecialchars($value).'</td>';
- $html .= '</tr>';
- }
- }
- }
- return $html;
- }
- $html = '';
- if($tsAdmin->getElement('success', $tsAdmin->connect()))
- {
- #login as serveradmin
- $tsAdmin->login($ts3_user, $ts3_pass);
- #select teamspeakserver
- $tsAdmin->selectServer($ts3_port);
- $customFieldSet = array();
- $output = $tsAdmin->tokenAdd('0','7','0','registrationtoken',$customFieldSet);
- $html = array2table($output['data']);
- }
- else
- {
- echo 'Connection could not be established.';
- }
- /**
- * This code retuns all errors from the debugLog
- */
- if(count($tsAdmin->getDebugLog()) > 0) {
- foreach($tsAdmin->getDebugLog() as $logEntry) {
- echo '<script>alert("'.$logEntry.'");</script>';
- }
- }
- echo "Okay, let's create a token for you.";
- echo '<br/><br/>';
- ?>
- <html>
- <head>
- </head>
- <body bgcolor="#B1BDA6">
- <br><br>
- <h1 align="center">Returnvalues:</h1>
- <br><br>
- <?php echo $html; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement