Project

General

Profile

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