From 295c75b65b3e0ead1a4d5f0edeb45ab5aa65ef96 Mon Sep 17 00:00:00 2001 From: lub Date: Sun, 2 Nov 2014 08:47:27 +0100 Subject: [PATCH] fix permanent creation of temp channels --- cronjob.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cronjob.php b/cronjob.php index 4ddf28b..8c8ebd5 100644 --- a/cronjob.php +++ b/cronjob.php @@ -16,7 +16,8 @@ foreach($roots as $root) { $groups = $sub->subChannelList(); $groupCount = count($groups); - + + $availablechannel = false; $i = 0; foreach($groups as $group) { if(catchExceptions($group['channel_name'], $exceptions)) { @@ -24,14 +25,17 @@ foreach($roots as $root) { continue; } $i++; - if($i == $groupCount AND $delete == false) { + if($group['total_clients'] == 0) { + $availablechannel = true; + } + if($i == $groupCount AND $availablechannel = false) { $regex = '#([0-9]{1,3})#e'; $replacement = '("$1" + 1)'; $newName = preg_replace($regex, $replacement, $group['channel_name']); createChannel($server, $newName, $sub, $options); } } - if($i == 0) { + if(empty($groups) OR $i == 0) { createChannel($server, $default, $sub, $options, array('channel_flag_permanent' => TRUE)); } }