From bedc00c873eec893542d5ed80347245aa6654c2b Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 11 May 2015 12:12:01 +0545 Subject: Code style Firewall Schedule --- usr/local/www/firewall_schedule.php | 277 ++++++++++++++++++------------------ 1 file changed, 142 insertions(+), 135 deletions(-) (limited to 'usr/local/www/firewall_schedule.php') diff --git a/usr/local/www/firewall_schedule.php b/usr/local/www/firewall_schedule.php index 56687f6..347f806 100644 --- a/usr/local/www/firewall_schedule.php +++ b/usr/local/www/firewall_schedule.php @@ -50,8 +50,9 @@ require("shaper.inc"); $pgtitle = array(gettext("Firewall"),gettext("Schedules")); -if (!is_array($config['schedules']['schedule'])) +if (!is_array($config['schedules']['schedule'])) { $config['schedules']['schedule'] = array(); +} $a_schedules = &$config['schedules']['schedule']; @@ -63,10 +64,10 @@ if ($_GET['act'] == "del") { $referenced_by = false; $schedule_name = $a_schedules[$_GET['id']]['name']; - if(is_array($config['filter']['rule'])) { - foreach($config['filter']['rule'] as $rule) { + if (is_array($config['filter']['rule'])) { + foreach ($config['filter']['rule'] as $rule) { //check for this later once this is established - if ($rule['sched'] == $schedule_name){ + if ($rule['sched'] == $schedule_name) { $referenced_by = $rule['descr']; $is_schedule_referenced = true; break; @@ -74,7 +75,7 @@ if ($_GET['act'] == "del") { } } - if($is_schedule_referenced == true) { + if ($is_schedule_referenced == true) { $savemsg = sprintf(gettext("Cannot delete Schedule. Currently in use by %s"),$referenced_by); } else { unset($a_schedules[$_GET['id']]); @@ -94,153 +95,159 @@ include("head.inc");
- - - - + + + + - - + + + - - - - - - - + + + + + + +
- - - - - -
" alt="add" />
-
+ + + + + +
" alt="add" />
+
+ - -  " width="17" height="17" border="0" alt="schedule" /> - - - - +  " width="17" height="17" border="0" alt="schedule" /> + + + - - - + $timeFriendly = $starttime . "-" . $stoptime; + $description = $timerange['rangedescr']; + + ?> + + + + + + +
+ + "; - $currentDay--; - if ($currentDay != $firstDay) - $dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; - else - $dayFriendly .= $monthArray[$month-1] . " " . $day; - $firstDayFound = false; - $firstPrint = true; + //get hours + $temptimerange = $timerange['hour']; + $temptimeseparator = strrpos($temptimerange, "-"); + + $starttime = substr ($temptimerange, 0, $temptimeseparator); + $stoptime = substr ($temptimerange, $temptimeseparator+1); + + if ($timerange['month']) { + $tempmontharray = explode(",", $timerange['month']); + $tempdayarray = explode(",",$timerange['day']); + $arraycounter = 0; + $firstDayFound = false; + $firstPrint = false; + foreach ($tempmontharray as $monthtmp) { + $month = $tempmontharray[$arraycounter]; + $day = $tempdayarray[$arraycounter]; + + if (!$firstDayFound) { + $firstDay = $day; + $firstmonth = $month; + $firstDayFound = true; + } + + $currentDay = $day; + $nextDay = $tempdayarray[$arraycounter+1]; + $currentDay++; + if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) { + if ($firstPrint) { + $dayFriendly .= "
"; + } + $currentDay--; + if ($currentDay != $firstDay) { + $dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; + } else { + $dayFriendly .= $monthArray[$month-1] . " " . $day; } - $arraycounter++; + $firstDayFound = false; + $firstPrint = true; } + $arraycounter++; } - else - { - $tempdayFriendly = $timerange['position']; - $firstDayFound = false; - $tempFriendlyDayArray = explode(",", $tempdayFriendly); - $currentDay = ""; - $firstDay = ""; - $nextDay = ""; - $counter = 0; - foreach ($tempFriendlyDayArray as $day){ - if ($day != ""){ - if (!$firstDayFound) - { - $firstDay = $tempFriendlyDayArray[$counter]; - $firstDayFound = true; + } else { + $tempdayFriendly = $timerange['position']; + $firstDayFound = false; + $tempFriendlyDayArray = explode(",", $tempdayFriendly); + $currentDay = ""; + $firstDay = ""; + $nextDay = ""; + $counter = 0; + foreach ($tempFriendlyDayArray as $day) { + if ($day != "") { + if (!$firstDayFound) { + $firstDay = $tempFriendlyDayArray[$counter]; + $firstDayFound = true; + } + $currentDay =$tempFriendlyDayArray[$counter]; + //get next day + $nextDay = $tempFriendlyDayArray[$counter+1]; + $currentDay++; + if ($currentDay != $nextDay) { + if ($firstprint) { + $dayFriendly .= "
"; } - $currentDay =$tempFriendlyDayArray[$counter]; - //get next day - $nextDay = $tempFriendlyDayArray[$counter+1]; - $currentDay++; - if ($currentDay != $nextDay){ - if ($firstprint) - $dayFriendly .= "
"; - $currentDay--; - if ($currentDay != $firstDay) - $dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1]; - else - $dayFriendly .= $dayArray[$firstDay-1]; - $firstDayFound = false; - $firstprint = true; + $currentDay--; + if ($currentDay != $firstDay) { + $dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1]; + } else { + $dayFriendly .= $dayArray[$firstDay-1]; } - $counter++; + $firstDayFound = false; + $firstprint = true; } + $counter++; } } - $timeFriendly = $starttime . "-" . $stoptime; - $description = $timerange['rangedescr']; - - ?>
-
-   - - - - - - -
" alt="edit" />" alt="delete" />
-
+
+   + + + + + + +
" alt="edit" />" alt="delete" />
+
- - - - - -
" alt="add" />
-
-


-
+ + + + + +
" alt="add" />
+
+


+
-- cgit v1.1