Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
972737ec
Commit
972737ec
authored
Aug 25, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) refactor firewall_schedule_edit.php
parent
9ac2f805
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1052 additions
and
1109 deletions
+1052
-1109
firewall_schedule_edit.php
src/www/firewall_schedule_edit.php
+1052
-1109
No files found.
src/www/firewall_schedule_edit.php
View file @
972737ec
...
...
@@ -75,108 +75,94 @@ function schedule_sort(){
usort
(
$config
[
'schedules'
][
'schedule'
],
"schedulecmp"
);
}
$pgtitle
=
array
(
gettext
(
"Firewall"
),
gettext
(
"Schedules"
),
gettext
(
"Edit"
));
$referer
=
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
?
$_SERVER
[
'HTTP_REFERER'
]
:
'/firewall_schedule.php'
);
$dayArray
=
array
(
gettext
(
'Mon'
),
gettext
(
'Tues'
),
gettext
(
'Wed'
),
gettext
(
'Thur'
),
gettext
(
'Fri'
),
gettext
(
'Sat'
),
gettext
(
'Sun'
));
$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'
));
if
(
!
is_array
(
$config
[
'schedules'
][
'schedule'
]))
$config
[
'schedules'
][
'schedule'
]
=
array
();
if
(
!
isset
(
$config
[
'schedules'
][
'schedule'
]))
{
$config
[
'schedules'
][
'schedule'
]
=
array
();
}
$a_schedules
=
&
$config
[
'schedules'
][
'schedule'
];
if
(
is_numericint
(
$_GET
[
'id'
]))
$id
=
$_GET
[
'id'
];
if
(
isset
(
$_POST
[
'id'
])
&&
is_numericint
(
$_POST
[
'id'
]))
$id
=
$_POST
[
'id'
];
// quick hack, cleanup follows
if
(
!
empty
(
$_GET
[
'name'
]))
{
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'GET'
)
{
// input record id, if valid
if
(
!
empty
(
$_GET
[
'name'
]))
{
foreach
(
$a_schedules
as
$i
=>
$sched
)
{
if
(
$sched
[
'name'
]
==
$_GET
[
'name'
])
{
$id
=
$i
;
break
;
}
}
}
if
(
isset
(
$id
)
&&
$a_schedules
[
$id
])
{
$pconfig
[
'name'
]
=
$a_schedules
[
$id
][
'name'
];
$pconfig
[
'descr'
]
=
html_entity_decode
(
$a_schedules
[
$id
][
'descr'
]);
$pconfig
[
'timerange'
]
=
$a_schedules
[
$id
][
'timerange'
];
$pconfig
[
'schedlabel'
]
=
$a_schedules
[
$id
][
'schedlabel'
];
$getSchedule
=
true
;
}
if
(
$_POST
)
{
}
elseif
(
isset
(
$_GET
[
'dup'
])
&&
isset
(
$a_schedules
[
$_GET
[
'dup'
]]))
{
$configId
=
$_GET
[
'dup'
];
}
elseif
(
isset
(
$_GET
[
'id'
])
&&
isset
(
$a_schedules
[
$_GET
[
'id'
]]))
{
$id
=
$_GET
[
'id'
];
$configId
=
$id
;
}
$pconfig
[
'name'
]
=
$a_schedules
[
$configId
][
'name'
];
$pconfig
[
'descr'
]
=
$a_schedules
[
$configId
][
'descr'
];
$pconfig
[
'timerange'
]
=
isset
(
$a_schedules
[
$configId
][
'timerange'
])
?
$a_schedules
[
$configId
][
'timerange'
]
:
array
();
$pconfig
[
'schedlabel'
]
=
isset
(
$a_schedules
[
$configId
][
'schedlabel'
])
?
$a_schedules
[
$configId
][
'schedlabel'
]
:
uniqid
();
}
elseif
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
if
(
isset
(
$_POST
[
'id'
])
&&
isset
(
$a_schedules
[
$_POST
[
'id'
]]))
{
$id
=
$_POST
[
'id'
];
}
$pconfig
=
$_POST
;
if
(
strtolower
(
$_POST
[
'name'
])
==
"lan"
)
// validate
if
(
strtolower
(
$pconfig
[
'name'
])
==
"lan"
)
$input_errors
[]
=
gettext
(
"Schedule may not be named LAN."
);
if
(
strtolower
(
$_POST
[
'name'
])
==
"wan"
)
if
(
strtolower
(
$pconfig
[
'name'
])
==
"wan"
)
$input_errors
[]
=
gettext
(
"Schedule may not be named WAN."
);
if
(
strtolower
(
$_POST
[
'name'
])
==
""
)
if
(
strtolower
(
$pconfig
[
'name'
])
==
""
)
$input_errors
[]
=
gettext
(
"Schedule name cannot be blank."
);
$x
=
is_validaliasname
(
$_POST
[
'name'
]);
$x
=
is_validaliasname
(
$pconfig
[
'name'
]);
if
(
!
isset
(
$x
))
{
$input_errors
[]
=
gettext
(
"Reserved word used for schedule name."
);
}
else
{
if
(
is_validaliasname
(
$_POST
[
'name'
])
==
false
)
}
elseif
(
$x
==
false
)
{
$input_errors
[]
=
gettext
(
"The schedule name may only consist of the characters a-z, A-Z, 0-9"
);
}
/* check for name conflicts */
foreach
(
$a_schedules
as
$schedule
)
{
if
(
isset
(
$id
)
&&
(
$a_schedules
[
$id
])
&&
(
$a_schedules
[
$id
]
===
$schedule
))
continue
;
if
(
$schedule
[
'name'
]
==
$_POST
[
'name'
])
{
foreach
(
$a_schedules
as
$schedId
=>
$schedule
)
{
if
(
$schedId
!=
$id
&&
$schedule
[
'name'
]
==
$pconfig
[
'name'
])
{
$input_errors
[]
=
gettext
(
"A Schedule with this name already exists."
);
break
;
}
}
$schedule
=
array
();
$schedule
[
'name'
]
=
$_POST
[
'name'
];
$schedule
[
'descr'
]
=
htmlentities
(
$_POST
[
'descr'
],
ENT_QUOTES
,
'UTF-8'
);
// parse time ranges
$pconfig
[
'timerange'
]
=
array
(
);
$timerangeFound
=
false
;
for
(
$x
=
0
;
$x
<
99
;
$x
++
){
if
(
$_POST
[
'schedule'
.
$x
])
{
if
(
!
preg_match
(
'/^[0-9]+:[0-9]+$/'
,
$_POST
[
'starttime'
.
$x
]))
{
$input_errors
[]
=
sprintf
(
gettext
(
"Invalid start time - '%s'"
),
$_POST
[
'starttime'
.
$x
]);
if
(
$pconfig
[
'schedule'
.
$x
])
{
if
(
!
preg_match
(
'/^[0-9]+:[0-9]+$/'
,
$pconfig
[
'starttime'
.
$x
]))
{
$input_errors
[]
=
sprintf
(
gettext
(
"Invalid start time - '%s'"
),
$pconfig
[
'starttime'
.
$x
]);
continue
;
}
if
(
!
preg_match
(
'/^[0-9]+:[0-9]+$/'
,
$_POST
[
'stoptime'
.
$x
]))
{
$input_errors
[]
=
sprintf
(
gettext
(
"Invalid stop time - '%s'"
),
$_POST
[
'stoptime'
.
$x
]);
if
(
!
preg_match
(
'/^[0-9]+:[0-9]+$/'
,
$pconfig
[
'stoptime'
.
$x
]))
{
$input_errors
[]
=
sprintf
(
gettext
(
"Invalid stop time - '%s'"
),
$pconfig
[
'stoptime'
.
$x
]);
continue
;
}
$timerangeFound
=
true
;
$timeparts
=
array
();
$firstprint
=
false
;
$timestr
=
$_POST
[
'schedule'
.
$x
];
$timehourstr
=
$_POST
[
'starttime'
.
$x
];
$timestr
=
$pconfig
[
'schedule'
.
$x
];
$timehourstr
=
$pconfig
[
'starttime'
.
$x
];
$timehourstr
.=
"-"
;
$timehourstr
.=
$_POST
[
'stoptime'
.
$x
];
$timedescrstr
=
htmlentities
(
$_POST
[
'timedescr'
.
$x
],
ENT_QUOTES
,
'UTF-8'
);
$timehourstr
.=
$pconfig
[
'stoptime'
.
$x
];
$timedescrstr
=
htmlentities
(
$pconfig
[
'timedescr'
.
$x
],
ENT_QUOTES
,
'UTF-8'
);
$dashpos
=
strpos
(
$timestr
,
'-'
);
if
(
$dashpos
===
false
)
{
if
(
$dashpos
===
false
)
{
$timeparts
[
'position'
]
=
$timestr
;
}
else
{
}
else
{
$tempindarray
=
array
();
$monthstr
=
""
;
$daystr
=
""
;
$tempindarray
=
explode
(
","
,
$timestr
);
foreach
(
$tempindarray
as
$currentselection
)
{
foreach
(
$tempindarray
as
$currentselection
)
{
if
(
$currentselection
){
if
(
$firstprint
)
{
if
(
$firstprint
)
{
$monthstr
.=
","
;
$daystr
.=
","
;
}
...
...
@@ -193,52 +179,42 @@ if ($_POST) {
}
$timeparts
[
'hour'
]
=
$timehourstr
;
$timeparts
[
'rangedescr'
]
=
$timedescrstr
;
$schedule
[
'timerange'
][
$x
]
=
$timeparts
;
$pconfig
[
'timerange'
][
$x
]
=
$timeparts
;
}
}
if
(
!
$timerangeFound
)
if
(
count
(
$pconfig
[
'timerange'
])
==
0
)
{
$input_errors
[]
=
gettext
(
"The schedule must have at least one time range configured."
);
}
if
(
!
$input_errors
)
{
if
(
!
empty
(
$pconfig
[
'schedlabel'
]))
if
(
count
(
$input_errors
)
==
0
)
{
$schedule
=
array
();
$schedule
[
'name'
]
=
$pconfig
[
'name'
];
$schedule
[
'descr'
]
=
$pconfig
[
'descr'
];
$schedule
[
'timerange'
]
=
$pconfig
[
'timerange'
];
$schedule
[
'schedlabel'
]
=
$pconfig
[
'schedlabel'
];
else
$schedule
[
'schedlabel'
]
=
uniqid
();
if
(
isset
(
$id
)
&&
$a_schedules
[
$id
])
{
if
(
isset
(
$id
))
{
$a_schedules
[
$id
]
=
$schedule
;
}
else
{
}
else
{
$a_schedules
[]
=
$schedule
;
}
schedule_sort
();
if
(
write_config
())
if
(
write_config
())
{
filter_configure
();
}
header
(
"Location: firewall_schedule.php"
);
exit
;
}
//we received input errors, copy data to prevent retype
else
{
if
(
!
$_POST
[
'schedule0'
])
$getSchedule
=
false
;
else
$getSchedule
=
true
;
$pconfig
[
'name'
]
=
$schedule
[
'name'
];
$pconfig
[
'descr'
]
=
$schedule
[
'descr'
];
$pconfig
[
'timerange'
]
=
$schedule
[
'timerange'
];
}
}
include
(
"head.inc"
);
/* put your custom HTML head content here */
/* using some of the new function calls */
$jscriptstr
=
<<<EOD
$pgtitle
=
array
(
gettext
(
"Firewall"
),
gettext
(
"Schedules"
),
gettext
(
"Edit"
));
legacy_html_escape_form_data
(
$pconfig
);
include
(
"head.inc"
);
?>
<script
type=
"text/javascript"
>
//
<!
[
CDATA
[
var
daysSelected
=
""
;
...
...
@@ -376,11 +352,11 @@ function daytoggle(id) {
}
function
update_month
(){
var indexNum = document.forms[0]
.monthsel.selectedIndex;
var selected = document.forms[0]
.monthsel.options[indexNum].text;
var
indexNum
=
document
.
iform
.
monthsel
.
selectedIndex
;
var
selected
=
document
.
iform
.
monthsel
.
options
[
indexNum
].
text
;
for
(
i
=
0
;
i
<=
11
;
i
++
){
option = document.forms[0]
.monthsel.options[i].text;
option
=
document
.
iform
.
monthsel
.
options
[
i
].
text
;
document
.
popupMonthLayer
=
eval
(
'
document.getElementById (option)
'
);
if
(
selected
==
option
)
{
...
...
@@ -648,15 +624,15 @@ function insertElements(tempFriendlyTime, starttimehour, starttimemin, stoptimeh
tr
.
appendChild
(
td
);
td
=
d
.
createElement
(
"
td
"
);
td.innerHTML="<input type='text' readonly class='vexpl'
name='starttime" + schCounter + "' id='starttime" + schCounter + "' style=' word-wrap:break-word; width:100%; border:0px solid;' value='" + starttimehour + ":" + starttimemin + "' />";
td
.
innerHTML
=
"
<input type='text' readonly
name='starttime
"
+
schCounter
+
"
' id='starttime
"
+
schCounter
+
"
' style=' word-wrap:break-word; width:100%; border:0px solid;' value='
"
+
starttimehour
+
"
:
"
+
starttimemin
+
"
' />
"
;
tr
.
appendChild
(
td
);
td
=
d
.
createElement
(
"
td
"
);
td.innerHTML="<input type='text' readonly class='vexpl'
name='stoptime" + schCounter + "' id='stoptime" + schCounter + "' style=' word-wrap:break-word; width:100%; border:0px solid;' value='" + stoptimehour + ":" + stoptimemin + "' />";
td
.
innerHTML
=
"
<input type='text' readonly
name='stoptime
"
+
schCounter
+
"
' id='stoptime
"
+
schCounter
+
"
' style=' word-wrap:break-word; width:100%; border:0px solid;' value='
"
+
stoptimehour
+
"
:
"
+
stoptimemin
+
"
' />
"
;
tr
.
appendChild
(
td
);
td
=
d
.
createElement
(
"
td
"
);
td.innerHTML="<input type='text' readonly class='vexpl'
name='timedescr" + schCounter + "' id='timedescr" + schCounter + "' style=' word-wrap:break-word; width:100%; border:0px solid;' value='" + tempdescr + "' />";
td
.
innerHTML
=
"
<input type='text' readonly
name='timedescr
"
+
schCounter
+
"
' id='timedescr
"
+
schCounter
+
"
' style=' word-wrap:break-word; width:100%; border:0px solid;' value='
"
+
tempdescr
+
"
' />
"
;
tr
.
appendChild
(
td
);
td
=
d
.
createElement
(
"
td
"
);
...
...
@@ -763,6 +739,7 @@ function editRow(incTime, el) {
}
removeRownoprompt
(
el
);
}
$
(
'
.selectpicker
'
).
selectpicker
(
'
refresh
'
);
}
function
removeRownoprompt
(
el
)
{
...
...
@@ -792,126 +769,113 @@ function removeRow(el) {
}
//]]>
</script>
EOD;
?>
<body>
<?php
include
(
"fbegin.inc"
);
echo
$jscriptstr
;
?>
<section
class=
"page-content-main"
>
<div
class=
"container-fluid"
>
<div
class=
"row"
>
<?php
if
(
isset
(
$input_errors
)
&&
count
(
$input_errors
)
>
0
)
print_input_errors
(
$input_errors
);
?>
<div
id=
"inputerrors"
></div>
<section
class=
"col-xs-12"
>
<div
class=
"content-box"
>
<header
class=
"content-box-head container-fluid"
>
<h3>
<?=
gettext
(
"Schedule information"
);
?>
</h3>
</header>
<div
class=
"content-box-main"
>
<div
class=
"content-box content-box-main"
>
<form
action=
"firewall_schedule_edit.php"
method=
"post"
name=
"iform"
id=
"iform"
>
<input
type=
"hidden"
name=
"schedlabel"
value=
"
<?=
$pconfig
[
'schedlabel'
];
?>
"
/>
<div
class=
"table-responsive"
>
<table
class=
"table table-striped table-sort
"
>
<table
class=
"table table-striped
"
>
<tbody>
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vncellreq"
>
<?=
gettext
(
"Schedule Name"
);
?>
</td>
<td
width=
"85%"
class=
"vtable"
>
<?php
if
(
is_schedule_inuse
(
$pconfig
[
'name'
])
==
true
)
:
?>
<input
name=
"name"
type=
"hidden"
id=
"name"
size=
"40"
value=
"
<?=
htmlspecialchars
(
$pconfig
[
'name'
]);
?>
"
/>
<?php
echo
$pconfig
[
'name'
];
?>
<td
width=
"15%"
><strong>
<?=
gettext
(
"Schedule information"
);
?>
</strong></td>
<td
width=
"85%"
align=
"right"
>
<small>
<?=
gettext
(
"full help"
);
?>
</small>
<i
class=
"fa fa-toggle-off text-danger"
style=
"cursor: pointer;"
id=
"show_all_help_page"
type=
"button"
></i></a>
</td>
</tr>
<tr>
<td><a
id=
"help_for_name"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"Schedule Name"
);
?>
</td>
<td>
<?php
if
(
is_schedule_inuse
(
$pconfig
[
'name'
])
==
true
)
:?>
<
input
name
=
"name"
type
=
"hidden"
id
=
"name"
value
=
"<?=htmlspecialchars(
$pconfig['name']
);?>"
/>
<?=
$pconfig
[
'name'
];
?>
<p>
<span
class=
"vexpl"
>
<?=
gettext
(
"NOTE: This schedule is in use so the name may not be modified!"
);
?>
</span
>
<?=
gettext
(
"NOTE: This schedule is in use so the name may not be modified!"
);
?
>
</p>
<?php
else
:
?>
<input
name=
"name"
type=
"text"
id=
"name"
size=
"40"
maxlength=
"40"
class=
"form-control unknown"
value=
"
<?=
htmlspecialchars
(
$pconfig
[
'name'
]);
?>
"
/><br
/>
<span
class=
"vexpl"
>
<?php
else
:
?>
<input
name=
"name"
type=
"text"
id=
"name"
value=
"
<?=
$pconfig
[
'name'
];
?>
"
/>
<div
class=
"hidden"
for=
"help_for_name"
>
<?=
gettext
(
"The name of the alias may only consist of the characters a-z, A-Z and 0-9"
);
?>
</span>
<?php
endif
;
?>
</div>
<?php
endif
;
?>
</td>
</tr>
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vncell"
>
<?=
gettext
(
"Description"
);
?>
</td>
<td
width=
"85%"
class=
"vtable"
><input
name=
"descr"
type=
"text"
id=
"descr"
size=
"40"
maxlength=
"40"
class=
"form-control unknown"
value=
"
<?=
htmlspecialchars
(
$pconfig
[
'descr'
]);
?>
"
/><br
/>
<span
class=
"vexpl"
>
<td><a
id=
"help_for_description"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"Description"
);
?>
</td>
<td>
<input
name=
"descr"
type=
"text"
id=
"descr"
value=
"
<?=
$pconfig
[
'descr'
];
?>
"
/><br
/>
<div
class=
"hidden"
for=
"help_for_name"
>
<?=
gettext
(
"You may enter a description here for your reference (not parsed)."
);
?>
</span>
</div>
</td>
</tr>
<!-- tr>
</tr -->
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vncellreq"
>
<?=
gettext
(
"Month"
);
?>
</td>
<td
width=
"85%"
class=
"vtable"
>
<select
name=
"monthsel"
class=
"form-control
"
id=
"monthsel"
onchange=
"update_month();"
>
<?php
<td><a
id=
"help_for_month"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"Month"
);
?>
</td>
<td
>
<select
name=
"monthsel"
class=
"selectpicker"
data-width=
"auto"
data-live-search=
"true
"
id=
"monthsel"
onchange=
"update_month();"
>
<?php
$monthcounter
=
date
(
"n"
);
$monthlimit
=
$monthcounter
+
12
;
$yearcounter
=
date
(
"Y"
);
for
(
$k
=
0
;
$k
<
12
;
$k
++
){
?>
<option
value=
"
<?php
echo
$monthcounter
;
?>
"
>
<?php
echo
date
(
"F_y"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
?>
</option>
<option
value=
"
<?=
$monthcounter
;
?>
"
>
<?=
date
(
"F_y"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
?>
</option>
<?php
if
(
$monthcounter
==
12
)
{
if
(
$monthcounter
==
12
)
{
$monthcounter
=
1
;
$yearcounter
++
;
}
else
{
}
else
{
$monthcounter
++
;
}
}
?>
</select><br
/><br
/>
<?php
</select>
<br
/><br
/>
<?php
$firstmonth
=
TRUE
;
$monthcounter
=
date
(
"n"
);
$yearcounter
=
date
(
"Y"
);
for
(
$k
=
0
;
$k
<
12
;
$k
++
){
$firstdayofmonth
=
date
(
"w"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
if
(
$firstdayofmonth
==
0
)
if
(
$firstdayofmonth
==
0
)
{
$firstdayofmonth
=
7
;
}
$daycounter
=
1
;
//number of day in month
$numberofdays
=
date
(
"t"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
$firstdayprinted
=
FALSE
;
$lasttr
=
FALSE
;
$positioncounter
=
1
;
//7 for Sun, 1 for Mon, 2 for Tues, etc
?>
<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"
;
?>
"
>
<table
border=
"1"
cellspacing=
"1"
cellpadding=
"1"
id=
"calTable
<?=
$monthcounter
.
$yearcounter
;
?>
"
class=
"tabcont
"
summary=
"month"
>
?>
<div
id=
"
<?=
date
(
"F_y"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
?>
"
style=
" position:relative; display:
<?=
$firstmonth
?
"block"
:
"none"
;
?>
"
>
<table
border=
"1"
cellspacing=
"1"
cellpadding=
"1"
id=
"calTable
<?=
$monthcounter
.
$yearcounter
;
?>
"
class=
"table table-condensed
"
summary=
"month"
>
<thead>
<tr><td
colspan=
"7"
align=
"center"
class=
"listbg"
>
<?php
echo
date
(
"F_Y"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
?>
</td></tr>
<tr><td
colspan=
"7"
align=
"center"
>
<?=
date
(
"F_Y"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
1
,
date
(
$yearcounter
)));
?>
</td></tr>
<tr>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p1');"
><u>
<?=
gettext
(
"Mon"
);
?>
</u></td>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p2');"
><u>
<?=
gettext
(
"Tue"
);
?>
</u></td>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p3');"
><u>
<?=
gettext
(
"Wed"
);
?>
</u></td>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p4');"
><u>
<?=
gettext
(
"Thu"
);
?>
</u></td>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p5');"
><u>
<?=
gettext
(
"Fri"
);
?>
</u></td>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p6');"
><u>
<?=
gettext
(
"Sat"
);
?>
</u></td>
<td
align=
"center"
class=
"listhdr
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p7');"
><u>
<?=
gettext
(
"Sun"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p1');"
><u>
<?=
gettext
(
"Mon"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p2');"
><u>
<?=
gettext
(
"Tue"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p3');"
><u>
<?=
gettext
(
"Wed"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p4');"
><u>
<?=
gettext
(
"Thu"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p5');"
><u>
<?=
gettext
(
"Fri"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p6');"
><u>
<?=
gettext
(
"Sat"
);
?>
</u></td>
<td
align=
"cente
r"
style=
"cursor: pointer;"
onclick=
"daytoggle('w1p7');"
><u>
<?=
gettext
(
"Sun"
);
?>
</u></td>
</tr>
</thead>
<tbody>
<?php
<?php
$firstmonth
=
FALSE
;
while
(
$daycounter
<=
$numberofdays
){
$weekcounter
=
date
(
"W"
,
mktime
(
0
,
0
,
0
,
date
(
$monthcounter
),
date
(
$daycounter
),
date
(
$yearcounter
)));
$weekcounter
=
ltrim
(
$weekcounter
,
"0"
);
if
(
$positioncounter
==
1
)
{
if
(
$positioncounter
==
1
)
{
echo
"<tr>"
;
}
if
(
$firstdayofmonth
==
$positioncounter
){
?>
...
...
@@ -920,122 +884,112 @@ EOD;
$daycounter
++
;
$firstdayprinted
=
TRUE
;
echo
"</td>"
;
}
elseif
(
$firstdayprinted
==
TRUE
&&
$daycounter
<=
$numberofdays
){
?>
}
elseif
(
$firstdayprinted
==
TRUE
&&
$daycounter
<=
$numberofdays
){
?>
<td
align=
"center"
style=
"cursor: pointer;"
class=
"listr"
id=
"w
<?=
$weekcounter
;
?>
p
<?=
$positioncounter
;
?>
"
onclick=
"daytoggle('w
<?=
$weekcounter
;
?>
p
<?=
$positioncounter
;
?>
-m
<?=
$monthcounter
;
?>
d
<?=
$daycounter
;
?>
');"
>
<?php
echo
$daycounter
;
$daycounter
++
;
echo
"</td>"
;
}
else
{
}
else
{
echo
"<td align=
\"
center
\"
class=
\"
listr
\"
></td>"
;
}
if
(
$positioncounter
==
7
||
$daycounter
>
$numberofdays
)
{
if
(
$positioncounter
==
7
||
$daycounter
>
$numberofdays
)
{
$positioncounter
=
1
;
echo
"</tr>"
;
}
else
{
}
else
{
$positioncounter
++
;
}
}
//end while loop?>
</
tbody
>
</
table
>
</
div
>
<?
php
if
(
$monthcounter
==
12
)
{
<?
php
if
(
$monthcounter
==
12
)
{
$monthcounter
=
1
;
$yearcounter
++
;
}
else
{
}
else
{
$monthcounter
++
;
}
}
//end for loop
?>
?>
<div
class=
"hidden"
for=
"help_for_month"
>
<br
/>
<?=
gettext
(
"Click individual date to select that date only. Click the appropriate weekday Header to select all occurrences of that weekday."
);
?>
</div>
</td>
</tr>
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vncellreq"
>
<?=
gettext
(
"Time"
);
?>
</td>
<td
width=
"85%"
class=
"vtable"
>
<td><a
id=
"help_for_time"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"Time"
);
?>
</td>
<td
>
<table
cellspacing=
"2"
class=
"tabcont"
summary=
"time"
>
<tr>
<td
class=
"listhdrr"
align=
"center"
>
<?=
gettext
(
"Start Time"
);
?>
</td><td></td><td
class=
"listhdrr"
align=
"center"
>
<?=
gettext
(
"Stop Time"
);
?>
</td>
<td>
<?=
gettext
(
"Start Time"
);
?>
</td>
<td>
<?=
gettext
(
"Stop Time"
);
?>
</td>
</tr>
<tr>
<td>
<select
name=
"starttimehour"
class=
"form-control"
id=
"starttimehour"
>
<?php
for
(
$i
=
0
;
$i
<
24
;
$i
++
)
{
echo
"<option value=
\"
$i
\"
>"
;
echo
$i
;
echo
"</option>"
;
}
?>
</select>
<?=
gettext
(
"Hr"
);
?>
<select
name=
"starttimemin"
class=
"form-control"
id=
"starttimemin"
>
<div
class=
"input-group"
>
<select
name=
"starttimehour"
class=
"selectpicker form-control"
data-width=
"auto"
data-size=
"5"
data-live-search=
"true"
id=
"starttimehour"
>
<?php
for
(
$i
=
0
;
$i
<
24
;
$i
++
)
:?>
<
option
value
=
"<?=
$i
;?>"
><?=
$i
;
?>
</option>
<?php
endfor
;
?>
</select>
<select
name=
"starttimemin"
class=
"selectpicker form-control"
data-width=
"auto"
data-size=
"5"
data-live-search=
"true"
id=
"starttimemin"
>
<option
value=
"00"
>
00
</option>
<option
value=
"15"
>
15
</option>
<option
value=
"30"
>
30
</option>
<option
value=
"45"
>
45
</option>
<option
value=
"59"
>
59
</option>
</select>
<?=
gettext
(
"Min"
);
?>
</select>
</div>
</td>
<td></td>
<td>
<select
name=
"stoptimehour"
class=
"form-control"
id=
"stoptimehour"
>
<?php
for
(
$i
=
0
;
$i
<
24
;
$i
++
)
{
if
(
$i
==
23
)
$selected
=
"selected=
\"
selected
\"
"
;
else
$selected
=
""
;
echo
"<option value=
\"
$i
\"
$selected
>"
;
echo
$i
;
echo
"</option>"
;
}
?>
</select>
<?=
gettext
(
"Hr"
);
?>
<select
name=
"stoptimemin"
class=
"form-control"
id=
"stoptimemin"
>
<div
class=
"input-group"
>
<select
name=
"stoptimehour"
class=
"selectpicker form-control"
data-width=
"auto"
data-size=
"5"
data-live-search=
"true"
id=
"stoptimehour"
>
<?php
for
(
$i
=
0
;
$i
<
24
;
$i
++
)
:?>
<
option
value
=
"<?=
$i
;?>"
><?=
$i
;
?>
</option>
<?php
endfor
;
?>
</select>
<select
name=
"stoptimemin"
class=
"selectpicker form-control"
data-width=
"auto"
data-size=
"5"
data-live-search=
"true"
id=
"stoptimemin"
>
<option
value=
"00"
>
00
</option>
<option
value=
"15"
>
15
</option>
<option
value=
"30"
>
30
</option>
<option
value=
"45"
>
45
</option>
<option
value=
"59"
selected=
"selected"
>
59
</option>
</select>
<?=
gettext
(
"Min"
);
?>
</select>
</div>
</td>
</tr>
</table><br
/>
</table>
<div
class=
"hidden"
for=
"help_for_time"
>
<br
/>
<?=
gettext
(
"Select the time range for the day(s) selected on the Month(s) above. A full day is 0:00-23:59."
)
?>
</div>
</td>
</tr>
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vncell"
>
<?=
gettext
(
"Time Range Description"
)
?>
</td>
<td
width=
"85%"
class=
"vtable"
><input
name=
"timerangedescr"
type=
"text"
class=
"form-control unknown"
id=
"timerangedescr"
size=
"40"
maxlength=
"40"
/><br
/>
<span
class=
"vexpl"
>
<td><a
id=
"help_for_timerange_desc"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"Time Range Description"
)
?>
</td>
<td>
<input
name=
"timerangedescr"
type=
"text"
id=
"timerangedescr"
/>
<div
class=
"hidden"
for=
"help_for_timerange_desc"
>
<?=
gettext
(
"You may enter a description here for your reference (not parsed)."
)
?>
</span
>
</div
>
</td>
</tr>
<tr>
<td
width=
"22%"
valign=
"top"
>
</td>
<td
width=
"78%"
>
<td
>
</td>
<td
>
<input
type=
"button"
value=
"
<?=
gettext
(
"Add Time"
);
?>
"
class=
"btn btn-default"
onclick=
"javascript:processEntries();"
/>
<input
type=
"button"
value=
"
<?=
gettext
(
"Clear Selection"
);
?>
"
class=
"btn btn-default"
onclick=
"javascript:clearCalendar(); clearTime(); clearDescr();"
/>
</td>
</tr>
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vtable"
></td>
<td
width=
"85%"
class=
"vtable"
></td>
<td
></td>
<td
></td>
</tr>
</tbody>
</table>
...
...
@@ -1047,20 +1001,19 @@ EOD;
</thead>
<tbody>
<tr>
<td
width=
"15%"
valign=
"top"
class=
"vncellreq"
>
<?=
gettext
(
"Configured Ranges"
);
?>
</td>
<td
width=
"85%"
>
<td
>
<?=
gettext
(
"Configured Ranges"
);
?>
</td>
<td
>
<table
id=
"scheduletable"
summary=
"range"
>
<tbody>
<tr>
<td
align=
"center"
class=
"listbg
"
width=
"35%"
>
<?=
gettext
(
"Day(s)"
);
?>
</td>
<td
align=
"center"
class=
"listbg
"
width=
"12%"
>
<?=
gettext
(
"Start Time"
);
?>
</td>
<td
align=
"center"
class=
"listbg
"
width=
"11%"
>
<?=
gettext
(
"Stop Time"
);
?>
</td>
<td
align=
"center"
class=
"listbg
"
width=
"42%"
>
<?=
gettext
(
"Description"
);
?>
</td>
<td
align=
"center
"
width=
"35%"
>
<?=
gettext
(
"Day(s)"
);
?>
</td>
<td
align=
"center
"
width=
"12%"
>
<?=
gettext
(
"Start Time"
);
?>
</td>
<td
align=
"center
"
width=
"11%"
>
<?=
gettext
(
"Stop Time"
);
?>
</td>
<td
align=
"center
"
width=
"42%"
>
<?=
gettext
(
"Description"
);
?>
</td>
</tr>
<?php
if
(
$getSchedule
){
if
(
isset
(
$pconfig
[
'timerange'
])
){
$counter
=
0
;
foreach
(
$pconfig
[
'timerange'
]
as
$timerange
)
{
$tempFriendlyTime
=
""
;
$tempID
=
""
;
...
...
@@ -1068,7 +1021,6 @@ EOD;
$dayFriendly
=
""
;
$tempFriendlyTime
=
""
;
$timedescr
=
$timerange
[
'rangedescr'
];
//get hours
$temptimerange
=
$timerange
[
'hour'
];
$temptimeseparator
=
strrpos
(
$temptimerange
,
"-"
);
...
...
@@ -1083,7 +1035,7 @@ EOD;
$firstPrint
=
false
;
$firstprint2
=
false
;
if
(
$timerange
[
'month'
]
){
if
(
!
empty
(
$timerange
[
'month'
])
){
$tempmontharray
=
explode
(
","
,
$timerange
[
'month'
]);
$tempdayarray
=
explode
(
","
,
$timerange
[
'day'
]);
$arraycounter
=
0
;
...
...
@@ -1097,16 +1049,12 @@ EOD;
}
$weeknumber
=
date
(
"W"
,
mktime
(
0
,
0
,
0
,
date
(
$month
),
date
(
$day
),
date
(
"Y"
)));
$weeknumber
=
ltrim
(
$weeknumber
,
"0"
);
if
(
$firstPrint
)
{
if
(
$firstPrint
)
{
$tempID
.=
","
;
}
$tempID
.=
"w"
.
$weeknumber
.
"p"
.
$daypos
.
"-m"
.
$month
.
"d"
.
$day
;
$firstPrint
=
true
;
if
(
!
$firstDayFound
)
{
if
(
!
$firstDayFound
)
{
$firstDay
=
$day
;
$firstmonth
=
$month
;
$firstDayFound
=
true
;
...
...
@@ -1116,26 +1064,24 @@ EOD;
$nextDay
=
$tempdayarray
[
$arraycounter
+
1
];
$currentDay
++
;
if
((
$currentDay
!=
$nextDay
)
||
(
$tempmontharray
[
$arraycounter
]
!=
$tempmontharray
[
$arraycounter
+
1
])){
if
(
$firstprint2
)
if
(
$firstprint2
)
{
$tempFriendlyTime
.=
", "
;
}
$currentDay
--
;
if
(
$currentDay
!=
$firstDay
)
if
(
$currentDay
!=
$firstDay
)
{
$tempFriendlyTime
.=
$monthArray
[
$firstmonth
-
1
]
.
" "
.
$firstDay
.
" - "
.
$currentDay
;
else
}
else
{
$tempFriendlyTime
.=
$monthArray
[
$month
-
1
]
.
" "
.
$day
;
}
$firstDayFound
=
false
;
$firstprint2
=
true
;
}
$arraycounter
++
;
}
}
else
{
}
else
{
$dayFriendly
=
$timerange
[
'position'
];
$tempID
=
$dayFriendly
;
}
$tempTime
=
$tempID
.
"||"
.
$starttime
.
"-"
.
$stoptime
.
"||"
.
$timedescr
;
//following code makes the days friendly appearing, IE instead of Mon, Tues, Wed it will show Mon - Wed
...
...
@@ -1147,11 +1093,10 @@ EOD;
$firstDay
=
""
;
$nextDay
=
""
;
$i
=
0
;
if
(
!
$timerange
[
'month'
])
{
if
(
empty
(
$timerange
[
'month'
]))
{
foreach
(
$tempFriendlyDayArray
as
$day
){
if
(
$day
!=
""
){
if
(
!
$firstDayFound
)
{
if
(
!
$firstDayFound
)
{
$firstDay
=
$tempFriendlyDayArray
[
$i
];
$firstDayFound
=
true
;
}
...
...
@@ -1160,13 +1105,15 @@ EOD;
$nextDay
=
$tempFriendlyDayArray
[
$i
+
1
];
$currentDay
++
;
if
(
$currentDay
!=
$nextDay
){
if
(
$firstprint
)
if
(
$firstprint
){
$tempFriendlyTime
.=
", "
;
}
$currentDay
--
;
if
(
$currentDay
!=
$firstDay
)
if
(
$currentDay
!=
$firstDay
)
{
$tempFriendlyTime
.=
$dayArray
[
$firstDay
-
1
]
.
" - "
.
$dayArray
[
$currentDay
-
1
];
else
}
else
{
$tempFriendlyTime
.=
$dayArray
[
$firstDay
-
1
];
}
$firstDayFound
=
false
;
$firstprint
=
true
;
}
...
...
@@ -1174,31 +1121,28 @@ EOD;
}
}
}
?>
?>
<tr>
<td>
<span
class=
"vexpl"
>
<?php
echo
$tempFriendlyTime
;
?>
</span>
<span>
<?=
$tempFriendlyTime
;
?>
</span>
</td>
<td>
<input
type=
'text'
readonly=
'readonly'
class=
'vexpl'
name=
'starttime
<?php
echo
$counter
;
?>
'
id=
'starttime
<?php
echo
$counter
;
?>
'
style=
' word-wrap:break-word; width:100%; border:0px solid;'
value=
'
<?php
echo
$starttime
;
?>
'
/>
<input
type=
'text'
readonly=
'readonly'
name=
'starttime
<?=
$counter
;
?>
'
id=
'starttime
<?=
$counter
;
?>
'
style=
' word-wrap:break-word; width:100%; border:0px solid;'
value=
'
<?=
$starttime
;
?>
'
/>
</td>
<td>
<input
type=
'text'
readonly=
'readonly'
class=
'vexpl'
name=
'stoptime
<?php
echo
$counter
;
?>
'
id=
'stoptime
<?php
echo
$counter
;
?>
'
style=
' word-wrap:break-word; width:100%; border:0px solid;'
value=
'
<?php
echo
$stoptime
;
?>
'
/>
<input
type=
'text'
readonly=
'readonly'
name=
'stoptime
<?=
$counter
;
?>
'
id=
'stoptime
<?=
$counter
;
?>
'
style=
' word-wrap:break-word; width:100%; border:0px solid;'
value=
'
<?=
$stoptime
;
?>
'
/>
</td>
<td>
<input
type=
'text'
readonly=
'readonly'
class=
'vexpl'
name=
'timedescr
<?php
echo
$counter
;
?>
'
id=
'timedescr
<?php
echo
$counter
;
?>
'
style=
' word-wrap:break-word; width:100%; border:0px solid;'
value=
'
<?php
echo
$timedescr
;
?>
'
/>
<input
type=
'text'
readonly=
'readonly'
name=
'timedescr
<?=
$counter
;
?>
'
id=
'timedescr
<?=
$counter
;
?>
'
style=
' word-wrap:break-word; width:100%; border:0px solid;'
value=
'
<?=
$timedescr
;
?>
'
/>
</td>
<td>
<a
onclick=
'editRow("
<?php
echo
$tempTime
;
?>
",this); return false;'
href=
'#'
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-edit
"
></span></a>
<a
onclick=
'editRow("
<?=
$tempTime
;
?>
",this); return false;'
href=
'#'
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-pencil
"
></span></a>
</td>
<td>
<a
onclick=
'removeRow(this); return false;'
href=
'#'
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-remove"
></span></a>
</td>
<td>
<input
type=
'hidden'
id=
'schedule
<?php
echo
$counter
;
?>
'
name=
'schedule
<?php
echo
$counter
;
?>
'
value=
'
<?php
echo
$tempID
;
?>
'
/>
<input
type=
'hidden'
id=
'schedule
<?=
$counter
;
?>
'
name=
'schedule
<?=
$counter
;
?>
'
value=
'
<?=
$tempID
;
?>
'
/>
</td>
</tr>
<?php
...
...
@@ -1212,12 +1156,12 @@ EOD;
</td>
</tr>
<tr>
<td
width=
"15%"
valign=
"top"
>
</td>
<td
width=
"85%"
>
<td
>
</td>
<td
>
<input
id=
"submit"
name=
"submit"
type=
"submit"
onclick=
"return checkForRanges();"
class=
"btn btn-primary"
value=
"
<?=
gettext
(
"Save"
);
?>
"
/>
<input
type=
"button"
class=
"btn btn-default"
value=
"
<?=
gettext
(
"Cancel"
);
?>
"
onclick=
"window.location.href='
<?=
$referer
;
?>
'"
/>
<?php
if
(
isset
(
$id
)
&&
$a_schedules
[
$id
]
)
:
?>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
htmlspecialchars
(
$id
)
;
?>
"
/>
<input
type=
"button"
class=
"btn btn-default"
value=
"
<?=
gettext
(
"Cancel"
);
?>
"
onclick=
"window.location.href='
<?=
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
?
$_SERVER
[
'HTTP_REFERER'
]
:
'/firewall_schedule.php'
)
;
?>
'"
/>
<?php
if
(
isset
(
$id
)
)
:
?>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$id
;
?>
"
/>
<?php
endif
;
?>
</td>
</tr>
...
...
@@ -1226,7 +1170,6 @@ EOD;
</div>
</form>
</div>
</div>
</section>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment