Revision 6c07db48
Added by Phil Davis about 10 years ago
usr/local/www/firewall_schedule_edit.php | ||
---|---|---|
60 | 60 |
require_once("filter.inc"); |
61 | 61 |
require_once("shaper.inc"); |
62 | 62 |
|
63 |
$pgtitle = array(gettext("Firewall"),gettext("Schedules"),gettext("Edit"));
|
|
63 |
$pgtitle = array(gettext("Firewall"), gettext("Schedules"), gettext("Edit"));
|
|
64 | 64 |
|
65 | 65 |
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firewall_schedule.php'); |
66 | 66 |
|
67 |
$dayArray = array (gettext('Mon'),gettext('Tues'),gettext('Wed'),gettext('Thur'),gettext('Fri'),gettext('Sat'),gettext('Sun'));
|
|
68 |
$monthArray = array (gettext('January'),gettext('February'),gettext('March'),gettext('April'),gettext('May'),gettext('June'),gettext('July'),gettext('August'),gettext('September'),gettext('October'),gettext('November'),gettext('December'));
|
|
67 |
$dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun'));
|
|
68 |
$monthArray = array (gettext('January'), gettext('February'), gettext('March'), gettext('April'), gettext('May'), gettext('June'), gettext('July'), gettext('August'), gettext('September'), gettext('October'), gettext('November'), gettext('December'));
|
|
69 | 69 |
|
70 | 70 |
if (!is_array($config['schedules']['schedule'])) { |
71 | 71 |
$config['schedules']['schedule'] = array(); |
... | ... | |
126 | 126 |
$schedule['descr'] = htmlentities($_POST['descr'], ENT_QUOTES, 'UTF-8'); |
127 | 127 |
|
128 | 128 |
$timerangeFound = false; |
129 |
for ($x=0; $x<99; $x++) {
|
|
129 |
for ($x = 0; $x < 99; $x++) {
|
|
130 | 130 |
if ($_POST['schedule' . $x]) { |
131 | 131 |
if (!preg_match('/^[0-9]+:[0-9]+$/', $_POST['starttime' . $x])) { |
132 | 132 |
$input_errors[] = sprintf(gettext("Invalid start time - '%s'"), $_POST['starttime' . $x]); |
... | ... | |
162 | 162 |
$monthpos = strpos($currentselection, "m"); |
163 | 163 |
$daypos = strpos($currentselection, "d"); |
164 | 164 |
$monthstr .= substr($currentselection, $monthpos+1, $daypos-$monthpos-1); |
165 |
$daystr .= substr($currentselection, $daypos+1);
|
|
165 |
$daystr .= substr($currentselection, $daypos+1); |
|
166 | 166 |
$firstprint = true; |
167 | 167 |
} |
168 | 168 |
} |
... | ... | |
220 | 220 |
<script type="text/javascript"> |
221 | 221 |
//<![CDATA[ |
222 | 222 |
var daysSelected = ""; |
223 |
var month_array = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
|
224 |
var day_array = ['Mon','Tues','Wed','Thur','Fri','Sat','Sun'];
|
|
223 |
var month_array = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
224 |
var day_array = ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'];
|
|
225 | 225 |
var schCounter = 0; |
226 | 226 |
|
227 | 227 |
function rgb2hex(rgb) { |
... | ... | |
239 | 239 |
var tempstr, tempstrdaypos, week, daypos, dayposdone = ""; |
240 | 240 |
|
241 | 241 |
var dayarray = daysSelected.split(","); |
242 |
for (i=0; i<=dayarray.length; i++) {
|
|
242 |
for (i = 0; i <= dayarray.length; i++) {
|
|
243 | 243 |
tempstr = dayarray[i]; |
244 | 244 |
tempstrdaypos = tempstr.search("p"); |
245 |
week = tempstr.substring(1,tempstrdaypos); |
|
245 |
week = tempstr.substring(1, tempstrdaypos);
|
|
246 | 246 |
week = parseInt(week); |
247 | 247 |
dashpos = tempstr.search("-"); |
248 | 248 |
daypos = tempstr.substring(tempstrdaypos+1, dashpos); |
... | ... | |
253 | 253 |
daycell = eval('document.getElementById(tempstr)'); |
254 | 254 |
if (daydone == "-1") { |
255 | 255 |
if (rgb2hex(daycell.style.backgroundColor) == "#F08080") { // lightcoral |
256 |
daytogglerepeating(week,daypos,true);
|
|
256 |
daytogglerepeating(week, daypos, true);
|
|
257 | 257 |
} else { |
258 |
daytogglerepeating(week,daypos,false);
|
|
258 |
daytogglerepeating(week, daypos, false);
|
|
259 | 259 |
} |
260 | 260 |
dayposdone += daypos + ","; |
261 | 261 |
} |
262 | 262 |
} |
263 | 263 |
} |
264 | 264 |
|
265 |
function daytogglerepeating(week,daypos,bExists) {
|
|
265 |
function daytogglerepeating(week, daypos, bExists) {
|
|
266 | 266 |
var tempstr, daycell, dayoriginal = ""; |
267 | 267 |
for (j=1; j<=53; j++) { |
268 | 268 |
tempstr = 'w' + j + 'p' + daypos; |
269 | 269 |
daycell = eval('document.getElementById(tempstr)'); |
270 |
dayoriginalpos = daysSelected.indexOf(tempstr);
|
|
270 |
dayoriginalpos = daysSelected.indexOf(tempstr); |
|
271 | 271 |
|
272 | 272 |
//if bExists set to true, means cell is already select it |
273 | 273 |
//unselect it and remove original day from daysSelected string |
... | ... | |
295 | 295 |
|
296 | 296 |
iddashpos = id.search("-"); |
297 | 297 |
var tempstrdaypos = id.search("p"); |
298 |
var week = id.substring(1,tempstrdaypos); |
|
298 |
var week = id.substring(1, tempstrdaypos);
|
|
299 | 299 |
week = parseInt(week); |
300 | 300 |
|
301 | 301 |
if (iddashpos == "-1") { |
... | ... | |
303 | 303 |
runrepeat = true; |
304 | 304 |
var daypos = id.substr(tempstrdaypos+1); |
305 | 305 |
} else { |
306 |
idmod = id.substring(0,iddashpos); |
|
307 |
var daypos = id.substring(tempstrdaypos+1,iddashpos); |
|
306 |
idmod = id.substring(0, iddashpos);
|
|
307 |
var daypos = id.substring(tempstrdaypos+1, iddashpos);
|
|
308 | 308 |
} |
309 | 309 |
|
310 | 310 |
daypos = parseInt(daypos); |
... | ... | |
318 | 318 |
str = id + ","; |
319 | 319 |
daysSelected = daysSelected.replace(str, ""); |
320 | 320 |
} else if (rgb2hex(daycell.style.backgroundColor) == "#F08080") { // lightcoral |
321 |
daytogglerepeating(week,daypos,true);
|
|
321 |
daytogglerepeating(week, daypos, true);
|
|
322 | 322 |
} else { |
323 | 323 |
//color is white cell |
324 | 324 |
if (!runrepeat) { |
325 | 325 |
daycell.style.backgroundColor = "#FF0000"; // red |
326 | 326 |
} else { |
327 | 327 |
daycell.style.backgroundColor = "#F08080"; // lightcoral |
328 |
daytogglerepeating(week,daypos,false);
|
|
328 |
daytogglerepeating(week, daypos, false);
|
|
329 | 329 |
} |
330 | 330 |
daysSelected += id + ","; |
331 | 331 |
} |
... | ... | |
343 | 343 |
var indexNum = document.forms[0].monthsel.selectedIndex; |
344 | 344 |
var selected = document.forms[0].monthsel.options[indexNum].text; |
345 | 345 |
|
346 |
for (i=0; i<=11; i++) {
|
|
346 |
for (i = 0; i <= 11; i++) {
|
|
347 | 347 |
option = document.forms[0].monthsel.options[i].text; |
348 | 348 |
document.popupMonthLayer = eval('document.getElementById (option)'); |
349 | 349 |
|
... | ... | |
413 | 413 |
|
414 | 414 |
//check for existing entries |
415 | 415 |
var findCurrentCounter; |
416 |
for (u=0; u<99; u++) {
|
|
416 |
for (u = 0; u < 99; u++) {
|
|
417 | 417 |
findCurrentCounter = document.getElementById("schedule" + u); |
418 | 418 |
if (!findCurrentCounter) { |
419 | 419 |
schCounter = u; |
... | ... | |
423 | 423 |
|
424 | 424 |
if (daysSelected != "") { |
425 | 425 |
//get days selected |
426 |
for (i=0; i<tempdayarray.length; i++) {
|
|
426 |
for (i = 0; i < tempdayarray.length; i++) {
|
|
427 | 427 |
tempstr = tempdayarray[i]; |
428 | 428 |
if (tempstr != "") { |
429 | 429 |
tempstrdaypos = tempstr.search("p"); |
430 |
week = tempstr.substring(1,tempstrdaypos); |
|
430 |
week = tempstr.substring(1, tempstrdaypos);
|
|
431 | 431 |
week = parseInt(week); |
432 | 432 |
dashpos = tempstr.search("-"); |
433 | 433 |
|
... | ... | |
461 | 461 |
var tempFriendlyMonthArray = monthstr.split(","); |
462 | 462 |
var tempFriendlyDayArray = daystr.split(","); |
463 | 463 |
var currentDay, firstDay, nextDay, currentMonth, nextMonth, firstDay, firstMonth = ""; |
464 |
for (k=0; k<tempFriendlyMonthArray.length; k++) {
|
|
464 |
for (k = 0; k < tempFriendlyMonthArray.length; k++) {
|
|
465 | 465 |
tempstr = tempFriendlyMonthArray[k]; |
466 | 466 |
if (tempstr != "") { |
467 | 467 |
if (!firstDayFound) { |
... | ... | |
502 | 502 |
tempFriendlyDayArray = rtempFriendlyDay.split(","); |
503 | 503 |
tempFriendlyDayArray.sort(); |
504 | 504 |
currentDay, firstDay, nextDay = ""; |
505 |
for (k=0; k<tempFriendlyDayArray.length; k++) {
|
|
505 |
for (k = 0; k < tempFriendlyDayArray.length; k++) {
|
|
506 | 506 |
tempstr = tempFriendlyDayArray[k]; |
507 | 507 |
if (tempstr != "") { |
508 | 508 |
if (!firstDayFound) { |
... | ... | |
538 | 538 |
tempsortArray.sort(); |
539 | 539 |
//clear tempID |
540 | 540 |
rtempID = ""; |
541 |
for (t=0; t<tempsortArray.length; t++) {
|
|
541 |
for (t = 0; t < tempsortArray.length; t++) {
|
|
542 | 542 |
if (tempsortArray[t] != "") { |
543 | 543 |
if (!isFirstdone) { |
544 | 544 |
rtempID += tempsortArray[t]; |
... | ... | |
551 | 551 |
|
552 | 552 |
|
553 | 553 |
//get time specified |
554 |
starttimehour = document.getElementById("starttimehour").value
|
|
554 |
starttimehour = document.getElementById("starttimehour").value |
|
555 | 555 |
starttimemin = document.getElementById("starttimemin").value; |
556 | 556 |
stoptimehour = document.getElementById("stoptimehour").value; |
557 | 557 |
stoptimemin = document.getElementById("stoptimemin").value; |
... | ... | |
694 | 694 |
document.getElementById("timerangedescr").value = descr; |
695 | 695 |
|
696 | 696 |
//toggle the appropriate days |
697 |
for (i=0; i<tempdayArray.length; i++) {
|
|
697 |
for (i = 0; i < tempdayArray.length; i++) {
|
|
698 | 698 |
if (tempdayArray[i]) { |
699 | 699 |
var tempweekstr = tempdayArray[i]; |
700 | 700 |
dashpos = tempweekstr.search("-"); |
... | ... | |
762 | 762 |
<td width="15%" valign="top" class="vncellreq"><?=gettext("Schedule Name");?></td> |
763 | 763 |
<td width="85%" class="vtable"> |
764 | 764 |
<?php if (is_schedule_inuse($pconfig['name']) == true): ?> |
765 |
<input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
|
|
765 |
<input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" /> |
|
766 | 766 |
<?php echo $pconfig['name']; ?> |
767 | 767 |
<p> |
768 | 768 |
<span class="vexpl"><?=gettext("NOTE: This schedule is in use so the name may not be modified!");?></span> |
... | ... | |
793 | 793 |
$monthcounter = date("n"); |
794 | 794 |
$monthlimit = $monthcounter + 12; |
795 | 795 |
$yearcounter = date("Y"); |
796 |
for ($k=0; $k<12; $k++) {?>
|
|
796 |
for ($k = 0; $k < 12; $k++) {?>
|
|
797 | 797 |
<option value="<?php echo $monthcounter;?>"><?php echo date("F_y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></option> |
798 | 798 |
<?php |
799 | 799 |
if ($monthcounter == 12) { |
... | ... | |
809 | 809 |
$firstmonth = TRUE; |
810 | 810 |
$monthcounter = date("n"); |
811 | 811 |
$yearcounter = date("Y"); |
812 |
for ($k=0; $k<12; $k++) {
|
|
812 |
for ($k = 0; $k < 12; $k++) {
|
|
813 | 813 |
$firstdayofmonth = date("w", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter))); |
814 | 814 |
if ($firstdayofmonth == 0) { |
815 | 815 |
$firstdayofmonth = 7; |
... | ... | |
822 | 822 |
$lasttr = FALSE; |
823 | 823 |
$positioncounter = 1;//7 for Sun, 1 for Mon, 2 for Tues, etc |
824 | 824 |
?> |
825 |
<div id="<?php echo date("F_y",mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?>" style=" position:relative; display:<?php if ($firstmonth)echo "block";else echo "none";?>"> |
|
825 |
<div id="<?php echo date("F_y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?>" style=" position:relative; display:<?php if ($firstmonth)echo "block";else echo "none";?>">
|
|
826 | 826 |
<table border="1" cellspacing="1" cellpadding="1" id="calTable<?=$monthcounter . $yearcounter;?>" class="tabcont" summary="month"> |
827 | 827 |
<tr> |
828 | 828 |
<td colspan="7" align="center" class="listbg"><b><?php echo date("F_Y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></b></td> |
... | ... | |
839 | 839 |
<?php |
840 | 840 |
$firstmonth = FALSE; |
841 | 841 |
while ($daycounter<=$numberofdays) { |
842 |
$weekcounter = date("W", mktime(0, 0, 0, date($monthcounter), date($daycounter), date($yearcounter)));
|
|
842 |
$weekcounter = date("W", mktime(0, 0, 0, date($monthcounter), date($daycounter), date($yearcounter))); |
|
843 | 843 |
$weekcounter = ltrim($weekcounter, "0"); |
844 | 844 |
if ($positioncounter == 1) { |
845 | 845 |
echo "<tr>"; |
... | ... | |
898 | 898 |
<td> |
899 | 899 |
<select name="starttimehour" class="formselect" id="starttimehour"> |
900 | 900 |
<?php |
901 |
for ($i=0; $i<24; $i++) {
|
|
901 |
for ($i = 0; $i < 24; $i++) {
|
|
902 | 902 |
echo "<option value=\"$i\">"; |
903 | 903 |
echo $i; |
904 | 904 |
echo "</option>"; |
... | ... | |
917 | 917 |
<td> |
918 | 918 |
<select name="stoptimehour" class="formselect" id="stoptimehour"> |
919 | 919 |
<?php |
920 |
for ($i=0; $i<24; $i++) {
|
|
921 |
if ($i==23) {
|
|
920 |
for ($i = 0; $i < 24; $i++) {
|
|
921 |
if ($i == 23) {
|
|
922 | 922 |
$selected = "selected=\"selected\""; |
923 | 923 |
} else { |
924 | 924 |
$selected = ""; |
... | ... | |
955 | 955 |
<tr> |
956 | 956 |
<td width="22%" valign="top"> </td> |
957 | 957 |
<td width="78%"> |
958 |
<input type="button" value="<?=gettext("Add Time");?>" class="formbtn" onclick="javascript:processEntries();" />
|
|
958 |
<input type="button" value="<?=gettext("Add Time");?>" class="formbtn" onclick="javascript:processEntries();" />
|
|
959 | 959 |
<input type="button" value="<?=gettext("Clear Selection");?>" class="formbtn" onclick="javascript:clearCalendar(); clearTime(); clearDescr();" /> |
960 | 960 |
</td> |
961 | 961 |
</tr> |
... | ... | |
1005 | 1005 |
|
1006 | 1006 |
if ($timerange['month']) { |
1007 | 1007 |
$tempmontharray = explode(",", $timerange['month']); |
1008 |
$tempdayarray = explode(",",$timerange['day']); |
|
1008 |
$tempdayarray = explode(",", $timerange['day']);
|
|
1009 | 1009 |
$arraycounter = 0; |
1010 | 1010 |
foreach ($tempmontharray as $monthtmp) { |
1011 | 1011 |
$month = $tempmontharray[$arraycounter]; |
... | ... | |
1021 | 1021 |
if ($firstPrint) { |
1022 | 1022 |
$tempID .= ","; |
1023 | 1023 |
} |
1024 |
$tempID .= "w" . $weeknumber . "p" . $daypos . "-m" . $month . "d" . $day;
|
|
1024 |
$tempID .= "w" . $weeknumber . "p" . $daypos . "-m" . $month . "d" . $day; |
|
1025 | 1025 |
$firstPrint = true; |
1026 | 1026 |
|
1027 | 1027 |
if (!$firstDayFound) { |
... | ... | |
1041 | 1041 |
if ($currentDay != $firstDay) { |
1042 | 1042 |
$tempFriendlyTime .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; |
1043 | 1043 |
} else { |
1044 |
$tempFriendlyTime .= $monthArray[$month-1] . " " . $day;
|
|
1044 |
$tempFriendlyTime .= $monthArray[$month-1] . " " . $day; |
|
1045 | 1045 |
} |
1046 | 1046 |
$firstDayFound = false; |
1047 | 1047 |
$firstprint2 = true; |
Also available in: Unified diff
Code spacing
and other random stuff I noticed.
I think this finishes messing with code style. The codebase should match
the developer style guide closely enough that 99.9% of changes will not
feel the need to also massage the formatting.