Project

General

Profile

Download (30.7 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
	Copyright (C) 2004 Scott Ullrich
6
	Copyright (C) 2010 Ermal Luçi
7
	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 658292ef Scott Ullrich
*/
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 f6339216 jim-p
require_once("filter.inc");
43 f9fc88cc sullrich
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 1e2d831c Renato Botelho
	$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 1e2d831c Renato Botelho
	require_once($pkg['includefile']);
87 2ca50c87 Ermal Lu?i
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 1e2d831c Renato Botelho
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
97
		if(!empty($field['bindstofield']) and $field['type'] <> "submit") {
98
			$fieldname = $field['name'];
99
			$fieldname = str_replace(" ", "", $fieldname);
100
			$fieldname = strtolower($fieldname);
101
			// update field with posted values.
102
			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
111
			update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
112
		}
113
114
	}
115
	// run custom php code embedded in xml config.
116
	if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
117 3ed807e4 Scott Ullrich
		eval($pkg['step'][$stepid]['stepsubmitphpaction']);
118 1e2d831c Renato Botelho
	}
119 27319e17 jim-p
	if (!$input_errors)
120
		write_config();
121 1e2d831c Renato Botelho
	$stepid++;
122
	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 1e2d831c Renato Botelho
		 */
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 6a11423f Colin Fleming
$closehead = false;
173 d88c6a9f Scott Ullrich
$pgtitle = array($title);
174 4df96eff Scott Ullrich
include("head.inc");
175 6bb5c9aa Bill Marquette
176 1e2d831c Renato Botelho
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
177 6a11423f Colin Fleming
	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
178 1e2d831c Renato Botelho
else
179 6a11423f Colin Fleming
	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
180 4df96eff Scott Ullrich
?>
181 6a11423f Colin Fleming
</head>
182 1ae55320 Ermal
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" >
183 8c01d3bb Scott Ullrich
184 33a56b27 Colin Smith
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
185 44c10295 Scott Ullrich
<script type="text/javascript">
186 6a11423f Colin Fleming
//<![CDATA[
187 38e7d556 Scott Ullrich
188 e881d1f3 Scott Ullrich
function  FieldValidate(userinput,  regexp,  message)
189
{
190 2465ff5b Ermal
	if(!userinput.match(regexp))
191
		alert(message);
192 e881d1f3 Scott Ullrich
}
193 38e7d556 Scott Ullrich
194 33a56b27 Colin Smith
function enablechange() {
195
<?php
196 1e2d831c Renato Botelho
	foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
197
		if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
198
			print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked) {' . "\n";
199
			if(isset($field['enablefields'])) {
200
				$enablefields = explode(',', $field['enablefields']);
201
				foreach($enablefields as $enablefield) {
202
					$enablefield = strtolower($enablefield);
203
					print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
204
				}
205
			}
206
			if(isset($field['checkenablefields'])) {
207
				$checkenablefields = explode(',', $field['checkenablefields']);
208
				foreach($checkenablefields as $checkenablefield) {
209
					$checkenablefield = strtolower($checkenablefield);
210
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
211
				}
212
			}
213
			print "\t" . '} else {' . "\n";
214
			if(isset($field['enablefields'])) {
215
				$enablefields = explode(',', $field['enablefields']);
216
				foreach($enablefields as $enablefield) {
217
					$enablefield = strtolower($enablefield);
218
					print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
219
				}
220
			}
221
			if(isset($field['checkenablefields'])) {
222
				$checkenablefields = explode(',', $field['checkenablefields']);
223
				foreach($checkenablefields as $checkenablefield) {
224
					$checkenablefield = strtolower($checkenablefield);
225
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
226
				}
227
			}
228
			print "\t" . '}' . "\n";
229
		}
230
	}
231 33a56b27 Colin Smith
?>
232 6bb5c9aa Bill Marquette
}
233 2465ff5b Ermal
234 1ae55320 Ermal
function disablechange() {
235
<?php
236 1e2d831c Renato Botelho
	foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
237
		if(isset($field['disablefields']) or isset($field['checkdisablefields'])) {
238
			print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked) {' . "\n";
239
			if(isset($field['disablefields'])) {
240
				$enablefields = explode(',', $field['disablefields']);
241
				foreach($enablefields as $enablefield) {
242
					$enablefield = strtolower($enablefield);
243
					print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
244
				}
245
			}
246
			if(isset($field['checkdisablefields'])) {
247
				$checkenablefields = explode(',', $field['checkdisablefields']);
248
				foreach($checkenablefields as $checkenablefield) {
249
					$checkenablefield = strtolower($checkenablefield);
250
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
251
				}
252
			}
253
			print "\t" . '} else {' . "\n";
254
			if(isset($field['disablefields'])) {
255
				$enablefields = explode(',', $field['disablefields']);
256
				foreach($enablefields as $enablefield) {
257
					$enablefield = strtolower($enablefield);
258
					print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
259
				}
260
			}
261
			if(isset($field['checkdisablefields'])) {
262
				$checkenablefields = explode(',', $field['checkdisablefields']);
263
				foreach($checkenablefields as $checkenablefield) {
264
					$checkenablefield = strtolower($checkenablefield);
265
					print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
266
				}
267
			}
268
			print "\t" . '}' . "\n";
269
		}
270
	}
271 1ae55320 Ermal
?>
272
}
273
274 2465ff5b Ermal
function showchange() {
275
<?php
276 1e2d831c Renato Botelho
	foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
277
		if(isset($field['showfields'])) {
278
			print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
279
			if(isset($field['showfields'])) {
280
				$showfields = explode(',', $field['showfields']);
281
				foreach($showfields as $showfield) {
282
					$showfield = strtolower($showfield);
283
					//print "\t\t" . 'document.iform.' . $showfield . ".display =\"none\";\n";
284 ea1cea05 Vinicius Coque
					print "\t\t jQuery('#". $showfield . "').hide();";
285 1e2d831c Renato Botelho
				}
286
			}
287
			print "\t" . '} else {' . "\n";
288
			if(isset($field['showfields'])) {
289
				$showfields = explode(',', $field['showfields']);
290
				foreach($showfields as $showfield) {
291
					$showfield = strtolower($showfield);
292
					#print "\t\t" . 'document.iform.' . $showfield . ".display =\"\";\n";
293 ea1cea05 Vinicius Coque
					print "\t\t jQuery('#". $showfield . "').show();";
294 1e2d831c Renato Botelho
				}
295
			}
296
			print "\t" . '}' . "\n";
297
		}
298 2465ff5b Ermal
	}
299
?>
300
}
301 6a11423f Colin Fleming
//]]>
302 6bb5c9aa Bill Marquette
</script>
303 33a56b27 Colin Smith
<?php } ?>
304 6bb5c9aa Bill Marquette
305 33a56b27 Colin Smith
<form action="wizard.php" method="post" name="iform" id="iform">
306 6a11423f Colin Fleming
<input type="hidden" name="xml" value="<?= htmlspecialchars($xml) ?>" />
307
<input type="hidden" name="stepid" value="<?= htmlspecialchars($stepid) ?>" />
308 658292ef Scott Ullrich
309 e48fc17d Scott Ullrich
<center>
310
311 6a11423f Colin Fleming
&nbsp;<br/>
312 1c3d61fe Scott Ullrich
313 fe2bfbfc Scott Ullrich
<?php
314 1c3d61fe Scott Ullrich
	if($title == "Reload in progress") {
315 3f394d09 Erik Fonnesbeck
		$ip = fixup_string("\$myurl");
316 1c3d61fe Scott Ullrich
	} else {
317 fe2bfbfc Scott Ullrich
		$ip = "/";
318 1c3d61fe Scott Ullrich
	}
319 2576dace Ermal Luçi
	echo "<a href='$ip'>";
320 fe2bfbfc Scott Ullrich
?>
321 6a11423f Colin Fleming
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif" alt="logo" /></a>
322
<p>&nbsp;</p>
323 b7bb1711 Ermal Lu?i
<div style="width:800px;background-color:#ffffff" id="roundme">
324 55b8d602 Scott Ullrich
<?php
325 27319e17 jim-p
	if ($input_errors)
326
		print_input_errors($input_errors);
327 eb20f3c5 Ermal Lu?i
	if ($savemsg)
328
		print_info_box($savemsg);
329 55b8d602 Scott Ullrich
	if ($_GET['message'] != "")
330 d8c1a6c5 Scott Ullrich
		print_info_box(htmlspecialchars($_GET['message']));
331 55b8d602 Scott Ullrich
	if ($_POST['message'] != "")
332 d8c1a6c5 Scott Ullrich
		print_info_box(htmlspecialchars($_POST['message']));
333 94017670 Ermal
?>
334 6a11423f Colin Fleming
<table bgcolor="#ffffff" width="95%" border="0" cellspacing="0" cellpadding="2" summary="wizard">
335 1e2d831c Renato Botelho
	<!-- wizard goes here -->
336
	<tr><td>&nbsp;</td></tr>
337
	<tr>
338
		<td class="tabcont">
339
			<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
340
341
				<tr><td colspan="2" align="center"><font size="2"><b><?= fixup_string($description) ?></b></font></td></tr><tr><td>&nbsp;</td></tr>
342
<?php
343 34b5c5a0 Scott Ullrich
	if(!$pkg['step'][$stepid]['disableheader'])
344 d51f86e0 Scott Ullrich
		echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
345 1e2d831c Renato Botelho
?>
346 34b5c5a0 Scott Ullrich
347 1e2d831c Renato Botelho
<?php
348 44c10295 Scott Ullrich
	$inputaliases = array();
349 34b5c5a0 Scott Ullrich
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
350
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
351
352 1e2d831c Renato Botelho
			$value = $field['value'];
353
			$name  = $field['name'];
354 658292ef Scott Ullrich
355 1e2d831c Renato Botelho
			$name = preg_replace("/\s+/", "", $name);
356
			$name = strtolower($name);
357 658292ef Scott Ullrich
358 1e2d831c Renato Botelho
			if($field['bindstofield'] <> "") {
359 b1919dd0 Scott Ullrich
				$arraynum = "";
360
				$field_conv = "";
361 cfbfd941 smos
				$field_split = explode("->", $field['bindstofield']);
362 b1919dd0 Scott Ullrich
				// arraynum is used in cases where there is an array of the same field
363
				// name such as dnsserver (2 of them)
364 a314bebc Ermal
				if($field['arraynum'] <> "")
365
					$arraynum = "[" . $field['arraynum'] . "]";
366
				foreach ($field_split as $f)
367
					$field_conv .= "['" . $f . "']";
368 60ce86ea Erik Fonnesbeck
				if($field['type'] == "checkbox")
369
					$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) { \$value = \$config" . $field_conv . $arraynum . "; if (empty(\$value)) \$value = true; }";
370
				else
371
					$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) \$value = \$config" . $field_conv . $arraynum . ";";
372 a314bebc Ermal
				eval($toeval);
373 1e2d831c Renato Botelho
			}
374 34b5c5a0 Scott Ullrich
375 1e2d831c Renato Botelho
			if(!$field['combinefieldsend'])
376
				echo "<tr>";
377
378
			switch ($field['type']) {
379
			case "input":
380
				if ($field['displayname']) {
381
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
382
					echo $field['displayname'];
383
					echo ":</td>\n";
384
				} else if(!$field['dontdisplayname']) {
385
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
386
					echo fixup_string($field['name']);
387
					echo ":</td>\n";
388
				}
389
				if(!$field['dontcombinecells'])
390
					echo "<td class=\"vtable\">\n";
391
392 605ae553 Renato Botelho
				echo "<input class='formfld unknown' id='" . $name . "' name='" . $name . "' value=\"" . htmlspecialchars($value) . "\"";
393 1e2d831c Renato Botelho
				if($field['size'])
394
					echo " size='" . $field['size'] . "' ";
395
				if($field['validate'])
396
					echo " onchange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
397
				echo " />\n";
398
399
				if($field['description'] <> "") {
400
					echo "<br /> " . $field['description'];
401
				}
402
				break;
403
			case "text":
404
				echo "<td colspan=\"2\" align=\"center\" class=\"vncell\">\n";
405
				if($field['description'] <> "") {
406
					echo "<center><br /> " . $field['description'] . "</center>";
407
				}
408
				break;
409
			case "inputalias":
410
				if ($field['displayname']) {
411
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
412
					echo $field['displayname'];
413
					echo ":</td>\n";
414
				} else if(!$field['dontdisplayname']) {
415
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
416
					echo fixup_string($field['name']);
417
					echo ":</td>\n";
418
				}
419
				if(!$field['dontcombinecells'])
420
					echo "<td class=\"vtable\">\n";
421
422
				$inputaliases[] = $name;
423 605ae553 Renato Botelho
				echo "<input class='formfldalias' autocomplete='off' id='" . $name . "' name='" . $name . "' value=\"" . htmlspecialchars($value) . "\"";
424 1e2d831c Renato Botelho
				if($field['size'])
425
					echo " size='" . $field['size'] . "' ";
426
				if($field['validate'])
427
					echo " onchange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
428
				echo " />\n";
429
430
				if($field['description'] <> "") {
431
					echo "<br /> " . $field['description'];
432
				}
433
				break;
434
			case "interfaces_selection":
435
			case "interface_select":
436
				$size = "";
437
				$multiple = "";
438
				$name = strtolower($name);
439 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
440 1e2d831c Renato Botelho
				echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
441
				echo "</td>";
442 34b5c5a0 Scott Ullrich
				echo "<td class=\"vtable\">\n";
443 1e2d831c Renato Botelho
				if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
444
				if($field['multiple'] <> "" and $field['multiple'] <> "0") {
445
					$multiple = "multiple=\"multiple\"";
446
					$name .= "[]";
447
				}
448
				echo "<select class='formselect' id='{$name}' name='{$name}' {$size} {$multiple}>\n";
449
				if($field['add_to_interfaces_selection'] <> "") {
450
					$SELECTED = "";
451
					if($field['add_to_interfaces_selection'] == $value) $SELECTED = " selected=\"selected\"";
452
					echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
453
				}
454
				if($field['type'] == "interface_select")
455
					$interfaces = get_interface_list();
456
				else
457
					$interfaces = get_configured_interface_with_descr();
458
				foreach ($interfaces as $ifname => $iface) {
459
					if ($field['type'] == "interface_select") {
460
						$iface = $ifname;
461
						if ($iface['mac'])
462
							$iface .= " ({$iface['mac']})";
463
					}
464
					$SELECTED = "";
465
					if ($value == $ifname) $SELECTED = " selected=\"selected\"";
466
					$to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $iface . "</option>\n";
467
					$to_echo .= "<!-- {$value} -->";
468
					$canecho = 0;
469
					if($field['interface_filter'] <> "") {
470
						if(stristr($ifname, $field['interface_filter']) == true)
471
							$canecho = 1;
472
					} else
473
						$canecho = 1;
474
					if($canecho == 1)
475
						echo $to_echo;
476
				}
477
				echo "</select>\n";
478 6bb5c9aa Bill Marquette
479 1e2d831c Renato Botelho
				if($field['description'] <> "") {
480
					echo "<br /> " . $field['description'];
481
				}
482 62a48760 Scott Ullrich
483 1e2d831c Renato Botelho
				break;
484
			case "password":
485
				if ($field['displayname']) {
486
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
487
					echo $field['displayname'];
488
					echo ":</td>\n";
489
				} else if(!$field['dontdisplayname']) {
490
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
491
					echo fixup_string($field['name']);
492
					echo ":</td>\n";
493
				}
494
				if(!$field['dontcombinecells'])
495
					echo "<td class=\"vtable\">";
496 605ae553 Renato Botelho
				echo "<input class='formfld pwd' id='" . $name . "' name='" . $name . "' value=\"" . htmlspecialchars($value) . "\" type='password' ";
497 1e2d831c Renato Botelho
				if($field['size'])
498
					echo " size='" . $field['size'] . "' ";
499
				echo " />\n";
500
501
				if($field['description'] <> "") {
502
					echo "<br /> " . $field['description'];
503
				}
504
505
				break;
506
			case "certca_selection":
507
				$size = "";
508
				$multiple = "";
509
				$name = strtolower($name);
510 62a48760 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
511 1e2d831c Renato Botelho
				echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
512
				echo "</td>";
513 62a48760 Scott Ullrich
				echo "<td class=\"vtable\">\n";
514 1e2d831c Renato Botelho
				if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
515
				echo "<select id='{$name}' name='{$name}' {$size}>\n";
516
				if($field['add_to_certca_selection'] <> "") {
517
					$SELECTED = "";
518
					if($field['add_to_certca_selection'] == $value) $SELECTED = " selected=\"selected\"";
519
					echo "<option value='" . $field['add_to_certca_selection'] . "'" . $SELECTED . ">" . $field['add_to_certca_selection'] . "</option>\n";
520
				}
521
				foreach($config['ca'] as $ca) {
522
					$name = htmlspecialchars($ca['descr']);
523
					$SELECTED = "";
524
					if ($value == $name) $SELECTED = " selected=\"selected\"";
525
					$to_echo = "<option value='" . $ca['refid'] . "'" . $SELECTED . ">" . $name . "</option>\n";
526
					$to_echo .= "<!-- {$value} -->";
527
					$canecho = 0;
528
					if($field['certca_filter'] <> "") {
529
						if(stristr($name, $field['certca_filter']) == true)
530
							$canecho = 1;
531
					} else {
532
						$canecho = 1;
533
					}
534
					if($canecho == 1)
535
						echo $to_echo;
536
				}
537
				echo "</select>\n";
538 62a48760 Scott Ullrich
539 1e2d831c Renato Botelho
				if($field['description'] <> "") {
540
					echo "<br /> " . $field['description'];
541
				}
542 b7bb1711 Ermal Lu?i
543 1e2d831c Renato Botelho
				break;
544
			case "cert_selection":
545
				$size = "";
546
				$multiple = "";
547
				$name = strtolower($name);
548 c062a711 jim-p
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
549 1e2d831c Renato Botelho
				echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
550
				echo "</td>";
551
				echo "<td class=\"vtable\">\n";
552
				if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
553
				echo "<select id='{$name}' name='{$name}' {$size}>\n";
554
				if($field['add_to_cert_selection'] <> "") {
555
					$SELECTED = "";
556
					if($field['add_to_cert_selection'] == $value) $SELECTED = " selected=\"selected\"";
557
					echo "<option value='" . $field['add_to_cert_selection'] . "'" . $SELECTED . ">" . $field['add_to_cert_selection'] . "</option>\n";
558
				}
559
				foreach($config['cert'] as $ca) {
560
					if (stristr($ca['descr'], "webconf"))
561
						continue;
562
					$name = htmlspecialchars($ca['descr']);
563
					$SELECTED = "";
564
					if ($value == $name) $SELECTED = " selected=\"selected\"";
565
					$to_echo = "<option value='" . $ca['refid'] . "'" . $SELECTED . ">" . $name . "</option>\n";
566
					$to_echo .= "<!-- {$value} -->";
567
					$canecho = 0;
568
					if($field['cert_filter'] <> "") {
569
						if(stristr($name, $field['cert_filter']) == true)
570
							$canecho = 1;
571
					} else {
572
						$canecho = 1;
573
					}
574
					if($canecho == 1)
575
						echo $to_echo;
576
				}
577
				echo "</select>\n";
578 66f773b4 Ermal Lu?i
579 1e2d831c Renato Botelho
				if($field['description'] <> "") {
580
					echo "<br /> " . $field['description'];
581
				}
582 b7bb1711 Ermal Lu?i
583 1e2d831c Renato Botelho
				break;
584
			case "select":
585
				if ($field['displayname']) {
586
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
587
					echo $field['displayname'];
588
					echo ":</td>\n";
589
				} else if(!$field['dontdisplayname']) {
590
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
591
					echo fixup_string($field['name']);
592
					echo ":</td>\n";
593
				}
594
				if($field['size']) $size = " size='" . $field['size'] . "' ";
595
				if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
596
				if(!$field['dontcombinecells'])
597
					echo "<td class=\"vtable\">\n";
598
				$onchange = "";
599
				foreach ($field['options']['option'] as $opt) {
600
					if($opt['enablefields'] <> "") {
601
						$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
602
					}
603
				}
604
				echo "<select class='formselect' " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
605
				foreach ($field['options']['option'] as $opt) {
606
					$selected = "";
607
					if($value == $opt['value'])
608
						$selected = " selected=\"selected\"";
609
					echo "\t<option value='" . $opt['value'] . "'" . $selected . ">";
610
					if ($opt['displayname'])
611
						echo $opt['displayname'];
612
					else
613
						echo $opt['name'];
614
					echo "</option>\n";
615
				}
616
				echo "</select>\n";
617
				echo "<!-- {$value} -->\n";
618 b7bb1711 Ermal Lu?i
619 1e2d831c Renato Botelho
				if($field['description'] <> "") {
620
					echo $field['description'];
621
				}
622 b7bb1711 Ermal Lu?i
623 1e2d831c Renato Botelho
				break;
624
			case "textarea":
625
				if ($field['displayname']) {
626
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
627
					echo $field['displayname'];
628
					echo ":</td>\n";
629
				} else if(!$field['dontdisplayname']) {
630
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
631
					echo fixup_string($field['name']);
632
					echo ":</td>";
633
				}
634
				if(!$field['dontcombinecells'])
635
					echo "<td class=\"vtable\">";
636
				echo "<textarea class='formpre' id='" . $name . "' name='" . $name . "'";
637
				if ($field['rows'])
638
					echo " rows='" . $field['rows'] . "' ";
639
				if ($field['cols'])
640
					echo " cols='" . $field['cols'] . "' ";
641
				echo ">" . $value . "</textarea>\n";
642
643
644
				if($field['description'] <> "") {
645
					echo "<br /> " . $field['description'];
646 34b5c5a0 Scott Ullrich
				}
647 66f773b4 Ermal Lu?i
648 1e2d831c Renato Botelho
				break;
649
			case "submit":
650
				echo "<td>&nbsp;<br/></td></tr>";
651
				echo "<tr><td colspan=\"2\" align=\"center\">";
652 605ae553 Renato Botelho
				echo "<input type='submit' name='" . $name . "' value=\"" . htmlspecialchars($field['name']) . "\" />\n";
653 b7bb1711 Ermal Lu?i
654 1e2d831c Renato Botelho
				if($field['description'] <> "") {
655
					echo "<br /> " . $field['description'];
656
				}
657 b7bb1711 Ermal Lu?i
658 1e2d831c Renato Botelho
				break;
659
			case "listtopic":
660
				echo "<td>&nbsp;</td></tr>";
661
				echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br /></td>\n";
662
663
				break;
664
			case "subnet_select":
665
				if ($field['displayname']) {
666
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
667
					echo $field['displayname'];
668
					echo ":</td>\n";
669
				} else if(!$field['dontdisplayname']) {
670
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
671
					echo fixup_string($field['name']);
672
					echo ":</td>";
673
				}
674
				if(!$field['dontcombinecells'])
675
					echo "<td class=\"vtable\">";
676
				echo "<select class='formselect' name='{$name}'>\n";
677
				for($x=1; $x<33; $x++) {
678
					$CHECKED = "";
679
					if($value == $x) $CHECKED = " selected=\"selected\"";
680
					if($x <> 31)
681
						echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
682
				}
683
				echo "</select>\n";
684 66f773b4 Ermal Lu?i
685 1e2d831c Renato Botelho
				if($field['description'] <> "") {
686
					echo "<br /> " . $field['description'];
687
				}
688 b7bb1711 Ermal Lu?i
689 1e2d831c Renato Botelho
				break;
690
			case "timezone_select":
691
				exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
692
				$timezonelist = array_filter($timezonelist, 'is_timezone');
693
				sort($timezonelist);
694
695
				/* kill carriage returns */
696
				for($x=0; $x<count($timezonelist); $x++)
697
					$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
698
699
				if ($field['displayname']) {
700
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
701
					echo $field['displayname'];
702
					echo ":</td>\n";
703
				} else if(!$field['dontdisplayname']) {
704
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
705
					echo fixup_string($field['name']);
706
					echo ":</td>";
707
				}
708
				if(!$field['dontcombinecells'])
709
					echo "<td class=\"vtable\">";
710
				echo "<select class='formselect' name='{$name}'>\n";
711
				foreach ($timezonelist as $tz) {
712
					if(strstr($tz, "GMT"))
713
						continue;
714
					$SELECTED = "";
715
					if ($value == $tz) $SELECTED = " selected=\"selected\"";
716 605ae553 Renato Botelho
					echo "<option value=\"" . htmlspecialchars($tz) . "\" {$SELECTED}>";
717 1e2d831c Renato Botelho
					echo htmlspecialchars($tz);
718
					echo "</option>\n";
719
				}
720
				echo "</select>\n";
721 b7bb1711 Ermal Lu?i
722 1e2d831c Renato Botelho
				if($field['description'] <> "") {
723
					echo "<br /> " . $field['description'];
724
				}
725 66f773b4 Ermal Lu?i
726 1e2d831c Renato Botelho
				break;
727
			case "checkbox":
728
				if ($field['displayname']) {
729
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
730
					echo $field['displayname'];
731
					echo ":</td>\n";
732
				} else if(!$field['dontdisplayname']) {
733
					echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
734
					echo $field['name'];
735
					echo ":</td>";
736
				}
737
				$checked = "";
738
				if($value <> "")
739
					$checked = " checked=\"checked\"";
740
				echo "<td class=\"vtable\"><input value=\"on\" type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
741
				if(isset($field['enablefields']) or isset($field['checkenablefields']))
742
					echo " onclick=\"enablechange()\"";
743
				else if(isset($field['disablefields']) or isset($field['checkdisablefields']))
744
					echo " onclick=\"disablechange()\"";
745
				echo " />\n";
746
747
				if($field['description'] <> "") {
748
					echo $field['description'];
749
				}
750 b7bb1711 Ermal Lu?i
751 1e2d831c Renato Botelho
				break;
752 bd31336e Scott Ullrich
			}
753 66f773b4 Ermal Lu?i
754 1e2d831c Renato Botelho
			if($field['typehint'] <> "") {
755
				echo $field['typehint'];
756
			}
757
			if($field['warning'] <> "") {
758
				echo "<br /><b><font color=\"red\">" . $field['warning'] . "</font></b>";
759 34b5c5a0 Scott Ullrich
			}
760 f3c6fdc0 Bill Marquette
761 1e2d831c Renato Botelho
			if(!$field['combinefieldsbegin']) {
762
				if (!$field['dontcombinecells'])
763
					echo "</td>";
764 8984dc5e Ermal
765 1e2d831c Renato Botelho
				echo "</tr>\n";
766
			}
767 1ae55320 Ermal
768 34b5c5a0 Scott Ullrich
		}
769
	}
770 1e2d831c Renato Botelho
?>
771
			</table>
772
		</td>
773
	</tr>
774 658292ef Scott Ullrich
</table>
775 6a11423f Colin Fleming
<br/>&nbsp;
776 5adb3375 Scott Ullrich
</div>
777 6a11423f Colin Fleming
</center>
778 658292ef Scott Ullrich
</form>
779 44c10295 Scott Ullrich
<script type="text/javascript">
780 6a11423f Colin Fleming
//<![CDATA[
781 62a48760 Scott Ullrich
	if (typeof ext_change != 'undefined') {
782
		ext_change();
783
	}
784
	if (typeof proto_change != 'undefined') {
785
		ext_change();
786
	}
787
	if (typeof proto_change != 'undefined') {
788
		proto_change();
789
	}
790 5adb3375 Scott Ullrich
791 62a48760 Scott Ullrich
<?php
792
	$isfirst = 0;
793
	$aliases = "";
794
	$addrisfirst = 0;
795
	$aliasesaddr = "";
796
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
797
		foreach($config['aliases']['alias'] as $alias_name) {
798 40050fab Ermal
				if($isfirst == 1)
799
					$aliases .= ",";
800 62a48760 Scott Ullrich
				$aliases .= "'" . $alias_name['name'] . "'";
801
				$isfirst = 1;
802
		}
803
?>
804
805
	var customarray=new Array(<?php echo $aliases; ?>);
806
807 44c10295 Scott Ullrich
	window.onload = function () {
808
809
		<?php
810
			$counter=0;
811
			foreach($inputaliases as $alias) {
812 40050fab Ermal
				echo "var oTextbox$counter = new AutoSuggestControl(document.getElementById(\"$alias\"), new StateSuggestions(customarray));\n";
813 44c10295 Scott Ullrich
				$counter++;
814
			}
815
		?>
816
817
	}
818
819 6a11423f Colin Fleming
//]]>
820 62a48760 Scott Ullrich
</script>
821 5adb3375 Scott Ullrich
822 34b5c5a0 Scott Ullrich
<?php
823
824
$fieldnames_array = Array();
825
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
826
	// create a fieldname loop that can be used with javascript
827
	// hide and enable features.
828 44c10295 Scott Ullrich
	echo "\n<script type=\"text/javascript\">\n";
829 6a11423f Colin Fleming
	echo "//<![CDATA[\n";
830 34b5c5a0 Scott Ullrich
	echo "function disableall() {\n";
831
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
832
		if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
833
			if(!$field['donotdisable'] <> "") {
834
				array_push($fieldnames_array, $field['name']);
835 4dc8f32e ccesario
				$fieldname = preg_replace("/\s+/", "", $field['name']);
836 34b5c5a0 Scott Ullrich
				$fieldname = strtolower($fieldname);
837
				echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
838
			}
839
		}
840
	}
841
	echo "}\ndisableall();\n";
842
	echo "function enableitems(selectedindex) {\n";
843
	echo "disableall();\n";
844
	$idcounter = 0;
845
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
846
		echo "\tswitch(selectedindex) {\n";
847
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
848
			if($field['options']['option'] <> "") {
849
				foreach ($field['options']['option'] as $opt) {
850
					if($opt['enablefields'] <> "") {
851
						echo "\t\tcase " . $idcounter . ":\n";
852 cfbfd941 smos
						$enablefields_split = explode(",", $opt['enablefields']);
853 34b5c5a0 Scott Ullrich
						foreach ($enablefields_split as $efs) {
854 4dc8f32e ccesario
							$fieldname = preg_replace("/\s+/", "", $efs);
855 34b5c5a0 Scott Ullrich
							$fieldname = strtolower($fieldname);
856
							if($fieldname <> "") {
857
								$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
858
								echo $onchange;
859
							}
860
						}
861
						echo "\t\t\tbreak;\n";
862
					}
863
					$idcounter = $idcounter + 1;
864
				}
865
			}
866
		}
867
		echo "\t}\n";
868
	}
869
	echo "}\n";
870 6a11423f Colin Fleming
	echo "//]]>\n";
871 34b5c5a0 Scott Ullrich
	echo "</script>\n\n";
872
}
873 e22e834d Renato Botelho
?>
874 34b5c5a0 Scott Ullrich
875 e22e834d Renato Botelho
<script type="text/javascript">
876
//<![CDATA[
877
NiftyCheck();
878
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
879
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
880
enablechange();
881
disablechange();
882
showchange();
883
//]]>
884
</script>
885 34b5c5a0 Scott Ullrich
886 e22e834d Renato Botelho
<?php
887 34b5c5a0 Scott Ullrich
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
888
	// handle after form display event.
889
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
890
}
891
892
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
893
	// handle after form display event.
894 1e2d831c Renato Botelho
	echo "\n<script type=\"text/javascript\">\n";
895 34b5c5a0 Scott Ullrich
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
896
	echo "</script>\n\n";
897
}
898
899 d51f86e0 Scott Ullrich
/*
900
 *  HELPER FUNCTIONS
901
 */
902
903
function fixup_string($string) {
904 a219c643 Erik Fonnesbeck
	global $config, $g, $myurl, $title;
905 78818d7a Scott Ullrich
	$newstring = $string;
906 d51f86e0 Scott Ullrich
	// fixup #1: $myurl -> http[s]://ip_address:port/
907 43d9a2d3 jim-p
	switch($config['system']['webgui']['protocol']) {
908 037304d8 Scott Ullrich
		case "http":
909
			$proto = "http";
910
			break;
911
		case "https":
912
			$proto = "https";
913
			break;
914
		default:
915
			$proto = "http";
916
			break;
917
	}
918 43d9a2d3 jim-p
	$port = $config['system']['webgui']['port'];
919 037304d8 Scott Ullrich
	if($port != "") {
920
		if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
921
			$urlport = ":" . $port;
922
		} elseif ($port != "80" and $port != "443") {
923
			$urlport = ":" . $port;
924
		} else {
925
			$urlport = "";
926
		}
927
	}
928 b8d4d7cd Erik Fonnesbeck
	$http_host = explode(":", $_SERVER['HTTP_HOST']);
929
	$http_host = $http_host[0];
930
	$urlhost = $http_host;
931 fd7f136b Erik Fonnesbeck
	// If finishing the setup wizard, check if accessing on a LAN or WAN address that changed
932
	if($title == "Reload in progress") {
933 6898927f Erik Fonnesbeck
		if (is_ipaddr($urlhost)) {
934
			$host_if = find_ip_interface($urlhost);
935
			if ($host_if) {
936
				$host_if = convert_real_interface_to_friendly_interface_name($host_if);
937
				if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr']))
938
					$urlhost = $config['interfaces'][$host_if]['ipaddr'];
939
			}
940 0bee2010 Erik Fonnesbeck
		} else if ($urlhost == $config['system']['hostname'])
941
			$urlhost = $config['wizardtemp']['system']['hostname'];
942
		else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain'])
943
			$urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain'];
944 fd7f136b Erik Fonnesbeck
	}
945 b8d4d7cd Erik Fonnesbeck
	if($urlhost != $http_host)
946
		file_put_contents("{$g['tmp_path']}/setupwizard_lastreferrer", $proto . "://" . $http_host . $urlport . $_SERVER['REQUEST_URI']);
947 fd7f136b Erik Fonnesbeck
	$myurl = $proto . "://" . $urlhost . $urlport . "/";
948 d70a5ac6 Ermal Lu?i
949
	if (strstr($newstring, "\$myurl"))
950
		$newstring = str_replace("\$myurl", $myurl, $newstring);
951 d2133701 Scott Ullrich
	// fixup #2: $wanip
952 d70a5ac6 Ermal Lu?i
	if (strstr($newstring, "\$wanip")) {
953
		$curwanip = get_interface_ip();
954
		$newstring = str_replace("\$wanip", $curwanip, $newstring);
955
	}
956 d2133701 Scott Ullrich
	// fixup #3: $lanip
957 d70a5ac6 Ermal Lu?i
	if (strstr($newstring, "\$lanip")) {
958
		$lanip = get_interface_ip("lan");
959
		$newstring = str_replace("\$lanip", $lanip, $newstring);
960
	}
961 d2133701 Scott Ullrich
	// fixup #4: fix'r'up here.
962 d51f86e0 Scott Ullrich
	return $newstring;
963
}
964
965 bd31336e Scott Ullrich
function is_timezone($elt) {
966
	return !preg_match("/\/$/", $elt);
967
}
968 d51f86e0 Scott Ullrich
969 c8000491 Scott Ullrich
?>
970
971
</body>
972 1e2d831c Renato Botelho
</html>