summaryrefslogtreecommitdiffstats
path: root/usr/local/www/firewall_schedule.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-11 12:12:01 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-11 12:12:01 +0545
commitbedc00c873eec893542d5ed80347245aa6654c2b (patch)
treeb9402b2e29a3e5222bea7d8bccb8ead4f6f31e94 /usr/local/www/firewall_schedule.php
parentd0c28e66a81bb06183b09514c6d1aa87e9c4deb0 (diff)
downloadpfsense-bedc00c873eec893542d5ed80347245aa6654c2b.zip
pfsense-bedc00c873eec893542d5ed80347245aa6654c2b.tar.gz
Code style Firewall Schedule
Diffstat (limited to 'usr/local/www/firewall_schedule.php')
-rw-r--r--usr/local/www/firewall_schedule.php277
1 files changed, 142 insertions, 135 deletions
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");
<form action="firewall_schedule.php" method="post">
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall schedule">
<tr>
- <td width="25%" class="listhdrr"><?=gettext("Name");?></td>
- <td width="35%" class="listhdrr"><?=gettext("Time Range(s)");?></td>
- <td width="35%" class="listhdr"><?=gettext("Description");?></td>
- <td width="5%" class="list sort_ignore">
- <table border="0" cellspacing="0" cellpadding="1" summary="add">
- <tr>
- <td width="17"></td>
- <td valign="middle"><a href="firewall_schedule_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add a new schedule");?>" alt="add" /></a></td>
- </tr>
- </table>
- </td>
+ <td width="25%" class="listhdrr"><?=gettext("Name");?></td>
+ <td width="35%" class="listhdrr"><?=gettext("Time Range(s)");?></td>
+ <td width="35%" class="listhdr"><?=gettext("Description");?></td>
+ <td width="5%" class="list sort_ignore">
+ <table border="0" cellspacing="0" cellpadding="1" summary="add">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="firewall_schedule_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add a new schedule");?>" alt="add" /></a></td>
+ </tr>
+ </table>
+ </td>
</tr>
<?php $i = 0; foreach ($a_schedules as $schedule): ?>
<tr>
- <td class="listlr" ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
+ <td class="listlr" ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
<?=htmlspecialchars($schedule['name']);?>
- <?php
- $schedstatus = filter_get_time_based_rule_status($schedule);
- if ($schedstatus) { ?>
- &nbsp;<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_frmfld_time.png" title="<?=gettext("Schedule is currently active");?>" width="17" height="17" border="0" alt="schedule" />
- <?php } ?>
-
- </td>
- <td class="listlr" ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
- <table width="98%" border="0" cellpadding="0" cellspacing="0" summary="schedule">
<?php
-
- foreach($schedule['timerange'] as $timerange) {
+ $schedstatus = filter_get_time_based_rule_status($schedule);
+ if ($schedstatus) { ?>
+ &nbsp;<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_frmfld_time.png" title="<?=gettext("Schedule is currently active");?>" width="17" height="17" border="0" alt="schedule" />
+ <?php } ?>
+ </td>
+ <td class="listlr" ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
+ <table width="98%" border="0" cellpadding="0" cellspacing="0" summary="schedule">
+ <?php
+ foreach ($schedule['timerange'] as $timerange) {
+ $tempFriendlyTime = "";
+ $tempID = "";
+ $firstprint = false;
+ if ($timerange) {
+ $dayFriendly = "";
$tempFriendlyTime = "";
- $tempID = "";
- $firstprint = false;
- if ($timerange){
- $dayFriendly = "";
- $tempFriendlyTime = "";
-
- //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 .= "<br />";
- $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 .= "<br />";
+ }
+ $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 .= "<br />";
}
- $currentDay =$tempFriendlyDayArray[$counter];
- //get next day
- $nextDay = $tempFriendlyDayArray[$counter+1];
- $currentDay++;
- if ($currentDay != $nextDay){
- if ($firstprint)
- $dayFriendly .= "<br />";
- $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'];
-
- ?><tr><td><?=$dayFriendly;?></td><td><?=$timeFriendly;?></td><td><?=$description;?></td></tr><?php
}
- }//end for?></table>
- </td>
- <td class="listbg" ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
- <?=htmlspecialchars($schedule['descr']);?>&nbsp;
- </td>
- <td valign="middle" class="list nowrap">
- <table border="0" cellspacing="0" cellpadding="1" summary="buttons">
- <tr>
- <td valign="middle"><a href="firewall_schedule_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit alias");?>" alt="edit" /></a></td>
- <td><a href="firewall_schedule.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext('Do you really want to delete this schedule?');?>')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete alias");?>" alt="delete" /></a></td>
- </tr>
- </table>
- </td>
-</tr>
+ $timeFriendly = $starttime . "-" . $stoptime;
+ $description = $timerange['rangedescr'];
+
+ ?>
+ <tr>
+ <td><?=$dayFriendly;?></td>
+ <td><?=$timeFriendly;?></td>
+ <td><?=$description;?></td>
+ </tr>
+ <?php
+ }
+ }//end for
+ ?>
+ </table>
+ </td>
+ <td class="listbg" ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
+ <?=htmlspecialchars($schedule['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" class="list nowrap">
+ <table border="0" cellspacing="0" cellpadding="1" summary="buttons">
+ <tr>
+ <td valign="middle"><a href="firewall_schedule_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit alias");?>" alt="edit" /></a></td>
+ <td><a href="firewall_schedule.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext('Do you really want to delete this schedule?');?>')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete alias");?>" alt="delete" /></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
<?php $i++; endforeach; ?>
-<tr>
- <td class="list" colspan="3"></td>
- <td class="list">
- <table border="0" cellspacing="0" cellpadding="1" summary="add">
- <tr>
- <td width="17"></td>
- <td valign="middle"><a href="firewall_schedule_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add a new schedule");?>" alt="add" /></a></td>
- </tr>
- </table>
- </td>
-</tr>
-<tr>
- <td class="tabcont" colspan="3">
- <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br /></strong></span><?=gettext("Schedules act as placeholders for time ranges to be used in Firewall Rules.");?></span></p>
- </td>
-</tr>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1" summary="add">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="firewall_schedule_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add a new schedule");?>" alt="add" /></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabcont" colspan="3">
+ <p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br /></strong></span><?=gettext("Schedules act as placeholders for time ranges to be used in Firewall Rules.");?></span></p>
+ </td>
+ </tr>
</table>
</form>
<?php include("fend.inc"); ?>
OpenPOWER on IntegriCloud