You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.0 KiB
PHTML

11 years ago
<?php
require_once('config.inc.php');
require_once('functions.php');
require_once('vendor/autoload.php');
9 years ago
$server = TeamSpeak3::factory('serverquery://'.$user.':'.$passwd.'@'.$host.':'.$queryport.'/?server_port='.$voiceport);
9 years ago
$exceptions = array_unique(array_merge($exceptions, $roots));
while(true) {
// get fresh channel list, because total_clients is cached
$server->channelListReset();
foreach($roots as $root) {
$root = $server->channelGetByName($root);
$subs = $root->subChannelList();
foreach($subs as $sub) {
if(catchExceptions($sub['channel_name'], $exceptions)) {
continue;
}
9 years ago
$groups = $sub->subChannelList();
$groupCount = count($groups);
$delete = false;
$i = 0;
foreach($groups as $group) {
if(catchExceptions($group['channel_name'], $exceptions)) {
$groupCount--;
continue;
}
$i++;
if($delete == true AND $group['total_clients'] == 0) {
$group->delete();
}
if($group['total_clients'] == 0) {
$delete = true;
}
if($i == $groupCount AND $delete == false) {
$regex = '#([0-9]{1,3})#';
$callback = function ($matches) {
return $matches[0]+1;
};
$newName = preg_replace_callback($regex, $callback, $group['channel_name']);
createChannel($server, $newName, $sub, $options);
}
}
if(empty($groups) OR $i == 0) {
$topic = $sub->getProperty('channel_topic');
if(!empty($topic)) {
$name = $topic;
} else {
$name = $default;
}
createChannel($server, $name, $sub, $options);
}
}
}
// anti-flood
sleep(1);
}