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