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 |
6b07c15a
|
Matthew Grooms
|
##|+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 |
658292ef
|
Scott Ullrich
|
require("guiconfig.inc");
|
39 |
f9fc88cc
|
sullrich
|
require("functions.inc");
|
40 |
|
|
require("filter.inc");
|
41 |
|
|
require("shaper.inc");
|
42 |
|
|
require("rrd.inc");
|
43 |
658292ef
|
Scott Ullrich
|
|
44 |
|
|
function gentitle_pkg($pgname) {
|
45 |
2fbd6806
|
Scott Ullrich
|
global $config;
|
46 |
|
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
47 |
658292ef
|
Scott Ullrich
|
}
|
48 |
|
|
|
49 |
d8c1a6c5
|
Scott Ullrich
|
$stepid = htmlspecialchars($_GET['stepid']);
|
50 |
658292ef
|
Scott Ullrich
|
if (isset($_POST['stepid']))
|
51 |
d8c1a6c5
|
Scott Ullrich
|
$stepid = htmlspecialchars($_POST['stepid']);
|
52 |
2fbd6806
|
Scott Ullrich
|
if (!$stepid) $stepid = "0";
|
53 |
658292ef
|
Scott Ullrich
|
|
54 |
d8c1a6c5
|
Scott Ullrich
|
$xml = htmlspecialchars($_GET['xml']);
|
55 |
|
|
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
|
56 |
658292ef
|
Scott Ullrich
|
|
57 |
|
|
if($xml == "") {
|
58 |
bb0c9569
|
Bill Marquette
|
$xml = "not_defined";
|
59 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
60 |
|
|
die;
|
61 |
658292ef
|
Scott Ullrich
|
} else {
|
62 |
bd31336e
|
Scott Ullrich
|
if (file_exists("{$g['www_path']}/wizards/{$xml}"))
|
63 |
fc19d371
|
Scott Ullrich
|
$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
|
64 |
bb0c9569
|
Bill Marquette
|
else {
|
65 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
66 |
|
|
die;
|
67 |
|
|
}
|
68 |
658292ef
|
Scott Ullrich
|
}
|
69 |
|
|
|
70 |
|
|
$title = $pkg['step'][$stepid]['title'];
|
71 |
|
|
$description = $pkg['step'][$stepid]['description'];
|
72 |
46985f19
|
Scott Ullrich
|
$totalsteps = $pkg['totalsteps'];
|
73 |
658292ef
|
Scott Ullrich
|
|
74 |
bd31336e
|
Scott Ullrich
|
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
|
75 |
|
|
$timezonelist = array_filter($timezonelist, 'is_timezone');
|
76 |
|
|
sort($timezonelist);
|
77 |
|
|
|
78 |
98b5b72b
|
Scott Ullrich
|
/* kill carriage returns */
|
79 |
e881d1f3
|
Scott Ullrich
|
for($x=0; $x<count($timezonelist); $x++)
|
80 |
98b5b72b
|
Scott Ullrich
|
$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
|
81 |
|
|
|
82 |
b3f4e57c
|
Scott Ullrich
|
if ($pkg['step'][$stepid]['includefile'])
|
83 |
|
|
require($pkg['step'][$stepid]['includefile']);
|
84 |
|
|
|
85 |
e1e7a425
|
Scott Ullrich
|
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
|
86 |
|
|
eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
658292ef
|
Scott Ullrich
|
if ($_POST) {
|
90 |
e48fc17d
|
Scott Ullrich
|
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 |
46985f19
|
Scott Ullrich
|
if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
|
99 |
e48fc17d
|
Scott Ullrich
|
if($field['bindstofield'])
|
100 |
3f83de3d
|
Scott Ullrich
|
update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
|
101 |
658292ef
|
Scott Ullrich
|
}
|
102 |
3ed807e4
|
Scott Ullrich
|
|
103 |
2fbd6806
|
Scott Ullrich
|
}
|
104 |
3ed807e4
|
Scott Ullrich
|
// 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 |
e48fc17d
|
Scott Ullrich
|
$stepid++;
|
110 |
46985f19
|
Scott Ullrich
|
if($stepid > $totalsteps) $stepid = $totalsteps;
|
111 |
658292ef
|
Scott Ullrich
|
}
|
112 |
|
|
|
113 |
46985f19
|
Scott Ullrich
|
$title = $pkg['step'][$stepid]['title'];
|
114 |
|
|
$description = $pkg['step'][$stepid]['description'];
|
115 |
|
|
|
116 |
3f83de3d
|
Scott Ullrich
|
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
|
117 |
e48fc17d
|
Scott Ullrich
|
global $config;
|
118 |
|
|
$field_split = split("->",$field);
|
119 |
|
|
foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
|
120 |
|
|
if($field_conv == "") return;
|
121 |
3f83de3d
|
Scott Ullrich
|
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 |
496f9155
|
Scott Ullrich
|
}
|
130 |
e881d1f3
|
Scott Ullrich
|
|
131 |
496f9155
|
Scott Ullrich
|
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 |
e881d1f3
|
Scott Ullrich
|
|
139 |
e48fc17d
|
Scott Ullrich
|
if($unset <> "") {
|
140 |
|
|
$text = "unset(\$config" . $field_conv . ");";
|
141 |
|
|
eval($text);
|
142 |
46985f19
|
Scott Ullrich
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
143 |
e48fc17d
|
Scott Ullrich
|
eval($text);
|
144 |
|
|
} else {
|
145 |
46985f19
|
Scott Ullrich
|
if($arraynum <> "") {
|
146 |
|
|
$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
|
147 |
|
|
} else {
|
148 |
|
|
$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
149 |
|
|
}
|
150 |
e48fc17d
|
Scott Ullrich
|
eval($text);
|
151 |
|
|
}
|
152 |
658292ef
|
Scott Ullrich
|
}
|
153 |
|
|
|
154 |
34b5c5a0
|
Scott Ullrich
|
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 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array($title);
|
161 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
162 |
6bb5c9aa
|
Bill Marquette
|
|
163 |
4df96eff
|
Scott Ullrich
|
?>
|
164 |
fc7bea0e
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
|
165 |
4e3391a3
|
Scott Ullrich
|
|
166 |
8c01d3bb
|
Scott Ullrich
|
<?php
|
167 |
ba21539c
|
Scott Ullrich
|
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
|
168 |
8c01d3bb
|
Scott Ullrich
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
|
169 |
4e3391a3
|
Scott Ullrich
|
else
|
170 |
|
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
|
171 |
8c01d3bb
|
Scott Ullrich
|
?>
|
172 |
|
|
|
173 |
33a56b27
|
Colin Smith
|
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
|
174 |
44c10295
|
Scott Ullrich
|
<script type="text/javascript">
|
175 |
f9e35766
|
Scott Ullrich
|
<!--
|
176 |
38e7d556
|
Scott Ullrich
|
|
177 |
e881d1f3
|
Scott Ullrich
|
function FieldValidate(userinput, regexp, message)
|
178 |
|
|
{
|
179 |
|
|
if(!userinput.match(regexp))
|
180 |
|
|
alert(message);
|
181 |
|
|
}
|
182 |
38e7d556
|
Scott Ullrich
|
|
183 |
33a56b27
|
Colin Smith
|
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 |
e881d1f3
|
Scott Ullrich
|
}
|
215 |
33a56b27
|
Colin Smith
|
print "\t" . '}' . "\n";
|
216 |
|
|
}
|
217 |
|
|
}
|
218 |
|
|
?>
|
219 |
6bb5c9aa
|
Bill Marquette
|
}
|
220 |
|
|
//-->
|
221 |
|
|
</script>
|
222 |
33a56b27
|
Colin Smith
|
<?php } ?>
|
223 |
6bb5c9aa
|
Bill Marquette
|
|
224 |
33a56b27
|
Colin Smith
|
<form action="wizard.php" method="post" name="iform" id="iform">
|
225 |
658292ef
|
Scott Ullrich
|
<input type="hidden" name="xml" value="<?= $xml ?>">
|
226 |
e48fc17d
|
Scott Ullrich
|
<input type="hidden" name="stepid" value="<?= $stepid ?>">
|
227 |
658292ef
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
228 |
|
|
|
229 |
e48fc17d
|
Scott Ullrich
|
<center>
|
230 |
|
|
|
231 |
|
|
<br>
|
232 |
1c3d61fe
|
Scott Ullrich
|
|
233 |
fe2bfbfc
|
Scott Ullrich
|
<?php
|
234 |
1c3d61fe
|
Scott Ullrich
|
if($title == "Reload in progress") {
|
235 |
a55e9c70
|
Ermal Lu?i
|
$ip = "http://" . get_interface_ip("lan");
|
236 |
1c3d61fe
|
Scott Ullrich
|
} else {
|
237 |
fe2bfbfc
|
Scott Ullrich
|
$ip = "/";
|
238 |
1c3d61fe
|
Scott Ullrich
|
}
|
239 |
2576dace
|
Ermal Luçi
|
echo "<a href='$ip'>";
|
240 |
fe2bfbfc
|
Scott Ullrich
|
?>
|
241 |
1c3d61fe
|
Scott Ullrich
|
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
|
242 |
d51f86e0
|
Scott Ullrich
|
<p>
|
243 |
85dc4438
|
Scott Ullrich
|
<div style="width:700px;background-color:#ffffff" id="roundme">
|
244 |
50f60bca
|
Scott Ullrich
|
<table bgcolor="#ffffff" width="600" cellspacing="0" cellpadding="3">
|
245 |
34b5c5a0
|
Scott Ullrich
|
<!-- wizard goes here -->
|
246 |
|
|
<tr><td> </td></tr>
|
247 |
77851510
|
Scott Ullrich
|
<tr><td colspan='2'>
|
248 |
55b8d602
|
Scott Ullrich
|
<?php
|
249 |
|
|
if ($_GET['message'] != "")
|
250 |
d8c1a6c5
|
Scott Ullrich
|
print_info_box(htmlspecialchars($_GET['message']));
|
251 |
55b8d602
|
Scott Ullrich
|
if ($_POST['message'] != "")
|
252 |
d8c1a6c5
|
Scott Ullrich
|
print_info_box(htmlspecialchars($_POST['message']));
|
253 |
77851510
|
Scott Ullrich
|
?></td></tr>
|
254 |
d51f86e0
|
Scott Ullrich
|
<tr><td colspan='2'><center><b><?= fixup_string($description) ?></b></center></td></tr><tr><td> </td></tr>
|
255 |
34b5c5a0
|
Scott Ullrich
|
<?php
|
256 |
|
|
if(!$pkg['step'][$stepid]['disableheader'])
|
257 |
d51f86e0
|
Scott Ullrich
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
|
258 |
34b5c5a0
|
Scott Ullrich
|
?>
|
259 |
|
|
|
260 |
|
|
<?php
|
261 |
44c10295
|
Scott Ullrich
|
$inputaliases = array();
|
262 |
34b5c5a0
|
Scott Ullrich
|
if($pkg['step'][$stepid]['fields']['field'] <> "") {
|
263 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
264 |
|
|
|
265 |
|
|
$value = $field['value'];
|
266 |
2fbd6806
|
Scott Ullrich
|
$name = $field['name'];
|
267 |
658292ef
|
Scott Ullrich
|
|
268 |
2fbd6806
|
Scott Ullrich
|
$name = ereg_replace(" ", "", $name);
|
269 |
|
|
$name = strtolower($name);
|
270 |
658292ef
|
Scott Ullrich
|
|
271 |
a8df0181
|
Scott Ullrich
|
if($field['bindstofield'] <> "") {
|
272 |
b1919dd0
|
Scott Ullrich
|
$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 |
33a56b27
|
Colin Smith
|
if ($field['type'] == "checkbox") {
|
282 |
35fecd55
|
Scott Ullrich
|
$toeval = "if(isset(\$config" . $field_conv . $arraynum . ")) \$value = \" CHECKED\";";
|
283 |
f2ec2c48
|
Scott Ullrich
|
eval($toeval);
|
284 |
|
|
}
|
285 |
a8df0181
|
Scott Ullrich
|
}
|
286 |
|
|
|
287 |
34b5c5a0
|
Scott Ullrich
|
if(!$field['combinefieldsend'])
|
288 |
|
|
echo "<tr>";
|
289 |
|
|
|
290 |
|
|
if ($field['type'] == "input") {
|
291 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
292 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
293 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
294 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
295 |
|
|
} else if(!$field['dontdisplayname']) {
|
296 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
297 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
298 |
34b5c5a0
|
Scott Ullrich
|
echo ":</td>\n";
|
299 |
|
|
}
|
300 |
|
|
if(!$field['dontcombinecells'])
|
301 |
|
|
echo "<td class=\"vtable\">\n";
|
302 |
6bb5c9aa
|
Bill Marquette
|
|
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 |
62a48760
|
Scott Ullrich
|
|
308 |
|
|
|
309 |
e881d1f3
|
Scott Ullrich
|
|
310 |
62a48760
|
Scott Ullrich
|
} else if ($field['type'] == "inputalias") {
|
311 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
312 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
313 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
314 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
315 |
|
|
} else if(!$field['dontdisplayname']) {
|
316 |
62a48760
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
317 |
|
|
echo fixup_string($field['name']);
|
318 |
|
|
echo ":</td>\n";
|
319 |
44c10295
|
Scott Ullrich
|
$inputaliases[] = $name;
|
320 |
62a48760
|
Scott Ullrich
|
}
|
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 |
e881d1f3
|
Scott Ullrich
|
echo ">\n";
|
328 |
|
|
|
329 |
62a48760
|
Scott Ullrich
|
|
330 |
|
|
|
331 |
496f9155
|
Scott Ullrich
|
} 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 |
7a29f783
|
Ermal Lu?i
|
echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
|
337 |
496f9155
|
Scott Ullrich
|
echo "</td>";
|
338 |
|
|
echo "<td class=\"vtable\">\n";
|
339 |
7b4710f9
|
Scott Ullrich
|
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
|
340 |
496f9155
|
Scott Ullrich
|
if($field['multiple'] <> "" and $field['multiple'] <> "0") {
|
341 |
7b4710f9
|
Scott Ullrich
|
$multiple = "multiple=\"multiple\"";
|
342 |
496f9155
|
Scott Ullrich
|
$name .= "[]";
|
343 |
|
|
}
|
344 |
7b4710f9
|
Scott Ullrich
|
echo "<select id='{$name}' name='{$name}' {$size} {$multiple}>\n";
|
345 |
496f9155
|
Scott Ullrich
|
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 |
203de6bf
|
Ermal Lu?i
|
$interfaces = get_configured_interface_with_descr();
|
351 |
496f9155
|
Scott Ullrich
|
foreach ($interfaces as $ifname => $iface) {
|
352 |
|
|
$SELECTED = "";
|
353 |
aecffb0a
|
Scott Ullrich
|
if ($value == $ifname) $SELECTED = " SELECTED";
|
354 |
203de6bf
|
Ermal Lu?i
|
$to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $iface . "</option>\n";
|
355 |
496f9155
|
Scott Ullrich
|
$to_echo .= "<!-- {$value} -->";
|
356 |
|
|
$canecho = 0;
|
357 |
|
|
if($field['interface_filter'] <> "") {
|
358 |
203de6bf
|
Ermal Lu?i
|
if(stristr($ifname, $field['interface_filter']) == true)
|
359 |
496f9155
|
Scott Ullrich
|
$canecho = 1;
|
360 |
|
|
} else {
|
361 |
|
|
$canecho = 1;
|
362 |
|
|
}
|
363 |
e881d1f3
|
Scott Ullrich
|
if($canecho == 1)
|
364 |
496f9155
|
Scott Ullrich
|
echo $to_echo;
|
365 |
|
|
}
|
366 |
|
|
echo "</select>\n";
|
367 |
|
|
} else if ($field['type'] == "password") {
|
368 |
34b5c5a0
|
Scott Ullrich
|
if(!$field['dontdisplayname']) {
|
369 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
370 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
371 |
34b5c5a0
|
Scott Ullrich
|
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 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
378 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
379 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
380 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
381 |
|
|
} 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['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 |
46985f19
|
Scott Ullrich
|
$selected = "";
|
399 |
|
|
if($value == $opt['value']) $selected = " SELECTED";
|
400 |
d6f53204
|
Ermal Lu?i
|
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 |
34b5c5a0
|
Scott Ullrich
|
}
|
407 |
|
|
echo "</select>\n";
|
408 |
|
|
} else if ($field['type'] == "textarea") {
|
409 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
410 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
411 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
412 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
413 |
|
|
} else if(!$field['dontdisplayname']) {
|
414 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
415 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($field['name']);
|
416 |
34b5c5a0
|
Scott Ullrich
|
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 |
2fbd6806
|
Scott Ullrich
|
echo "<tr><td colspan='2'><center>";
|
424 |
|
|
echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
|
425 |
34b5c5a0
|
Scott Ullrich
|
} else if ($field['type'] == "listtopic") {
|
426 |
|
|
echo "<td> </td><tr>";
|
427 |
|
|
echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br></td>\n";
|
428 |
bd31336e
|
Scott Ullrich
|
} else if ($field['type'] == "subnet_select") {
|
429 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
430 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
431 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
432 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
433 |
|
|
} else if(!$field['dontdisplayname']) {
|
434 |
bd31336e
|
Scott Ullrich
|
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 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
450 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
451 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
452 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
453 |
|
|
} else if(!$field['dontdisplayname']) {
|
454 |
bd31336e
|
Scott Ullrich
|
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 |
34b5c5a0
|
Scott Ullrich
|
} else if ($field['type'] == "checkbox") {
|
470 |
7a29f783
|
Ermal Lu?i
|
if ($field['displayname']) {
|
471 |
|
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
472 |
d6f53204
|
Ermal Lu?i
|
echo $field['displayname'];
|
473 |
7a29f783
|
Ermal Lu?i
|
echo ":</td>\n";
|
474 |
|
|
} else if(!$field['dontdisplayname']) {
|
475 |
34b5c5a0
|
Scott Ullrich
|
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
|
476 |
|
|
echo $field['name'];
|
477 |
|
|
echo ":</td>";
|
478 |
|
|
}
|
479 |
|
|
$checked = "";
|
480 |
f2ec2c48
|
Scott Ullrich
|
if($value <> "") $checked = " CHECKED";
|
481 |
33a56b27
|
Colin Smith
|
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 |
34b5c5a0
|
Scott Ullrich
|
}
|
485 |
|
|
|
486 |
|
|
if($field['typehint'] <> "") {
|
487 |
|
|
echo $field['typehint'];
|
488 |
2fbd6806
|
Scott Ullrich
|
}
|
489 |
34b5c5a0
|
Scott Ullrich
|
|
490 |
788ff7cb
|
Scott Ullrich
|
if($field['description'] <> "") {
|
491 |
|
|
echo "<br>" . $field['description'];
|
492 |
34b5c5a0
|
Scott Ullrich
|
echo "</td>";
|
493 |
788ff7cb
|
Scott Ullrich
|
}
|
494 |
34b5c5a0
|
Scott Ullrich
|
|
495 |
|
|
if(!$field['combinefieldsbegin'])
|
496 |
|
|
echo "</tr>\n";
|
497 |
f3c6fdc0
|
Bill Marquette
|
|
498 |
|
|
if($field['warning'] <> "") {
|
499 |
|
|
echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
|
500 |
|
|
}
|
501 |
|
|
|
502 |
34b5c5a0
|
Scott Ullrich
|
}
|
503 |
|
|
}
|
504 |
|
|
?>
|
505 |
658292ef
|
Scott Ullrich
|
</table>
|
506 |
85dc4438
|
Scott Ullrich
|
<br>
|
507 |
5adb3375
|
Scott Ullrich
|
</div>
|
508 |
658292ef
|
Scott Ullrich
|
</form>
|
509 |
44c10295
|
Scott Ullrich
|
<script type="text/javascript">
|
510 |
62a48760
|
Scott Ullrich
|
<!--
|
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 |
5adb3375
|
Scott Ullrich
|
|
521 |
62a48760
|
Scott Ullrich
|
<?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 |
44c10295
|
Scott Ullrich
|
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 |
62a48760
|
Scott Ullrich
|
//-->
|
556 |
|
|
</script>
|
557 |
5adb3375
|
Scott Ullrich
|
<script type="text/javascript">
|
558 |
|
|
NiftyCheck();
|
559 |
e881d1f3
|
Scott Ullrich
|
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
|
560 |
|
|
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
|
561 |
5adb3375
|
Scott Ullrich
|
</script>
|
562 |
|
|
|
563 |
34b5c5a0
|
Scott Ullrich
|
<?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 |
44c10295
|
Scott Ullrich
|
echo "\n<script type=\"text/javascript\">\n";
|
570 |
34b5c5a0
|
Scott Ullrich
|
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 |
44c10295
|
Scott Ullrich
|
echo "\n<script type=\"text/javascript\">\n";
|
623 |
34b5c5a0
|
Scott Ullrich
|
echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
|
624 |
|
|
echo "</script>\n\n";
|
625 |
|
|
}
|
626 |
|
|
|
627 |
d51f86e0
|
Scott Ullrich
|
/*
|
628 |
|
|
* HELPER FUNCTIONS
|
629 |
|
|
*/
|
630 |
|
|
|
631 |
|
|
function fixup_string($string) {
|
632 |
a0190b50
|
Scott Ullrich
|
global $config, $myurl;
|
633 |
78818d7a
|
Scott Ullrich
|
$newstring = $string;
|
634 |
d51f86e0
|
Scott Ullrich
|
// fixup #1: $myurl -> http[s]://ip_address:port/
|
635 |
037304d8
|
Scott Ullrich
|
switch($config['system']['webguiproto']) {
|
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 |
d51f86e0
|
Scott Ullrich
|
$port = $config['system']['webguiport'];
|
647 |
037304d8
|
Scott Ullrich
|
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 |
a55e9c70
|
Ermal Lu?i
|
$myurl = $proto . "://" . get_interface_ip("lan") . $urlport . "/";
|
657 |
78818d7a
|
Scott Ullrich
|
$newstring = str_replace("\$myurl", $myurl, $newstring);
|
658 |
d2133701
|
Scott Ullrich
|
// fixup #2: $wanip
|
659 |
85a5da13
|
Ermal Luçi
|
$curwanip = get_interface_ip();
|
660 |
78818d7a
|
Scott Ullrich
|
$newstring = str_replace("\$wanip", $curwanip, $newstring);
|
661 |
d2133701
|
Scott Ullrich
|
// fixup #3: $lanip
|
662 |
a55e9c70
|
Ermal Lu?i
|
$lanip = get_interface_ip("lan");
|
663 |
78818d7a
|
Scott Ullrich
|
$newstring = str_replace("\$lanip", $lanip, $newstring);
|
664 |
d2133701
|
Scott Ullrich
|
// fixup #4: fix'r'up here.
|
665 |
d51f86e0
|
Scott Ullrich
|
return $newstring;
|
666 |
|
|
}
|
667 |
|
|
|
668 |
bd31336e
|
Scott Ullrich
|
function is_timezone($elt) {
|
669 |
|
|
return !preg_match("/\/$/", $elt);
|
670 |
|
|
}
|
671 |
d51f86e0
|
Scott Ullrich
|
|
672 |
c8000491
|
Scott Ullrich
|
?>
|
673 |
|
|
|
674 |
|
|
</body>
|
675 |
|
|
</html>
|