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.

66 lines
1.7 KiB
PHTML

11 years ago
<?php
require_once('config.inc.php');
require_once($framework);
$exceptions = array_unique(array_merge($exceptions, $roots));
$server = TeamSpeak3::factory('serverquery://'.$user.':'.$passwd.'@'.$host.':'.$queryport.'/?server_port='.$voiceport);
foreach($roots as $root) {
$root = $server->channelGetByName($root);
$subs = $root->subChannelList();
foreach($subs as $sub) {
if(catchExceptions($sub['channel_name'], $exceptions)) {
continue;
}
$groups = $sub->subChannelList();
$groupCount = count($groups);
$availablechannel = false;
11 years ago
$i = 0;
foreach($groups as $group) {
if(catchExceptions($group['channel_name'], $exceptions)) {
$groupCount--;
11 years ago
continue;
}
$i++;
if($group['total_clients'] == 0) {
$availablechannel = true;
}
if($i == $groupCount AND $availablechannel = false) {
11 years ago
$regex = '#([0-9]{1,3})#e';
$replacement = '("$1" + 1)';
$newName = preg_replace($regex, $replacement, $group['channel_name']);
createChannel($server, $newName, $sub, $options);
11 years ago
}
}
if(empty($groups) OR $i == 0) {
createChannel($server, $default, $sub, $options, array('channel_flag_permanent' => TRUE));
11 years ago
}
}
}
function createChannel($server, $name, $parent, $options, $addparam = array()) {
$parameters = array(
'channel_name' => $name,
'cpid' => $parent->getId()
);
$parameters = array_merge($parameters, $addparam);
$id = $server->channelCreate($parameters);
if($options['inherit_icons']) {
$channel = $server->channelGetById($id);
$channel->modify(array('channel_icon_id' => $parent->getProperty('channel_icon_id')));
}
11 years ago
}
function catchExceptions($name, $excpetions) {
foreach($excpetions as $exception) {
if($name == $exception) {
return true;
}
}
return false;
}