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 |
|
|
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 |
|
|
require("guiconfig.inc");
|
31 |
|
|
|
32 |
|
|
function gentitle_pkg($pgname) {
|
33 |
2fbd6806
|
Scott Ullrich
|
global $config;
|
34 |
|
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
35 |
658292ef
|
Scott Ullrich
|
}
|
36 |
|
|
|
37 |
|
|
$stepid = $_GET['stepid'];
|
38 |
|
|
if (isset($_POST['stepid']))
|
39 |
|
|
$stepid = $_POST['stepid'];
|
40 |
2fbd6806
|
Scott Ullrich
|
if (!$stepid) $stepid = "0";
|
41 |
658292ef
|
Scott Ullrich
|
|
42 |
|
|
// XXX: Make this input safe.
|
43 |
|
|
$xml = $_GET['xml'];
|
44 |
|
|
if($_POST['xml']) $xml = $_POST['xml'];
|
45 |
|
|
|
46 |
|
|
if($xml == "") {
|
47 |
bb0c9569
|
Bill Marquette
|
$xml = "not_defined";
|
48 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
49 |
|
|
die;
|
50 |
658292ef
|
Scott Ullrich
|
} else {
|
51 |
bd31336e
|
Scott Ullrich
|
if (file_exists("{$g['www_path']}/wizards/{$xml}"))
|
52 |
fc19d371
|
Scott Ullrich
|
$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
|
53 |
bb0c9569
|
Bill Marquette
|
else {
|
54 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
55 |
|
|
die;
|
56 |
|
|
}
|
57 |
658292ef
|
Scott Ullrich
|
}
|
58 |
|
|
|
59 |
|
|
$title = $pkg['step'][$stepid]['title'];
|
60 |
|
|
$description = $pkg['step'][$stepid]['description'];
|
61 |
46985f19
|
Scott Ullrich
|
$totalsteps = $pkg['totalsteps'];
|
62 |
658292ef
|
Scott Ullrich
|
|
63 |
bd31336e
|
Scott Ullrich
|
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
|
64 |
|
|
$timezonelist = array_filter($timezonelist, 'is_timezone');
|
65 |
|
|
sort($timezonelist);
|
66 |
|
|
|
67 |
e1e7a425
|
Scott Ullrich
|
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
|
68 |
|
|
eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
658292ef
|
Scott Ullrich
|
if ($_POST) {
|
72 |
e48fc17d
|
Scott Ullrich
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
73 |
|
|
if($field['bindstofield'] <> "" and $field['type'] <> "submit") {
|
74 |
|
|
$fieldname = $field['name'];
|
75 |
|
|
$unset_fields = "";
|
76 |
|
|
$fieldname = ereg_replace(" ", "", $fieldname);
|
77 |
|
|
$fieldname = strtolower($fieldname);
|
78 |
|
|
// update field with posted values.
|
79 |
|
|
if($field['unsetfield'] <> "") $unset_fields = "yes";
|
80 |
46985f19
|
Scott Ullrich
|
if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
|
81 |
e48fc17d
|
Scott Ullrich
|
if($field['bindstofield'])
|
82 |
3f83de3d
|
Scott Ullrich
|
update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
|
83 |
658292ef
|
Scott Ullrich
|
}
|
84 |
3ed807e4
|
Scott Ullrich
|
|
85 |
2fbd6806
|
Scott Ullrich
|
}
|
86 |
3ed807e4
|
Scott Ullrich
|
// run custom php code embedded in xml config.
|
87 |
|
|
if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
|
88 |
|
|
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
|
89 |
|
|
}
|
90 |
|
|
write_config();
|
91 |
e48fc17d
|
Scott Ullrich
|
$stepid++;
|
92 |
46985f19
|
Scott Ullrich
|
if($stepid > $totalsteps) $stepid = $totalsteps;
|
93 |
658292ef
|
Scott Ullrich
|
}
|
94 |
|
|
|
95 |
46985f19
|
Scott Ullrich
|
$title = $pkg['step'][$stepid]['title'];
|
96 |
|
|
$description = $pkg['step'][$stepid]['description'];
|
97 |
|
|
|
98 |
3f83de3d
|
Scott Ullrich
|
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
|
99 |
e48fc17d
|
Scott Ullrich
|
global $config;
|
100 |
|
|
$field_split = split("->",$field);
|
101 |
|
|
foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
|
102 |
|
|
if($field_conv == "") return;
|
103 |
3f83de3d
|
Scott Ullrich
|
if($field_type == "checkbox" and $updatetext <> "on") {
|
104 |
|
|
/*
|
105 |
|
|
item is a checkbox, it should have the value "on"
|
106 |
|
|
if it was checked
|
107 |
|
|
*/
|
108 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
109 |
|
|
eval($text);
|
110 |
|
|
return;
|
111 |
496f9155
|
Scott Ullrich
|
}
|
112 |
|
|
|
113 |
|
|
if($field_type == "interfaces_selection") {
|
114 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
115 |
|
|
eval($text);
|
116 |
|
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
117 |
|
|
eval($text);
|
118 |
|
|
return;
|
119 |
|
|
}
|
120 |
|
|
|
121 |
e48fc17d
|
Scott Ullrich
|
if($unset <> "") {
|
122 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
123 |
|
|
eval($text);
|
124 |
46985f19
|
Scott Ullrich
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
125 |
e48fc17d
|
Scott Ullrich
|
eval($text);
|
126 |
|
|
} else {
|
127 |
46985f19
|
Scott Ullrich
|
if($arraynum <> "") {
|
128 |
|
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
129 |
|
|
} else {
|
130 |
|
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
131 |
|
|
}
|
132 |
e48fc17d
|
Scott Ullrich
|
eval($text);
|
133 |
|
|
}
|
134 |
658292ef
|
Scott Ullrich
|
}
|
135 |
|
|
|
136 |
34b5c5a0
|
Scott Ullrich
|
if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") {
|
137 |
|
|
// handle before form display event.
|
138 |
|
|
// good for modifying posted values, etc.
|
139 |
|
|
eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
|
140 |
|
|
}
|
141 |
|
|
|
142 |
4df96eff
|
Scott Ullrich
|
$pgtitle = $title;
|
143 |
|
|
include("head.inc");
|
144 |
6bb5c9aa
|
Bill Marquette
|
|
145 |
4df96eff
|
Scott Ullrich
|
?>
|
146 |
fc7bea0e
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
|
147 |
33a56b27
|
Colin Smith
|
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
|
148 |
|
|
<script language="JavaScript">
|
149 |
f9e35766
|
Scott Ullrich
|
<!--
|
150 |
38e7d556
|
Scott Ullrich
|
|
151 |
|
|
function FieldValidate(userinput, regexp, message)
|
152 |
|
|
{
|
153 |
|
|
if(!userinput.match(regexp))
|
154 |
|
|
alert(message);
|
155 |
|
|
}
|
156 |
|
|
|
157 |
33a56b27
|
Colin Smith
|
function enablechange() {
|
158 |
|
|
<?php
|
159 |
|
|
foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
|
160 |
|
|
if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
|
161 |
|
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
|
162 |
|
|
if(isset($field['enablefields'])) {
|
163 |
|
|
$enablefields = explode(',', $field['enablefields']);
|
164 |
|
|
foreach($enablefields as $enablefield) {
|
165 |
|
|
$enablefield = strtolower($enablefield);
|
166 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
if(isset($field['checkenablefields'])) {
|
170 |
|
|
$checkenablefields = explode(',', $field['checkenablefields']);
|
171 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
172 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
173 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
|
174 |
|
|
}
|
175 |
|
|
}
|
176 |
|
|
print "\t" . '} else {' . "\n";
|
177 |
|
|
if(isset($field['enablefields'])) {
|
178 |
|
|
foreach($enablefields as $enablefield) {
|
179 |
|
|
$enablefield = strtolower($enablefield);
|
180 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
|
181 |
|
|
}
|
182 |
|
|
}
|
183 |
|
|
if(isset($field['checkenablefields'])) {
|
184 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
185 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
186 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
|
|
print "\t" . '}' . "\n";
|
190 |
|
|
}
|
191 |
|
|
}
|
192 |
|
|
?>
|
193 |
6bb5c9aa
|
Bill Marquette
|
}
|
194 |
|
|
//-->
|
195 |
|
|
</script>
|
196 |
33a56b27
|
Colin Smith
|
<?php } ?>
|
197 |
6bb5c9aa
|
Bill Marquette
|
|
198 |
33a56b27
|
Colin Smith
|
<form action="wizard.php" method="post" name="iform" id="iform">
|
199 |
658292ef
|
Scott Ullrich
|
<input type="hidden" name="xml" value="<?= $xml ?>">
|
200 |
e48fc17d
|
Scott Ullrich
|
<input type="hidden" name="stepid" value="<?= $stepid ?>">
|
201 |
658292ef
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
202 |
|
|
|
203 |
e48fc17d
|
Scott Ullrich
|
<center>
|
204 |
|
|
|
205 |
|
|
<br>
|
206 |
fe2bfbfc
|
Scott Ullrich
|
<?php
|
207 |
|
|
if($title == "Reload in progress")
|
208 |
d1c844e1
|
Scott Ullrich
|
$ip = "http://{$config['interfaces']['lan']['ipaddr']}";
|
209 |
fe2bfbfc
|
Scott Ullrich
|
else
|
210 |
|
|
$ip = "/";
|
211 |
77851510
|
Scott Ullrich
|
|
212 |
fe2bfbfc
|
Scott Ullrich
|
?>
|
213 |
e48fc17d
|
Scott Ullrich
|
|
214 |
fe2bfbfc
|
Scott Ullrich
|
<a href="<?php echo $ip; ?>"><img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
|
215 |
d51f86e0
|
Scott Ullrich
|
<p>
|
216 |
85dc4438
|
Scott Ullrich
|
<div style="width:700px;background-color:#ffffff" id="roundme">
|
217 |
50f60bca
|
Scott Ullrich
|
<table bgcolor="#ffffff" width="600" cellspacing="0" cellpadding="3">
|
218 |
34b5c5a0
|
Scott Ullrich
|
<!-- wizard goes here -->
|
219 |
|
|
<tr><td> </td></tr>
|
220 |
77851510
|
Scott Ullrich
|
<tr><td colspan='2'>
|
221 |
|
|
<?php if ($_GET['message'] != "") {
|
222 |
|
|
print_info_box($_GET['message']);
|
223 |
|
|
}
|
224 |
|
|
?></td></tr>
|
225 |
d51f86e0
|
Scott Ullrich
|
<tr><td colspan='2'><center><b><?= fixup_string($description) ?></b></center></td></tr><tr><td> </td></tr>
|
226 |
34b5c5a0
|
Scott Ullrich
|
<?php
|
227 |
|
|
if(!$pkg['step'][$stepid]['disableheader'])
|
228 |
d51f86e0
|
Scott Ullrich
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
|
229 |
34b5c5a0
|
Scott Ullrich
|
?>
|
230 |
|
|
|
231 |
|
|
<?php
|
232 |
|
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
233 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
234 |
|
|
|
235 |
|
|
$value = $field['value'];
|
236 |
2fbd6806
|
Scott Ullrich
|
$name = $field['name'];
|
237 |
658292ef
|
Scott Ullrich
|
|
238 |
2fbd6806
|
Scott Ullrich
|
$name = ereg_replace(" ", "", $name);
|
239 |
|
|
$name = strtolower($name);
|
240 |
658292ef
|
Scott Ullrich
|
|
241 |
a8df0181
|
Scott Ullrich
|
if($field['bindstofield'] <> "") {
|
242 |
b1919dd0
|
Scott Ullrich
|
$arraynum = "";
|
243 |
|
|
$field_conv = "";
|
244 |
|
|
$field_split = split("->", $field['bindstofield']);
|
245 |
|
|
// arraynum is used in cases where there is an array of the same field
|
246 |
|
|
// name such as dnsserver (2 of them)
|
247 |
|
|
if($field['arraynum'] <> "") $arraynum = "[" . $field['arraynum'] . "]";
|
248 |
|
|
foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
|
249 |
|
|
$toeval = "\$value = \$config" . $field_conv . $arraynum . ";";
|
250 |
|
|
eval($toeval);
|
251 |
33a56b27
|
Colin Smith
|
if ($field['type'] == "checkbox") {
|
252 |
35fecd55
|
Scott Ullrich
|
$toeval = "if(isset(\$config" . $field_conv . $arraynum . ")) \$value = \" CHECKED\";";
|
253 |
f2ec2c48
|
Scott Ullrich
|
eval($toeval);
|
254 |
|
|
}
|
255 |
a8df0181
|
Scott Ullrich
|
}
|
256 |
|
|
|
257 |
34b5c5a0
|
Scott Ullrich
|
if(!$field['combinefieldsend'])
|
258 |
|
|
echo "<tr>";
|
259 |
|
|
|
260 |
|
|
if ($field['type'] == "input") {
|
261 |
|
|
if(!$field['dontdisplayname']) {
|
262 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
263 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
264 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
265 |
|
|
}
|
266 |
|
|
if(!$field['dontcombinecells'])
|
267 |
|
|
echo "<td class=\"vtable\">\n";
|
268 |
6bb5c9aa
|
Bill Marquette
|
|
269 |
|
|
echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'";
|
270 |
|
|
if($field['validate'])
|
271 |
|
|
echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
|
272 |
|
|
echo ">\n";
|
273 |
496f9155
|
Scott Ullrich
|
} else if($field['type'] == "interfaces_selection") {
|
274 |
|
|
$size = "";
|
275 |
|
|
$multiple = "";
|
276 |
|
|
$name = strtolower($name);
|
277 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
278 |
7b4710f9
|
Scott Ullrich
|
echo fixup_string($field['name']) . ":\n";
|
279 |
496f9155
|
Scott Ullrich
|
echo "</td>";
|
280 |
|
|
echo "<td class=\"vtable\">\n";
|
281 |
7b4710f9
|
Scott Ullrich
|
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
|
282 |
496f9155
|
Scott Ullrich
|
if($field['multiple'] <> "" and $field['multiple'] <> "0") {
|
283 |
7b4710f9
|
Scott Ullrich
|
$multiple = "multiple=\"multiple\"";
|
284 |
496f9155
|
Scott Ullrich
|
$name .= "[]";
|
285 |
|
|
}
|
286 |
7b4710f9
|
Scott Ullrich
|
echo "<select id='{$name}' name='{$name}' {$size} {$multiple}>\n";
|
287 |
496f9155
|
Scott Ullrich
|
if($field['add_to_interfaces_selection'] <> "") {
|
288 |
|
|
$SELECTED = "";
|
289 |
|
|
if($field['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
|
290 |
|
|
echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
|
291 |
|
|
}
|
292 |
|
|
$interfaces = &$config['interfaces'];
|
293 |
|
|
if($field['all_interfaces'] <> "") {
|
294 |
|
|
$ints = split(" ", `/sbin/ifconfig -l`);
|
295 |
|
|
$interfaces = array();
|
296 |
|
|
foreach ($ints as $int) {
|
297 |
|
|
$interfaces[]['descr'] = $int;
|
298 |
|
|
$interfaces[] = $int;
|
299 |
|
|
}
|
300 |
|
|
}
|
301 |
|
|
foreach ($interfaces as $ifname => $iface) {
|
302 |
|
|
if ($iface['descr'])
|
303 |
|
|
$ifdescr = $iface['descr'];
|
304 |
|
|
else
|
305 |
|
|
$ifdescr = strtoupper($ifname);
|
306 |
|
|
$ifname = $iface['descr'];
|
307 |
|
|
$ip = "";
|
308 |
|
|
if($field['all_interfaces'] <> "") {
|
309 |
|
|
$ifdescr = $iface;
|
310 |
|
|
$ip = " " . find_interface_ip($iface);
|
311 |
|
|
}
|
312 |
|
|
$SELECTED = "";
|
313 |
|
|
if($value == $ifdescr) $SELECTED = " SELECTED";
|
314 |
|
|
$to_echo = "<option value='" . $ifdescr . "'" . $SELECTED . ">" . $ifdescr . $ip . "</option>\n";
|
315 |
|
|
$to_echo .= "<!-- {$value} -->";
|
316 |
|
|
$canecho = 0;
|
317 |
|
|
if($field['interface_filter'] <> "") {
|
318 |
|
|
if(stristr($iface, $field['interface_filter']) == true)
|
319 |
|
|
$canecho = 1;
|
320 |
|
|
} else {
|
321 |
|
|
$canecho = 1;
|
322 |
|
|
}
|
323 |
|
|
if($canecho == 1)
|
324 |
|
|
echo $to_echo;
|
325 |
|
|
}
|
326 |
|
|
echo "</select>\n";
|
327 |
|
|
} else if ($field['type'] == "password") {
|
328 |
34b5c5a0
|
Scott Ullrich
|
if(!$field['dontdisplayname']) {
|
329 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
330 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
331 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
332 |
|
|
}
|
333 |
|
|
if(!$field['dontcombinecells'])
|
334 |
|
|
echo "<td class=\"vtable\">";
|
335 |
|
|
echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "' type='password'>\n";
|
336 |
|
|
} else if ($field['type'] == "select") {
|
337 |
|
|
if(!$field['dontdisplayname']) {
|
338 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
339 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
340 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
341 |
|
|
}
|
342 |
|
|
if($field['size']) $size = " size='" . $field['size'] . "' ";
|
343 |
|
|
if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
|
344 |
|
|
if(!$field['dontcombinecells'])
|
345 |
|
|
echo "<td class=\"vtable\">\n";
|
346 |
|
|
$onchange = "";
|
347 |
|
|
foreach ($field['options']['option'] as $opt) {
|
348 |
|
|
if($opt['enablefields'] <> "") {
|
349 |
|
|
$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
|
350 |
|
|
}
|
351 |
|
|
}
|
352 |
|
|
echo "<select " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
|
353 |
|
|
foreach ($field['options']['option'] as $opt) {
|
354 |
46985f19
|
Scott Ullrich
|
$selected = "";
|
355 |
|
|
if($value == $opt['value']) $selected = " SELECTED";
|
356 |
34b5c5a0
|
Scott Ullrich
|
echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">" . $opt['name'] . "</option>\n";
|
357 |
|
|
}
|
358 |
|
|
echo "</select>\n";
|
359 |
|
|
} else if ($field['type'] == "textarea") {
|
360 |
|
|
if(!$field['dontdisplayname']) {
|
361 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
362 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
363 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>";
|
364 |
|
|
}
|
365 |
|
|
if(!$field['dontcombinecells'])
|
366 |
|
|
echo "<td class=\"vtable\">";
|
367 |
|
|
echo "<textarea id='" . $name . "' name='" . $name . ">" . $value . "</textarea>\n";
|
368 |
|
|
} else if ($field['type'] == "submit") {
|
369 |
|
|
echo "<td> <br></td></tr>";
|
370 |
2fbd6806
|
Scott Ullrich
|
echo "<tr><td colspan='2'><center>";
|
371 |
|
|
echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
|
372 |
34b5c5a0
|
Scott Ullrich
|
} else if ($field['type'] == "listtopic") {
|
373 |
|
|
echo "<td> </td><tr>";
|
374 |
|
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br></td>\n";
|
375 |
bd31336e
|
Scott Ullrich
|
} else if ($field['type'] == "subnet_select") {
|
376 |
|
|
if(!$field['dontdisplayname']) {
|
377 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
378 |
|
|
echo fixup_string($field['name']);
|
379 |
|
|
echo ":</td>";
|
380 |
|
|
}
|
381 |
|
|
if(!$field['dontcombinecells'])
|
382 |
|
|
echo "<td class=\"vtable\">";
|
383 |
|
|
echo "<select name='{$name}'>\n";
|
384 |
|
|
for($x=1; $x<33; $x++) {
|
385 |
|
|
$CHECKED = "";
|
386 |
|
|
if($value == $x) $CHECKED = " SELECTED";
|
387 |
|
|
if($x <> 31)
|
388 |
|
|
echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
|
389 |
|
|
}
|
390 |
|
|
echo "</select>\n";
|
391 |
|
|
} else if ($field['type'] == "timezone_select") {
|
392 |
|
|
if(!$field['dontdisplayname']) {
|
393 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
394 |
|
|
echo fixup_string($field['name']);
|
395 |
|
|
echo ":</td>";
|
396 |
|
|
}
|
397 |
|
|
if(!$field['dontcombinecells'])
|
398 |
|
|
echo "<td class=\"vtable\">";
|
399 |
|
|
echo "<select name='{$name}'>\n";
|
400 |
|
|
foreach ($timezonelist as $tz) {
|
401 |
|
|
$SELECTED = "";
|
402 |
|
|
if ($value == $tz) $SELECTED = " SELECTED";
|
403 |
|
|
echo "<option value='" . htmlspecialchars($tz) . "' {$SELECTED}>";
|
404 |
|
|
echo htmlspecialchars($tz);
|
405 |
|
|
echo "</option>\n";
|
406 |
|
|
}
|
407 |
|
|
echo "</select>\n";
|
408 |
34b5c5a0
|
Scott Ullrich
|
} else if ($field['type'] == "checkbox") {
|
409 |
|
|
if(!$field['dontdisplayname']) {
|
410 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
411 |
|
|
echo $field['name'];
|
412 |
|
|
echo ":</td>";
|
413 |
|
|
}
|
414 |
|
|
$checked = "";
|
415 |
f2ec2c48
|
Scott Ullrich
|
if($value <> "") $checked = " CHECKED";
|
416 |
33a56b27
|
Colin Smith
|
echo "<td class=\"vtable\"><input type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
|
417 |
|
|
if(isset($field['enablefields']) or isset($field['checkenablefields'])) echo " onClick=\"enablechange()\"";
|
418 |
|
|
echo ">\n";
|
419 |
34b5c5a0
|
Scott Ullrich
|
}
|
420 |
|
|
|
421 |
|
|
if($field['typehint'] <> "") {
|
422 |
|
|
echo $field['typehint'];
|
423 |
2fbd6806
|
Scott Ullrich
|
}
|
424 |
34b5c5a0
|
Scott Ullrich
|
|
425 |
788ff7cb
|
Scott Ullrich
|
if($field['description'] <> "") {
|
426 |
|
|
echo "<br>" . $field['description'];
|
427 |
34b5c5a0
|
Scott Ullrich
|
echo "</td>";
|
428 |
788ff7cb
|
Scott Ullrich
|
}
|
429 |
34b5c5a0
|
Scott Ullrich
|
|
430 |
|
|
if(!$field['combinefieldsbegin'])
|
431 |
|
|
echo "</tr>\n";
|
432 |
f3c6fdc0
|
Bill Marquette
|
|
433 |
|
|
if($field['warning'] <> "") {
|
434 |
|
|
echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
|
435 |
|
|
}
|
436 |
|
|
|
437 |
34b5c5a0
|
Scott Ullrich
|
}
|
438 |
|
|
}
|
439 |
|
|
?>
|
440 |
658292ef
|
Scott Ullrich
|
</table>
|
441 |
85dc4438
|
Scott Ullrich
|
<br>
|
442 |
5adb3375
|
Scott Ullrich
|
</div>
|
443 |
658292ef
|
Scott Ullrich
|
</form>
|
444 |
5adb3375
|
Scott Ullrich
|
|
445 |
|
|
<script type="text/javascript">
|
446 |
|
|
NiftyCheck();
|
447 |
b39d4999
|
Scott Ullrich
|
Rounded("div#roundme","all","#333333","#FFFFFF","smooth");
|
448 |
5adb3375
|
Scott Ullrich
|
</script>
|
449 |
|
|
|
450 |
658292ef
|
Scott Ullrich
|
</body>
|
451 |
|
|
</html>
|
452 |
34b5c5a0
|
Scott Ullrich
|
|
453 |
|
|
<?php
|
454 |
|
|
|
455 |
|
|
$fieldnames_array = Array();
|
456 |
|
|
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
|
457 |
|
|
// create a fieldname loop that can be used with javascript
|
458 |
|
|
// hide and enable features.
|
459 |
|
|
echo "\n<script language=\"JavaScript\">\n";
|
460 |
|
|
echo "function disableall() {\n";
|
461 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
462 |
|
|
if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
|
463 |
|
|
if(!$field['donotdisable'] <> "") {
|
464 |
|
|
array_push($fieldnames_array, $field['name']);
|
465 |
|
|
$fieldname = ereg_replace(" ", "", $field['name']);
|
466 |
|
|
$fieldname = strtolower($fieldname);
|
467 |
|
|
echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
|
468 |
|
|
}
|
469 |
|
|
}
|
470 |
|
|
}
|
471 |
|
|
echo "}\ndisableall();\n";
|
472 |
|
|
echo "function enableitems(selectedindex) {\n";
|
473 |
|
|
echo "disableall();\n";
|
474 |
|
|
$idcounter = 0;
|
475 |
|
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
476 |
|
|
echo "\tswitch(selectedindex) {\n";
|
477 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
478 |
|
|
if($field['options']['option'] <> "") {
|
479 |
|
|
foreach ($field['options']['option'] as $opt) {
|
480 |
|
|
if($opt['enablefields'] <> "") {
|
481 |
|
|
echo "\t\tcase " . $idcounter . ":\n";
|
482 |
|
|
$enablefields_split = split(",", $opt['enablefields']);
|
483 |
|
|
foreach ($enablefields_split as $efs) {
|
484 |
|
|
$fieldname = ereg_replace(" ", "", $efs);
|
485 |
|
|
$fieldname = strtolower($fieldname);
|
486 |
|
|
if($fieldname <> "") {
|
487 |
|
|
$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
|
488 |
|
|
echo $onchange;
|
489 |
|
|
}
|
490 |
|
|
}
|
491 |
|
|
echo "\t\t\tbreak;\n";
|
492 |
|
|
}
|
493 |
|
|
$idcounter = $idcounter + 1;
|
494 |
|
|
}
|
495 |
|
|
}
|
496 |
|
|
}
|
497 |
|
|
echo "\t}\n";
|
498 |
|
|
}
|
499 |
|
|
echo "}\n";
|
500 |
|
|
echo "disableall();\n";
|
501 |
|
|
echo "</script>\n\n";
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
|
506 |
|
|
// handle after form display event.
|
507 |
|
|
eval($pkg['step'][$stepid]['stepafterformdisplay']);
|
508 |
|
|
}
|
509 |
|
|
|
510 |
|
|
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
|
511 |
|
|
// handle after form display event.
|
512 |
|
|
echo "\n<script language=\"JavaScript\">\n";
|
513 |
|
|
echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
|
514 |
|
|
echo "</script>\n\n";
|
515 |
|
|
}
|
516 |
|
|
|
517 |
d51f86e0
|
Scott Ullrich
|
/*
|
518 |
|
|
* HELPER FUNCTIONS
|
519 |
|
|
*/
|
520 |
|
|
|
521 |
|
|
function fixup_string($string) {
|
522 |
a0190b50
|
Scott Ullrich
|
global $config, $myurl;
|
523 |
78818d7a
|
Scott Ullrich
|
$newstring = $string;
|
524 |
d51f86e0
|
Scott Ullrich
|
// fixup #1: $myurl -> http[s]://ip_address:port/
|
525 |
037304d8
|
Scott Ullrich
|
switch($config['system']['webguiproto']) {
|
526 |
|
|
case "http":
|
527 |
|
|
$proto = "http";
|
528 |
|
|
break;
|
529 |
|
|
case "https":
|
530 |
|
|
$proto = "https";
|
531 |
|
|
break;
|
532 |
|
|
default:
|
533 |
|
|
$proto = "http";
|
534 |
|
|
break;
|
535 |
|
|
}
|
536 |
d51f86e0
|
Scott Ullrich
|
$port = $config['system']['webguiport'];
|
537 |
037304d8
|
Scott Ullrich
|
if($port != "") {
|
538 |
|
|
if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
|
539 |
|
|
$urlport = ":" . $port;
|
540 |
|
|
} elseif ($port != "80" and $port != "443") {
|
541 |
|
|
$urlport = ":" . $port;
|
542 |
|
|
} else {
|
543 |
|
|
$urlport = "";
|
544 |
|
|
}
|
545 |
|
|
}
|
546 |
|
|
$myurl = $proto . "://" . $config['interfaces']['lan']['ipaddr'] . $urlport . "/";
|
547 |
78818d7a
|
Scott Ullrich
|
$newstring = str_replace("\$myurl", $myurl, $newstring);
|
548 |
d2133701
|
Scott Ullrich
|
// fixup #2: $wanip
|
549 |
|
|
$curwanip = get_current_wan_address();
|
550 |
78818d7a
|
Scott Ullrich
|
$newstring = str_replace("\$wanip", $curwanip, $newstring);
|
551 |
d2133701
|
Scott Ullrich
|
// fixup #3: $lanip
|
552 |
78818d7a
|
Scott Ullrich
|
$lanip = $config['interfaces']['lan']['ipaddr'];
|
553 |
|
|
$newstring = str_replace("\$lanip", $lanip, $newstring);
|
554 |
d2133701
|
Scott Ullrich
|
// fixup #4: fix'r'up here.
|
555 |
d51f86e0
|
Scott Ullrich
|
return $newstring;
|
556 |
|
|
}
|
557 |
|
|
|
558 |
bd31336e
|
Scott Ullrich
|
function is_timezone($elt) {
|
559 |
|
|
return !preg_match("/\/$/", $elt);
|
560 |
|
|
}
|
561 |
d51f86e0
|
Scott Ullrich
|
|
562 |
037304d8
|
Scott Ullrich
|
?>
|