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