put foreach in a while(true) loop

master
lub 5 years ago
parent 08fca8d441
commit d0565ba96d

@ -7,40 +7,43 @@ $server = TeamSpeak3::factory('serverquery://'.$user.':'.$passwd.'@'.$host.':'.$
$exceptions = array_unique(array_merge($exceptions, $roots)); $exceptions = array_unique(array_merge($exceptions, $roots));
foreach($roots as $root) { while(true) {
$root = $server->channelGetByName($root); foreach($roots as $root) {
$subs = $root->subChannelList(); $root = $server->channelGetByName($root);
foreach($subs as $sub) { $subs = $root->subChannelList();
if(catchExceptions($sub['channel_name'], $exceptions)) { foreach($subs as $sub) {
continue; if(catchExceptions($sub['channel_name'], $exceptions)) {
} continue;
}
$groups = $sub->subChannelList(); $groups = $sub->subChannelList();
$groupCount = count($groups); $groupCount = count($groups);
$delete = false; $delete = false;
$i = 0; $i = 0;
foreach($groups as $group) { foreach($groups as $group) {
if(catchExceptions($group['channel_name'], $exceptions)) { if(catchExceptions($group['channel_name'], $exceptions)) {
$groupCount--; $groupCount--;
continue; continue;
} }
$i++; $i++;
if($delete == true AND $group['total_clients'] == 0) { if($delete == true AND $group['total_clients'] == 0) {
$group->delete(); $group->delete();
} }
if($group['total_clients'] == 0) { if($group['total_clients'] == 0) {
$delete = true; $delete = true;
} }
if($i == $groupCount AND $delete == false) { if($i == $groupCount AND $delete == false) {
$regex = '#([0-9]{1,3})#e'; $regex = '#([0-9]{1,3})#e';
$replacement = '("$1" + 1)'; $replacement = '("$1" + 1)';
$newName = preg_replace($regex, $replacement, $group['channel_name']); $newName = preg_replace($regex, $replacement, $group['channel_name']);
createChannel($server, $newName, $sub, $options); createChannel($server, $newName, $sub, $options);
} }
} }
if(empty($groups) OR $i == 0) { if(empty($groups) OR $i == 0) {
createChannel($server, $default, $sub, $options, array('channel_flag_permanent' => TRUE)); createChannel($server, $default, $sub, $options, array('channel_flag_permanent' => TRUE));
} }
} }
} }
sleep(1);
}
Loading…
Cancel
Save