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