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