Move all clients of a servergroup to another one.

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
So yea it basically allows you to move all clients of a group to another group. It's supposed to be used for learning purposes and it includes multiple vulnerabilities so you shouldn't use it on your server without actually knowing what you are doing.

xx32ra8.png


PHP:
<?php
require_once('config.php');
require_once('ts3admin.class.php');

$tsHandle = new ts3admin($cfg['host'], $cfg['qPort']);
if($tsHandle->getElement('success', $tsHandle->connect())) {
  $tsHandle->login($cfg['username'], $cfg['password']);
    $tsHandle->selectServer($cfg['sPort']);
  $tsHandle->setName($cfg['nickname']);

  echo '<form action="" method="post">Move all clients from <select name="fromSGID">';
  foreach($tsHandle->serverGroupList()['data'] as $sGroup) { if($sGroup['type'] == 1){ echo '<option value="'.$sGroup['sgid'].'">'.$sGroup['name'].'</option>'; } }
  echo '</select> to <select name="toSGID">';
  foreach($tsHandle->serverGroupList()['data'] as $sGroup) { if($sGroup['type'] == 1){ echo '<option value="'.$sGroup['sgid'].'">'.$sGroup['name'].'</option>'; } }
  echo '</select> <input type="submit" value="Move"></form><br>';

  if(isset($_POST['fromSGID']) && $_POST['fromSGID'] != '' && isset($_POST['toSGID']) && $_POST['toSGID'] != ''){
    foreach($tsHandle->clientList("-groups")['data'] as $client){
      if($client['client_type'] == 0){
        $cGroups = explode(',', $client['client_servergroups']);
        if(in_array($_POST['fromSGID'], $cGroups)){
          $tsHandle->serverGroupDeleteClient($_POST['fromSGID'], $client['client_database_id']);
          if(!in_array($_POST['toSGID'], $cGroups)){
            $tsHandle->serverGroupAddClient($_POST['toSGID'], $client['client_database_id']);
          }
        }
      }
    }
  }

  foreach ($tsHandle->serverGroupList()['data'] as $sGroup) {
    if($sGroup['type'] == 1){
      echo '<b>'.$sGroup['sgid'].' - '.$sGroup['name'].'</b><br>';
      foreach($tsHandle->clientList("-groups")['data'] as $client){
        if($client['client_type'] == 0){
          $cGroups = explode(',', $client['client_servergroups']);
          if(in_array($sGroup['sgid'], $cGroups)){
            echo $client['client_nickname'].'<br>';
          }
        }
      }
    }
  }
} else {
    echo 'Connection could not be established.';
}
?>

config.php
PHP:
<?php
$cfg = array(
  'username'   =>    'serveradmin',
  'password'   =>    'password',
  'host'         =>    '127.0.0.1',
  'sPort'       =>    '9987',
  'qPort'      =>    '10011',
  'nickname'   =>    'R4P3 Bot'
);
?>
 
Top