1 |
658292ef
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
658292ef
|
Scott Ullrich
|
/*
|
4 |
57333fa0
|
Scott Ullrich
|
wizard.php
|
5 |
658292ef
|
Scott Ullrich
|
Copyright (C) 2004 Scott Ullrich
|
6 |
a3db8d75
|
Ermal
|
Copyright (C) 2010 Ermal Lu?i
|
7 |
658292ef
|
Scott Ullrich
|
All rights reserved.
|
8 |
|
|
|
9 |
|
|
Redistribution and use in source and binary forms, with or without
|
10 |
|
|
modification, are permitted provided that the following conditions are met:
|
11 |
|
|
|
12 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
this list of conditions and the following disclaimer.
|
14 |
|
|
|
15 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
documentation and/or other materials provided with the distribution.
|
18 |
|
|
|
19 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
29 |
|
|
*/
|
30 |
|
|
|
31 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
32 |
|
|
##|*IDENT=page-pfsensewizardsubsystem
|
33 |
|
|
##|*NAME=pfSense wizard subsystem page
|
34 |
|
|
##|*DESCR=Allow access to the 'pfSense wizard subsystem' page.
|
35 |
|
|
##|*MATCH=wizard.php*
|
36 |
|
|
##|-PRIV
|
37 |
|
|
|
38 |
|
|
|
39 |
658292ef
|
Scott Ullrich
|
require("guiconfig.inc");
|
40 |
f9fc88cc
|
sullrich
|
require("functions.inc");
|
41 |
|
|
require("filter.inc");
|
42 |
|
|
require("shaper.inc");
|
43 |
|
|
require("rrd.inc");
|
44 |
658292ef
|
Scott Ullrich
|
|
45 |
|
|
function gentitle_pkg($pgname) {
|
46 |
2fbd6806
|
Scott Ullrich
|
global $config;
|
47 |
|
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
48 |
658292ef
|
Scott Ullrich
|
}
|
49 |
|
|
|
50 |
d8c1a6c5
|
Scott Ullrich
|
$stepid = htmlspecialchars($_GET['stepid']);
|
51 |
658292ef
|
Scott Ullrich
|
if (isset($_POST['stepid']))
|
52 |
d8c1a6c5
|
Scott Ullrich
|
$stepid = htmlspecialchars($_POST['stepid']);
|
53 |
72a5f424
|
Ermal Lu?i
|
if (!$stepid)
|
54 |
|
|
$stepid = "0";
|
55 |
658292ef
|
Scott Ullrich
|
|
56 |
d8c1a6c5
|
Scott Ullrich
|
$xml = htmlspecialchars($_GET['xml']);
|
57 |
5a8a69b3
|
Ermal Lu?i
|
if($_POST['xml'])
|
58 |
|
|
$xml = htmlspecialchars($_POST['xml']);
|
59 |
658292ef
|
Scott Ullrich
|
|
60 |
5a8a69b3
|
Ermal Lu?i
|
if(empty($xml)) {
|
61 |
bb0c9569
|
Bill Marquette
|
$xml = "not_defined";
|
62 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
63 |
|
|
die;
|
64 |
658292ef
|
Scott Ullrich
|
} else {
|
65 |
bd31336e
|
Scott Ullrich
|
if (file_exists("{$g['www_path']}/wizards/{$xml}"))
|
66 |
fc19d371
|
Scott Ullrich
|
$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
|
67 |
bb0c9569
|
Bill Marquette
|
else {
|
68 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
69 |
|
|
die;
|
70 |
|
|
}
|
71 |
658292ef
|
Scott Ullrich
|
}
|
72 |
|
|
|
73 |
5a8a69b3
|
Ermal Lu?i
|
if (!is_array($pkg)) {
|
74 |
|
|
print_info_box_np("ERROR: Could not parse {$g['www_path']}/wizards/{$xml} file.");
|
75 |
|
|
die;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
658292ef
|
Scott Ullrich
|
$title = $pkg['step'][$stepid]['title'];
|
79 |
|
|
$description = $pkg['step'][$stepid]['description'];
|
80 |
46985f19
|
Scott Ullrich
|
$totalsteps = $pkg['totalsteps'];
|
81 |
658292ef
|
Scott Ullrich
|
|
82 |
2ca50c87
|
Ermal Lu?i
|
if ($pkg['includefile'])
|
83 |
|
|
require_once($pkg['includefile']);
|
84 |
|
|
|
85 |
b3f4e57c
|
Scott Ullrich
|
if ($pkg['step'][$stepid]['includefile'])
|
86 |
5a8a69b3
|
Ermal Lu?i
|
require_once($pkg['step'][$stepid]['includefile']);
|
87 |
b3f4e57c
|
Scott Ullrich
|
|
88 |
e1e7a425
|
Scott Ullrich
|
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
|
89 |
a314bebc
|
Ermal
|
eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
|
90 |
e1e7a425
|
Scott Ullrich
|
}
|
91 |
|
|
|
92 |
658292ef
|
Scott Ullrich
|
if ($_POST) {
|
93 |
e48fc17d
|
Scott Ullrich
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
94 |
ba9e9bbf
|
Ermal Lu?i
|
if(!empty($field['bindstofield']) and $field['type'] <> "submit") {
|
95 |
e48fc17d
|
Scott Ullrich
|
$fieldname = $field['name'];
|
96 |
72a5f424
|
Ermal Lu?i
|
$fieldname = str_replace(" ", "", $fieldname);
|
97 |
e48fc17d
|
Scott Ullrich
|
$fieldname = strtolower($fieldname);
|
98 |
|
|
// update field with posted values.
|
99 |
ba9e9bbf
|
Ermal Lu?i
|
if($field['unsetfield'] <> "")
|
100 |
|
|
$unset_fields = "yes";
|
101 |
|
|
else
|
102 |
|
|
$unset_fields = "";
|
103 |
|
|
if($field['arraynum'] <> "")
|
104 |
|
|
$arraynum = $field['arraynum'];
|
105 |
|
|
else
|
106 |
|
|
$arraynum = "";
|
107 |
72a5f424
|
Ermal Lu?i
|
|
108 |
|
|
update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
|
109 |
658292ef
|
Scott Ullrich
|
}
|
110 |
3ed807e4
|
Scott Ullrich
|
|
111 |
2fbd6806
|
Scott Ullrich
|
}
|
112 |
3ed807e4
|
Scott Ullrich
|
// run custom php code embedded in xml config.
|
113 |
|
|
if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
|
114 |
|
|
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
|
115 |
|
|
}
|
116 |
|
|
write_config();
|
117 |
e48fc17d
|
Scott Ullrich
|
$stepid++;
|
118 |
72a5f424
|
Ermal Lu?i
|
if($stepid > $totalsteps)
|
119 |
|
|
$stepid = $totalsteps;
|
120 |
658292ef
|
Scott Ullrich
|
}
|
121 |
|
|
|
122 |
46985f19
|
Scott Ullrich
|
$title = $pkg['step'][$stepid]['title'];
|
123 |
|
|
$description = $pkg['step'][$stepid]['description'];
|
124 |
|
|
|
125 |
3f83de3d
|
Scott Ullrich
|
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
|
126 |
eb20f3c5
|
Ermal Lu?i
|
global $config;
|
127 |
e48fc17d
|
Scott Ullrich
|
$field_split = split("->",$field);
|
128 |
72a5f424
|
Ermal Lu?i
|
foreach ($field_split as $f)
|
129 |
|
|
$field_conv .= "['" . $f . "']";
|
130 |
|
|
if($field_conv == "")
|
131 |
|
|
return;
|
132 |
|
|
if(($field_type == "checkbox" and $updatetext <> "on") || $updatetext == "") {
|
133 |
3f83de3d
|
Scott Ullrich
|
/*
|
134 |
|
|
item is a checkbox, it should have the value "on"
|
135 |
|
|
if it was checked
|
136 |
|
|
*/
|
137 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
138 |
|
|
eval($text);
|
139 |
|
|
return;
|
140 |
496f9155
|
Scott Ullrich
|
}
|
141 |
e881d1f3
|
Scott Ullrich
|
|
142 |
496f9155
|
Scott Ullrich
|
if($field_type == "interfaces_selection") {
|
143 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
144 |
|
|
eval($text);
|
145 |
|
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
146 |
|
|
eval($text);
|
147 |
|
|
return;
|
148 |
|
|
}
|
149 |
e881d1f3
|
Scott Ullrich
|
|
150 |
e48fc17d
|
Scott Ullrich
|
if($unset <> "") {
|
151 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
152 |
|
|
eval($text);
|
153 |
46985f19
|
Scott Ullrich
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
154 |
e48fc17d
|
Scott Ullrich
|
eval($text);
|
155 |
|
|
} else {
|
156 |
46985f19
|
Scott Ullrich
|
if($arraynum <> "") {
|
157 |
|
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
158 |
|
|
} else {
|
159 |
|
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
160 |
|
|
}
|
161 |
e48fc17d
|
Scott Ullrich
|
eval($text);
|
162 |
|
|
}
|
163 |
658292ef
|
Scott Ullrich
|
}
|
164 |
|
|
|
165 |
a314bebc
|
Ermal
|
// handle before form display event.
|
166 |
|
|
do {
|
167 |
|
|
$oldstepid = $stepid;
|
168 |
|
|
if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "")
|
169 |
|
|
eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
|
170 |
|
|
} while ($oldstepid != $stepid);
|
171 |
34b5c5a0
|
Scott Ullrich
|
|
172 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array($title);
|
173 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
174 |
6bb5c9aa
|
Bill Marquette
|
|
175 |
4df96eff
|
Scott Ullrich
|
?>
|
176 |
1ae55320
|
Ermal
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" >
|
177 |
4e3391a3
|
Scott Ullrich
|
|
178 |
8c01d3bb
|
Scott Ullrich
|
<?php
|
179 |
ba21539c
|
Scott Ullrich
|
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
|
180 |
8c01d3bb
|
Scott Ullrich
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
|
181 |
4e3391a3
|
Scott Ullrich
|
else
|
182 |
|
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
|
183 |
8c01d3bb
|
Scott Ullrich
|
?>
|
184 |
|
|
|
185 |
33a56b27
|
Colin Smith
|
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
|
186 |
44c10295
|
Scott Ullrich
|
<script type="text/javascript">
|
187 |
f9e35766
|
Scott Ullrich
|
<!--
|
188 |
38e7d556
|
Scott Ullrich
|
|
189 |
e881d1f3
|
Scott Ullrich
|
function FieldValidate(userinput, regexp, message)
|
190 |
|
|
{
|
191 |
2465ff5b
|
Ermal
|
if(!userinput.match(regexp))
|
192 |
|
|
alert(message);
|
193 |
e881d1f3
|
Scott Ullrich
|
}
|
194 |
38e7d556
|
Scott Ullrich
|
|
195 |
33a56b27
|
Colin Smith
|
function enablechange() {
|
196 |
|
|
<?php
|
197 |
|
|
foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
|
198 |
|
|
if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
|
199 |
|
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
|
200 |
|
|
if(isset($field['enablefields'])) {
|
201 |
|
|
$enablefields = explode(',', $field['enablefields']);
|
202 |
|
|
foreach($enablefields as $enablefield) {
|
203 |
|
|
$enablefield = strtolower($enablefield);
|
204 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
|
205 |
|
|
}
|
206 |
|
|
}
|
207 |
|
|
if(isset($field['checkenablefields'])) {
|
208 |
|
|
$checkenablefields = explode(',', $field['checkenablefields']);
|
209 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
210 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
211 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
|
212 |
|
|
}
|
213 |
|
|
}
|
214 |
|
|
print "\t" . '} else {' . "\n";
|
215 |
|
|
if(isset($field['enablefields'])) {
|
216 |
2465ff5b
|
Ermal
|
$enablefields = explode(',', $field['enablefields']);
|
217 |
33a56b27
|
Colin Smith
|
foreach($enablefields as $enablefield) {
|
218 |
|
|
$enablefield = strtolower($enablefield);
|
219 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
if(isset($field['checkenablefields'])) {
|
223 |
2465ff5b
|
Ermal
|
$checkenablefields = explode(',', $field['checkenablefields']);
|
224 |
33a56b27
|
Colin Smith
|
foreach($checkenablefields as $checkenablefield) {
|
225 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
226 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
|
227 |
|
|
}
|
228 |
e881d1f3
|
Scott Ullrich
|
}
|
229 |
33a56b27
|
Colin Smith
|
print "\t" . '}' . "\n";
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
?>
|
233 |
6bb5c9aa
|
Bill Marquette
|
}
|
234 |
2465ff5b
|
Ermal
|
|
235 |
1ae55320
|
Ermal
|
function disablechange() {
|
236 |
|
|
<?php
|
237 |
|
|
foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
|
238 |
|
|
if(isset($field['disablefields']) or isset($field['checkdisablefields'])) {
|
239 |
|
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked) {' . "\n";
|
240 |
|
|
if(isset($field['disablefields'])) {
|
241 |
|
|
$enablefields = explode(',', $field['disablefields']);
|
242 |
|
|
foreach($enablefields as $enablefield) {
|
243 |
|
|
$enablefield = strtolower($enablefield);
|
244 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
if(isset($field['checkdisablefields'])) {
|
248 |
|
|
$checkenablefields = explode(',', $field['checkdisablefields']);
|
249 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
250 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
251 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
print "\t" . '} else {' . "\n";
|
255 |
|
|
if(isset($field['disablefields'])) {
|
256 |
|
|
$enablefields = explode(',', $field['disablefields']);
|
257 |
|
|
foreach($enablefields as $enablefield) {
|
258 |
|
|
$enablefield = strtolower($enablefield);
|
259 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
|
260 |
|
|
}
|
261 |
|
|
}
|
262 |
|
|
if(isset($field['checkdisablefields'])) {
|
263 |
|
|
$checkenablefields = explode(',', $field['checkdisablefields']);
|
264 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
265 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
266 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
|
267 |
|
|
}
|
268 |
|
|
}
|
269 |
|
|
print "\t" . '}' . "\n";
|
270 |
|
|
}
|
271 |
|
|
}
|
272 |
|
|
?>
|
273 |
|
|
}
|
274 |
|
|
|
275 |
2465ff5b
|
Ermal
|
function showchange() {
|
276 |
|
|
<?php
|
277 |
|
|
foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
|
278 |
1ae55320
|
Ermal
|
if(isset($field['showfields'])) {
|
279 |
2465ff5b
|
Ermal
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
|
280 |
|
|
if(isset($field['showfields'])) {
|
281 |
|
|
$showfields = explode(',', $field['showfields']);
|
282 |
|
|
foreach($showfields as $showfield) {
|
283 |
|
|
$showfield = strtolower($showfield);
|
284 |
1ae55320
|
Ermal
|
//print "\t\t" . 'document.iform.' . $showfield . ".display =\"none\";\n";
|
285 |
|
|
print "\t\t \$('". $showfield . "').hide();";
|
286 |
2465ff5b
|
Ermal
|
}
|
287 |
|
|
}
|
288 |
|
|
print "\t" . '} else {' . "\n";
|
289 |
|
|
if(isset($field['showfields'])) {
|
290 |
|
|
$showfields = explode(',', $field['showfields']);
|
291 |
|
|
foreach($showfields as $showfield) {
|
292 |
|
|
$showfield = strtolower($showfield);
|
293 |
1ae55320
|
Ermal
|
#print "\t\t" . 'document.iform.' . $showfield . ".display =\"\";\n";
|
294 |
|
|
print "\t\t \$('". $showfield . "').show();";
|
295 |
2465ff5b
|
Ermal
|
}
|
296 |
|
|
}
|
297 |
|
|
print "\t" . '}' . "\n";
|
298 |
|
|
}
|
299 |
|
|
}
|
300 |
|
|
?>
|
301 |
|
|
}
|
302 |
6bb5c9aa
|
Bill Marquette
|
//-->
|
303 |
|
|
</script>
|
304 |
33a56b27
|
Colin Smith
|
<?php } ?>
|
305 |
6bb5c9aa
|
Bill Marquette
|
|
306 |
33a56b27
|
Colin Smith
|
<form action="wizard.php" method="post" name="iform" id="iform">
|
307 |
658292ef
|
Scott Ullrich
|
<input type="hidden" name="xml" value="<?= $xml ?>">
|
308 |
e48fc17d
|
Scott Ullrich
|
<input type="hidden" name="stepid" value="<?= $stepid ?>">
|
309 |
658292ef
|
Scott Ullrich
|
|
310 |
e48fc17d
|
Scott Ullrich
|
<center>
|
311 |
|
|
|
312 |
|
|
<br>
|
313 |
1c3d61fe
|
Scott Ullrich
|
|
314 |
fe2bfbfc
|
Scott Ullrich
|
<?php
|
315 |
1c3d61fe
|
Scott Ullrich
|
if($title == "Reload in progress") {
|
316 |
3f394d09
|
Erik Fonnesbeck
|
$ip = fixup_string("\$myurl");
|
317 |
1c3d61fe
|
Scott Ullrich
|
} else {
|
318 |
fe2bfbfc
|
Scott Ullrich
|
$ip = "/";
|
319 |
1c3d61fe
|
Scott Ullrich
|
}
|
320 |
2576dace
|
Ermal Luçi
|
echo "<a href='$ip'>";
|
321 |
fe2bfbfc
|
Scott Ullrich
|
?>
|
322 |
1c3d61fe
|
Scott Ullrich
|
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
|
323 |
d51f86e0
|
Scott Ullrich
|
<p>
|
324 |
b7bb1711
|
Ermal Lu?i
|
<div style="width:800px;background-color:#ffffff" id="roundme">
|
325 |
|
|
<table bgcolor="#ffffff" width="95%" border="0" cellspacing="0" cellpadding="2">
|
326 |
34b5c5a0
|
Scott Ullrich
|
<!-- wizard goes here -->
|
327 |
|
|
<tr><td> </td></tr>
|
328 |
77851510
|
Scott Ullrich
|
<tr><td colspan='2'>
|
329 |
55b8d602
|
Scott Ullrich
|
<?php
|
330 |
eb20f3c5
|
Ermal Lu?i
|
if ($savemsg)
|
331 |
|
|
print_info_box($savemsg);
|
332 |
55b8d602
|
Scott Ullrich
|
if ($_GET['message'] != "")
|
333 |
d8c1a6c5
|
Scott Ullrich
|
print_info_box(htmlspecialchars($_GET['message']));
|
334 |
55b8d602
|
Scott Ullrich
|
if ($_POST['message'] != "")
|
335 |
d8c1a6c5
|
Scott Ullrich
|
print_info_box(htmlspecialchars($_POST['message']));
|
336 |
77851510
|
Scott Ullrich
|
?></td></tr>
|
337 |
b7bb1711
|
Ermal Lu?i
|
<tr>
|
338 |
|
|
<td class="tabcont">
|
339 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
340 |
|
|
|
341 |
|
|
<tr><td colspan='2'><center><font size="2"><b><?= fixup_string($description) ?></b></font></center></td></tr><tr><td> </td></tr>
|
342 |
34b5c5a0
|
Scott Ullrich
|
<?php
|
343 |
|
|
if(!$pkg['step'][$stepid]['disableheader'])
|
344 |
d51f86e0
|
Scott Ullrich
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
|
345 |
34b5c5a0
|
Scott Ullrich
|
?>
|
346 |
|
|
|
347 |
|
|
<?php
|
348 |
44c10295
|
Scott Ullrich
|
$inputaliases = array();
|
349 |
34b5c5a0
|
Scott Ullrich
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
350 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
351 |
|
|
|
352 |
|
|
$value = $field['value'];
|
353 |
2fbd6806
|
Scott Ullrich
|
$name = $field['name'];
|
354 |
658292ef
|
Scott Ullrich
|
|
355 |
2fbd6806
|
Scott Ullrich
|
$name = ereg_replace(" ", "", $name);
|
356 |
|
|
$name = strtolower($name);
|
357 |
658292ef
|
Scott Ullrich
|
|
358 |
a8df0181
|
Scott Ullrich
|
if($field['bindstofield'] <> "") {
|
359 |
b1919dd0
|
Scott Ullrich
|
$arraynum = "";
|
360 |
|
|
$field_conv = "";
|
361 |
|
|
$field_split = split("->", $field['bindstofield']);
|
362 |
|
|
// arraynum is used in cases where there is an array of the same field
|
363 |
|
|
// name such as dnsserver (2 of them)
|
364 |
a314bebc
|
Ermal
|
if($field['arraynum'] <> "")
|
365 |
|
|
$arraynum = "[" . $field['arraynum'] . "]";
|
366 |
|
|
foreach ($field_split as $f)
|
367 |
|
|
$field_conv .= "['" . $f . "']";
|
368 |
|
|
$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) \$value = \$config" . $field_conv . $arraynum . ";";
|
369 |
|
|
eval($toeval);
|
370 |
a8df0181
|
Scott Ullrich
|
}
|
371 |
|
|
|
372 |
34b5c5a0
|
Scott Ullrich
|
if(!$field['combinefieldsend'])
|
373 |
|
|
echo "<tr>";
|
374 |
|
|
|
375 |
b7bb1711
|
Ermal Lu?i
|
switch ($field['type']) {
|
376 |
|
|
case "input":
|
377 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
378 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
379 |
8984dc5e
|
Ermal
|
echo $field['displayname'];
|
380 |
|
|
echo ":</td>\n";
|
381 |
7a29f783
|
Ermal Lu?i
|
} else if(!$field['dontdisplayname']) {
|
382 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
383 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
384 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
385 |
|
|
}
|
386 |
|
|
if(!$field['dontcombinecells'])
|
387 |
|
|
echo "<td class=\"vtable\">\n";
|
388 |
6bb5c9aa
|
Bill Marquette
|
|
389 |
66f773b4
|
Ermal Lu?i
|
echo "<input class='formfld unknown' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
|
390 |
|
|
if($field['size'])
|
391 |
|
|
echo " size='" . $field['size'] . "' ";
|
392 |
6bb5c9aa
|
Bill Marquette
|
if($field['validate'])
|
393 |
|
|
echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
|
394 |
|
|
echo ">\n";
|
395 |
62a48760
|
Scott Ullrich
|
|
396 |
66f773b4
|
Ermal Lu?i
|
if($field['description'] <> "") {
|
397 |
|
|
echo "<br /> " . $field['description'];
|
398 |
|
|
}
|
399 |
b7bb1711
|
Ermal Lu?i
|
break;
|
400 |
|
|
case "text":
|
401 |
66f773b4
|
Ermal Lu?i
|
echo "<td colspan=\"2\" align=\"center\" class=\"vncell\">\n";
|
402 |
|
|
if($field['description'] <> "") {
|
403 |
b7bb1711
|
Ermal Lu?i
|
echo "<center><br /> " . $field['description'] . "</center>";
|
404 |
66f773b4
|
Ermal Lu?i
|
}
|
405 |
b7bb1711
|
Ermal Lu?i
|
break;
|
406 |
|
|
case "inputalias":
|
407 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
408 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
409 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
410 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
411 |
|
|
} else if(!$field['dontdisplayname']) {
|
412 |
62a48760
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
413 |
|
|
echo fixup_string($field['name']);
|
414 |
|
|
echo ":</td>\n";
|
415 |
|
|
}
|
416 |
|
|
if(!$field['dontcombinecells'])
|
417 |
|
|
echo "<td class=\"vtable\">\n";
|
418 |
|
|
|
419 |
40050fab
|
Ermal
|
$inputaliases[] = $name;
|
420 |
|
|
echo "<input class='formfldalias' autocomplete='off' class='formfldalias' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
|
421 |
66f773b4
|
Ermal Lu?i
|
if($field['size'])
|
422 |
|
|
echo " size='" . $field['size'] . "' ";
|
423 |
62a48760
|
Scott Ullrich
|
if($field['validate'])
|
424 |
|
|
echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
|
425 |
e881d1f3
|
Scott Ullrich
|
echo ">\n";
|
426 |
|
|
|
427 |
66f773b4
|
Ermal Lu?i
|
if($field['description'] <> "") {
|
428 |
|
|
echo "<br /> " . $field['description'];
|
429 |
|
|
}
|
430 |
b7bb1711
|
Ermal Lu?i
|
break;
|
431 |
|
|
case "interfaces_selection":
|
432 |
496f9155
|
Scott Ullrich
|
$size = "";
|
433 |
|
|
$multiple = "";
|
434 |
|
|
$name = strtolower($name);
|
435 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
436 |
7a29f783
|
Ermal Lu?i
|
echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
|
437 |
496f9155
|
Scott Ullrich
|
echo "</td>";
|
438 |
|
|
echo "<td class=\"vtable\">\n";
|
439 |
7b4710f9
|
Scott Ullrich
|
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
|
440 |
496f9155
|
Scott Ullrich
|
if($field['multiple'] <> "" and $field['multiple'] <> "0") {
|
441 |
7b4710f9
|
Scott Ullrich
|
$multiple = "multiple=\"multiple\"";
|
442 |
496f9155
|
Scott Ullrich
|
$name .= "[]";
|
443 |
|
|
}
|
444 |
66f773b4
|
Ermal Lu?i
|
echo "<select class='formselect' id='{$name}' name='{$name}' {$size} {$multiple}>\n";
|
445 |
496f9155
|
Scott Ullrich
|
if($field['add_to_interfaces_selection'] <> "") {
|
446 |
|
|
$SELECTED = "";
|
447 |
|
|
if($field['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
|
448 |
|
|
echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
|
449 |
|
|
}
|
450 |
203de6bf
|
Ermal Lu?i
|
$interfaces = get_configured_interface_with_descr();
|
451 |
496f9155
|
Scott Ullrich
|
foreach ($interfaces as $ifname => $iface) {
|
452 |
|
|
$SELECTED = "";
|
453 |
aecffb0a
|
Scott Ullrich
|
if ($value == $ifname) $SELECTED = " SELECTED";
|
454 |
203de6bf
|
Ermal Lu?i
|
$to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $iface . "</option>\n";
|
455 |
496f9155
|
Scott Ullrich
|
$to_echo .= "<!-- {$value} -->";
|
456 |
|
|
$canecho = 0;
|
457 |
|
|
if($field['interface_filter'] <> "") {
|
458 |
203de6bf
|
Ermal Lu?i
|
if(stristr($ifname, $field['interface_filter']) == true)
|
459 |
496f9155
|
Scott Ullrich
|
$canecho = 1;
|
460 |
|
|
} else {
|
461 |
|
|
$canecho = 1;
|
462 |
|
|
}
|
463 |
e881d1f3
|
Scott Ullrich
|
if($canecho == 1)
|
464 |
496f9155
|
Scott Ullrich
|
echo $to_echo;
|
465 |
|
|
}
|
466 |
|
|
echo "</select>\n";
|
467 |
66f773b4
|
Ermal Lu?i
|
|
468 |
|
|
if($field['description'] <> "") {
|
469 |
|
|
echo "<br /> " . $field['description'];
|
470 |
|
|
}
|
471 |
b7bb1711
|
Ermal Lu?i
|
|
472 |
|
|
break;
|
473 |
|
|
case "password":
|
474 |
34b5c5a0
|
Scott Ullrich
|
if(!$field['dontdisplayname']) {
|
475 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
476 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
477 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
478 |
|
|
}
|
479 |
|
|
if(!$field['dontcombinecells'])
|
480 |
|
|
echo "<td class=\"vtable\">";
|
481 |
66f773b4
|
Ermal Lu?i
|
echo "<input class='formfld password' id='" . $name . "' name='" . $name . "' value='" . $value . "' type='password' ";
|
482 |
|
|
if($field['size'])
|
483 |
|
|
echo " size='" . $field['size'] . "' ";
|
484 |
|
|
echo ">\n";
|
485 |
|
|
|
486 |
|
|
if($field['description'] <> "") {
|
487 |
|
|
echo "<br /> " . $field['description'];
|
488 |
|
|
}
|
489 |
b7bb1711
|
Ermal Lu?i
|
|
490 |
|
|
break;
|
491 |
|
|
case "certca_selection":
|
492 |
66f773b4
|
Ermal Lu?i
|
$size = "";
|
493 |
|
|
$multiple = "";
|
494 |
|
|
$name = strtolower($name);
|
495 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
496 |
|
|
echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
|
497 |
|
|
echo "</td>";
|
498 |
|
|
echo "<td class=\"vtable\">\n";
|
499 |
|
|
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
|
500 |
|
|
echo "<select id='{$name}' name='{$name}' {$size}>\n";
|
501 |
|
|
if($field['add_to_certca_selection'] <> "") {
|
502 |
|
|
$SELECTED = "";
|
503 |
|
|
if($field['add_to_certca_selection'] == $value) $SELECTED = " SELECTED";
|
504 |
|
|
echo "<option value='" . $field['add_to_certca_selection'] . "'" . $SELECTED . ">" . $field['add_to_certca_selection'] . "</option>\n";
|
505 |
|
|
}
|
506 |
|
|
foreach($config['system']['ca'] as $ca) {
|
507 |
|
|
$name = htmlspecialchars($ca['name']);
|
508 |
|
|
$SELECTED = "";
|
509 |
|
|
if ($value == $name) $SELECTED = " SELECTED";
|
510 |
|
|
$to_echo = "<option value='" . $ca['refid'] . "'" . $SELECTED . ">" . $name . "</option>\n";
|
511 |
|
|
$to_echo .= "<!-- {$value} -->";
|
512 |
|
|
$canecho = 0;
|
513 |
|
|
if($field['certca_filter'] <> "") {
|
514 |
|
|
if(stristr($name, $field['certca_filter']) == true)
|
515 |
|
|
$canecho = 1;
|
516 |
|
|
} else {
|
517 |
|
|
$canecho = 1;
|
518 |
|
|
}
|
519 |
|
|
if($canecho == 1)
|
520 |
|
|
echo $to_echo;
|
521 |
|
|
}
|
522 |
|
|
echo "</select>\n";
|
523 |
|
|
|
524 |
|
|
if($field['description'] <> "") {
|
525 |
|
|
echo "<br /> " . $field['description'];
|
526 |
|
|
}
|
527 |
b7bb1711
|
Ermal Lu?i
|
|
528 |
|
|
break;
|
529 |
|
|
case "cert_selection":
|
530 |
66f773b4
|
Ermal Lu?i
|
$size = "";
|
531 |
|
|
$multiple = "";
|
532 |
|
|
$name = strtolower($name);
|
533 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
534 |
|
|
echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
|
535 |
|
|
echo "</td>";
|
536 |
|
|
echo "<td class=\"vtable\">\n";
|
537 |
|
|
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
|
538 |
|
|
echo "<select id='{$name}' name='{$name}' {$size}>\n";
|
539 |
|
|
if($field['add_to_cert_selection'] <> "") {
|
540 |
|
|
$SELECTED = "";
|
541 |
|
|
if($field['add_to_cert_selection'] == $value) $SELECTED = " SELECTED";
|
542 |
|
|
echo "<option value='" . $field['add_to_cert_selection'] . "'" . $SELECTED . ">" . $field['add_to_cert_selection'] . "</option>\n";
|
543 |
|
|
}
|
544 |
|
|
foreach($config['system']['cert'] as $ca) {
|
545 |
|
|
if (stristr($ca['name'], "webconf"))
|
546 |
|
|
continue;
|
547 |
|
|
$name = htmlspecialchars($ca['name']);
|
548 |
|
|
$SELECTED = "";
|
549 |
|
|
if ($value == $name) $SELECTED = " SELECTED";
|
550 |
|
|
$to_echo = "<option value='" . $ca['refid'] . "'" . $SELECTED . ">" . $name . "</option>\n";
|
551 |
|
|
$to_echo .= "<!-- {$value} -->";
|
552 |
|
|
$canecho = 0;
|
553 |
|
|
if($field['cert_filter'] <> "") {
|
554 |
|
|
if(stristr($name, $field['cert_filter']) == true)
|
555 |
|
|
$canecho = 1;
|
556 |
|
|
} else {
|
557 |
|
|
$canecho = 1;
|
558 |
|
|
}
|
559 |
|
|
if($canecho == 1)
|
560 |
|
|
echo $to_echo;
|
561 |
|
|
}
|
562 |
|
|
echo "</select>\n";
|
563 |
|
|
|
564 |
|
|
if($field['description'] <> "") {
|
565 |
|
|
echo "<br /> " . $field['description'];
|
566 |
|
|
}
|
567 |
b7bb1711
|
Ermal Lu?i
|
|
568 |
|
|
break;
|
569 |
|
|
case "select":
|
570 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
571 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
572 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
573 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
574 |
|
|
} else if(!$field['dontdisplayname']) {
|
575 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
576 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
577 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
578 |
|
|
}
|
579 |
|
|
if($field['size']) $size = " size='" . $field['size'] . "' ";
|
580 |
|
|
if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
|
581 |
|
|
if(!$field['dontcombinecells'])
|
582 |
|
|
echo "<td class=\"vtable\">\n";
|
583 |
|
|
$onchange = "";
|
584 |
|
|
foreach ($field['options']['option'] as $opt) {
|
585 |
|
|
if($opt['enablefields'] <> "") {
|
586 |
|
|
$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
|
587 |
|
|
}
|
588 |
|
|
}
|
589 |
66f773b4
|
Ermal Lu?i
|
echo "<select class='formselect' " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
|
590 |
34b5c5a0
|
Scott Ullrich
|
foreach ($field['options']['option'] as $opt) {
|
591 |
46985f19
|
Scott Ullrich
|
$selected = "";
|
592 |
47aa4fc4
|
Ermal
|
if($value == $opt['value'])
|
593 |
|
|
$selected = " SELECTED";
|
594 |
|
|
echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">";
|
595 |
d6f53204
|
Ermal Lu?i
|
if ($opt['displayname'])
|
596 |
|
|
echo $opt['displayname'];
|
597 |
|
|
else
|
598 |
|
|
echo $opt['name'];
|
599 |
|
|
echo "</option>\n";
|
600 |
34b5c5a0
|
Scott Ullrich
|
}
|
601 |
|
|
echo "</select>\n";
|
602 |
a314bebc
|
Ermal
|
echo "<!-- {$value} -->\n";
|
603 |
66f773b4
|
Ermal Lu?i
|
|
604 |
|
|
if($field['description'] <> "") {
|
605 |
|
|
echo $field['description'];
|
606 |
|
|
}
|
607 |
b7bb1711
|
Ermal Lu?i
|
|
608 |
|
|
break;
|
609 |
|
|
case "textarea":
|
610 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
611 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
612 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
613 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
614 |
|
|
} else if(!$field['dontdisplayname']) {
|
615 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
616 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
617 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>";
|
618 |
|
|
}
|
619 |
|
|
if(!$field['dontcombinecells'])
|
620 |
|
|
echo "<td class=\"vtable\">";
|
621 |
66f773b4
|
Ermal Lu?i
|
echo "<textarea class='formpre' id='" . $name . "' name='" . $name . "'";
|
622 |
|
|
if ($field['rows'])
|
623 |
|
|
echo " rows='" . $field['rows'] . "' ";
|
624 |
|
|
if ($field['cols'])
|
625 |
|
|
echo " cols='" . $field['cols'] . "' ";
|
626 |
|
|
echo ">" . $value . "</textarea>\n";
|
627 |
|
|
|
628 |
|
|
|
629 |
|
|
if($field['description'] <> "") {
|
630 |
|
|
echo "<br /> " . $field['description'];
|
631 |
|
|
}
|
632 |
b7bb1711
|
Ermal Lu?i
|
|
633 |
|
|
break;
|
634 |
|
|
case "submit":
|
635 |
34b5c5a0
|
Scott Ullrich
|
echo "<td> <br></td></tr>";
|
636 |
2fbd6806
|
Scott Ullrich
|
echo "<tr><td colspan='2'><center>";
|
637 |
|
|
echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
|
638 |
66f773b4
|
Ermal Lu?i
|
|
639 |
|
|
if($field['description'] <> "") {
|
640 |
|
|
echo "<br /> " . $field['description'];
|
641 |
|
|
}
|
642 |
b7bb1711
|
Ermal Lu?i
|
|
643 |
|
|
break;
|
644 |
|
|
case "listtopic":
|
645 |
|
|
echo "<td> </td></tr>";
|
646 |
|
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br ></td>\n";
|
647 |
|
|
|
648 |
|
|
break;
|
649 |
|
|
case "subnet_select":
|
650 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
651 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
652 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
653 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
654 |
|
|
} else if(!$field['dontdisplayname']) {
|
655 |
bd31336e
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
656 |
|
|
echo fixup_string($field['name']);
|
657 |
|
|
echo ":</td>";
|
658 |
|
|
}
|
659 |
|
|
if(!$field['dontcombinecells'])
|
660 |
|
|
echo "<td class=\"vtable\">";
|
661 |
66f773b4
|
Ermal Lu?i
|
echo "<select class='formselect' name='{$name}'>\n";
|
662 |
bd31336e
|
Scott Ullrich
|
for($x=1; $x<33; $x++) {
|
663 |
|
|
$CHECKED = "";
|
664 |
|
|
if($value == $x) $CHECKED = " SELECTED";
|
665 |
|
|
if($x <> 31)
|
666 |
|
|
echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
|
667 |
|
|
}
|
668 |
|
|
echo "</select>\n";
|
669 |
66f773b4
|
Ermal Lu?i
|
|
670 |
|
|
if($field['description'] <> "") {
|
671 |
|
|
echo "<br /> " . $field['description'];
|
672 |
|
|
}
|
673 |
b7bb1711
|
Ermal Lu?i
|
|
674 |
|
|
break;
|
675 |
|
|
case "timezone_select":
|
676 |
5a8a69b3
|
Ermal Lu?i
|
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
|
677 |
|
|
$timezonelist = array_filter($timezonelist, 'is_timezone');
|
678 |
|
|
sort($timezonelist);
|
679 |
|
|
|
680 |
|
|
/* kill carriage returns */
|
681 |
|
|
for($x=0; $x<count($timezonelist); $x++)
|
682 |
|
|
$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
|
683 |
|
|
|
684 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
685 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
686 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
687 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
688 |
|
|
} else if(!$field['dontdisplayname']) {
|
689 |
bd31336e
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
690 |
|
|
echo fixup_string($field['name']);
|
691 |
|
|
echo ":</td>";
|
692 |
|
|
}
|
693 |
|
|
if(!$field['dontcombinecells'])
|
694 |
|
|
echo "<td class=\"vtable\">";
|
695 |
66f773b4
|
Ermal Lu?i
|
echo "<select class='formselect' name='{$name}'>\n";
|
696 |
bd31336e
|
Scott Ullrich
|
foreach ($timezonelist as $tz) {
|
697 |
|
|
$SELECTED = "";
|
698 |
|
|
if ($value == $tz) $SELECTED = " SELECTED";
|
699 |
|
|
echo "<option value='" . htmlspecialchars($tz) . "' {$SELECTED}>";
|
700 |
|
|
echo htmlspecialchars($tz);
|
701 |
|
|
echo "</option>\n";
|
702 |
|
|
}
|
703 |
|
|
echo "</select>\n";
|
704 |
66f773b4
|
Ermal Lu?i
|
|
705 |
|
|
if($field['description'] <> "") {
|
706 |
|
|
echo "<br /> " . $field['description'];
|
707 |
|
|
}
|
708 |
b7bb1711
|
Ermal Lu?i
|
|
709 |
|
|
break;
|
710 |
|
|
case "checkbox":
|
711 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
712 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
713 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
714 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
715 |
|
|
} else if(!$field['dontdisplayname']) {
|
716 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
717 |
|
|
echo $field['name'];
|
718 |
|
|
echo ":</td>";
|
719 |
|
|
}
|
720 |
|
|
$checked = "";
|
721 |
eb20f3c5
|
Ermal Lu?i
|
if($value <> "")
|
722 |
|
|
$checked = " CHECKED";
|
723 |
72a5f424
|
Ermal Lu?i
|
echo "<td class=\"vtable\"><input value=\"on\" type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
|
724 |
b7bb1711
|
Ermal Lu?i
|
if(isset($field['enablefields']) or isset($field['checkenablefields']))
|
725 |
|
|
echo " onClick=\"enablechange()\"";
|
726 |
1ae55320
|
Ermal
|
else if(isset($field['disablefields']) or isset($field['checkdisablefields']))
|
727 |
|
|
echo " onClick=\"disablechange()\"";
|
728 |
33a56b27
|
Colin Smith
|
echo ">\n";
|
729 |
66f773b4
|
Ermal Lu?i
|
|
730 |
|
|
if($field['description'] <> "") {
|
731 |
|
|
echo $field['description'];
|
732 |
|
|
}
|
733 |
b7bb1711
|
Ermal Lu?i
|
|
734 |
|
|
break;
|
735 |
34b5c5a0
|
Scott Ullrich
|
}
|
736 |
|
|
|
737 |
|
|
if($field['typehint'] <> "") {
|
738 |
|
|
echo $field['typehint'];
|
739 |
2fbd6806
|
Scott Ullrich
|
}
|
740 |
f3c6fdc0
|
Bill Marquette
|
if($field['warning'] <> "") {
|
741 |
b7bb1711
|
Ermal Lu?i
|
echo "<br ><b><font color=\"red\">" . $field['warning'] . "</font></b>";
|
742 |
f3c6fdc0
|
Bill Marquette
|
}
|
743 |
|
|
|
744 |
8984dc5e
|
Ermal
|
if(!$field['combinefieldsbegin']) {
|
745 |
|
|
if (!$field['dontcombinecells'])
|
746 |
|
|
echo "</td>";
|
747 |
|
|
|
748 |
|
|
echo "</tr>\n";
|
749 |
|
|
}
|
750 |
1ae55320
|
Ermal
|
|
751 |
34b5c5a0
|
Scott Ullrich
|
}
|
752 |
|
|
}
|
753 |
|
|
?>
|
754 |
b7bb1711
|
Ermal Lu?i
|
</table>
|
755 |
|
|
</td></tr>
|
756 |
658292ef
|
Scott Ullrich
|
</table>
|
757 |
85dc4438
|
Scott Ullrich
|
<br>
|
758 |
5adb3375
|
Scott Ullrich
|
</div>
|
759 |
658292ef
|
Scott Ullrich
|
</form>
|
760 |
44c10295
|
Scott Ullrich
|
<script type="text/javascript">
|
761 |
62a48760
|
Scott Ullrich
|
<!--
|
762 |
|
|
if (typeof ext_change != 'undefined') {
|
763 |
|
|
ext_change();
|
764 |
|
|
}
|
765 |
|
|
if (typeof proto_change != 'undefined') {
|
766 |
|
|
ext_change();
|
767 |
|
|
}
|
768 |
|
|
if (typeof proto_change != 'undefined') {
|
769 |
|
|
proto_change();
|
770 |
|
|
}
|
771 |
5adb3375
|
Scott Ullrich
|
|
772 |
62a48760
|
Scott Ullrich
|
<?php
|
773 |
|
|
$isfirst = 0;
|
774 |
|
|
$aliases = "";
|
775 |
|
|
$addrisfirst = 0;
|
776 |
|
|
$aliasesaddr = "";
|
777 |
|
|
if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
|
778 |
|
|
foreach($config['aliases']['alias'] as $alias_name) {
|
779 |
40050fab
|
Ermal
|
if($isfirst == 1)
|
780 |
|
|
$aliases .= ",";
|
781 |
62a48760
|
Scott Ullrich
|
$aliases .= "'" . $alias_name['name'] . "'";
|
782 |
|
|
$isfirst = 1;
|
783 |
|
|
}
|
784 |
|
|
?>
|
785 |
|
|
|
786 |
|
|
var customarray=new Array(<?php echo $aliases; ?>);
|
787 |
|
|
|
788 |
44c10295
|
Scott Ullrich
|
window.onload = function () {
|
789 |
|
|
|
790 |
|
|
<?php
|
791 |
|
|
$counter=0;
|
792 |
|
|
foreach($inputaliases as $alias) {
|
793 |
40050fab
|
Ermal
|
echo "var oTextbox$counter = new AutoSuggestControl(document.getElementById(\"$alias\"), new StateSuggestions(customarray));\n";
|
794 |
44c10295
|
Scott Ullrich
|
$counter++;
|
795 |
|
|
}
|
796 |
|
|
?>
|
797 |
|
|
|
798 |
|
|
}
|
799 |
|
|
|
800 |
62a48760
|
Scott Ullrich
|
//-->
|
801 |
|
|
</script>
|
802 |
5adb3375
|
Scott Ullrich
|
<script type="text/javascript">
|
803 |
|
|
NiftyCheck();
|
804 |
e881d1f3
|
Scott Ullrich
|
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
|
805 |
|
|
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
|
806 |
1ae55320
|
Ermal
|
enablechange();
|
807 |
|
|
disablechange();
|
808 |
|
|
showchange();
|
809 |
5adb3375
|
Scott Ullrich
|
</script>
|
810 |
|
|
|
811 |
34b5c5a0
|
Scott Ullrich
|
<?php
|
812 |
|
|
|
813 |
|
|
$fieldnames_array = Array();
|
814 |
|
|
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
|
815 |
|
|
// create a fieldname loop that can be used with javascript
|
816 |
|
|
// hide and enable features.
|
817 |
44c10295
|
Scott Ullrich
|
echo "\n<script type=\"text/javascript\">\n";
|
818 |
34b5c5a0
|
Scott Ullrich
|
echo "function disableall() {\n";
|
819 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
820 |
|
|
if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
|
821 |
|
|
if(!$field['donotdisable'] <> "") {
|
822 |
|
|
array_push($fieldnames_array, $field['name']);
|
823 |
|
|
$fieldname = ereg_replace(" ", "", $field['name']);
|
824 |
|
|
$fieldname = strtolower($fieldname);
|
825 |
|
|
echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
|
826 |
|
|
}
|
827 |
|
|
}
|
828 |
|
|
}
|
829 |
|
|
echo "}\ndisableall();\n";
|
830 |
|
|
echo "function enableitems(selectedindex) {\n";
|
831 |
|
|
echo "disableall();\n";
|
832 |
|
|
$idcounter = 0;
|
833 |
|
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
834 |
|
|
echo "\tswitch(selectedindex) {\n";
|
835 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
836 |
|
|
if($field['options']['option'] <> "") {
|
837 |
|
|
foreach ($field['options']['option'] as $opt) {
|
838 |
|
|
if($opt['enablefields'] <> "") {
|
839 |
|
|
echo "\t\tcase " . $idcounter . ":\n";
|
840 |
|
|
$enablefields_split = split(",", $opt['enablefields']);
|
841 |
|
|
foreach ($enablefields_split as $efs) {
|
842 |
|
|
$fieldname = ereg_replace(" ", "", $efs);
|
843 |
|
|
$fieldname = strtolower($fieldname);
|
844 |
|
|
if($fieldname <> "") {
|
845 |
|
|
$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
|
846 |
|
|
echo $onchange;
|
847 |
|
|
}
|
848 |
|
|
}
|
849 |
|
|
echo "\t\t\tbreak;\n";
|
850 |
|
|
}
|
851 |
|
|
$idcounter = $idcounter + 1;
|
852 |
|
|
}
|
853 |
|
|
}
|
854 |
|
|
}
|
855 |
|
|
echo "\t}\n";
|
856 |
|
|
}
|
857 |
|
|
echo "}\n";
|
858 |
|
|
echo "</script>\n\n";
|
859 |
|
|
}
|
860 |
|
|
|
861 |
|
|
|
862 |
|
|
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
|
863 |
|
|
// handle after form display event.
|
864 |
|
|
eval($pkg['step'][$stepid]['stepafterformdisplay']);
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
|
868 |
|
|
// handle after form display event.
|
869 |
44c10295
|
Scott Ullrich
|
echo "\n<script type=\"text/javascript\">\n";
|
870 |
34b5c5a0
|
Scott Ullrich
|
echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
|
871 |
|
|
echo "</script>\n\n";
|
872 |
|
|
}
|
873 |
|
|
|
874 |
d51f86e0
|
Scott Ullrich
|
/*
|
875 |
|
|
* HELPER FUNCTIONS
|
876 |
|
|
*/
|
877 |
|
|
|
878 |
|
|
function fixup_string($string) {
|
879 |
a0190b50
|
Scott Ullrich
|
global $config, $myurl;
|
880 |
78818d7a
|
Scott Ullrich
|
$newstring = $string;
|
881 |
d51f86e0
|
Scott Ullrich
|
// fixup #1: $myurl -> http[s]://ip_address:port/
|
882 |
43d9a2d3
|
jim-p
|
switch($config['system']['webgui']['protocol']) {
|
883 |
037304d8
|
Scott Ullrich
|
case "http":
|
884 |
|
|
$proto = "http";
|
885 |
|
|
break;
|
886 |
|
|
case "https":
|
887 |
|
|
$proto = "https";
|
888 |
|
|
break;
|
889 |
|
|
default:
|
890 |
|
|
$proto = "http";
|
891 |
|
|
break;
|
892 |
|
|
}
|
893 |
43d9a2d3
|
jim-p
|
$port = $config['system']['webgui']['port'];
|
894 |
037304d8
|
Scott Ullrich
|
if($port != "") {
|
895 |
|
|
if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
|
896 |
|
|
$urlport = ":" . $port;
|
897 |
|
|
} elseif ($port != "80" and $port != "443") {
|
898 |
|
|
$urlport = ":" . $port;
|
899 |
|
|
} else {
|
900 |
|
|
$urlport = "";
|
901 |
|
|
}
|
902 |
|
|
}
|
903 |
39d1c22d
|
sullrich
|
$myurl = $proto . "://" . $_SERVER['HTTP_HOST'] . $urlport . "/";
|
904 |
d70a5ac6
|
Ermal Lu?i
|
|
905 |
|
|
if (strstr($newstring, "\$myurl"))
|
906 |
|
|
$newstring = str_replace("\$myurl", $myurl, $newstring);
|
907 |
d2133701
|
Scott Ullrich
|
// fixup #2: $wanip
|
908 |
d70a5ac6
|
Ermal Lu?i
|
if (strstr($newstring, "\$wanip")) {
|
909 |
|
|
$curwanip = get_interface_ip();
|
910 |
|
|
$newstring = str_replace("\$wanip", $curwanip, $newstring);
|
911 |
|
|
}
|
912 |
d2133701
|
Scott Ullrich
|
// fixup #3: $lanip
|
913 |
d70a5ac6
|
Ermal Lu?i
|
if (strstr($newstring, "\$lanip")) {
|
914 |
|
|
$lanip = get_interface_ip("lan");
|
915 |
|
|
$newstring = str_replace("\$lanip", $lanip, $newstring);
|
916 |
|
|
}
|
917 |
d2133701
|
Scott Ullrich
|
// fixup #4: fix'r'up here.
|
918 |
d51f86e0
|
Scott Ullrich
|
return $newstring;
|
919 |
|
|
}
|
920 |
|
|
|
921 |
bd31336e
|
Scott Ullrich
|
function is_timezone($elt) {
|
922 |
|
|
return !preg_match("/\/$/", $elt);
|
923 |
|
|
}
|
924 |
d51f86e0
|
Scott Ullrich
|
|
925 |
c8000491
|
Scott Ullrich
|
?>
|
926 |
|
|
|
927 |
|
|
</body>
|
928 |
|
|
</html>
|