Project

General

Profile

Download (33.1 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 a3db8d75 Ermal
    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
	print_info_box_np("ERROR:  Could not open " . $xml . ".");
66
	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
		print_info_box_np("ERROR:  Could not open " . $xml . ".");
72
		die;
73
	}
74 658292ef Scott Ullrich
}
75
76 5a8a69b3 Ermal Lu?i
if (!is_array($pkg)) {
77
	print_info_box_np("ERROR: Could not parse {$g['www_path']}/wizards/{$xml} file.");
78
	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 658292ef Scott Ullrich
if ($_POST) {
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
	write_config();
120 e48fc17d Scott Ullrich
    $stepid++;
121 72a5f424 Ermal Lu?i
    if($stepid > $totalsteps)
122
	$stepid = $totalsteps;
123 658292ef Scott Ullrich
}
124
125 3f83de3d Scott Ullrich
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
126 eb20f3c5 Ermal Lu?i
	global $config;
127 e48fc17d Scott Ullrich
	$field_split = split("->",$field);
128 72a5f424 Ermal Lu?i
	foreach ($field_split as $f)
129
		$field_conv .= "['" . $f . "']";
130
	if($field_conv == "")
131
		return;
132 a4f07557 Ermal
	if ($arraynum <> "")
133 ddc75a80 Ermal
		$field_conv .= "[" . $arraynum . "]";
134 72a5f424 Ermal Lu?i
	if(($field_type == "checkbox" and $updatetext <> "on") || $updatetext == "") {
135 3f83de3d Scott Ullrich
		/*
136 a4f07557 Ermal
		 * item is a checkbox, it should have the value "on"
137
		 * if it was checked
138
                 */
139 b4eb3a17 jim-p
		$var = "\$config{$field_conv}";
140
		$text = "if (isset({$var})) unset({$var});";
141 3f83de3d Scott Ullrich
		eval($text);
142
		return;
143 496f9155 Scott Ullrich
	}
144 e881d1f3 Scott Ullrich
145 496f9155 Scott Ullrich
	if($field_type == "interfaces_selection") {
146 b4eb3a17 jim-p
		$var = "\$config{$field_conv}";
147
		$text = "if (isset({$var})) unset({$var});";
148 496f9155 Scott Ullrich
		$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
149
		eval($text);
150
		return;
151
	}
152 e881d1f3 Scott Ullrich
153 ddc75a80 Ermal
	if($unset == "yes") {
154 e48fc17d Scott Ullrich
		$text = "unset(\$config" . $field_conv . ");";
155
		eval($text);
156
	}
157 a4f07557 Ermal
	$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
158
	eval($text);
159 658292ef Scott Ullrich
}
160
161 42f1649f Erik Fonnesbeck
$title       = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
162
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
163
164 a314bebc Ermal
// handle before form display event.
165
do {
166
	$oldstepid = $stepid;
167
	if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "")
168
		eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
169
} while ($oldstepid != $stepid);
170 34b5c5a0 Scott Ullrich
171 d88c6a9f Scott Ullrich
$pgtitle = array($title);
172 4df96eff Scott Ullrich
include("head.inc");
173 6bb5c9aa Bill Marquette
174 4df96eff Scott Ullrich
?>
175 1ae55320 Ermal
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" >
176 4e3391a3 Scott Ullrich
177 8c01d3bb Scott Ullrich
<?php
178 ba21539c Scott Ullrich
	if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
179 8c01d3bb Scott Ullrich
		echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
180 4e3391a3 Scott Ullrich
	else 
181
		echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
182 8c01d3bb Scott Ullrich
?>
183
184 33a56b27 Colin Smith
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
185 44c10295 Scott Ullrich
<script type="text/javascript">
186 f9e35766 Scott Ullrich
<!--
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
        foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
197
                if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
198 ba374e4b Ermal
                        print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked) {' . "\n";
199 33a56b27 Colin Smith
                        if(isset($field['enablefields'])) {
200
                                $enablefields = explode(',', $field['enablefields']);
201
                                foreach($enablefields as $enablefield) {
202
                                        $enablefield = strtolower($enablefield);
203 b554f7bf Ermal
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
204 33a56b27 Colin Smith
                                }
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 2465ff5b Ermal
                                $enablefields = explode(',', $field['enablefields']);
216 33a56b27 Colin Smith
                                foreach($enablefields as $enablefield) {
217
                                        $enablefield = strtolower($enablefield);
218 b554f7bf Ermal
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
219 33a56b27 Colin Smith
                                }
220
                        }
221
                        if(isset($field['checkenablefields'])) {
222 2465ff5b Ermal
                                $checkenablefields = explode(',', $field['checkenablefields']);
223 33a56b27 Colin Smith
                                foreach($checkenablefields as $checkenablefield) {
224
                                        $checkenablefield = strtolower($checkenablefield);
225
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
226
                                }
227 e881d1f3 Scott Ullrich
                        }
228 33a56b27 Colin Smith
                        print "\t" . '}' . "\n";
229
                }
230
        }
231
?>
232 6bb5c9aa Bill Marquette
}
233 2465ff5b Ermal
234 1ae55320 Ermal
function disablechange() {
235
<?php
236
        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 b554f7bf Ermal
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
251 1ae55320 Ermal
                                }
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 b554f7bf Ermal
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
266 1ae55320 Ermal
                                }
267
                        }
268
                        print "\t" . '}' . "\n";
269
                }
270
        }
271
?>
272
}
273
274 2465ff5b Ermal
function showchange() {
275
<?php
276
        foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
277 1ae55320 Ermal
                if(isset($field['showfields'])) {
278 2465ff5b Ermal
                        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 1ae55320 Ermal
                                        //print "\t\t" . 'document.iform.' . $showfield . ".display =\"none\";\n";
284
					print "\t\t \$('". $showfield . "').hide();";
285 2465ff5b Ermal
                                }
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 1ae55320 Ermal
                                        #print "\t\t" . 'document.iform.' . $showfield . ".display =\"\";\n";
293
					print "\t\t \$('". $showfield . "').show();";
294 2465ff5b Ermal
                                }
295
                        }
296
                        print "\t" . '}' . "\n";
297
                }
298
	}
299
?>
300
}
301 6bb5c9aa Bill Marquette
//-->
302
</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 658292ef Scott Ullrich
<input type="hidden" name="xml" value="<?= $xml ?>">
307 e48fc17d Scott Ullrich
<input type="hidden" name="stepid" value="<?= $stepid ?>">
308 658292ef Scott Ullrich
309 e48fc17d Scott Ullrich
<center>
310
311
&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 1c3d61fe Scott Ullrich
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
322 d51f86e0 Scott Ullrich
<p>
323 b7bb1711 Ermal Lu?i
<div style="width:800px;background-color:#ffffff" id="roundme">
324
<table bgcolor="#ffffff" width="95%" border="0" cellspacing="0" cellpadding="2">
325 34b5c5a0 Scott Ullrich
    <!-- wizard goes here -->
326
    <tr><td>&nbsp;</td></tr>
327 77851510 Scott Ullrich
    <tr><td colspan='2'>
328 55b8d602 Scott Ullrich
<?php
329 eb20f3c5 Ermal Lu?i
	if ($savemsg)
330
		print_info_box($savemsg);
331 55b8d602 Scott Ullrich
	if ($_GET['message'] != "")
332 d8c1a6c5 Scott Ullrich
		print_info_box(htmlspecialchars($_GET['message']));
333 55b8d602 Scott Ullrich
	if ($_POST['message'] != "")
334 d8c1a6c5 Scott Ullrich
		print_info_box(htmlspecialchars($_POST['message']));
335 77851510 Scott Ullrich
?></td></tr>
336 b7bb1711 Ermal Lu?i
 <tr>
337
	<td class="tabcont">
338
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
339
340
    <tr><td colspan='2'><center><font size="2"><b><?= fixup_string($description) ?></b></font></center></td></tr><tr><td>&nbsp;</td></tr>
341 34b5c5a0 Scott Ullrich
    <?php
342
	if(!$pkg['step'][$stepid]['disableheader'])
343 d51f86e0 Scott Ullrich
		echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
344 34b5c5a0 Scott Ullrich
    ?>
345
346
    <?php
347 44c10295 Scott Ullrich
	$inputaliases = array();
348 34b5c5a0 Scott Ullrich
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
349
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
350
351
		    $value = $field['value'];
352 2fbd6806 Scott Ullrich
		    $name  = $field['name'];
353 658292ef Scott Ullrich
354 2fbd6806 Scott Ullrich
		    $name = ereg_replace(" ", "", $name);
355
		    $name = strtolower($name);
356 658292ef Scott Ullrich
357 a8df0181 Scott Ullrich
		    if($field['bindstofield'] <> "") {
358 b1919dd0 Scott Ullrich
				$arraynum = "";
359
				$field_conv = "";
360
				$field_split = split("->", $field['bindstofield']);
361
				// arraynum is used in cases where there is an array of the same field
362
				// name such as dnsserver (2 of them)
363 a314bebc Ermal
				if($field['arraynum'] <> "")
364
					$arraynum = "[" . $field['arraynum'] . "]";
365
				foreach ($field_split as $f)
366
					$field_conv .= "['" . $f . "']";
367 60ce86ea Erik Fonnesbeck
				if($field['type'] == "checkbox")
368
					$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) { \$value = \$config" . $field_conv . $arraynum . "; if (empty(\$value)) \$value = true; }";
369
				else
370
					$toeval = "if (isset(\$config" . $field_conv . $arraynum . ")) \$value = \$config" . $field_conv . $arraynum . ";";
371 a314bebc Ermal
				eval($toeval);
372 a8df0181 Scott Ullrich
		    }
373
374 34b5c5a0 Scott Ullrich
		    if(!$field['combinefieldsend'])
375
			echo "<tr>";
376
377 b7bb1711 Ermal Lu?i
		    switch ($field['type']) {
378
		    case "input":
379 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
380
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
381 8984dc5e Ermal
				echo $field['displayname'];
382
				echo ":</td>\n";
383 7a29f783 Ermal Lu?i
			} else if(!$field['dontdisplayname']) {
384 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
385 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
386 34b5c5a0 Scott Ullrich
				echo ":</td>\n";
387
			}
388
			if(!$field['dontcombinecells'])
389
				echo "<td class=\"vtable\">\n";
390 6bb5c9aa Bill Marquette
391 66f773b4 Ermal Lu?i
			echo "<input class='formfld unknown' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
392
			if($field['size'])
393
				echo " size='" . $field['size'] . "' ";
394 6bb5c9aa Bill Marquette
			if($field['validate'])
395
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
396
			echo ">\n";
397 62a48760 Scott Ullrich
398 66f773b4 Ermal Lu?i
			if($field['description'] <> "") {
399
				echo "<br /> " . $field['description'];
400
		    	}
401 b7bb1711 Ermal Lu?i
			break;
402
		    case "text":
403 66f773b4 Ermal Lu?i
			echo "<td colspan=\"2\" align=\"center\" class=\"vncell\">\n";
404
			if($field['description'] <> "") {
405 b7bb1711 Ermal Lu?i
                                echo "<center><br /> " . $field['description'] . "</center>";
406 66f773b4 Ermal Lu?i
                        }
407 b7bb1711 Ermal Lu?i
			break;
408
		    case "inputalias":
409 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
410
                                echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
411 d6f53204 Ermal Lu?i
                                echo $field['displayname'];
412 7a29f783 Ermal Lu?i
                                echo ":</td>\n";
413
			} else if(!$field['dontdisplayname']) {
414 62a48760 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
415
				echo fixup_string($field['name']);
416
				echo ":</td>\n";
417
			}
418
			if(!$field['dontcombinecells'])
419
				echo "<td class=\"vtable\">\n";
420
421 40050fab Ermal
			$inputaliases[] = $name;
422
			echo "<input class='formfldalias' autocomplete='off' class='formfldalias' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
423 66f773b4 Ermal Lu?i
			if($field['size'])
424
				echo " size='" . $field['size'] . "' ";
425 62a48760 Scott Ullrich
			if($field['validate'])
426
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
427 e881d1f3 Scott Ullrich
			echo ">\n";
428
429 66f773b4 Ermal Lu?i
			if($field['description'] <> "") {
430
				echo "<br /> " . $field['description'];
431
		    	}
432 b7bb1711 Ermal Lu?i
			break;
433
		    case "interfaces_selection":
434 496f9155 Scott Ullrich
			$size = "";
435
			$multiple = "";
436
			$name = strtolower($name);
437
			echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
438 7a29f783 Ermal Lu?i
			echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
439 496f9155 Scott Ullrich
			echo "</td>";
440
			echo "<td class=\"vtable\">\n";
441 7b4710f9 Scott Ullrich
			if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
442 496f9155 Scott Ullrich
			if($field['multiple'] <> "" and $field['multiple'] <> "0") {
443 7b4710f9 Scott Ullrich
			  $multiple = "multiple=\"multiple\"";
444 496f9155 Scott Ullrich
			  $name .= "[]";
445
			}
446 66f773b4 Ermal Lu?i
			echo "<select class='formselect' id='{$name}' name='{$name}' {$size} {$multiple}>\n";
447 496f9155 Scott Ullrich
			if($field['add_to_interfaces_selection'] <> "") {
448
				$SELECTED = "";
449
				if($field['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
450
				echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
451
			}
452 203de6bf Ermal Lu?i
			$interfaces = get_configured_interface_with_descr();
453 496f9155 Scott Ullrich
			foreach ($interfaces as $ifname => $iface) {
454
			  $SELECTED = "";
455 aecffb0a Scott Ullrich
			  if ($value == $ifname) $SELECTED = " SELECTED";
456 203de6bf Ermal Lu?i
			  $to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $iface . "</option>\n";
457 496f9155 Scott Ullrich
			  $to_echo .= "<!-- {$value} -->";
458
			  $canecho = 0;
459
			  if($field['interface_filter'] <> "") {
460 203de6bf Ermal Lu?i
				if(stristr($ifname, $field['interface_filter']) == true)
461 496f9155 Scott Ullrich
					$canecho = 1;
462
			  } else {
463
				$canecho = 1;
464
			  }
465 e881d1f3 Scott Ullrich
			  if($canecho == 1)
466 496f9155 Scott Ullrich
				echo $to_echo;
467
			}
468
				echo "</select>\n";
469 66f773b4 Ermal Lu?i
470
			if($field['description'] <> "") {
471
				echo "<br /> " . $field['description'];
472
		    	}
473 b7bb1711 Ermal Lu?i
474
			break;
475
		    case "password":
476 c062a711 jim-p
			if ($field['displayname']) {
477
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
478
				echo $field['displayname'];
479
				echo ":</td>\n";
480
			} else if(!$field['dontdisplayname']) {
481 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
482 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
483 34b5c5a0 Scott Ullrich
				echo ":</td>\n";
484
			}
485
			if(!$field['dontcombinecells'])
486
				echo "<td class=\"vtable\">";
487 c062a711 jim-p
			echo "<input class='formfld pwd' id='" . $name . "' name='" . $name . "' value='" . $value . "' type='password' ";
488 66f773b4 Ermal Lu?i
			if($field['size'])
489
				echo " size='" . $field['size'] . "' ";
490
			echo ">\n";
491
492
			if($field['description'] <> "") {
493
				echo "<br /> " . $field['description'];
494
		    	}
495 b7bb1711 Ermal Lu?i
496
			break;
497
		    case "certca_selection":
498 66f773b4 Ermal Lu?i
                        $size = "";
499
                        $multiple = "";
500
                        $name = strtolower($name);
501
                        echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
502
                        echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
503
                        echo "</td>";
504
                        echo "<td class=\"vtable\">\n";
505
                        if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
506
                        echo "<select id='{$name}' name='{$name}' {$size}>\n";
507
                        if($field['add_to_certca_selection'] <> "") {
508
                                $SELECTED = "";
509
                                if($field['add_to_certca_selection'] == $value) $SELECTED = " SELECTED";
510
                                echo "<option value='" . $field['add_to_certca_selection'] . "'" . $SELECTED . ">" . $field['add_to_certca_selection'] . "</option>\n";
511
                        }
512
			foreach($config['system']['ca'] as $ca) {
513
				$name = htmlspecialchars($ca['name']);
514
                          $SELECTED = "";
515
                          if ($value == $name) $SELECTED = " SELECTED";
516
                          $to_echo = "<option value='" . $ca['refid'] . "'" . $SELECTED . ">" . $name . "</option>\n";
517
                          $to_echo .= "<!-- {$value} -->";
518
                          $canecho = 0;
519
                          if($field['certca_filter'] <> "") {
520
                                if(stristr($name, $field['certca_filter']) == true)
521
                                        $canecho = 1;
522
                          } else {
523
                                $canecho = 1;
524
                          }
525
                          if($canecho == 1)
526
                                echo $to_echo;
527
                        }
528
                                echo "</select>\n";
529
530
			if($field['description'] <> "") {
531
				echo "<br /> " . $field['description'];
532
		    	}
533 b7bb1711 Ermal Lu?i
534
			break;
535
		    case "cert_selection":
536 66f773b4 Ermal Lu?i
                        $size = "";
537
                        $multiple = "";
538
                        $name = strtolower($name);
539
                        echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
540
                        echo fixup_string($field['displayname'] ? $field['displayname'] : $field['name']) . ":\n";
541
                        echo "</td>";
542
                        echo "<td class=\"vtable\">\n";
543
                        if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
544
                        echo "<select id='{$name}' name='{$name}' {$size}>\n";
545
                        if($field['add_to_cert_selection'] <> "") {
546
                                $SELECTED = "";
547
                                if($field['add_to_cert_selection'] == $value) $SELECTED = " SELECTED";
548
                                echo "<option value='" . $field['add_to_cert_selection'] . "'" . $SELECTED . ">" . $field['add_to_cert_selection'] . "</option>\n";
549
                        }
550
                        foreach($config['system']['cert'] as $ca) {
551
				if (stristr($ca['name'], "webconf"))
552
					continue;
553
                                $name = htmlspecialchars($ca['name']);
554
                          $SELECTED = "";
555
                          if ($value == $name) $SELECTED = " SELECTED";
556
                          $to_echo = "<option value='" . $ca['refid'] . "'" . $SELECTED . ">" . $name . "</option>\n";
557
                          $to_echo .= "<!-- {$value} -->";
558
                          $canecho = 0;
559
                          if($field['cert_filter'] <> "") {
560
                                if(stristr($name, $field['cert_filter']) == true)
561
                                        $canecho = 1;
562
                          } else {
563
                                $canecho = 1;
564
                          }
565
                          if($canecho == 1)
566
                                echo $to_echo;
567
                        }
568
                                echo "</select>\n";
569
570
			if($field['description'] <> "") {
571
				echo "<br /> " . $field['description'];
572
		    	}
573 b7bb1711 Ermal Lu?i
574
			break;
575
		    case "select":
576 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
577
                                echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
578 d6f53204 Ermal Lu?i
                                echo $field['displayname'];
579 7a29f783 Ermal Lu?i
                                echo ":</td>\n";
580
			} else if(!$field['dontdisplayname']) {
581 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
582 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
583 34b5c5a0 Scott Ullrich
				echo ":</td>\n";
584
			}
585
			if($field['size']) $size = " size='" . $field['size'] . "' ";
586
			if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
587
			if(!$field['dontcombinecells'])
588
				echo "<td class=\"vtable\">\n";
589
			$onchange = "";
590
			foreach ($field['options']['option'] as $opt) {
591
				if($opt['enablefields'] <> "") {
592
					$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
593
				}
594
			}
595 66f773b4 Ermal Lu?i
			echo "<select class='formselect' " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
596 34b5c5a0 Scott Ullrich
			foreach ($field['options']['option'] as $opt) {
597 46985f19 Scott Ullrich
				$selected = "";
598 47aa4fc4 Ermal
				if($value == $opt['value'])
599
					$selected = " SELECTED";
600
				echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">";
601 d6f53204 Ermal Lu?i
				if ($opt['displayname'])
602
					echo $opt['displayname'];
603
				else
604
					echo $opt['name'];
605
				echo "</option>\n";
606 34b5c5a0 Scott Ullrich
			}
607
			echo "</select>\n";
608 a314bebc Ermal
                        echo "<!-- {$value} -->\n";
609 66f773b4 Ermal Lu?i
610
			if($field['description'] <> "") {
611
				echo $field['description'];
612
		    	}
613 b7bb1711 Ermal Lu?i
614
			break;
615
		    case "textarea":
616 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
617
                                echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
618 d6f53204 Ermal Lu?i
                                echo $field['displayname'];
619 7a29f783 Ermal Lu?i
                                echo ":</td>\n";
620
			} else if(!$field['dontdisplayname']) {
621 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
622 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
623 34b5c5a0 Scott Ullrich
				echo ":</td>";
624
			}
625
			if(!$field['dontcombinecells'])
626
				echo "<td class=\"vtable\">";
627 66f773b4 Ermal Lu?i
			echo "<textarea class='formpre' id='" . $name . "' name='" . $name . "'";
628
			if ($field['rows'])
629
				echo " rows='" . $field['rows'] . "' ";
630
			if ($field['cols'])
631
				echo " cols='" . $field['cols'] . "' ";
632
			echo ">" . $value . "</textarea>\n";
633
				
634
635
			if($field['description'] <> "") {
636
				echo "<br /> " . $field['description'];
637
		    	}
638 b7bb1711 Ermal Lu?i
639
			break;
640
		    case "submit":
641 34b5c5a0 Scott Ullrich
			echo "<td>&nbsp;<br></td></tr>";
642 2fbd6806 Scott Ullrich
			echo "<tr><td colspan='2'><center>";
643
			echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
644 66f773b4 Ermal Lu?i
645
			if($field['description'] <> "") {
646
				echo "<br /> " . $field['description'];
647
		    	}
648 b7bb1711 Ermal Lu?i
649
			break;
650
		    case "listtopic":
651
			echo "<td>&nbsp;</td></tr>";
652
			echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br ></td>\n";
653
654
			break;
655
		    case "subnet_select":
656 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
657
                                echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
658 d6f53204 Ermal Lu?i
                                echo $field['displayname'];
659 7a29f783 Ermal Lu?i
                                echo ":</td>\n";
660
			} else if(!$field['dontdisplayname']) {
661 bd31336e Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
662
				echo fixup_string($field['name']);
663
				echo ":</td>";
664
			}
665
			if(!$field['dontcombinecells'])
666
				echo "<td class=\"vtable\">";
667 66f773b4 Ermal Lu?i
			echo "<select class='formselect' name='{$name}'>\n";
668 bd31336e Scott Ullrich
			for($x=1; $x<33; $x++) {
669
				$CHECKED = "";
670
				if($value == $x) $CHECKED = " SELECTED";
671
				if($x <> 31)
672
					echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
673
			}
674
			echo "</select>\n";
675 66f773b4 Ermal Lu?i
676
			if($field['description'] <> "") {
677
				echo "<br /> " . $field['description'];
678
		    	}
679 b7bb1711 Ermal Lu?i
680
			break;
681
		    case "timezone_select":
682 5a8a69b3 Ermal Lu?i
			exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
683
			$timezonelist = array_filter($timezonelist, 'is_timezone');
684
			sort($timezonelist);
685
686
			/* kill carriage returns */
687
			for($x=0; $x<count($timezonelist); $x++)
688
				$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
689
690 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
691
                                echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
692 d6f53204 Ermal Lu?i
                                echo $field['displayname'];
693 7a29f783 Ermal Lu?i
                                echo ":</td>\n";
694
			} else if(!$field['dontdisplayname']) {
695 bd31336e Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
696
				echo fixup_string($field['name']);
697
				echo ":</td>";
698
			}
699
			if(!$field['dontcombinecells'])
700
				echo "<td class=\"vtable\">";
701 66f773b4 Ermal Lu?i
			echo "<select class='formselect' name='{$name}'>\n";
702 bd31336e Scott Ullrich
			foreach ($timezonelist as $tz) {
703 ce6b39f2 jim-p
				if(strstr($tz, "GMT"))
704
					continue;
705 bd31336e Scott Ullrich
				$SELECTED = "";
706
				if ($value == $tz) $SELECTED = " SELECTED";
707
				echo "<option value='" . htmlspecialchars($tz) . "' {$SELECTED}>";
708
				echo htmlspecialchars($tz);
709
				echo "</option>\n";
710
			}
711
			echo "</select>\n";
712 66f773b4 Ermal Lu?i
713
			if($field['description'] <> "") {
714
				echo "<br /> " . $field['description'];
715
		    	}
716 b7bb1711 Ermal Lu?i
717
			break;
718
		    case "checkbox":
719 7a29f783 Ermal Lu?i
			if ($field['displayname']) {
720
                                echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
721 d6f53204 Ermal Lu?i
                                echo $field['displayname'];
722 7a29f783 Ermal Lu?i
                                echo ":</td>\n";
723
			} else if(!$field['dontdisplayname']) {
724 34b5c5a0 Scott Ullrich
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
725
				echo $field['name'];
726
				echo ":</td>";
727
			}
728
			$checked = "";
729 eb20f3c5 Ermal Lu?i
			if($value <> "")
730
				$checked = " CHECKED";
731 72a5f424 Ermal Lu?i
			echo "<td class=\"vtable\"><input value=\"on\" type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
732 b7bb1711 Ermal Lu?i
			if(isset($field['enablefields']) or isset($field['checkenablefields']))
733
				echo " onClick=\"enablechange()\"";
734 1ae55320 Ermal
			else if(isset($field['disablefields']) or isset($field['checkdisablefields']))
735
				echo " onClick=\"disablechange()\"";
736 33a56b27 Colin Smith
			echo ">\n";
737 66f773b4 Ermal Lu?i
738
			if($field['description'] <> "") {
739
				echo $field['description'];
740
		    	}
741 b7bb1711 Ermal Lu?i
742
			break;
743 34b5c5a0 Scott Ullrich
		    }
744
745
		    if($field['typehint'] <> "") {
746
			echo $field['typehint'];
747 2fbd6806 Scott Ullrich
		    }
748 f3c6fdc0 Bill Marquette
		    if($field['warning'] <> "") {
749 b7bb1711 Ermal Lu?i
			echo "<br ><b><font color=\"red\">" . $field['warning'] . "</font></b>";
750 f3c6fdc0 Bill Marquette
		    }
751
752 8984dc5e Ermal
		    if(!$field['combinefieldsbegin']) {
753
		    	if (!$field['dontcombinecells'])
754
		    		echo "</td>";
755
756
			 echo "</tr>\n";
757
		    }
758 1ae55320 Ermal
759 34b5c5a0 Scott Ullrich
		}
760
	}
761
    ?>
762 b7bb1711 Ermal Lu?i
	</table>
763
	</td></tr>
764 658292ef Scott Ullrich
</table>
765 85dc4438 Scott Ullrich
<br>&nbsp;
766 5adb3375 Scott Ullrich
</div>
767 658292ef Scott Ullrich
</form>
768 44c10295 Scott Ullrich
<script type="text/javascript">
769 62a48760 Scott Ullrich
<!--
770
	if (typeof ext_change != 'undefined') {
771
		ext_change();
772
	}
773
	if (typeof proto_change != 'undefined') {
774
		ext_change();
775
	}
776
	if (typeof proto_change != 'undefined') {
777
		proto_change();
778
	}
779 5adb3375 Scott Ullrich
780 62a48760 Scott Ullrich
<?php
781
	$isfirst = 0;
782
	$aliases = "";
783
	$addrisfirst = 0;
784
	$aliasesaddr = "";
785
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
786
		foreach($config['aliases']['alias'] as $alias_name) {
787 40050fab Ermal
				if($isfirst == 1)
788
					$aliases .= ",";
789 62a48760 Scott Ullrich
				$aliases .= "'" . $alias_name['name'] . "'";
790
				$isfirst = 1;
791
		}
792
?>
793
794
	var customarray=new Array(<?php echo $aliases; ?>);
795
796 44c10295 Scott Ullrich
	window.onload = function () {
797
798
		<?php
799
			$counter=0;
800
			foreach($inputaliases as $alias) {
801 40050fab Ermal
				echo "var oTextbox$counter = new AutoSuggestControl(document.getElementById(\"$alias\"), new StateSuggestions(customarray));\n";
802 44c10295 Scott Ullrich
				$counter++;
803
			}
804
		?>
805
806
	}
807
808 62a48760 Scott Ullrich
//-->
809
</script>
810 5adb3375 Scott Ullrich
<script type="text/javascript">
811
NiftyCheck();
812 e881d1f3 Scott Ullrich
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
813
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
814 1ae55320 Ermal
enablechange();
815
disablechange();
816
showchange();
817 5adb3375 Scott Ullrich
</script>
818
819 34b5c5a0 Scott Ullrich
<?php
820
821
$fieldnames_array = Array();
822
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
823
	// create a fieldname loop that can be used with javascript
824
	// hide and enable features.
825 44c10295 Scott Ullrich
	echo "\n<script type=\"text/javascript\">\n";
826 34b5c5a0 Scott Ullrich
	echo "function disableall() {\n";
827
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
828
		if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
829
			if(!$field['donotdisable'] <> "") {
830
				array_push($fieldnames_array, $field['name']);
831
				$fieldname = ereg_replace(" ", "", $field['name']);
832
				$fieldname = strtolower($fieldname);
833
				echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
834
			}
835
		}
836
	}
837
	echo "}\ndisableall();\n";
838
	echo "function enableitems(selectedindex) {\n";
839
	echo "disableall();\n";
840
	$idcounter = 0;
841
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
842
		echo "\tswitch(selectedindex) {\n";
843
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
844
			if($field['options']['option'] <> "") {
845
				foreach ($field['options']['option'] as $opt) {
846
					if($opt['enablefields'] <> "") {
847
						echo "\t\tcase " . $idcounter . ":\n";
848
						$enablefields_split = split(",", $opt['enablefields']);
849
						foreach ($enablefields_split as $efs) {
850
							$fieldname = ereg_replace(" ", "", $efs);
851
							$fieldname = strtolower($fieldname);
852
							if($fieldname <> "") {
853
								$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
854
								echo $onchange;
855
							}
856
						}
857
						echo "\t\t\tbreak;\n";
858
					}
859
					$idcounter = $idcounter + 1;
860
				}
861
			}
862
		}
863
		echo "\t}\n";
864
	}
865
	echo "}\n";
866
	echo "</script>\n\n";
867
}
868
869
870
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
871
	// handle after form display event.
872
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
873
}
874
875
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
876
	// handle after form display event.
877 44c10295 Scott Ullrich
        echo "\n<script type=\"text/javascript\">\n";
878 34b5c5a0 Scott Ullrich
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
879
	echo "</script>\n\n";
880
}
881
882 d51f86e0 Scott Ullrich
/*
883
 *  HELPER FUNCTIONS
884
 */
885
886
function fixup_string($string) {
887 a0190b50 Scott Ullrich
	global $config, $myurl;
888 78818d7a Scott Ullrich
	$newstring = $string;
889 d51f86e0 Scott Ullrich
	// fixup #1: $myurl -> http[s]://ip_address:port/
890 43d9a2d3 jim-p
	switch($config['system']['webgui']['protocol']) {
891 037304d8 Scott Ullrich
		case "http":
892
			$proto = "http";
893
			break;
894
		case "https":
895
			$proto = "https";
896
			break;
897
		default:
898
			$proto = "http";
899
			break;
900
	}
901 43d9a2d3 jim-p
	$port = $config['system']['webgui']['port'];
902 037304d8 Scott Ullrich
	if($port != "") {
903
		if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
904
			$urlport = ":" . $port;
905
		} elseif ($port != "80" and $port != "443") {
906
			$urlport = ":" . $port;
907
		} else {
908
			$urlport = "";
909
		}
910
	}
911 39d1c22d sullrich
	$myurl = $proto . "://" . $_SERVER['HTTP_HOST'] . $urlport . "/";
912 d70a5ac6 Ermal Lu?i
913
	if (strstr($newstring, "\$myurl"))
914
		$newstring = str_replace("\$myurl", $myurl, $newstring);
915 d2133701 Scott Ullrich
	// fixup #2: $wanip
916 d70a5ac6 Ermal Lu?i
	if (strstr($newstring, "\$wanip")) {
917
		$curwanip = get_interface_ip();
918
		$newstring = str_replace("\$wanip", $curwanip, $newstring);
919
	}
920 d2133701 Scott Ullrich
	// fixup #3: $lanip
921 d70a5ac6 Ermal Lu?i
	if (strstr($newstring, "\$lanip")) {
922
		$lanip = get_interface_ip("lan");
923
		$newstring = str_replace("\$lanip", $lanip, $newstring);
924
	}
925 d2133701 Scott Ullrich
	// fixup #4: fix'r'up here.
926 d51f86e0 Scott Ullrich
	return $newstring;
927
}
928
929 bd31336e Scott Ullrich
function is_timezone($elt) {
930
	return !preg_match("/\/$/", $elt);
931
}
932 d51f86e0 Scott Ullrich
933 c8000491 Scott Ullrich
?>
934
935
</body>
936
</html>