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