Project

General

Profile

Download (30.8 KB) Statistics
| Branch: | Tag: | Revision:
1 658292ef Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 658292ef Scott Ullrich
/*
4 1e2d831c Renato Botelho
	wizard.php
5 6317d31d Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6 1e2d831c Renato Botelho
	Copyright (C) 2010 Ermal Luçi
7 dd447bde Jim Thompson
	Copyright (C) 2004 Scott Ullrich
8 1e2d831c Renato Botelho
	All rights reserved.
9
10
	Redistribution and use in source and binary forms, with or without
11
	modification, 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 the
18
	   documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30 658292ef Scott Ullrich
*/
31
32 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-pfsensewizardsubsystem
34
##|*NAME=pfSense wizard subsystem page
35
##|*DESCR=Allow access to the 'pfSense wizard subsystem' page.
36
##|*MATCH=wizard.php*
37
##|-PRIV
38
39
40 fe4fc20b Renato Botelho
require("globals.inc");
41 658292ef Scott Ullrich
require("guiconfig.inc");
42 f9fc88cc sullrich
require("functions.inc");
43 f6339216 jim-p
require_once("filter.inc");
44 f9fc88cc sullrich
require("shaper.inc");
45 1b34f8a7 Ermal
require_once("rrd.inc");
46 658292ef Scott Ullrich
47
function gentitle_pkg($pgname) {
48 2fbd6806 Scott Ullrich
	global $config;
49
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
50 658292ef Scott Ullrich
}
51
52 fe4fc20b Renato Botelho
global $g;
53
54 d8c1a6c5 Scott Ullrich
$stepid = htmlspecialchars($_GET['stepid']);
55 658292ef Scott Ullrich
if (isset($_POST['stepid']))
56 1e2d831c Renato Botelho
	$stepid = htmlspecialchars($_POST['stepid']);
57 72a5f424 Ermal Lu?i
if (!$stepid)
58
	$stepid = "0";
59 658292ef Scott Ullrich
60 d8c1a6c5 Scott Ullrich
$xml = htmlspecialchars($_GET['xml']);
61 5a8a69b3 Ermal Lu?i
if($_POST['xml'])
62
	$xml = htmlspecialchars($_POST['xml']);
63 658292ef Scott Ullrich
64 5a8a69b3 Ermal Lu?i
if(empty($xml)) {
65 bb0c9569 Bill Marquette
	$xml = "not_defined";
66 185b9fbd Renato Botelho
	print_info_box_np(sprintf(gettext("ERROR:  Could not open %s."), $xml));
67 bb0c9569 Bill Marquette
	die;
68 658292ef Scott Ullrich
} else {
69 bd31336e Scott Ullrich
	if (file_exists("{$g['www_path']}/wizards/{$xml}"))
70 fc19d371 Scott Ullrich
		$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
71 bb0c9569 Bill Marquette
	else {
72 185b9fbd Renato Botelho
		print_info_box_np(sprintf(gettext("ERROR:  Could not open %s."), $xml));
73 bb0c9569 Bill Marquette
		die;
74
	}
75 658292ef Scott Ullrich
}
76
77 5a8a69b3 Ermal Lu?i
if (!is_array($pkg)) {
78 3a3fb8ea Erik Fonnesbeck
	print_info_box_np(sprintf(gettext("ERROR: Could not parse %s/wizards/%s file."),$g['www_path'],$xml));
79 5a8a69b3 Ermal Lu?i
	die;
80
}
81
82 fe4fc20b Renato Botelho
$title       = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
83
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
84
$totalsteps  = $pkg['totalsteps'];
85 658292ef Scott Ullrich
86 2ca50c87 Ermal Lu?i
if ($pkg['includefile'])
87 1e2d831c Renato Botelho
	require_once($pkg['includefile']);
88 2ca50c87 Ermal Lu?i
89 b3f4e57c Scott Ullrich
if ($pkg['step'][$stepid]['includefile'])
90 5a8a69b3 Ermal Lu?i
	require_once($pkg['step'][$stepid]['includefile']);
91 b3f4e57c Scott Ullrich
92 e1e7a425 Scott Ullrich
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
93 a314bebc Ermal
	eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
94 e1e7a425 Scott Ullrich
}
95
96 27319e17 jim-p
if ($_POST && !$input_errors) {
97 1e2d831c Renato Botelho
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
98
		if(!empty($field['bindstofield']) and $field['type'] <> "submit") {
99
			$fieldname = $field['name'];
100
			$fieldname = str_replace(" ", "", $fieldname);
101
			$fieldname = strtolower($fieldname);
102
			// update field with posted values.
103
			if($field['unsetfield'] <> "")
104
				$unset_fields = "yes";
105
			else
106
				$unset_fields = "";
107
			if($field['arraynum'] <> "")
108
				$arraynum = $field['arraynum'];
109
			else
110
				$arraynum = "";
111
112
			update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
113
		}
114
115
	}
116
	// run custom php code embedded in xml config.
117
	if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
118 3ed807e4 Scott Ullrich
		eval($pkg['step'][$stepid]['stepsubmitphpaction']);
119 1e2d831c Renato Botelho
	}
120 27319e17 jim-p
	if (!$input_errors)
121
		write_config();
122 1e2d831c Renato Botelho
	$stepid++;
123
	if($stepid > $totalsteps)
124
		$stepid = $totalsteps;
125 658292ef Scott Ullrich
}
126
127 3f83de3d Scott Ullrich
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
128 eb20f3c5 Ermal Lu?i
	global $config;
129 cfbfd941 smos
	$field_split = explode("->",$field);
130 72a5f424 Ermal Lu?i
	foreach ($field_split as $f)
131
		$field_conv .= "['" . $f . "']";
132
	if($field_conv == "")
133
		return;
134 a4f07557 Ermal
	if ($arraynum <> "")
135 ddc75a80 Ermal
		$field_conv .= "[" . $arraynum . "]";
136 72a5f424 Ermal Lu?i
	if(($field_type == "checkbox" and $updatetext <> "on") || $updatetext == "") {
137 3f83de3d Scott Ullrich
		/*
138 a4f07557 Ermal
		 * item is a checkbox, it should have the value "on"
139
		 * if it was checked
140 1e2d831c Renato Botelho
		 */
141 b4eb3a17 jim-p
		$var = "\$config{$field_conv}";
142
		$text = "if (isset({$var})) unset({$var});";
143 3f83de3d Scott Ullrich
		eval($text);
144
		return;
145 496f9155 Scott Ullrich
	}
146 e881d1f3 Scott Ullrich
147 496f9155 Scott Ullrich
	if($field_type == "interfaces_selection") {
148 b4eb3a17 jim-p
		$var = "\$config{$field_conv}";
149
		$text = "if (isset({$var})) unset({$var});";
150 389c778e gnhb
		$text .= "\$config" . $field_conv . " = \"" . $updatetext . "\";";
151 496f9155 Scott Ullrich
		eval($text);
152
		return;
153
	}
154 e881d1f3 Scott Ullrich
155 ddc75a80 Ermal
	if($unset == "yes") {
156 e48fc17d Scott Ullrich
		$text = "unset(\$config" . $field_conv . ");";
157
		eval($text);
158
	}
159 9882cbef jim-p
	$text = "\$config" . $field_conv . " = \"" . addslashes($updatetext) . "\";";
160 a4f07557 Ermal
	eval($text);
161 658292ef Scott Ullrich
}
162
163 42f1649f Erik Fonnesbeck
$title       = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
164
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
165
166 a314bebc Ermal
// handle before form display event.
167
do {
168
	$oldstepid = $stepid;
169
	if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "")
170
		eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
171
} while ($oldstepid != $stepid);
172 34b5c5a0 Scott Ullrich
173 6a11423f Colin Fleming
$closehead = false;
174 d88c6a9f Scott Ullrich
$pgtitle = array($title);
175 4df96eff Scott Ullrich
include("head.inc");
176 6bb5c9aa Bill Marquette
177 1e2d831c Renato Botelho
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
178 6a11423f Colin Fleming
	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
179 1e2d831c Renato Botelho
else
180 6a11423f Colin Fleming
	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
181 4df96eff Scott Ullrich
?>
182 6a11423f Colin Fleming
</head>
183 1ae55320 Ermal
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" >
184 8c01d3bb Scott Ullrich
185 33a56b27 Colin Smith
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
186 44c10295 Scott Ullrich
<script type="text/javascript">
187 6a11423f Colin Fleming
//<![CDATA[
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 1e2d831c Renato Botelho
	foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
198
		if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
199
			print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked) {' . "\n";
200
			if(isset($field['enablefields'])) {
201
				$enablefields = explode(',', $field['enablefields']);
202
				foreach($enablefields as $enablefield) {
203
					$enablefield = strtolower($enablefield);
204
					print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
205
				}
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
				$enablefields = explode(',', $field['enablefields']);
217
				foreach($enablefields as $enablefield) {
218
					$enablefield = strtolower($enablefield);
219
					print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
220
				}
221
			}
222
			if(isset($field['checkenablefields'])) {
223
				$checkenablefields = explode(',', $field['checkenablefields']);
224
				foreach($checkenablefields as $checkenablefield) {
225
					$checkenablefield = strtolower($checkenablefield);
226
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
227
				}
228
			}
229
			print "\t" . '}' . "\n";
230
		}
231
	}
232 33a56b27 Colin Smith
?>
233 6bb5c9aa Bill Marquette
}
234 2465ff5b Ermal
235 1ae55320 Ermal
function disablechange() {
236
<?php
237 1e2d831c Renato Botelho
	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
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
252
				}
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
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
267
				}
268
			}
269
			print "\t" . '}' . "\n";
270
		}
271
	}
272 1ae55320 Ermal
?>
273
}
274
275 2465ff5b Ermal
function showchange() {
276
<?php
277 1e2d831c Renato Botelho
	foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
278
		if(isset($field['showfields'])) {
279
			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
					//print "\t\t" . 'document.iform.' . $showfield . ".display =\"none\";\n";
285 ea1cea05 Vinicius Coque
					print "\t\t jQuery('#". $showfield . "').hide();";
286 1e2d831c Renato Botelho
				}
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
					#print "\t\t" . 'document.iform.' . $showfield . ".display =\"\";\n";
294 ea1cea05 Vinicius Coque
					print "\t\t jQuery('#". $showfield . "').show();";
295 1e2d831c Renato Botelho
				}
296
			}
297
			print "\t" . '}' . "\n";
298
		}
299 2465ff5b Ermal
	}
300
?>
301
}
302 6a11423f Colin Fleming
//]]>
303 6bb5c9aa Bill Marquette
</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 6a11423f Colin Fleming
<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 8cd558b6 ayvis
&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 6a11423f Colin Fleming
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif" alt="logo" /></a>
323
<p>&nbsp;</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 6a11423f Colin Fleming
<table bgcolor="#ffffff" width="95%" border="0" cellspacing="0" cellpadding="2" summary="wizard">
336 1e2d831c Renato Botelho
	<!-- wizard goes here -->
337
	<tr><td>&nbsp;</td></tr>
338
	<tr>
339
		<td class="tabcont">
340
			<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
341
342
				<tr><td colspan="2" align="center"><font size="2"><b><?= fixup_string($description) ?></b></font></td></tr><tr><td>&nbsp;</td></tr>
343
<?php
344 34b5c5a0 Scott Ullrich
	if(!$pkg['step'][$stepid]['disableheader'])
345 d51f86e0 Scott Ullrich
		echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
346 1e2d831c Renato Botelho
?>
347 34b5c5a0 Scott Ullrich
348 1e2d831c Renato Botelho
<?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 1e2d831c Renato Botelho
			$value = $field['value'];
354
			$name  = $field['name'];
355 658292ef Scott Ullrich
356 1e2d831c Renato Botelho
			$name = preg_replace("/\s+/", "", $name);
357
			$name = strtolower($name);
358 658292ef Scott Ullrich
359 1e2d831c Renato Botelho
			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 1e2d831c Renato Botelho
			}
375 34b5c5a0 Scott Ullrich
376 1e2d831c Renato Botelho
			if(!$field['combinefieldsend'])
377
				echo "<tr>";
378
379
			switch ($field['type']) {
380
			case "input":
381
				if ($field['displayname']) {
382
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
383
					echo $field['displayname'];
384
					echo ":</td>\n";
385
				} else if(!$field['dontdisplayname']) {
386
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
387
					echo fixup_string($field['name']);
388
					echo ":</td>\n";
389
				}
390
				if(!$field['dontcombinecells'])
391
					echo "<td class=\"vtable\">\n";
392
393 605ae553 Renato Botelho
				echo "<input class='formfld unknown' id='" . $name . "' name='" . $name . "' value=\"" . htmlspecialchars($value) . "\"";
394 1e2d831c Renato Botelho
				if($field['size'])
395
					echo " size='" . $field['size'] . "' ";
396
				if($field['validate'])
397
					echo " onchange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
398
				echo " />\n";
399
400
				if($field['description'] <> "") {
401
					echo "<br /> " . $field['description'];
402
				}
403
				break;
404
			case "text":
405
				echo "<td colspan=\"2\" align=\"center\" class=\"vncell\">\n";
406
				if($field['description'] <> "") {
407
					echo "<center><br /> " . $field['description'] . "</center>";
408
				}
409
				break;
410
			case "inputalias":
411
				if ($field['displayname']) {
412
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
413
					echo $field['displayname'];
414
					echo ":</td>\n";
415
				} else if(!$field['dontdisplayname']) {
416
					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
				$inputaliases[] = $name;
424 605ae553 Renato Botelho
				echo "<input class='formfldalias' autocomplete='off' id='" . $name . "' name='" . $name . "' value=\"" . htmlspecialchars($value) . "\"";
425 1e2d831c Renato Botelho
				if($field['size'])
426
					echo " size='" . $field['size'] . "' ";
427
				if($field['validate'])
428
					echo " onchange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
429
				echo " />\n";
430
431
				if($field['description'] <> "") {
432
					echo "<br /> " . $field['description'];
433
				}
434
				break;
435
			case "interfaces_selection":
436
			case "interface_select":
437
				$size = "";
438
				$multiple = "";
439
				$name = strtolower($name);
440 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
441 1e2d831c Renato Botelho
				echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
442
				echo "</td>";
443 34b5c5a0 Scott Ullrich
				echo "<td class=\"vtable\">\n";
444 1e2d831c Renato Botelho
				if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
445
				if($field['multiple'] <> "" and $field['multiple'] <> "0") {
446
					$multiple = "multiple=\"multiple\"";
447
					$name .= "[]";
448
				}
449
				echo "<select class='formselect' id='{$name}' name='{$name}' {$size} {$multiple}>\n";
450
				if($field['add_to_interfaces_selection'] <> "") {
451
					$SELECTED = "";
452
					if($field['add_to_interfaces_selection'] == $value) $SELECTED = " selected=\"selected\"";
453
					echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
454
				}
455
				if($field['type'] == "interface_select")
456
					$interfaces = get_interface_list();
457
				else
458
					$interfaces = get_configured_interface_with_descr();
459
				foreach ($interfaces as $ifname => $iface) {
460
					if ($field['type'] == "interface_select") {
461
						$iface = $ifname;
462
						if ($iface['mac'])
463
							$iface .= " ({$iface['mac']})";
464
					}
465
					$SELECTED = "";
466
					if ($value == $ifname) $SELECTED = " selected=\"selected\"";
467
					$to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $iface . "</option>\n";
468
					$to_echo .= "<!-- {$value} -->";
469
					$canecho = 0;
470
					if($field['interface_filter'] <> "") {
471
						if(stristr($ifname, $field['interface_filter']) == true)
472
							$canecho = 1;
473
					} else
474
						$canecho = 1;
475
					if($canecho == 1)
476
						echo $to_echo;
477
				}
478
				echo "</select>\n";
479 6bb5c9aa Bill Marquette
480 1e2d831c Renato Botelho
				if($field['description'] <> "") {
481
					echo "<br /> " . $field['description'];
482
				}
483 62a48760 Scott Ullrich
484 1e2d831c Renato Botelho
				break;
485
			case "password":
486
				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
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
492
					echo fixup_string($field['name']);
493
					echo ":</td>\n";
494
				}
495
				if(!$field['dontcombinecells'])
496
					echo "<td class=\"vtable\">";
497 605ae553 Renato Botelho
				echo "<input class='formfld pwd' id='" . $name . "' name='" . $name . "' value=\"" . htmlspecialchars($value) . "\" type='password' ";
498 1e2d831c Renato Botelho
				if($field['size'])
499
					echo " size='" . $field['size'] . "' ";
500
				echo " />\n";
501
502
				if($field['description'] <> "") {
503
					echo "<br /> " . $field['description'];
504
				}
505
506
				break;
507
			case "certca_selection":
508
				$size = "";
509
				$multiple = "";
510
				$name = strtolower($name);
511 62a48760 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
512 1e2d831c Renato Botelho
				echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
513
				echo "</td>";
514 62a48760 Scott Ullrich
				echo "<td class=\"vtable\">\n";
515 1e2d831c Renato Botelho
				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=\"selected\"";
520
					echo "<option value='" . $field['add_to_certca_selection'] . "'" . $SELECTED . ">" . $field['add_to_certca_selection'] . "</option>\n";
521
				}
522
				foreach($config['ca'] as $ca) {
523
					$name = htmlspecialchars($ca['descr']);
524
					$SELECTED = "";
525
					if ($value == $name) $SELECTED = " 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 62a48760 Scott Ullrich
540 1e2d831c Renato Botelho
				if($field['description'] <> "") {
541
					echo "<br /> " . $field['description'];
542
				}
543 b7bb1711 Ermal Lu?i
544 1e2d831c Renato Botelho
				break;
545
			case "cert_selection":
546
				$size = "";
547
				$multiple = "";
548
				$name = strtolower($name);
549 c062a711 jim-p
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
550 1e2d831c Renato Botelho
				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=\"selected\"";
558
					echo "<option value='" . $field['add_to_cert_selection'] . "'" . $SELECTED . ">" . $field['add_to_cert_selection'] . "</option>\n";
559
				}
560
				foreach($config['cert'] as $ca) {
561
					if (stristr($ca['descr'], "webconf"))
562
						continue;
563
					$name = htmlspecialchars($ca['descr']);
564
					$SELECTED = "";
565
					if ($value == $name) $SELECTED = " 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 66f773b4 Ermal Lu?i
580 1e2d831c Renato Botelho
				if($field['description'] <> "") {
581
					echo "<br /> " . $field['description'];
582
				}
583 b7bb1711 Ermal Lu?i
584 1e2d831c Renato Botelho
				break;
585
			case "select":
586
				if ($field['displayname']) {
587
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
588
					echo $field['displayname'];
589
					echo ":</td>\n";
590
				} else if(!$field['dontdisplayname']) {
591
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
592
					echo fixup_string($field['name']);
593
					echo ":</td>\n";
594
				}
595
				if($field['size']) $size = " size='" . $field['size'] . "' ";
596 c5a12cde Colin Fleming
				if($field['multiple'] == "yes") $multiple = "multiple=\"multiple\" ";
597 1e2d831c Renato Botelho
				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
				echo "<select class='formselect' " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
606
				foreach ($field['options']['option'] as $opt) {
607
					$selected = "";
608
					if($value == $opt['value'])
609
						$selected = " selected=\"selected\"";
610
					echo "\t<option value='" . $opt['value'] . "'" . $selected . ">";
611
					if ($opt['displayname'])
612
						echo $opt['displayname'];
613
					else
614
						echo $opt['name'];
615
					echo "</option>\n";
616
				}
617
				echo "</select>\n";
618
				echo "<!-- {$value} -->\n";
619 b7bb1711 Ermal Lu?i
620 1e2d831c Renato Botelho
				if($field['description'] <> "") {
621
					echo $field['description'];
622
				}
623 b7bb1711 Ermal Lu?i
624 1e2d831c Renato Botelho
				break;
625
			case "textarea":
626
				if ($field['displayname']) {
627
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
628
					echo $field['displayname'];
629
					echo ":</td>\n";
630
				} else if(!$field['dontdisplayname']) {
631
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
632
					echo fixup_string($field['name']);
633
					echo ":</td>";
634
				}
635
				if(!$field['dontcombinecells'])
636
					echo "<td class=\"vtable\">";
637
				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 34b5c5a0 Scott Ullrich
				}
648 66f773b4 Ermal Lu?i
649 1e2d831c Renato Botelho
				break;
650
			case "submit":
651 8cd558b6 ayvis
				echo "<td>&nbsp;<br /></td></tr>";
652 1e2d831c Renato Botelho
				echo "<tr><td colspan=\"2\" align=\"center\">";
653 605ae553 Renato Botelho
				echo "<input type='submit' name='" . $name . "' value=\"" . htmlspecialchars($field['name']) . "\" />\n";
654 b7bb1711 Ermal Lu?i
655 1e2d831c Renato Botelho
				if($field['description'] <> "") {
656
					echo "<br /> " . $field['description'];
657
				}
658 b7bb1711 Ermal Lu?i
659 1e2d831c Renato Botelho
				break;
660
			case "listtopic":
661
				echo "<td>&nbsp;</td></tr>";
662 c5a12cde Colin Fleming
				echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br />\n";
663 1e2d831c Renato Botelho
664
				break;
665
			case "subnet_select":
666
				if ($field['displayname']) {
667
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
668
					echo $field['displayname'];
669
					echo ":</td>\n";
670
				} else if(!$field['dontdisplayname']) {
671
					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
				echo "<select class='formselect' name='{$name}'>\n";
678
				for($x=1; $x<33; $x++) {
679
					$CHECKED = "";
680
					if($value == $x) $CHECKED = " selected=\"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 1e2d831c Renato Botelho
				if($field['description'] <> "") {
687
					echo "<br /> " . $field['description'];
688
				}
689 b7bb1711 Ermal Lu?i
690 1e2d831c Renato Botelho
				break;
691
			case "timezone_select":
692
				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
				if ($field['displayname']) {
701
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
702
					echo $field['displayname'];
703
					echo ":</td>\n";
704
				} else if(!$field['dontdisplayname']) {
705
					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
				echo "<select class='formselect' name='{$name}'>\n";
712
				foreach ($timezonelist as $tz) {
713
					if(strstr($tz, "GMT"))
714
						continue;
715
					$SELECTED = "";
716
					if ($value == $tz) $SELECTED = " selected=\"selected\"";
717 605ae553 Renato Botelho
					echo "<option value=\"" . htmlspecialchars($tz) . "\" {$SELECTED}>";
718 1e2d831c Renato Botelho
					echo htmlspecialchars($tz);
719
					echo "</option>\n";
720
				}
721
				echo "</select>\n";
722 b7bb1711 Ermal Lu?i
723 1e2d831c Renato Botelho
				if($field['description'] <> "") {
724
					echo "<br /> " . $field['description'];
725
				}
726 66f773b4 Ermal Lu?i
727 1e2d831c Renato Botelho
				break;
728
			case "checkbox":
729
				if ($field['displayname']) {
730
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
731
					echo $field['displayname'];
732
					echo ":</td>\n";
733
				} else if(!$field['dontdisplayname']) {
734
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
735
					echo $field['name'];
736
					echo ":</td>";
737
				}
738
				$checked = "";
739
				if($value <> "")
740
					$checked = " checked=\"checked\"";
741
				echo "<td class=\"vtable\"><input value=\"on\" type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
742
				if(isset($field['enablefields']) or isset($field['checkenablefields']))
743
					echo " onclick=\"enablechange()\"";
744
				else if(isset($field['disablefields']) or isset($field['checkdisablefields']))
745
					echo " onclick=\"disablechange()\"";
746
				echo " />\n";
747
748
				if($field['description'] <> "") {
749
					echo $field['description'];
750
				}
751 b7bb1711 Ermal Lu?i
752 1e2d831c Renato Botelho
				break;
753 bd31336e Scott Ullrich
			}
754 66f773b4 Ermal Lu?i
755 1e2d831c Renato Botelho
			if($field['typehint'] <> "") {
756
				echo $field['typehint'];
757
			}
758
			if($field['warning'] <> "") {
759
				echo "<br /><b><font color=\"red\">" . $field['warning'] . "</font></b>";
760 34b5c5a0 Scott Ullrich
			}
761 f3c6fdc0 Bill Marquette
762 1e2d831c Renato Botelho
			if(!$field['combinefieldsbegin']) {
763
				if (!$field['dontcombinecells'])
764
					echo "</td>";
765 8984dc5e Ermal
766 1e2d831c Renato Botelho
				echo "</tr>\n";
767
			}
768 1ae55320 Ermal
769 34b5c5a0 Scott Ullrich
		}
770
	}
771 1e2d831c Renato Botelho
?>
772
			</table>
773
		</td>
774
	</tr>
775 658292ef Scott Ullrich
</table>
776 8cd558b6 ayvis
<br />&nbsp;
777 5adb3375 Scott Ullrich
</div>
778 6a11423f Colin Fleming
</center>
779 658292ef Scott Ullrich
</form>
780 44c10295 Scott Ullrich
<script type="text/javascript">
781 6a11423f Colin Fleming
//<![CDATA[
782 62a48760 Scott Ullrich
	if (typeof ext_change != 'undefined') {
783
		ext_change();
784
	}
785
	if (typeof proto_change != 'undefined') {
786
		ext_change();
787
	}
788
	if (typeof proto_change != 'undefined') {
789
		proto_change();
790
	}
791 5adb3375 Scott Ullrich
792 62a48760 Scott Ullrich
<?php
793
	$isfirst = 0;
794
	$aliases = "";
795
	$addrisfirst = 0;
796
	$aliasesaddr = "";
797
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
798
		foreach($config['aliases']['alias'] as $alias_name) {
799 40050fab Ermal
				if($isfirst == 1)
800
					$aliases .= ",";
801 62a48760 Scott Ullrich
				$aliases .= "'" . $alias_name['name'] . "'";
802
				$isfirst = 1;
803
		}
804
?>
805
806
	var customarray=new Array(<?php echo $aliases; ?>);
807
808 44c10295 Scott Ullrich
	window.onload = function () {
809
810
		<?php
811
			$counter=0;
812
			foreach($inputaliases as $alias) {
813 40050fab Ermal
				echo "var oTextbox$counter = new AutoSuggestControl(document.getElementById(\"$alias\"), new StateSuggestions(customarray));\n";
814 44c10295 Scott Ullrich
				$counter++;
815
			}
816
		?>
817
818
	}
819
820 6a11423f Colin Fleming
//]]>
821 62a48760 Scott Ullrich
</script>
822 5adb3375 Scott Ullrich
823 34b5c5a0 Scott Ullrich
<?php
824
825
$fieldnames_array = Array();
826
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
827
	// create a fieldname loop that can be used with javascript
828
	// hide and enable features.
829 44c10295 Scott Ullrich
	echo "\n<script type=\"text/javascript\">\n";
830 6a11423f Colin Fleming
	echo "//<![CDATA[\n";
831 34b5c5a0 Scott Ullrich
	echo "function disableall() {\n";
832
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
833
		if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
834
			if(!$field['donotdisable'] <> "") {
835
				array_push($fieldnames_array, $field['name']);
836 4dc8f32e ccesario
				$fieldname = preg_replace("/\s+/", "", $field['name']);
837 34b5c5a0 Scott Ullrich
				$fieldname = strtolower($fieldname);
838
				echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
839
			}
840
		}
841
	}
842
	echo "}\ndisableall();\n";
843
	echo "function enableitems(selectedindex) {\n";
844
	echo "disableall();\n";
845
	$idcounter = 0;
846
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
847
		echo "\tswitch(selectedindex) {\n";
848
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
849
			if($field['options']['option'] <> "") {
850
				foreach ($field['options']['option'] as $opt) {
851
					if($opt['enablefields'] <> "") {
852
						echo "\t\tcase " . $idcounter . ":\n";
853 cfbfd941 smos
						$enablefields_split = explode(",", $opt['enablefields']);
854 34b5c5a0 Scott Ullrich
						foreach ($enablefields_split as $efs) {
855 4dc8f32e ccesario
							$fieldname = preg_replace("/\s+/", "", $efs);
856 34b5c5a0 Scott Ullrich
							$fieldname = strtolower($fieldname);
857
							if($fieldname <> "") {
858
								$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
859
								echo $onchange;
860
							}
861
						}
862
						echo "\t\t\tbreak;\n";
863
					}
864
					$idcounter = $idcounter + 1;
865
				}
866
			}
867
		}
868
		echo "\t}\n";
869
	}
870
	echo "}\n";
871 6a11423f Colin Fleming
	echo "//]]>\n";
872 34b5c5a0 Scott Ullrich
	echo "</script>\n\n";
873
}
874 e22e834d Renato Botelho
?>
875 34b5c5a0 Scott Ullrich
876 e22e834d Renato Botelho
<script type="text/javascript">
877
//<![CDATA[
878
NiftyCheck();
879
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
880
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
881
enablechange();
882
disablechange();
883
showchange();
884
//]]>
885
</script>
886 34b5c5a0 Scott Ullrich
887 e22e834d Renato Botelho
<?php
888 34b5c5a0 Scott Ullrich
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
889
	// handle after form display event.
890
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
891
}
892
893
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
894
	// handle after form display event.
895 1e2d831c Renato Botelho
	echo "\n<script type=\"text/javascript\">\n";
896 1b244d38 Colin Fleming
	echo "//<![CDATA[\n";
897 34b5c5a0 Scott Ullrich
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
898 1b244d38 Colin Fleming
	echo "//]]>\n";
899 34b5c5a0 Scott Ullrich
	echo "</script>\n\n";
900
}
901
902 d51f86e0 Scott Ullrich
/*
903
 *  HELPER FUNCTIONS
904
 */
905
906
function fixup_string($string) {
907 a219c643 Erik Fonnesbeck
	global $config, $g, $myurl, $title;
908 78818d7a Scott Ullrich
	$newstring = $string;
909 d51f86e0 Scott Ullrich
	// fixup #1: $myurl -> http[s]://ip_address:port/
910 43d9a2d3 jim-p
	switch($config['system']['webgui']['protocol']) {
911 037304d8 Scott Ullrich
		case "http":
912
			$proto = "http";
913
			break;
914
		case "https":
915
			$proto = "https";
916
			break;
917
		default:
918
			$proto = "http";
919
			break;
920
	}
921 43d9a2d3 jim-p
	$port = $config['system']['webgui']['port'];
922 037304d8 Scott Ullrich
	if($port != "") {
923
		if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
924
			$urlport = ":" . $port;
925
		} elseif ($port != "80" and $port != "443") {
926
			$urlport = ":" . $port;
927
		} else {
928
			$urlport = "";
929
		}
930
	}
931 bc53fec6 Renato Botelho
	$http_host = $_SERVER['SERVER_NAME'];
932 b8d4d7cd Erik Fonnesbeck
	$urlhost = $http_host;
933 fd7f136b Erik Fonnesbeck
	// If finishing the setup wizard, check if accessing on a LAN or WAN address that changed
934
	if($title == "Reload in progress") {
935 6898927f Erik Fonnesbeck
		if (is_ipaddr($urlhost)) {
936
			$host_if = find_ip_interface($urlhost);
937
			if ($host_if) {
938
				$host_if = convert_real_interface_to_friendly_interface_name($host_if);
939
				if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr']))
940
					$urlhost = $config['interfaces'][$host_if]['ipaddr'];
941
			}
942 0bee2010 Erik Fonnesbeck
		} else if ($urlhost == $config['system']['hostname'])
943
			$urlhost = $config['wizardtemp']['system']['hostname'];
944
		else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain'])
945
			$urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain'];
946 fd7f136b Erik Fonnesbeck
	}
947 b8d4d7cd Erik Fonnesbeck
	if($urlhost != $http_host)
948
		file_put_contents("{$g['tmp_path']}/setupwizard_lastreferrer", $proto . "://" . $http_host . $urlport . $_SERVER['REQUEST_URI']);
949 fd7f136b Erik Fonnesbeck
	$myurl = $proto . "://" . $urlhost . $urlport . "/";
950 d70a5ac6 Ermal Lu?i
951
	if (strstr($newstring, "\$myurl"))
952
		$newstring = str_replace("\$myurl", $myurl, $newstring);
953 d2133701 Scott Ullrich
	// fixup #2: $wanip
954 d70a5ac6 Ermal Lu?i
	if (strstr($newstring, "\$wanip")) {
955
		$curwanip = get_interface_ip();
956
		$newstring = str_replace("\$wanip", $curwanip, $newstring);
957
	}
958 d2133701 Scott Ullrich
	// fixup #3: $lanip
959 d70a5ac6 Ermal Lu?i
	if (strstr($newstring, "\$lanip")) {
960
		$lanip = get_interface_ip("lan");
961
		$newstring = str_replace("\$lanip", $lanip, $newstring);
962
	}
963 d2133701 Scott Ullrich
	// fixup #4: fix'r'up here.
964 d51f86e0 Scott Ullrich
	return $newstring;
965
}
966
967 bd31336e Scott Ullrich
function is_timezone($elt) {
968
	return !preg_match("/\/$/", $elt);
969
}
970 d51f86e0 Scott Ullrich
971 c8000491 Scott Ullrich
?>
972
973
</body>
974 1e2d831c Renato Botelho
</html>