1 |
658292ef
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
1e2d831c
|
Renato Botelho
|
wizard.php
|
4 |
658292ef
|
Scott Ullrich
|
*/
|
5 |
4e43ef22
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
|
|
*
|
8 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
9 |
|
|
* 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
|
16 |
|
|
* the documentation and/or other materials provided with the
|
17 |
|
|
* distribution.
|
18 |
|
|
*
|
19 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
20 |
|
|
* must display the following acknowledgment:
|
21 |
|
|
* "This product includes software developed by the pfSense Project
|
22 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
23 |
|
|
*
|
24 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
25 |
|
|
* endorse or promote products derived from this software without
|
26 |
|
|
* prior written permission. For written permission, please contact
|
27 |
|
|
* coreteam@pfsense.org.
|
28 |
|
|
*
|
29 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
30 |
|
|
* nor may "pfSense" appear in their names without prior written
|
31 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
32 |
|
|
*
|
33 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
34 |
|
|
* acknowledgment:
|
35 |
|
|
*
|
36 |
|
|
* "This product includes software developed by the pfSense Project
|
37 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
38 |
|
|
*
|
39 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
40 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
41 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
43 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
44 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
45 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
46 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
48 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
49 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
50 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
51 |
|
|
*
|
52 |
|
|
* ====================================================================
|
53 |
|
|
*
|
54 |
|
|
*/
|
55 |
658292ef
|
Scott Ullrich
|
|
56 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
57 |
|
|
##|*IDENT=page-pfsensewizardsubsystem
|
58 |
5230f468
|
jim-p
|
##|*NAME=pfSense wizard subsystem
|
59 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'pfSense wizard subsystem' page.
|
60 |
|
|
##|*MATCH=wizard.php*
|
61 |
|
|
##|-PRIV
|
62 |
|
|
|
63 |
fe4fc20b
|
Renato Botelho
|
require("globals.inc");
|
64 |
658292ef
|
Scott Ullrich
|
require("guiconfig.inc");
|
65 |
f9fc88cc
|
sullrich
|
require("functions.inc");
|
66 |
f6339216
|
jim-p
|
require_once("filter.inc");
|
67 |
f9fc88cc
|
sullrich
|
require("shaper.inc");
|
68 |
1b34f8a7
|
Ermal
|
require_once("rrd.inc");
|
69 |
60ff91f1
|
Renato Botelho
|
require_once("system.inc");
|
70 |
658292ef
|
Scott Ullrich
|
|
71 |
3d8c7228
|
Stephen Beaver
|
// This causes the step #, field type and field name to be printed at the top of the page
|
72 |
d190da6a
|
Stephen Beaver
|
define(DEBUG, false);
|
73 |
|
|
|
74 |
658292ef
|
Scott Ullrich
|
function gentitle_pkg($pgname) {
|
75 |
2fbd6806
|
Scott Ullrich
|
global $config;
|
76 |
|
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
77 |
658292ef
|
Scott Ullrich
|
}
|
78 |
|
|
|
79 |
fe4fc20b
|
Renato Botelho
|
global $g;
|
80 |
|
|
|
81 |
d8c1a6c5
|
Scott Ullrich
|
$stepid = htmlspecialchars($_GET['stepid']);
|
82 |
f566451e
|
Phil Davis
|
if (isset($_POST['stepid'])) {
|
83 |
1e2d831c
|
Renato Botelho
|
$stepid = htmlspecialchars($_POST['stepid']);
|
84 |
f566451e
|
Phil Davis
|
}
|
85 |
4e43ef22
|
Stephen Beaver
|
|
86 |
f566451e
|
Phil Davis
|
if (!$stepid) {
|
87 |
72a5f424
|
Ermal Lu?i
|
$stepid = "0";
|
88 |
f566451e
|
Phil Davis
|
}
|
89 |
658292ef
|
Scott Ullrich
|
|
90 |
d8c1a6c5
|
Scott Ullrich
|
$xml = htmlspecialchars($_GET['xml']);
|
91 |
f566451e
|
Phil Davis
|
if ($_POST['xml']) {
|
92 |
5a8a69b3
|
Ermal Lu?i
|
$xml = htmlspecialchars($_POST['xml']);
|
93 |
f566451e
|
Phil Davis
|
}
|
94 |
658292ef
|
Scott Ullrich
|
|
95 |
f566451e
|
Phil Davis
|
if (empty($xml)) {
|
96 |
bb0c9569
|
Bill Marquette
|
$xml = "not_defined";
|
97 |
185b9fbd
|
Renato Botelho
|
print_info_box_np(sprintf(gettext("ERROR: Could not open %s."), $xml));
|
98 |
bb0c9569
|
Bill Marquette
|
die;
|
99 |
658292ef
|
Scott Ullrich
|
} else {
|
100 |
44bcf766
|
jim-p
|
$wizard_xml_prefix = "{$g['www_path']}/wizards";
|
101 |
|
|
$wizard_full_path = "{$wizard_xml_prefix}/{$xml}";
|
102 |
|
|
if (substr_compare(realpath($wizard_full_path), $wizard_xml_prefix, 0, strlen($wizard_xml_prefix))) {
|
103 |
|
|
print_info_box_np(gettext("ERROR: Invalid path specified."));
|
104 |
|
|
die;
|
105 |
|
|
}
|
106 |
|
|
if (file_exists($wizard_full_path)) {
|
107 |
|
|
$pkg = parse_xml_config_pkg($wizard_full_path, "pfsensewizard");
|
108 |
f566451e
|
Phil Davis
|
} else {
|
109 |
185b9fbd
|
Renato Botelho
|
print_info_box_np(sprintf(gettext("ERROR: Could not open %s."), $xml));
|
110 |
bb0c9569
|
Bill Marquette
|
die;
|
111 |
|
|
}
|
112 |
658292ef
|
Scott Ullrich
|
}
|
113 |
|
|
|
114 |
5a8a69b3
|
Ermal Lu?i
|
if (!is_array($pkg)) {
|
115 |
6c07db48
|
Phil Davis
|
print_info_box_np(sprintf(gettext("ERROR: Could not parse %s/wizards/%s file."), $g['www_path'], $xml));
|
116 |
5a8a69b3
|
Ermal Lu?i
|
die;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
89dcfa01
|
Stephen Beaver
|
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
|
120 |
fe4fc20b
|
Renato Botelho
|
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
|
121 |
89dcfa01
|
Stephen Beaver
|
$totalsteps = $pkg['totalsteps'];
|
122 |
658292ef
|
Scott Ullrich
|
|
123 |
f566451e
|
Phil Davis
|
if ($pkg['includefile']) {
|
124 |
1e2d831c
|
Renato Botelho
|
require_once($pkg['includefile']);
|
125 |
f566451e
|
Phil Davis
|
}
|
126 |
2ca50c87
|
Ermal Lu?i
|
|
127 |
f566451e
|
Phil Davis
|
if ($pkg['step'][$stepid]['includefile']) {
|
128 |
5a8a69b3
|
Ermal Lu?i
|
require_once($pkg['step'][$stepid]['includefile']);
|
129 |
f566451e
|
Phil Davis
|
}
|
130 |
b3f4e57c
|
Scott Ullrich
|
|
131 |
f566451e
|
Phil Davis
|
if ($pkg['step'][$stepid]['stepsubmitbeforesave']) {
|
132 |
a314bebc
|
Ermal
|
eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
|
133 |
e1e7a425
|
Scott Ullrich
|
}
|
134 |
|
|
|
135 |
27319e17
|
jim-p
|
if ($_POST && !$input_errors) {
|
136 |
1e2d831c
|
Renato Botelho
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
137 |
89dcfa01
|
Stephen Beaver
|
if (!empty($field['bindstofield']) and $field['type'] != "submit") {
|
138 |
1e2d831c
|
Renato Botelho
|
$fieldname = $field['name'];
|
139 |
|
|
$fieldname = str_replace(" ", "", $fieldname);
|
140 |
|
|
$fieldname = strtolower($fieldname);
|
141 |
|
|
// update field with posted values.
|
142 |
89dcfa01
|
Stephen Beaver
|
if ($field['unsetfield'] != "") {
|
143 |
1e2d831c
|
Renato Botelho
|
$unset_fields = "yes";
|
144 |
f566451e
|
Phil Davis
|
} else {
|
145 |
1e2d831c
|
Renato Botelho
|
$unset_fields = "";
|
146 |
f566451e
|
Phil Davis
|
}
|
147 |
4e43ef22
|
Stephen Beaver
|
|
148 |
89dcfa01
|
Stephen Beaver
|
if ($field['arraynum'] != "") {
|
149 |
1e2d831c
|
Renato Botelho
|
$arraynum = $field['arraynum'];
|
150 |
f566451e
|
Phil Davis
|
} else {
|
151 |
1e2d831c
|
Renato Botelho
|
$arraynum = "";
|
152 |
f566451e
|
Phil Davis
|
}
|
153 |
1e2d831c
|
Renato Botelho
|
|
154 |
f566451e
|
Phil Davis
|
update_config_field($field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
|
155 |
1e2d831c
|
Renato Botelho
|
}
|
156 |
|
|
|
157 |
|
|
}
|
158 |
|
|
// run custom php code embedded in xml config.
|
159 |
89dcfa01
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['stepsubmitphpaction'] != "") {
|
160 |
3ed807e4
|
Scott Ullrich
|
eval($pkg['step'][$stepid]['stepsubmitphpaction']);
|
161 |
1e2d831c
|
Renato Botelho
|
}
|
162 |
f566451e
|
Phil Davis
|
if (!$input_errors) {
|
163 |
27319e17
|
jim-p
|
write_config();
|
164 |
f566451e
|
Phil Davis
|
}
|
165 |
4e43ef22
|
Stephen Beaver
|
|
166 |
1e2d831c
|
Renato Botelho
|
$stepid++;
|
167 |
f566451e
|
Phil Davis
|
if ($stepid > $totalsteps) {
|
168 |
1e2d831c
|
Renato Botelho
|
$stepid = $totalsteps;
|
169 |
f566451e
|
Phil Davis
|
}
|
170 |
658292ef
|
Scott Ullrich
|
}
|
171 |
|
|
|
172 |
3f83de3d
|
Scott Ullrich
|
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
|
173 |
eb20f3c5
|
Ermal Lu?i
|
global $config;
|
174 |
6c07db48
|
Phil Davis
|
$field_split = explode("->", $field);
|
175 |
f566451e
|
Phil Davis
|
foreach ($field_split as $f) {
|
176 |
72a5f424
|
Ermal Lu?i
|
$field_conv .= "['" . $f . "']";
|
177 |
f566451e
|
Phil Davis
|
}
|
178 |
|
|
if ($field_conv == "") {
|
179 |
72a5f424
|
Ermal Lu?i
|
return;
|
180 |
f566451e
|
Phil Davis
|
}
|
181 |
89dcfa01
|
Stephen Beaver
|
if ($arraynum != "") {
|
182 |
ddc75a80
|
Ermal
|
$field_conv .= "[" . $arraynum . "]";
|
183 |
f566451e
|
Phil Davis
|
}
|
184 |
89dcfa01
|
Stephen Beaver
|
if (($field_type == "checkbox" and $updatetext != "on") || $updatetext == "") {
|
185 |
3f83de3d
|
Scott Ullrich
|
/*
|
186 |
a4f07557
|
Ermal
|
* item is a checkbox, it should have the value "on"
|
187 |
|
|
* if it was checked
|
188 |
1e2d831c
|
Renato Botelho
|
*/
|
189 |
b4eb3a17
|
jim-p
|
$var = "\$config{$field_conv}";
|
190 |
|
|
$text = "if (isset({$var})) unset({$var});";
|
191 |
3f83de3d
|
Scott Ullrich
|
eval($text);
|
192 |
|
|
return;
|
193 |
496f9155
|
Scott Ullrich
|
}
|
194 |
e881d1f3
|
Scott Ullrich
|
|
195 |
f566451e
|
Phil Davis
|
if ($field_type == "interfaces_selection") {
|
196 |
b4eb3a17
|
jim-p
|
$var = "\$config{$field_conv}";
|
197 |
|
|
$text = "if (isset({$var})) unset({$var});";
|
198 |
389c778e
|
gnhb
|
$text .= "\$config" . $field_conv . " = \"" . $updatetext . "\";";
|
199 |
496f9155
|
Scott Ullrich
|
eval($text);
|
200 |
|
|
return;
|
201 |
|
|
}
|
202 |
e881d1f3
|
Scott Ullrich
|
|
203 |
f566451e
|
Phil Davis
|
if ($unset == "yes") {
|
204 |
e48fc17d
|
Scott Ullrich
|
$text = "unset(\$config" . $field_conv . ");";
|
205 |
|
|
eval($text);
|
206 |
|
|
}
|
207 |
9882cbef
|
jim-p
|
$text = "\$config" . $field_conv . " = \"" . addslashes($updatetext) . "\";";
|
208 |
a4f07557
|
Ermal
|
eval($text);
|
209 |
658292ef
|
Scott Ullrich
|
}
|
210 |
|
|
|
211 |
89dcfa01
|
Stephen Beaver
|
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
|
212 |
42f1649f
|
Erik Fonnesbeck
|
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
|
213 |
|
|
|
214 |
a314bebc
|
Ermal
|
// handle before form display event.
|
215 |
|
|
do {
|
216 |
|
|
$oldstepid = $stepid;
|
217 |
89dcfa01
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['stepbeforeformdisplay'] != "") {
|
218 |
a314bebc
|
Ermal
|
eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
|
219 |
f566451e
|
Phil Davis
|
}
|
220 |
a314bebc
|
Ermal
|
} while ($oldstepid != $stepid);
|
221 |
34b5c5a0
|
Scott Ullrich
|
|
222 |
6a11423f
|
Colin Fleming
|
$closehead = false;
|
223 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array($title);
|
224 |
89dcfa01
|
Stephen Beaver
|
$notitle = true;
|
225 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
226 |
6bb5c9aa
|
Bill Marquette
|
|
227 |
4e43ef22
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['fields']['field'] != "") { ?>
|
228 |
44c10295
|
Scott Ullrich
|
<script type="text/javascript">
|
229 |
6a11423f
|
Colin Fleming
|
//<![CDATA[
|
230 |
e79dc517
|
Stephen Beaver
|
|
231 |
|
|
|
232 |
89dcfa01
|
Stephen Beaver
|
function FieldValidate(userinput, regexp, message) {
|
233 |
|
|
if (!userinput.match(regexp)) {
|
234 |
|
|
alert(message);
|
235 |
|
|
}
|
236 |
f566451e
|
Phil Davis
|
}
|
237 |
38e7d556
|
Scott Ullrich
|
|
238 |
89dcfa01
|
Stephen Beaver
|
function enablechange() {
|
239 |
e79dc517
|
Stephen Beaver
|
|
240 |
89dcfa01
|
Stephen Beaver
|
<?php
|
241 |
e79dc517
|
Stephen Beaver
|
|
242 |
89dcfa01
|
Stephen Beaver
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
243 |
|
|
if (isset($field['enablefields']) or isset($field['checkenablefields'])) {
|
244 |
e79dc517
|
Stephen Beaver
|
print "\t" . 'if ( $("#" + "' . strtolower($field['name']) . '").prop("checked") ) {' . "\n";
|
245 |
|
|
|
246 |
89dcfa01
|
Stephen Beaver
|
if (isset($field['enablefields'])) {
|
247 |
|
|
$enablefields = explode(',', $field['enablefields']);
|
248 |
|
|
foreach ($enablefields as $enablefield) {
|
249 |
|
|
$enablefield = strtolower($enablefield);
|
250 |
e79dc517
|
Stephen Beaver
|
print "\t\t" . '$("#" + "' . $enablefield . '").prop("disabled", false);' . "\n";
|
251 |
89dcfa01
|
Stephen Beaver
|
}
|
252 |
1e2d831c
|
Renato Botelho
|
}
|
253 |
e79dc517
|
Stephen Beaver
|
|
254 |
89dcfa01
|
Stephen Beaver
|
if (isset($field['checkenablefields'])) {
|
255 |
|
|
$checkenablefields = explode(',', $field['checkenablefields']);
|
256 |
|
|
foreach ($checkenablefields as $checkenablefield) {
|
257 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
258 |
e79dc517
|
Stephen Beaver
|
print "\t\t" . '$("#" + "' . $checkenablefield . '").prop("checked", true);' . "\n";
|
259 |
89dcfa01
|
Stephen Beaver
|
}
|
260 |
1e2d831c
|
Renato Botelho
|
}
|
261 |
e79dc517
|
Stephen Beaver
|
|
262 |
89dcfa01
|
Stephen Beaver
|
print "\t" . '} else {' . "\n";
|
263 |
|
|
if (isset($field['enablefields'])) {
|
264 |
|
|
$enablefields = explode(',', $field['enablefields']);
|
265 |
|
|
foreach ($enablefields as $enablefield) {
|
266 |
|
|
$enablefield = strtolower($enablefield);
|
267 |
e79dc517
|
Stephen Beaver
|
print "\t\t" . '$("#" + "' . $enablefield . '").prop("disabled", true);' . "\n";
|
268 |
|
|
|
269 |
89dcfa01
|
Stephen Beaver
|
}
|
270 |
1e2d831c
|
Renato Botelho
|
}
|
271 |
e79dc517
|
Stephen Beaver
|
|
272 |
|
|
if (isset($field['checkdisablefields'])) {
|
273 |
|
|
$checkenablefields = explode(',', $field['checkdisablefields']);
|
274 |
|
|
foreach ($checkenablefields as $checkenablefield) {
|
275 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
276 |
|
|
print "\t\t" . '$("#" + "' . $checkenablefield . '").prop("checked", false);' . "\n";
|
277 |
89dcfa01
|
Stephen Beaver
|
}
|
278 |
1e2d831c
|
Renato Botelho
|
}
|
279 |
e79dc517
|
Stephen Beaver
|
|
280 |
89dcfa01
|
Stephen Beaver
|
print "\t" . '}' . "\n";
|
281 |
1e2d831c
|
Renato Botelho
|
}
|
282 |
|
|
}
|
283 |
89dcfa01
|
Stephen Beaver
|
?>
|
284 |
e79dc517
|
Stephen Beaver
|
|
285 |
1e2d831c
|
Renato Botelho
|
}
|
286 |
2465ff5b
|
Ermal
|
|
287 |
89dcfa01
|
Stephen Beaver
|
function disablechange() {
|
288 |
|
|
<?php
|
289 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
290 |
|
|
if (isset($field['disablefields']) or isset($field['checkdisablefields'])) {
|
291 |
e79dc517
|
Stephen Beaver
|
|
292 |
|
|
print "\t" . 'if ( $("#" + "' . strtolower($field['name']) . '").prop("checked") ) {' . "\n";
|
293 |
|
|
|
294 |
89dcfa01
|
Stephen Beaver
|
if (isset($field['disablefields'])) {
|
295 |
|
|
$enablefields = explode(',', $field['disablefields']);
|
296 |
|
|
foreach ($enablefields as $enablefield) {
|
297 |
|
|
$enablefield = strtolower($enablefield);
|
298 |
e79dc517
|
Stephen Beaver
|
|
299 |
|
|
print "\t\t" . '$("#" + "' . $enablefield . '").prop("disabled", true);' . "\n";
|
300 |
89dcfa01
|
Stephen Beaver
|
}
|
301 |
1e2d831c
|
Renato Botelho
|
}
|
302 |
89dcfa01
|
Stephen Beaver
|
if (isset($field['checkdisablefields'])) {
|
303 |
|
|
$checkenablefields = explode(',', $field['checkdisablefields']);
|
304 |
|
|
foreach ($checkenablefields as $checkenablefield) {
|
305 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
306 |
e79dc517
|
Stephen Beaver
|
print "\t\t" . '$("#" + "' . $checkenablefield . '").prop("checked", true);' . "\n";
|
307 |
89dcfa01
|
Stephen Beaver
|
}
|
308 |
1e2d831c
|
Renato Botelho
|
}
|
309 |
89dcfa01
|
Stephen Beaver
|
print "\t" . '} else {' . "\n";
|
310 |
|
|
if (isset($field['disablefields'])) {
|
311 |
|
|
$enablefields = explode(',', $field['disablefields']);
|
312 |
|
|
foreach ($enablefields as $enablefield) {
|
313 |
|
|
$enablefield = strtolower($enablefield);
|
314 |
e79dc517
|
Stephen Beaver
|
print "\t\t" . '$("#" + "' . $enablefield . '").prop("disabled", false);' . "\n";
|
315 |
89dcfa01
|
Stephen Beaver
|
}
|
316 |
1e2d831c
|
Renato Botelho
|
}
|
317 |
89dcfa01
|
Stephen Beaver
|
if (isset($field['checkdisablefields'])) {
|
318 |
|
|
$checkenablefields = explode(',', $field['checkdisablefields']);
|
319 |
|
|
foreach ($checkenablefields as $checkenablefield) {
|
320 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
321 |
e79dc517
|
Stephen Beaver
|
print "\t\t" . '$("#" + "' . $checkenablefield . '").prop("checked", false);' . "\n";
|
322 |
89dcfa01
|
Stephen Beaver
|
}
|
323 |
1e2d831c
|
Renato Botelho
|
}
|
324 |
89dcfa01
|
Stephen Beaver
|
print "\t" . '}' . "\n";
|
325 |
1e2d831c
|
Renato Botelho
|
}
|
326 |
|
|
}
|
327 |
89dcfa01
|
Stephen Beaver
|
?>
|
328 |
1e2d831c
|
Renato Botelho
|
}
|
329 |
1ae55320
|
Ermal
|
|
330 |
89dcfa01
|
Stephen Beaver
|
function showchange() {
|
331 |
2465ff5b
|
Ermal
|
<?php
|
332 |
89dcfa01
|
Stephen Beaver
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
333 |
f566451e
|
Phil Davis
|
if (isset($field['showfields'])) {
|
334 |
89dcfa01
|
Stephen Beaver
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
|
335 |
|
|
if (isset($field['showfields'])) {
|
336 |
|
|
$showfields = explode(',', $field['showfields']);
|
337 |
|
|
foreach ($showfields as $showfield) {
|
338 |
|
|
$showfield = strtolower($showfield);
|
339 |
|
|
//print "\t\t" . 'document.iform.' . $showfield . ".display =\"none\";\n";
|
340 |
|
|
print "\t\t jQuery('#". $showfield . "').hide();";
|
341 |
|
|
}
|
342 |
1e2d831c
|
Renato Botelho
|
}
|
343 |
89dcfa01
|
Stephen Beaver
|
print "\t" . '} else {' . "\n";
|
344 |
|
|
if (isset($field['showfields'])) {
|
345 |
|
|
$showfields = explode(',', $field['showfields']);
|
346 |
|
|
foreach ($showfields as $showfield) {
|
347 |
|
|
$showfield = strtolower($showfield);
|
348 |
|
|
#print "\t\t" . 'document.iform.' . $showfield . ".display =\"\";\n";
|
349 |
|
|
print "\t\t jQuery('#". $showfield . "').show();";
|
350 |
|
|
}
|
351 |
1e2d831c
|
Renato Botelho
|
}
|
352 |
89dcfa01
|
Stephen Beaver
|
print "\t" . '}' . "\n";
|
353 |
1e2d831c
|
Renato Botelho
|
}
|
354 |
|
|
}
|
355 |
2465ff5b
|
Ermal
|
?>
|
356 |
89dcfa01
|
Stephen Beaver
|
}
|
357 |
e79dc517
|
Stephen Beaver
|
|
358 |
6a11423f
|
Colin Fleming
|
//]]>
|
359 |
6bb5c9aa
|
Bill Marquette
|
</script>
|
360 |
89dcfa01
|
Stephen Beaver
|
<?php }
|
361 |
|
|
|
362 |
4e43ef22
|
Stephen Beaver
|
function fixup_string($string) {
|
363 |
|
|
global $config, $g, $myurl, $title;
|
364 |
|
|
$newstring = $string;
|
365 |
|
|
// fixup #1: $myurl -> http[s]://ip_address:port/
|
366 |
|
|
switch ($config['system']['webgui']['protocol']) {
|
367 |
|
|
case "http":
|
368 |
|
|
$proto = "http";
|
369 |
|
|
break;
|
370 |
|
|
case "https":
|
371 |
|
|
$proto = "https";
|
372 |
|
|
break;
|
373 |
|
|
default:
|
374 |
|
|
$proto = "http";
|
375 |
|
|
break;
|
376 |
|
|
}
|
377 |
|
|
$port = $config['system']['webgui']['port'];
|
378 |
|
|
if ($port != "") {
|
379 |
|
|
if (($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
|
380 |
|
|
$urlport = ":" . $port;
|
381 |
|
|
} elseif ($port != "80" and $port != "443") {
|
382 |
|
|
$urlport = ":" . $port;
|
383 |
|
|
} else {
|
384 |
|
|
$urlport = "";
|
385 |
|
|
}
|
386 |
|
|
}
|
387 |
89dcfa01
|
Stephen Beaver
|
|
388 |
4e43ef22
|
Stephen Beaver
|
$http_host = $_SERVER['SERVER_NAME'];
|
389 |
|
|
$urlhost = $http_host;
|
390 |
|
|
// If finishing the setup wizard, check if accessing on a LAN or WAN address that changed
|
391 |
f566451e
|
Phil Davis
|
if ($title == "Reload in progress") {
|
392 |
4e43ef22
|
Stephen Beaver
|
if (is_ipaddr($urlhost)) {
|
393 |
|
|
$host_if = find_ip_interface($urlhost);
|
394 |
|
|
if ($host_if) {
|
395 |
|
|
$host_if = convert_real_interface_to_friendly_interface_name($host_if);
|
396 |
|
|
if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr'])) {
|
397 |
|
|
$urlhost = $config['interfaces'][$host_if]['ipaddr'];
|
398 |
|
|
}
|
399 |
|
|
}
|
400 |
|
|
} else if ($urlhost == $config['system']['hostname']) {
|
401 |
|
|
$urlhost = $config['wizardtemp']['system']['hostname'];
|
402 |
|
|
} else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain']) {
|
403 |
|
|
$urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain'];
|
404 |
|
|
}
|
405 |
1c3d61fe
|
Scott Ullrich
|
}
|
406 |
4e43ef22
|
Stephen Beaver
|
|
407 |
|
|
if ($urlhost != $http_host) {
|
408 |
|
|
file_put_contents("{$g['tmp_path']}/setupwizard_lastreferrer", $proto . "://" . $http_host . $urlport . $_SERVER['REQUEST_URI']);
|
409 |
f566451e
|
Phil Davis
|
}
|
410 |
4e43ef22
|
Stephen Beaver
|
|
411 |
|
|
$myurl = $proto . "://" . $urlhost . $urlport . "/";
|
412 |
|
|
|
413 |
|
|
if (strstr($newstring, "\$myurl")) {
|
414 |
|
|
$newstring = str_replace("\$myurl", $myurl, $newstring);
|
415 |
f566451e
|
Phil Davis
|
}
|
416 |
4e43ef22
|
Stephen Beaver
|
// fixup #2: $wanip
|
417 |
|
|
if (strstr($newstring, "\$wanip")) {
|
418 |
|
|
$curwanip = get_interface_ip();
|
419 |
|
|
$newstring = str_replace("\$wanip", $curwanip, $newstring);
|
420 |
f566451e
|
Phil Davis
|
}
|
421 |
4e43ef22
|
Stephen Beaver
|
// fixup #3: $lanip
|
422 |
|
|
if (strstr($newstring, "\$lanip")) {
|
423 |
|
|
$lanip = get_interface_ip("lan");
|
424 |
|
|
$newstring = str_replace("\$lanip", $lanip, $newstring);
|
425 |
f566451e
|
Phil Davis
|
}
|
426 |
4e43ef22
|
Stephen Beaver
|
// fixup #4: fix'r'up here.
|
427 |
|
|
return $newstring;
|
428 |
|
|
}
|
429 |
89dcfa01
|
Stephen Beaver
|
|
430 |
4e43ef22
|
Stephen Beaver
|
function is_timezone($elt) {
|
431 |
|
|
return !preg_match("/\/$/", $elt);
|
432 |
|
|
}
|
433 |
|
|
|
434 |
|
|
if ($title == "Reload in progress") {
|
435 |
|
|
$ip = fixup_string("\$myurl");
|
436 |
|
|
} else {
|
437 |
|
|
$ip = "/";
|
438 |
|
|
}
|
439 |
|
|
|
440 |
|
|
if ($input_errors) {
|
441 |
|
|
print_input_errors($input_errors);
|
442 |
|
|
}
|
443 |
|
|
if ($savemsg) {
|
444 |
|
|
print_info_box($savemsg, 'success');
|
445 |
|
|
}
|
446 |
|
|
if ($_GET['message'] != "") {
|
447 |
|
|
print_info_box(htmlspecialchars($_GET['message']));
|
448 |
|
|
}
|
449 |
|
|
if ($_POST['message'] != "") {
|
450 |
|
|
print_info_box(htmlspecialchars($_POST['message']));
|
451 |
|
|
}
|
452 |
|
|
|
453 |
|
|
$completion = ($stepid == 0) ? 0:($stepid * 100) / ($totalsteps -1);
|
454 |
94017670
|
Ermal
|
?>
|
455 |
4e43ef22
|
Stephen Beaver
|
|
456 |
|
|
<!-- Present the pfSense logo -->
|
457 |
40547fe4
|
Stephen Beaver
|
<div style="text-align:center"><p><a href="<?=$ip?>"><img border="0" src="logo-black.png" alt="logo-black" align="middle" height="45" width="180" /></a></p></div><br /><br/>
|
458 |
4e43ef22
|
Stephen Beaver
|
|
459 |
|
|
<!-- Draw a progress bar to show step progress -->
|
460 |
|
|
<div class="progress">
|
461 |
|
|
<div class="progress-bar" role="progressbar" aria-valuenow="<?=$completion?>" aria-valuemin="0" aria-valuemax="100" style="width:<?=$completion?>%">
|
462 |
|
|
</div>
|
463 |
|
|
</div>
|
464 |
|
|
|
465 |
1e2d831c
|
Renato Botelho
|
<?php
|
466 |
89dcfa01
|
Stephen Beaver
|
|
467 |
4e43ef22
|
Stephen Beaver
|
$form = new Form(false);
|
468 |
89dcfa01
|
Stephen Beaver
|
|
469 |
4e43ef22
|
Stephen Beaver
|
$form->addGlobal(new Form_Input(
|
470 |
|
|
'stepid',
|
471 |
|
|
null,
|
472 |
|
|
'hidden',
|
473 |
|
|
$stepid
|
474 |
|
|
));
|
475 |
34b5c5a0
|
Scott Ullrich
|
|
476 |
4e43ef22
|
Stephen Beaver
|
$form->addGlobal(new Form_Input(
|
477 |
|
|
'xml',
|
478 |
|
|
null,
|
479 |
|
|
'hidden',
|
480 |
|
|
$xml
|
481 |
|
|
));
|
482 |
34b5c5a0
|
Scott Ullrich
|
|
483 |
4e43ef22
|
Stephen Beaver
|
$section = new Form_Section(fixup_string($title));
|
484 |
658292ef
|
Scott Ullrich
|
|
485 |
c86c14dc
|
Phil Davis
|
if ($description) {
|
486 |
4e43ef22
|
Stephen Beaver
|
$section->addInput(new Form_StaticText(
|
487 |
|
|
null,
|
488 |
|
|
fixup_string($description)
|
489 |
|
|
));
|
490 |
|
|
}
|
491 |
658292ef
|
Scott Ullrich
|
|
492 |
4e43ef22
|
Stephen Beaver
|
$inputaliases = array();
|
493 |
|
|
if ($pkg['step'][$stepid]['fields']['field'] != "") {
|
494 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
495 |
|
|
|
496 |
|
|
$value = $field['value'];
|
497 |
|
|
$name = $field['name'];
|
498 |
89dcfa01
|
Stephen Beaver
|
|
499 |
4e43ef22
|
Stephen Beaver
|
$name = preg_replace("/\s+/", "", $name);
|
500 |
|
|
$name = strtolower($name);
|
501 |
|
|
|
502 |
|
|
if ($field['bindstofield'] != "") {
|
503 |
|
|
$arraynum = "";
|
504 |
|
|
$field_conv = "";
|
505 |
|
|
$field_split = explode("->", $field['bindstofield']);
|
506 |
|
|
// arraynum is used in cases where there is an array of the same field
|
507 |
|
|
// name such as dnsserver (2 of them)
|
508 |
|
|
if ($field['arraynum'] != "") {
|
509 |
|
|
$arraynum = "[" . $field['arraynum'] . "]";
|
510 |
1e2d831c
|
Renato Botelho
|
}
|
511 |
4e43ef22
|
Stephen Beaver
|
|
512 |
|
|
foreach ($field_split as $f) {
|
513 |
|
|
$field_conv .= "['" . $f . "']";
|
514 |
f566451e
|
Phil Davis
|
}
|
515 |
4e43ef22
|
Stephen Beaver
|
|
516 |
|
|
if ($field['type'] == "checkbox") {
|
517 |
|
|
$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) { \$value = \$config" . $field_conv . $arraynum . "; if (empty(\$value)) \$value = true; }";
|
518 |
|
|
} else {
|
519 |
|
|
$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) \$value = \$config" . $field_conv . $arraynum . ";";
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
eval($toeval);
|
523 |
|
|
}
|
524 |
|
|
|
525 |
d190da6a
|
Stephen Beaver
|
|
526 |
c86c14dc
|
Phil Davis
|
if (DEBUG) {
|
527 |
d190da6a
|
Stephen Beaver
|
print('Step: ' . $pkg['step'][$stepid]['id'] . ', Field: ' . $field['type'] . ', Name: ' . $name . '<br />');
|
528 |
|
|
}
|
529 |
|
|
|
530 |
4e43ef22
|
Stephen Beaver
|
switch ($field['type']) {
|
531 |
1e2d831c
|
Renato Botelho
|
case "input":
|
532 |
|
|
if ($field['displayname']) {
|
533 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
534 |
|
|
|
535 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
536 |
89dcfa01
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
537 |
1e2d831c
|
Renato Botelho
|
}
|
538 |
89dcfa01
|
Stephen Beaver
|
|
539 |
|
|
$section->addInput(new Form_Input(
|
540 |
|
|
$name,
|
541 |
|
|
$etitle,
|
542 |
|
|
'text',
|
543 |
|
|
$value
|
544 |
|
|
))->setHelp($field['description'])
|
545 |
16fd8f4a
|
Stephen Beaver
|
->setOnchange(($field['validate']) ? "FieldValidate(this.value, " . $field['validate'] . ", " . $field['message'] . ")":"");
|
546 |
89dcfa01
|
Stephen Beaver
|
|
547 |
1e2d831c
|
Renato Botelho
|
break;
|
548 |
|
|
case "text":
|
549 |
89dcfa01
|
Stephen Beaver
|
$section->addInput(new Form_StaticText(
|
550 |
|
|
null,
|
551 |
|
|
$field['description']
|
552 |
|
|
));
|
553 |
4e43ef22
|
Stephen Beaver
|
|
554 |
1e2d831c
|
Renato Botelho
|
break;
|
555 |
|
|
case "inputalias":
|
556 |
|
|
if ($field['displayname']) {
|
557 |
4e43ef22
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
558 |
|
|
|
559 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
560 |
4e43ef22
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
561 |
f566451e
|
Phil Davis
|
}
|
562 |
1e2d831c
|
Renato Botelho
|
|
563 |
4e43ef22
|
Stephen Beaver
|
$onchange = "";
|
564 |
|
|
|
565 |
f566451e
|
Phil Davis
|
if ($field['validate']) {
|
566 |
16fd8f4a
|
Stephen Beaver
|
$onchange="FieldValidate(this.value, " . $field['validate'] . ", " . $field['message'] . ")";
|
567 |
f566451e
|
Phil Davis
|
}
|
568 |
1e2d831c
|
Renato Botelho
|
|
569 |
4e43ef22
|
Stephen Beaver
|
$section->addInput(new Form_Input(
|
570 |
|
|
$name,
|
571 |
|
|
$etitle,
|
572 |
|
|
'text',
|
573 |
|
|
$value
|
574 |
|
|
))->setAttribute('autocomplete', 'off')
|
575 |
|
|
->setOnchange($onchange)
|
576 |
|
|
->setHelp($field['description']);
|
577 |
|
|
|
578 |
1e2d831c
|
Renato Botelho
|
break;
|
579 |
|
|
case "interfaces_selection":
|
580 |
|
|
case "interface_select":
|
581 |
4e43ef22
|
Stephen Beaver
|
|
582 |
1e2d831c
|
Renato Botelho
|
$name = strtolower($name);
|
583 |
4e43ef22
|
Stephen Beaver
|
$options = array();
|
584 |
|
|
$selected = array();
|
585 |
|
|
|
586 |
|
|
$etitle = (fixup_string($field['displayname'])) ? $field['displayname'] : $field['name'];
|
587 |
|
|
|
588 |
c86c14dc
|
Phil Davis
|
if (($field['multiple'] != "") && ($field['multiple'] != "0")) {
|
589 |
4e43ef22
|
Stephen Beaver
|
$multiple = true;
|
590 |
c86c14dc
|
Phil Davis
|
} else {
|
591 |
4e43ef22
|
Stephen Beaver
|
$multiple = false;
|
592 |
c86c14dc
|
Phil Davis
|
}
|
593 |
4e43ef22
|
Stephen Beaver
|
|
594 |
89dcfa01
|
Stephen Beaver
|
if ($field['add_to_interfaces_selection'] != "") {
|
595 |
f566451e
|
Phil Davis
|
if ($field['add_to_interfaces_selection'] == $value) {
|
596 |
4e43ef22
|
Stephen Beaver
|
array_push($selected, $value);
|
597 |
f566451e
|
Phil Davis
|
}
|
598 |
4e43ef22
|
Stephen Beaver
|
|
599 |
|
|
$options[$field['add_to_interfaces_selection']] = $field['add_to_interfaces_selection'];
|
600 |
1e2d831c
|
Renato Botelho
|
}
|
601 |
4e43ef22
|
Stephen Beaver
|
|
602 |
f566451e
|
Phil Davis
|
if ($field['type'] == "interface_select") {
|
603 |
1e2d831c
|
Renato Botelho
|
$interfaces = get_interface_list();
|
604 |
f566451e
|
Phil Davis
|
} else {
|
605 |
1e2d831c
|
Renato Botelho
|
$interfaces = get_configured_interface_with_descr();
|
606 |
f566451e
|
Phil Davis
|
}
|
607 |
4e43ef22
|
Stephen Beaver
|
|
608 |
1e2d831c
|
Renato Botelho
|
foreach ($interfaces as $ifname => $iface) {
|
609 |
|
|
if ($field['type'] == "interface_select") {
|
610 |
|
|
$iface = $ifname;
|
611 |
f566451e
|
Phil Davis
|
if ($iface['mac']) {
|
612 |
1e2d831c
|
Renato Botelho
|
$iface .= " ({$iface['mac']})";
|
613 |
f566451e
|
Phil Davis
|
}
|
614 |
1e2d831c
|
Renato Botelho
|
}
|
615 |
4e43ef22
|
Stephen Beaver
|
|
616 |
c86c14dc
|
Phil Davis
|
if ($value == $ifname) {
|
617 |
4e43ef22
|
Stephen Beaver
|
array_push($selected, $value);
|
618 |
c86c14dc
|
Phil Davis
|
}
|
619 |
4e43ef22
|
Stephen Beaver
|
|
620 |
1e2d831c
|
Renato Botelho
|
$canecho = 0;
|
621 |
89dcfa01
|
Stephen Beaver
|
if ($field['interface_filter'] != "") {
|
622 |
f566451e
|
Phil Davis
|
if (stristr($ifname, $field['interface_filter']) == true) {
|
623 |
1e2d831c
|
Renato Botelho
|
$canecho = 1;
|
624 |
f566451e
|
Phil Davis
|
}
|
625 |
|
|
} else {
|
626 |
1e2d831c
|
Renato Botelho
|
$canecho = 1;
|
627 |
f566451e
|
Phil Davis
|
}
|
628 |
4e43ef22
|
Stephen Beaver
|
|
629 |
f566451e
|
Phil Davis
|
if ($canecho == 1) {
|
630 |
4e43ef22
|
Stephen Beaver
|
$options[$ifname] = $iface;
|
631 |
f566451e
|
Phil Davis
|
}
|
632 |
1e2d831c
|
Renato Botelho
|
}
|
633 |
6bb5c9aa
|
Bill Marquette
|
|
634 |
4e43ef22
|
Stephen Beaver
|
$section->addInput(new Form_Select(
|
635 |
|
|
$name,
|
636 |
|
|
$etitle,
|
637 |
|
|
($multiple) ? $selected:$selected[0],
|
638 |
|
|
$options,
|
639 |
|
|
$multiple
|
640 |
|
|
))->setHelp($field['description']);
|
641 |
62a48760
|
Scott Ullrich
|
|
642 |
1e2d831c
|
Renato Botelho
|
break;
|
643 |
|
|
case "password":
|
644 |
|
|
if ($field['displayname']) {
|
645 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
646 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
647 |
89dcfa01
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
648 |
1e2d831c
|
Renato Botelho
|
}
|
649 |
89dcfa01
|
Stephen Beaver
|
|
650 |
|
|
$section->addInput(new Form_Input(
|
651 |
|
|
$name,
|
652 |
|
|
$etitle,
|
653 |
|
|
'password',
|
654 |
|
|
$value
|
655 |
|
|
))->setHelp($field['description'])
|
656 |
16fd8f4a
|
Stephen Beaver
|
->setOnchange(($field['validate']) ? "FieldValidate(this.value, " . $field['validate'] . ", " . $field['message'] .")":"");
|
657 |
1e2d831c
|
Renato Botelho
|
|
658 |
|
|
break;
|
659 |
|
|
case "certca_selection":
|
660 |
4e43ef22
|
Stephen Beaver
|
$options = array();
|
661 |
|
|
$selected = "";
|
662 |
|
|
|
663 |
1e2d831c
|
Renato Botelho
|
$name = strtolower($name);
|
664 |
4e43ef22
|
Stephen Beaver
|
|
665 |
|
|
$etitle = (fixup_string($field['displayname']) ? $field['displayname'] : $field['name']);
|
666 |
|
|
|
667 |
89dcfa01
|
Stephen Beaver
|
if ($field['add_to_certca_selection'] != "") {
|
668 |
f566451e
|
Phil Davis
|
if ($field['add_to_certca_selection'] == $value) {
|
669 |
4e43ef22
|
Stephen Beaver
|
$selected = $value;
|
670 |
f566451e
|
Phil Davis
|
}
|
671 |
4e43ef22
|
Stephen Beaver
|
|
672 |
|
|
$options[$field['add_to_certca_selection']] = $field['add_to_certca_selection'];
|
673 |
1e2d831c
|
Renato Botelho
|
}
|
674 |
4e43ef22
|
Stephen Beaver
|
|
675 |
f566451e
|
Phil Davis
|
foreach ($config['ca'] as $ca) {
|
676 |
de90f855
|
jim-p
|
$caname = htmlspecialchars($ca['descr']);
|
677 |
4e43ef22
|
Stephen Beaver
|
|
678 |
c86c14dc
|
Phil Davis
|
if ($value == $caname) {
|
679 |
4e43ef22
|
Stephen Beaver
|
$selected = $value;
|
680 |
c86c14dc
|
Phil Davis
|
}
|
681 |
4e43ef22
|
Stephen Beaver
|
|
682 |
1e2d831c
|
Renato Botelho
|
$canecho = 0;
|
683 |
89dcfa01
|
Stephen Beaver
|
if ($field['certca_filter'] != "") {
|
684 |
de90f855
|
jim-p
|
if (stristr($caname, $field['certca_filter']) == true) {
|
685 |
1e2d831c
|
Renato Botelho
|
$canecho = 1;
|
686 |
f566451e
|
Phil Davis
|
}
|
687 |
1e2d831c
|
Renato Botelho
|
} else {
|
688 |
|
|
$canecho = 1;
|
689 |
|
|
}
|
690 |
f566451e
|
Phil Davis
|
if ($canecho == 1) {
|
691 |
de90f855
|
jim-p
|
$options[$ca['refid']] = $caname;
|
692 |
f566451e
|
Phil Davis
|
}
|
693 |
1e2d831c
|
Renato Botelho
|
}
|
694 |
62a48760
|
Scott Ullrich
|
|
695 |
4e43ef22
|
Stephen Beaver
|
$section->addInput(new Form_Select(
|
696 |
|
|
$name,
|
697 |
|
|
$etitle,
|
698 |
|
|
$selected,
|
699 |
|
|
$options
|
700 |
|
|
))->setHelp($field['description']);
|
701 |
b7bb1711
|
Ermal Lu?i
|
|
702 |
1e2d831c
|
Renato Botelho
|
break;
|
703 |
|
|
case "cert_selection":
|
704 |
4e43ef22
|
Stephen Beaver
|
$options = array();
|
705 |
|
|
$selected = array();
|
706 |
|
|
|
707 |
|
|
$multiple = false;
|
708 |
1e2d831c
|
Renato Botelho
|
$name = strtolower($name);
|
709 |
4e43ef22
|
Stephen Beaver
|
|
710 |
|
|
$etitle = (fixup_string($field['displayname']) ? $field['displayname'] : $field['name']);
|
711 |
|
|
|
712 |
89dcfa01
|
Stephen Beaver
|
if ($field['add_to_cert_selection'] != "") {
|
713 |
f566451e
|
Phil Davis
|
if ($field['add_to_cert_selection'] == $value) {
|
714 |
4e43ef22
|
Stephen Beaver
|
array_push($selected, $value);
|
715 |
f566451e
|
Phil Davis
|
}
|
716 |
4e43ef22
|
Stephen Beaver
|
|
717 |
|
|
$options[$field['add_to_cert_selection']] = $field['add_to_cert_selection'];
|
718 |
1e2d831c
|
Renato Botelho
|
}
|
719 |
4e43ef22
|
Stephen Beaver
|
|
720 |
f566451e
|
Phil Davis
|
foreach ($config['cert'] as $ca) {
|
721 |
|
|
if (stristr($ca['descr'], "webconf")) {
|
722 |
1e2d831c
|
Renato Botelho
|
continue;
|
723 |
f566451e
|
Phil Davis
|
}
|
724 |
4e43ef22
|
Stephen Beaver
|
|
725 |
de90f855
|
jim-p
|
$caname = htmlspecialchars($ca['descr']);
|
726 |
4e43ef22
|
Stephen Beaver
|
|
727 |
de90f855
|
jim-p
|
if ($value == $caname) {
|
728 |
4e43ef22
|
Stephen Beaver
|
array_push($selected, $value);
|
729 |
f566451e
|
Phil Davis
|
}
|
730 |
4e43ef22
|
Stephen Beaver
|
|
731 |
|
|
|
732 |
1e2d831c
|
Renato Botelho
|
$canecho = 0;
|
733 |
89dcfa01
|
Stephen Beaver
|
if ($field['cert_filter'] != "") {
|
734 |
de90f855
|
jim-p
|
if (stristr($caname, $field['cert_filter']) == true) {
|
735 |
1e2d831c
|
Renato Botelho
|
$canecho = 1;
|
736 |
f566451e
|
Phil Davis
|
}
|
737 |
1e2d831c
|
Renato Botelho
|
} else {
|
738 |
|
|
$canecho = 1;
|
739 |
|
|
}
|
740 |
4e43ef22
|
Stephen Beaver
|
|
741 |
f566451e
|
Phil Davis
|
if ($canecho == 1) {
|
742 |
de90f855
|
jim-p
|
$options[$ca['refid']] = $caname;
|
743 |
f566451e
|
Phil Davis
|
}
|
744 |
1e2d831c
|
Renato Botelho
|
}
|
745 |
66f773b4
|
Ermal Lu?i
|
|
746 |
4e43ef22
|
Stephen Beaver
|
$section->addInput(new Form_Select(
|
747 |
|
|
$name,
|
748 |
|
|
$etitle,
|
749 |
|
|
($multiple) ? $selected:$selected[0],
|
750 |
|
|
$options,
|
751 |
|
|
$multiple
|
752 |
|
|
))->setHelp($field['description']);
|
753 |
b7bb1711
|
Ermal Lu?i
|
|
754 |
1e2d831c
|
Renato Botelho
|
break;
|
755 |
|
|
case "select":
|
756 |
|
|
if ($field['displayname']) {
|
757 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
758 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
759 |
89dcfa01
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
760 |
1e2d831c
|
Renato Botelho
|
}
|
761 |
89dcfa01
|
Stephen Beaver
|
|
762 |
f566451e
|
Phil Davis
|
if ($field['size']) {
|
763 |
|
|
$size = " size='" . $field['size'] . "' ";
|
764 |
|
|
}
|
765 |
89dcfa01
|
Stephen Beaver
|
|
766 |
|
|
$multiple = ($field['multiple'] == "yes");
|
767 |
|
|
|
768 |
1e2d831c
|
Renato Botelho
|
$onchange = "";
|
769 |
|
|
foreach ($field['options']['option'] as $opt) {
|
770 |
89dcfa01
|
Stephen Beaver
|
if ($opt['enablefields'] != "") {
|
771 |
|
|
$onchange = "Javascript:enableitems(this.selectedIndex);";
|
772 |
1e2d831c
|
Renato Botelho
|
}
|
773 |
|
|
}
|
774 |
89dcfa01
|
Stephen Beaver
|
|
775 |
|
|
$options = array();
|
776 |
|
|
$selected = array();
|
777 |
|
|
|
778 |
1e2d831c
|
Renato Botelho
|
foreach ($field['options']['option'] as $opt) {
|
779 |
f566451e
|
Phil Davis
|
if ($value == $opt['value']) {
|
780 |
89dcfa01
|
Stephen Beaver
|
array_push($selected, $value);
|
781 |
f566451e
|
Phil Davis
|
}
|
782 |
89dcfa01
|
Stephen Beaver
|
|
783 |
f566451e
|
Phil Davis
|
if ($opt['displayname']) {
|
784 |
89dcfa01
|
Stephen Beaver
|
$options[$opt['value']] = $opt['displayname'];
|
785 |
f566451e
|
Phil Davis
|
} else {
|
786 |
89dcfa01
|
Stephen Beaver
|
$options[$opt['value']] = $opt['name'];
|
787 |
f566451e
|
Phil Davis
|
}
|
788 |
b7bb1711
|
Ermal Lu?i
|
|
789 |
1e2d831c
|
Renato Botelho
|
}
|
790 |
b7bb1711
|
Ermal Lu?i
|
|
791 |
89dcfa01
|
Stephen Beaver
|
$section->addInput(new Form_Select(
|
792 |
|
|
$name,
|
793 |
|
|
$etitle,
|
794 |
|
|
($multiple) ? $selected:$selected[0],
|
795 |
|
|
$options,
|
796 |
|
|
$multiple
|
797 |
|
|
))->setHelp($field['description'])->setOnchange($onchange);
|
798 |
|
|
|
799 |
1e2d831c
|
Renato Botelho
|
break;
|
800 |
|
|
case "textarea":
|
801 |
|
|
if ($field['displayname']) {
|
802 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
803 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
804 |
89dcfa01
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
805 |
1e2d831c
|
Renato Botelho
|
}
|
806 |
89dcfa01
|
Stephen Beaver
|
|
807 |
3478ac16
|
Stephen Beaver
|
$section->addInput(new Form_Textarea(
|
808 |
89dcfa01
|
Stephen Beaver
|
$name,
|
809 |
|
|
$etitle,
|
810 |
|
|
$value
|
811 |
|
|
))->setHelp($field['description'])
|
812 |
|
|
->setAttribute('rows', $field['rows'])
|
813 |
16fd8f4a
|
Stephen Beaver
|
->setOnchange(($field['validate']) ? "FieldValidate(this.value, " . $field['validate'] . ", " . $field['message'] . ")":"");
|
814 |
1e2d831c
|
Renato Botelho
|
|
815 |
|
|
break;
|
816 |
|
|
case "submit":
|
817 |
89dcfa01
|
Stephen Beaver
|
$form->addGlobal(new Form_Button(
|
818 |
|
|
$name,
|
819 |
|
|
$field['name']
|
820 |
|
|
));
|
821 |
b7bb1711
|
Ermal Lu?i
|
|
822 |
1e2d831c
|
Renato Botelho
|
break;
|
823 |
|
|
case "listtopic":
|
824 |
89dcfa01
|
Stephen Beaver
|
$form->add($section);
|
825 |
|
|
$section = new Form_Section($field['name']);
|
826 |
|
|
|
827 |
1e2d831c
|
Renato Botelho
|
break;
|
828 |
|
|
case "subnet_select":
|
829 |
|
|
if ($field['displayname']) {
|
830 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
831 |
|
|
} else /* if (!$field['dontdisplayname']) */ {
|
832 |
|
|
$etitle = fixup_string($field['name']);
|
833 |
1e2d831c
|
Renato Botelho
|
}
|
834 |
89dcfa01
|
Stephen Beaver
|
|
835 |
|
|
$section->addInput(new Form_Select(
|
836 |
|
|
$name,
|
837 |
|
|
$etitle,
|
838 |
|
|
$value,
|
839 |
|
|
array_combine(range(32, 1, -1), range(32, 1, -1))
|
840 |
|
|
))->setHelp($field['description']);
|
841 |
|
|
|
842 |
1e2d831c
|
Renato Botelho
|
break;
|
843 |
|
|
case "timezone_select":
|
844 |
60ff91f1
|
Renato Botelho
|
$timezonelist = system_get_timezone_list();
|
845 |
1e2d831c
|
Renato Botelho
|
|
846 |
|
|
/* kill carriage returns */
|
847 |
6c07db48
|
Phil Davis
|
for ($x = 0; $x < count($timezonelist); $x++) {
|
848 |
1e2d831c
|
Renato Botelho
|
$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
|
849 |
f566451e
|
Phil Davis
|
}
|
850 |
1e2d831c
|
Renato Botelho
|
|
851 |
|
|
if ($field['displayname']) {
|
852 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
853 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
854 |
89dcfa01
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
855 |
|
|
}
|
856 |
|
|
|
857 |
|
|
if (!$field['dontcombinecells']) {
|
858 |
|
|
//echo "<td class=\"vtable\">";
|
859 |
1e2d831c
|
Renato Botelho
|
}
|
860 |
89dcfa01
|
Stephen Beaver
|
|
861 |
|
|
$section->addInput(new Form_Select(
|
862 |
|
|
$name,
|
863 |
|
|
$etitle,
|
864 |
f8ae3586
|
Stephen Beaver
|
($value == "") ? $g['default_timezone'] : $value,
|
865 |
89dcfa01
|
Stephen Beaver
|
array_combine($timezonelist, $timezonelist)
|
866 |
|
|
))->setHelp($field['description']);
|
867 |
b7bb1711
|
Ermal Lu?i
|
|
868 |
1e2d831c
|
Renato Botelho
|
break;
|
869 |
|
|
case "checkbox":
|
870 |
|
|
if ($field['displayname']) {
|
871 |
89dcfa01
|
Stephen Beaver
|
$etitle = $field['displayname'];
|
872 |
|
|
|
873 |
f566451e
|
Phil Davis
|
} else if (!$field['dontdisplayname']) {
|
874 |
89dcfa01
|
Stephen Beaver
|
$etitle = fixup_string($field['name']);
|
875 |
f566451e
|
Phil Davis
|
}
|
876 |
89dcfa01
|
Stephen Beaver
|
|
877 |
f566451e
|
Phil Davis
|
if (isset($field['enablefields']) or isset($field['checkenablefields'])) {
|
878 |
e79dc517
|
Stephen Beaver
|
$onclick = "enablechange()";
|
879 |
f566451e
|
Phil Davis
|
} else if (isset($field['disablefields']) or isset($field['checkdisablefields'])) {
|
880 |
e79dc517
|
Stephen Beaver
|
$onclick = "disablechange()";
|
881 |
f566451e
|
Phil Davis
|
}
|
882 |
89dcfa01
|
Stephen Beaver
|
|
883 |
|
|
$section->addInput(new Form_Checkbox(
|
884 |
|
|
$name,
|
885 |
|
|
$etitle,
|
886 |
|
|
$field['typehint'],
|
887 |
|
|
($value != ""),
|
888 |
|
|
'on'
|
889 |
|
|
))->setHelp($field['description'])
|
890 |
|
|
->setOnclick($onclick);
|
891 |
|
|
|
892 |
1e2d831c
|
Renato Botelho
|
break;
|
893 |
4e43ef22
|
Stephen Beaver
|
} // e-o-switch
|
894 |
|
|
} // e-o-foreach(package)
|
895 |
|
|
} // e-o- if(we have fields)
|
896 |
66f773b4
|
Ermal Lu?i
|
|
897 |
4e43ef22
|
Stephen Beaver
|
$form->add($section);
|
898 |
|
|
print($form);
|
899 |
1e2d831c
|
Renato Botelho
|
?>
|
900 |
89dcfa01
|
Stephen Beaver
|
|
901 |
44c10295
|
Scott Ullrich
|
<script type="text/javascript">
|
902 |
6a11423f
|
Colin Fleming
|
//<![CDATA[
|
903 |
e79dc517
|
Stephen Beaver
|
|
904 |
89dcfa01
|
Stephen Beaver
|
if (typeof ext_change != 'undefined') {
|
905 |
|
|
ext_change();
|
906 |
|
|
}
|
907 |
|
|
if (typeof proto_change != 'undefined') {
|
908 |
|
|
ext_change();
|
909 |
|
|
}
|
910 |
|
|
if (typeof proto_change != 'undefined') {
|
911 |
|
|
proto_change();
|
912 |
|
|
}
|
913 |
5adb3375
|
Scott Ullrich
|
|
914 |
89dcfa01
|
Stephen Beaver
|
<?php
|
915 |
|
|
$isfirst = 0;
|
916 |
|
|
$aliases = "";
|
917 |
|
|
$addrisfirst = 0;
|
918 |
|
|
$aliasesaddr = "";
|
919 |
|
|
if ($config['aliases']['alias'] != "" and is_array($config['aliases']['alias'])) {
|
920 |
|
|
foreach ($config['aliases']['alias'] as $alias_name) {
|
921 |
|
|
if ($isfirst == 1) {
|
922 |
|
|
$aliases .= ",";
|
923 |
|
|
}
|
924 |
|
|
$aliases .= "'" . $alias_name['name'] . "'";
|
925 |
|
|
$isfirst = 1;
|
926 |
f566451e
|
Phil Davis
|
}
|
927 |
62a48760
|
Scott Ullrich
|
}
|
928 |
89dcfa01
|
Stephen Beaver
|
?>
|
929 |
62a48760
|
Scott Ullrich
|
|
930 |
89dcfa01
|
Stephen Beaver
|
var customarray=new Array(<?=$aliases; ?>);
|
931 |
62a48760
|
Scott Ullrich
|
|
932 |
89dcfa01
|
Stephen Beaver
|
window.onload = function () {
|
933 |
44c10295
|
Scott Ullrich
|
|
934 |
4e43ef22
|
Stephen Beaver
|
<?php
|
935 |
89dcfa01
|
Stephen Beaver
|
$counter = 0;
|
936 |
|
|
foreach ($inputaliases as $alias) {
|
937 |
4e43ef22
|
Stephen Beaver
|
?>
|
938 |
|
|
$('#' + '<?php echo $alias; ?>').autocomplete({
|
939 |
|
|
source: customarray
|
940 |
|
|
});
|
941 |
|
|
<?php
|
942 |
89dcfa01
|
Stephen Beaver
|
}
|
943 |
4e43ef22
|
Stephen Beaver
|
?>
|
944 |
44c10295
|
Scott Ullrich
|
}
|
945 |
e79dc517
|
Stephen Beaver
|
|
946 |
6a11423f
|
Colin Fleming
|
//]]>
|
947 |
62a48760
|
Scott Ullrich
|
</script>
|
948 |
5adb3375
|
Scott Ullrich
|
|
949 |
34b5c5a0
|
Scott Ullrich
|
<?php
|
950 |
|
|
|
951 |
|
|
$fieldnames_array = Array();
|
952 |
89dcfa01
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['disableallfieldsbydefault'] != "") {
|
953 |
34b5c5a0
|
Scott Ullrich
|
// create a fieldname loop that can be used with javascript
|
954 |
|
|
// hide and enable features.
|
955 |
44c10295
|
Scott Ullrich
|
echo "\n<script type=\"text/javascript\">\n";
|
956 |
6a11423f
|
Colin Fleming
|
echo "//<![CDATA[\n";
|
957 |
34b5c5a0
|
Scott Ullrich
|
echo "function disableall() {\n";
|
958 |
|
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
959 |
89dcfa01
|
Stephen Beaver
|
if ($field['type'] != "submit" and $field['type'] != "listtopic") {
|
960 |
|
|
if (!$field['donotdisable'] != "") {
|
961 |
34b5c5a0
|
Scott Ullrich
|
array_push($fieldnames_array, $field['name']);
|
962 |
4dc8f32e
|
ccesario
|
$fieldname = preg_replace("/\s+/", "", $field['name']);
|
963 |
34b5c5a0
|
Scott Ullrich
|
$fieldname = strtolower($fieldname);
|
964 |
|
|
echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
|
965 |
|
|
}
|
966 |
|
|
}
|
967 |
|
|
}
|
968 |
|
|
echo "}\ndisableall();\n";
|
969 |
|
|
echo "function enableitems(selectedindex) {\n";
|
970 |
|
|
echo "disableall();\n";
|
971 |
|
|
$idcounter = 0;
|
972 |
89dcfa01
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['fields']['field'] != "") {
|
973 |
f566451e
|
Phil Davis
|
echo "\tswitch (selectedindex) {\n";
|
974 |
34b5c5a0
|
Scott Ullrich
|
foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
|
975 |
89dcfa01
|
Stephen Beaver
|
if ($field['options']['option'] != "") {
|
976 |
34b5c5a0
|
Scott Ullrich
|
foreach ($field['options']['option'] as $opt) {
|
977 |
89dcfa01
|
Stephen Beaver
|
if ($opt['enablefields'] != "") {
|
978 |
34b5c5a0
|
Scott Ullrich
|
echo "\t\tcase " . $idcounter . ":\n";
|
979 |
cfbfd941
|
smos
|
$enablefields_split = explode(",", $opt['enablefields']);
|
980 |
34b5c5a0
|
Scott Ullrich
|
foreach ($enablefields_split as $efs) {
|
981 |
4dc8f32e
|
ccesario
|
$fieldname = preg_replace("/\s+/", "", $efs);
|
982 |
34b5c5a0
|
Scott Ullrich
|
$fieldname = strtolower($fieldname);
|
983 |
89dcfa01
|
Stephen Beaver
|
if ($fieldname != "") {
|
984 |
34b5c5a0
|
Scott Ullrich
|
$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
|
985 |
|
|
echo $onchange;
|
986 |
|
|
}
|
987 |
|
|
}
|
988 |
|
|
echo "\t\t\tbreak;\n";
|
989 |
|
|
}
|
990 |
|
|
$idcounter = $idcounter + 1;
|
991 |
|
|
}
|
992 |
|
|
}
|
993 |
|
|
}
|
994 |
|
|
echo "\t}\n";
|
995 |
|
|
}
|
996 |
|
|
echo "}\n";
|
997 |
6a11423f
|
Colin Fleming
|
echo "//]]>\n";
|
998 |
34b5c5a0
|
Scott Ullrich
|
echo "</script>\n\n";
|
999 |
|
|
}
|
1000 |
e22e834d
|
Renato Botelho
|
?>
|
1001 |
34b5c5a0
|
Scott Ullrich
|
|
1002 |
e22e834d
|
Renato Botelho
|
<script type="text/javascript">
|
1003 |
|
|
//<![CDATA[
|
1004 |
c86c14dc
|
Phil Davis
|
events.push(function() {
|
1005 |
4e43ef22
|
Stephen Beaver
|
enablechange();
|
1006 |
|
|
disablechange();
|
1007 |
|
|
showchange();
|
1008 |
e79dc517
|
Stephen Beaver
|
});
|
1009 |
e22e834d
|
Renato Botelho
|
//]]>
|
1010 |
|
|
</script>
|
1011 |
34b5c5a0
|
Scott Ullrich
|
|
1012 |
e22e834d
|
Renato Botelho
|
<?php
|
1013 |
89dcfa01
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['stepafterformdisplay'] != "") {
|
1014 |
34b5c5a0
|
Scott Ullrich
|
// handle after form display event.
|
1015 |
|
|
eval($pkg['step'][$stepid]['stepafterformdisplay']);
|
1016 |
|
|
}
|
1017 |
|
|
|
1018 |
89dcfa01
|
Stephen Beaver
|
if ($pkg['step'][$stepid]['javascriptafterformdisplay'] != "") {
|
1019 |
34b5c5a0
|
Scott Ullrich
|
// handle after form display event.
|
1020 |
1e2d831c
|
Renato Botelho
|
echo "\n<script type=\"text/javascript\">\n";
|
1021 |
1b244d38
|
Colin Fleming
|
echo "//<![CDATA[\n";
|
1022 |
34b5c5a0
|
Scott Ullrich
|
echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
|
1023 |
1b244d38
|
Colin Fleming
|
echo "//]]>\n";
|
1024 |
34b5c5a0
|
Scott Ullrich
|
echo "</script>\n\n";
|
1025 |
|
|
}
|
1026 |
|
|
|
1027 |
89dcfa01
|
Stephen Beaver
|
include("foot.inc");
|