1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
wizard.php
|
5
|
Copyright (C) 2004 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
##|+PRIV
|
31
|
##|*IDENT=page-pfsensewizardsubsystem
|
32
|
##|*NAME=pfSense wizard subsystem page
|
33
|
##|*DESCR=Allow access to the 'pfSense wizard subsystem' page.
|
34
|
##|*MATCH=wizard.php*
|
35
|
##|-PRIV
|
36
|
|
37
|
|
38
|
require("guiconfig.inc");
|
39
|
require("functions.inc");
|
40
|
require("filter.inc");
|
41
|
require("shaper.inc");
|
42
|
require("rrd.inc");
|
43
|
|
44
|
function gentitle_pkg($pgname) {
|
45
|
global $config;
|
46
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
47
|
}
|
48
|
|
49
|
$stepid = htmlspecialchars($_GET['stepid']);
|
50
|
if (isset($_POST['stepid']))
|
51
|
$stepid = htmlspecialchars($_POST['stepid']);
|
52
|
if (!$stepid) $stepid = "0";
|
53
|
|
54
|
$xml = htmlspecialchars($_GET['xml']);
|
55
|
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
|
56
|
|
57
|
if($xml == "") {
|
58
|
$xml = "not_defined";
|
59
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
60
|
die;
|
61
|
} else {
|
62
|
if (file_exists("{$g['www_path']}/wizards/{$xml}"))
|
63
|
$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
|
64
|
else {
|
65
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
66
|
die;
|
67
|
}
|
68
|
}
|
69
|
|
70
|
$title = $pkg['step'][$stepid]['title'];
|
71
|
$description = $pkg['step'][$stepid]['description'];
|
72
|
$totalsteps = $pkg['totalsteps'];
|
73
|
|
74
|
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
|
75
|
$timezonelist = array_filter($timezonelist, 'is_timezone');
|
76
|
sort($timezonelist);
|
77
|
|
78
|
/* kill carriage returns */
|
79
|
for($x=0; $x<count($timezonelist); $x++)
|
80
|
$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
|
81
|
|
82
|
if ($pkg['step'][$stepid]['includefile'])
|
83
|
require($pkg['step'][$stepid]['includefile']);
|
84
|
|
85
|
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
|
86
|
eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
|
87
|
}
|
88
|
|
89
|
if ($_POST) {
|
90
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
91
|
if($field['bindstofield'] <> "" and $field['type'] <> "submit") {
|
92
|
$fieldname = $field['name'];
|
93
|
$unset_fields = "";
|
94
|
$fieldname = ereg_replace(" ", "", $fieldname);
|
95
|
$fieldname = strtolower($fieldname);
|
96
|
// update field with posted values.
|
97
|
if($field['unsetfield'] <> "") $unset_fields = "yes";
|
98
|
if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
|
99
|
if($field['bindstofield'])
|
100
|
update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
|
101
|
}
|
102
|
|
103
|
}
|
104
|
// run custom php code embedded in xml config.
|
105
|
if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
|
106
|
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
|
107
|
}
|
108
|
write_config();
|
109
|
$stepid++;
|
110
|
if($stepid > $totalsteps) $stepid = $totalsteps;
|
111
|
}
|
112
|
|
113
|
$title = $pkg['step'][$stepid]['title'];
|
114
|
$description = $pkg['step'][$stepid]['description'];
|
115
|
|
116
|
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
|
117
|
global $config;
|
118
|
$field_split = split("->",$field);
|
119
|
foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
|
120
|
if($field_conv == "") return;
|
121
|
if($field_type == "checkbox" and $updatetext <> "on") {
|
122
|
/*
|
123
|
item is a checkbox, it should have the value "on"
|
124
|
if it was checked
|
125
|
*/
|
126
|
$text = "unset(\$config" . $field_conv . ");";
|
127
|
eval($text);
|
128
|
return;
|
129
|
}
|
130
|
|
131
|
if($field_type == "interfaces_selection") {
|
132
|
$text = "unset(\$config" . $field_conv . ");";
|
133
|
eval($text);
|
134
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
135
|
eval($text);
|
136
|
return;
|
137
|
}
|
138
|
|
139
|
if($unset <> "") {
|
140
|
$text = "unset(\$config" . $field_conv . ");";
|
141
|
eval($text);
|
142
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
143
|
eval($text);
|
144
|
} else {
|
145
|
if($arraynum <> "") {
|
146
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
147
|
} else {
|
148
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
149
|
}
|
150
|
eval($text);
|
151
|
}
|
152
|
}
|
153
|
|
154
|
if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") {
|
155
|
// handle before form display event.
|
156
|
// good for modifying posted values, etc.
|
157
|
eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
|
158
|
}
|
159
|
|
160
|
$pgtitle = array($title);
|
161
|
include("head.inc");
|
162
|
|
163
|
?>
|
164
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
|
165
|
|
166
|
<?php
|
167
|
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
|
168
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
|
169
|
else
|
170
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
|
171
|
?>
|
172
|
|
173
|
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
|
174
|
<script type="text/javascript">
|
175
|
<!--
|
176
|
|
177
|
function FieldValidate(userinput, regexp, message)
|
178
|
{
|
179
|
if(!userinput.match(regexp))
|
180
|
alert(message);
|
181
|
}
|
182
|
|
183
|
function enablechange() {
|
184
|
<?php
|
185
|
foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
|
186
|
if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
|
187
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
|
188
|
if(isset($field['enablefields'])) {
|
189
|
$enablefields = explode(',', $field['enablefields']);
|
190
|
foreach($enablefields as $enablefield) {
|
191
|
$enablefield = strtolower($enablefield);
|
192
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
|
193
|
}
|
194
|
}
|
195
|
if(isset($field['checkenablefields'])) {
|
196
|
$checkenablefields = explode(',', $field['checkenablefields']);
|
197
|
foreach($checkenablefields as $checkenablefield) {
|
198
|
$checkenablefield = strtolower($checkenablefield);
|
199
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
|
200
|
}
|
201
|
}
|
202
|
print "\t" . '} else {' . "\n";
|
203
|
if(isset($field['enablefields'])) {
|
204
|
foreach($enablefields as $enablefield) {
|
205
|
$enablefield = strtolower($enablefield);
|
206
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
|
207
|
}
|
208
|
}
|
209
|
if(isset($field['checkenablefields'])) {
|
210
|
foreach($checkenablefields as $checkenablefield) {
|
211
|
$checkenablefield = strtolower($checkenablefield);
|
212
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
|
213
|
}
|
214
|
}
|
215
|
print "\t" . '}' . "\n";
|
216
|
}
|
217
|
}
|
218
|
?>
|
219
|
}
|
220
|
//-->
|
221
|
</script>
|
222
|
<?php } ?>
|
223
|
|
224
|
<form action="wizard.php" method="post" name="iform" id="iform">
|
225
|
<input type="hidden" name="xml" value="<?= $xml ?>">
|
226
|
<input type="hidden" name="stepid" value="<?= $stepid ?>">
|
227
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
228
|
|
229
|
<center>
|
230
|
|
231
|
<br>
|
232
|
|
233
|
<?php
|
234
|
if($title == "Reload in progress") {
|
235
|
$ip = fixup_string($_SERVER['HTTP_HOST']);
|
236
|
} else {
|
237
|
$ip = "/";
|
238
|
}
|
239
|
echo "<a href='$ip'>";
|
240
|
?>
|
241
|
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
|
242
|
<p>
|
243
|
<div style="width:700px;background-color:#ffffff" id="roundme">
|
244
|
<table bgcolor="#ffffff" width="600" cellspacing="0" cellpadding="3">
|
245
|
<!-- wizard goes here -->
|
246
|
<tr><td> </td></tr>
|
247
|
<tr><td colspan='2'>
|
248
|
<?php
|
249
|
if ($_GET['message'] != "")
|
250
|
print_info_box(htmlspecialchars($_GET['message']));
|
251
|
if ($_POST['message'] != "")
|
252
|
print_info_box(htmlspecialchars($_POST['message']));
|
253
|
?></td></tr>
|
254
|
<tr><td colspan='2'><center><b><?= fixup_string($description) ?></b></center></td></tr><tr><td> </td></tr>
|
255
|
<?php
|
256
|
if(!$pkg['step'][$stepid]['disableheader'])
|
257
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
|
258
|
?>
|
259
|
|
260
|
<?php
|
261
|
$inputaliases = array();
|
262
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
263
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
264
|
|
265
|
$value = $field['value'];
|
266
|
$name = $field['name'];
|
267
|
|
268
|
$name = ereg_replace(" ", "", $name);
|
269
|
$name = strtolower($name);
|
270
|
|
271
|
if($field['bindstofield'] <> "") {
|
272
|
$arraynum = "";
|
273
|
$field_conv = "";
|
274
|
$field_split = split("->", $field['bindstofield']);
|
275
|
// arraynum is used in cases where there is an array of the same field
|
276
|
// name such as dnsserver (2 of them)
|
277
|
if($field['arraynum'] <> "") $arraynum = "[" . $field['arraynum'] . "]";
|
278
|
foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
|
279
|
$toeval = "\$value = \$config" . $field_conv . $arraynum . ";";
|
280
|
eval($toeval);
|
281
|
if ($field['type'] == "checkbox") {
|
282
|
$toeval = "if(isset(\$config" . $field_conv . $arraynum . ")) \$value = \" CHECKED\";";
|
283
|
eval($toeval);
|
284
|
}
|
285
|
}
|
286
|
|
287
|
if(!$field['combinefieldsend'])
|
288
|
echo "<tr>";
|
289
|
|
290
|
if ($field['type'] == "input") {
|
291
|
if ($field['displayname']) {
|
292
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
293
|
echo $field['displayname'];
|
294
|
echo ":</td>\n";
|
295
|
} else if(!$field['dontdisplayname']) {
|
296
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
297
|
echo fixup_string($field['name']);
|
298
|
echo ":</td>\n";
|
299
|
}
|
300
|
if(!$field['dontcombinecells'])
|
301
|
echo "<td class=\"vtable\">\n";
|
302
|
|
303
|
echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'";
|
304
|
if($field['validate'])
|
305
|
echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
|
306
|
echo ">\n";
|
307
|
|
308
|
|
309
|
|
310
|
} else if ($field['type'] == "inputalias") {
|
311
|
if ($field['displayname']) {
|
312
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
313
|
echo $field['displayname'];
|
314
|
echo ":</td>\n";
|
315
|
} else if(!$field['dontdisplayname']) {
|
316
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
317
|
echo fixup_string($field['name']);
|
318
|
echo ":</td>\n";
|
319
|
$inputaliases[] = $name;
|
320
|
}
|
321
|
if(!$field['dontcombinecells'])
|
322
|
echo "<td class=\"vtable\">\n";
|
323
|
|
324
|
echo "<input autocomplete='off' class='formfldalias' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
|
325
|
if($field['validate'])
|
326
|
echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
|
327
|
echo ">\n";
|
328
|
|
329
|
|
330
|
|
331
|
} else if($field['type'] == "interfaces_selection") {
|
332
|
$size = "";
|
333
|
$multiple = "";
|
334
|
$name = strtolower($name);
|
335
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
336
|
echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
|
337
|
echo "</td>";
|
338
|
echo "<td class=\"vtable\">\n";
|
339
|
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
|
340
|
if($field['multiple'] <> "" and $field['multiple'] <> "0") {
|
341
|
$multiple = "multiple=\"multiple\"";
|
342
|
$name .= "[]";
|
343
|
}
|
344
|
echo "<select id='{$name}' name='{$name}' {$size} {$multiple}>\n";
|
345
|
if($field['add_to_interfaces_selection'] <> "") {
|
346
|
$SELECTED = "";
|
347
|
if($field['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
|
348
|
echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
|
349
|
}
|
350
|
$interfaces = get_configured_interface_with_descr();
|
351
|
foreach ($interfaces as $ifname => $iface) {
|
352
|
$SELECTED = "";
|
353
|
if ($value == $ifname) $SELECTED = " SELECTED";
|
354
|
$to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $iface . "</option>\n";
|
355
|
$to_echo .= "<!-- {$value} -->";
|
356
|
$canecho = 0;
|
357
|
if($field['interface_filter'] <> "") {
|
358
|
if(stristr($ifname, $field['interface_filter']) == true)
|
359
|
$canecho = 1;
|
360
|
} else {
|
361
|
$canecho = 1;
|
362
|
}
|
363
|
if($canecho == 1)
|
364
|
echo $to_echo;
|
365
|
}
|
366
|
echo "</select>\n";
|
367
|
} else if ($field['type'] == "password") {
|
368
|
if(!$field['dontdisplayname']) {
|
369
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
370
|
echo fixup_string($field['name']);
|
371
|
echo ":</td>\n";
|
372
|
}
|
373
|
if(!$field['dontcombinecells'])
|
374
|
echo "<td class=\"vtable\">";
|
375
|
echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "' type='password'>\n";
|
376
|
} else if ($field['type'] == "select") {
|
377
|
if ($field['displayname']) {
|
378
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
379
|
echo $field['displayname'];
|
380
|
echo ":</td>\n";
|
381
|
} else if(!$field['dontdisplayname']) {
|
382
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
383
|
echo fixup_string($field['name']);
|
384
|
echo ":</td>\n";
|
385
|
}
|
386
|
if($field['size']) $size = " size='" . $field['size'] . "' ";
|
387
|
if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
|
388
|
if(!$field['dontcombinecells'])
|
389
|
echo "<td class=\"vtable\">\n";
|
390
|
$onchange = "";
|
391
|
foreach ($field['options']['option'] as $opt) {
|
392
|
if($opt['enablefields'] <> "") {
|
393
|
$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
|
394
|
}
|
395
|
}
|
396
|
echo "<select " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
|
397
|
foreach ($field['options']['option'] as $opt) {
|
398
|
$selected = "";
|
399
|
if($value == $opt['value']) $selected = " SELECTED";
|
400
|
echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">";
|
401
|
if ($opt['displayname'])
|
402
|
echo $opt['displayname'];
|
403
|
else
|
404
|
echo $opt['name'];
|
405
|
echo "</option>\n";
|
406
|
}
|
407
|
echo "</select>\n";
|
408
|
} else if ($field['type'] == "textarea") {
|
409
|
if ($field['displayname']) {
|
410
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
411
|
echo $field['displayname'];
|
412
|
echo ":</td>\n";
|
413
|
} else if(!$field['dontdisplayname']) {
|
414
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
415
|
echo fixup_string($field['name']);
|
416
|
echo ":</td>";
|
417
|
}
|
418
|
if(!$field['dontcombinecells'])
|
419
|
echo "<td class=\"vtable\">";
|
420
|
echo "<textarea id='" . $name . "' name='" . $name . ">" . $value . "</textarea>\n";
|
421
|
} else if ($field['type'] == "submit") {
|
422
|
echo "<td> <br></td></tr>";
|
423
|
echo "<tr><td colspan='2'><center>";
|
424
|
echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
|
425
|
} else if ($field['type'] == "listtopic") {
|
426
|
echo "<td> </td><tr>";
|
427
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br></td>\n";
|
428
|
} else if ($field['type'] == "subnet_select") {
|
429
|
if ($field['displayname']) {
|
430
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
431
|
echo $field['displayname'];
|
432
|
echo ":</td>\n";
|
433
|
} else if(!$field['dontdisplayname']) {
|
434
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
435
|
echo fixup_string($field['name']);
|
436
|
echo ":</td>";
|
437
|
}
|
438
|
if(!$field['dontcombinecells'])
|
439
|
echo "<td class=\"vtable\">";
|
440
|
echo "<select name='{$name}'>\n";
|
441
|
for($x=1; $x<33; $x++) {
|
442
|
$CHECKED = "";
|
443
|
if($value == $x) $CHECKED = " SELECTED";
|
444
|
if($x <> 31)
|
445
|
echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
|
446
|
}
|
447
|
echo "</select>\n";
|
448
|
} else if ($field['type'] == "timezone_select") {
|
449
|
if ($field['displayname']) {
|
450
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
451
|
echo $field['displayname'];
|
452
|
echo ":</td>\n";
|
453
|
} else if(!$field['dontdisplayname']) {
|
454
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
455
|
echo fixup_string($field['name']);
|
456
|
echo ":</td>";
|
457
|
}
|
458
|
if(!$field['dontcombinecells'])
|
459
|
echo "<td class=\"vtable\">";
|
460
|
echo "<select name='{$name}'>\n";
|
461
|
foreach ($timezonelist as $tz) {
|
462
|
$SELECTED = "";
|
463
|
if ($value == $tz) $SELECTED = " SELECTED";
|
464
|
echo "<option value='" . htmlspecialchars($tz) . "' {$SELECTED}>";
|
465
|
echo htmlspecialchars($tz);
|
466
|
echo "</option>\n";
|
467
|
}
|
468
|
echo "</select>\n";
|
469
|
} else if ($field['type'] == "checkbox") {
|
470
|
if ($field['displayname']) {
|
471
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
472
|
echo $field['displayname'];
|
473
|
echo ":</td>\n";
|
474
|
} else if(!$field['dontdisplayname']) {
|
475
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
476
|
echo $field['name'];
|
477
|
echo ":</td>";
|
478
|
}
|
479
|
$checked = "";
|
480
|
if($value <> "") $checked = " CHECKED";
|
481
|
echo "<td class=\"vtable\"><input type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
|
482
|
if(isset($field['enablefields']) or isset($field['checkenablefields'])) echo " onClick=\"enablechange()\"";
|
483
|
echo ">\n";
|
484
|
}
|
485
|
|
486
|
if($field['typehint'] <> "") {
|
487
|
echo $field['typehint'];
|
488
|
}
|
489
|
|
490
|
if($field['description'] <> "") {
|
491
|
echo "<br>" . $field['description'];
|
492
|
echo "</td>";
|
493
|
}
|
494
|
|
495
|
if(!$field['combinefieldsbegin'])
|
496
|
echo "</tr>\n";
|
497
|
|
498
|
if($field['warning'] <> "") {
|
499
|
echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
|
500
|
}
|
501
|
|
502
|
}
|
503
|
}
|
504
|
?>
|
505
|
</table>
|
506
|
<br>
|
507
|
</div>
|
508
|
</form>
|
509
|
<script type="text/javascript">
|
510
|
<!--
|
511
|
if (typeof ext_change != 'undefined') {
|
512
|
ext_change();
|
513
|
}
|
514
|
if (typeof proto_change != 'undefined') {
|
515
|
ext_change();
|
516
|
}
|
517
|
if (typeof proto_change != 'undefined') {
|
518
|
proto_change();
|
519
|
}
|
520
|
|
521
|
<?php
|
522
|
$isfirst = 0;
|
523
|
$aliases = "";
|
524
|
$addrisfirst = 0;
|
525
|
$aliasesaddr = "";
|
526
|
if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
|
527
|
foreach($config['aliases']['alias'] as $alias_name) {
|
528
|
if(!stristr($alias_name['address'], ".")) {
|
529
|
if($isfirst == 1) $aliases .= ",";
|
530
|
$aliases .= "'" . $alias_name['name'] . "'";
|
531
|
$isfirst = 1;
|
532
|
} else {
|
533
|
if($addrisfirst == 1) $aliasesaddr .= ",";
|
534
|
$aliasesaddr .= "'" . $alias_name['name'] . "'";
|
535
|
$addrisfirst = 1;
|
536
|
}
|
537
|
}
|
538
|
?>
|
539
|
|
540
|
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
|
541
|
var customarray=new Array(<?php echo $aliases; ?>);
|
542
|
|
543
|
window.onload = function () {
|
544
|
|
545
|
<?php
|
546
|
$counter=0;
|
547
|
foreach($inputaliases as $alias) {
|
548
|
echo "var oTextbox$counter = new AutoSuggestControl(document.getElementById(\"$alias\"), new StateSuggestions(addressarray));\n";
|
549
|
$counter++;
|
550
|
}
|
551
|
?>
|
552
|
|
553
|
}
|
554
|
|
555
|
//-->
|
556
|
</script>
|
557
|
<script type="text/javascript">
|
558
|
NiftyCheck();
|
559
|
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
|
560
|
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
|
561
|
</script>
|
562
|
|
563
|
<?php
|
564
|
|
565
|
$fieldnames_array = Array();
|
566
|
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
|
567
|
// create a fieldname loop that can be used with javascript
|
568
|
// hide and enable features.
|
569
|
echo "\n<script type=\"text/javascript\">\n";
|
570
|
echo "function disableall() {\n";
|
571
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
572
|
if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
|
573
|
if(!$field['donotdisable'] <> "") {
|
574
|
array_push($fieldnames_array, $field['name']);
|
575
|
$fieldname = ereg_replace(" ", "", $field['name']);
|
576
|
$fieldname = strtolower($fieldname);
|
577
|
echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
|
578
|
}
|
579
|
}
|
580
|
}
|
581
|
echo "}\ndisableall();\n";
|
582
|
echo "function enableitems(selectedindex) {\n";
|
583
|
echo "disableall();\n";
|
584
|
$idcounter = 0;
|
585
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
586
|
echo "\tswitch(selectedindex) {\n";
|
587
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
588
|
if($field['options']['option'] <> "") {
|
589
|
foreach ($field['options']['option'] as $opt) {
|
590
|
if($opt['enablefields'] <> "") {
|
591
|
echo "\t\tcase " . $idcounter . ":\n";
|
592
|
$enablefields_split = split(",", $opt['enablefields']);
|
593
|
foreach ($enablefields_split as $efs) {
|
594
|
$fieldname = ereg_replace(" ", "", $efs);
|
595
|
$fieldname = strtolower($fieldname);
|
596
|
if($fieldname <> "") {
|
597
|
$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
|
598
|
echo $onchange;
|
599
|
}
|
600
|
}
|
601
|
echo "\t\t\tbreak;\n";
|
602
|
}
|
603
|
$idcounter = $idcounter + 1;
|
604
|
}
|
605
|
}
|
606
|
}
|
607
|
echo "\t}\n";
|
608
|
}
|
609
|
echo "}\n";
|
610
|
echo "disableall();\n";
|
611
|
echo "</script>\n\n";
|
612
|
}
|
613
|
|
614
|
|
615
|
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
|
616
|
// handle after form display event.
|
617
|
eval($pkg['step'][$stepid]['stepafterformdisplay']);
|
618
|
}
|
619
|
|
620
|
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
|
621
|
// handle after form display event.
|
622
|
echo "\n<script type=\"text/javascript\">\n";
|
623
|
echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
|
624
|
echo "</script>\n\n";
|
625
|
}
|
626
|
|
627
|
/*
|
628
|
* HELPER FUNCTIONS
|
629
|
*/
|
630
|
|
631
|
function fixup_string($string) {
|
632
|
global $config, $myurl;
|
633
|
$newstring = $string;
|
634
|
// fixup #1: $myurl -> http[s]://ip_address:port/
|
635
|
switch($config['system']['webgui']['protocol']) {
|
636
|
case "http":
|
637
|
$proto = "http";
|
638
|
break;
|
639
|
case "https":
|
640
|
$proto = "https";
|
641
|
break;
|
642
|
default:
|
643
|
$proto = "http";
|
644
|
break;
|
645
|
}
|
646
|
$port = $config['system']['webgui']['port'];
|
647
|
if($port != "") {
|
648
|
if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
|
649
|
$urlport = ":" . $port;
|
650
|
} elseif ($port != "80" and $port != "443") {
|
651
|
$urlport = ":" . $port;
|
652
|
} else {
|
653
|
$urlport = "";
|
654
|
}
|
655
|
}
|
656
|
$myurl = $proto . "://" . $_SERVER['HTTP_HOST'] . $urlport . "/";
|
657
|
$newstring = str_replace("\$myurl", $myurl, $newstring);
|
658
|
// fixup #2: $wanip
|
659
|
$curwanip = get_interface_ip();
|
660
|
$newstring = str_replace("\$wanip", $curwanip, $newstring);
|
661
|
// fixup #3: $lanip
|
662
|
$lanip = get_interface_ip("lan");
|
663
|
$newstring = str_replace("\$lanip", $lanip, $newstring);
|
664
|
// fixup #4: fix'r'up here.
|
665
|
return $newstring;
|
666
|
}
|
667
|
|
668
|
function is_timezone($elt) {
|
669
|
return !preg_match("/\/$/", $elt);
|
670
|
}
|
671
|
|
672
|
?>
|
673
|
|
674
|
</body>
|
675
|
</html>
|
676
|
|