Project

General

Profile

Download (20.7 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
    All rights reserved.
7
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
require("guiconfig.inc");
31
32
function gentitle_pkg($pgname) {
33 2fbd6806 Scott Ullrich
	global $config;
34
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
35 658292ef Scott Ullrich
}
36
37 d8c1a6c5 Scott Ullrich
$stepid = htmlspecialchars($_GET['stepid']);
38 658292ef Scott Ullrich
if (isset($_POST['stepid']))
39 d8c1a6c5 Scott Ullrich
    $stepid = htmlspecialchars($_POST['stepid']);
40 2fbd6806 Scott Ullrich
if (!$stepid) $stepid = "0";
41 658292ef Scott Ullrich
42 d8c1a6c5 Scott Ullrich
$xml = htmlspecialchars($_GET['xml']);
43
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
44 658292ef Scott Ullrich
45
if($xml == "") {
46 bb0c9569 Bill Marquette
	$xml = "not_defined";
47
	print_info_box_np("ERROR:  Could not open " . $xml . ".");
48
	die;
49 658292ef Scott Ullrich
} else {
50 bd31336e Scott Ullrich
	if (file_exists("{$g['www_path']}/wizards/{$xml}"))
51 fc19d371 Scott Ullrich
		$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
52 bb0c9569 Bill Marquette
	else {
53
		print_info_box_np("ERROR:  Could not open " . $xml . ".");
54
		die;
55
	}
56 658292ef Scott Ullrich
}
57
58
$title          = $pkg['step'][$stepid]['title'];
59
$description    = $pkg['step'][$stepid]['description'];
60 46985f19 Scott Ullrich
$totalsteps     = $pkg['totalsteps'];
61 658292ef Scott Ullrich
62 bd31336e Scott Ullrich
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
63
$timezonelist = array_filter($timezonelist, 'is_timezone');
64
sort($timezonelist);
65
66 98b5b72b Scott Ullrich
/* kill carriage returns */
67 e881d1f3 Scott Ullrich
for($x=0; $x<count($timezonelist); $x++)
68 98b5b72b Scott Ullrich
		$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
69
70 b3f4e57c Scott Ullrich
if ($pkg['step'][$stepid]['includefile'])
71
	require($pkg['step'][$stepid]['includefile']);
72
73 e1e7a425 Scott Ullrich
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
74
		eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
75
}
76
77 658292ef Scott Ullrich
if ($_POST) {
78 e48fc17d Scott Ullrich
    foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
79
        if($field['bindstofield'] <> "" and $field['type'] <> "submit") {
80
		$fieldname = $field['name'];
81
		$unset_fields = "";
82
		$fieldname = ereg_replace(" ", "", $fieldname);
83
		$fieldname = strtolower($fieldname);
84
		// update field with posted values.
85
                if($field['unsetfield'] <> "") $unset_fields = "yes";
86 46985f19 Scott Ullrich
		if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
87 e48fc17d Scott Ullrich
		if($field['bindstofield'])
88 3f83de3d Scott Ullrich
			update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
89 658292ef Scott Ullrich
        }
90 3ed807e4 Scott Ullrich
91 2fbd6806 Scott Ullrich
    }
92 3ed807e4 Scott Ullrich
    // run custom php code embedded in xml config.
93
    if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
94
		eval($pkg['step'][$stepid]['stepsubmitphpaction']);
95
    }
96
	write_config();
97 e48fc17d Scott Ullrich
    $stepid++;
98 46985f19 Scott Ullrich
    if($stepid > $totalsteps) $stepid = $totalsteps;
99 658292ef Scott Ullrich
}
100
101 46985f19 Scott Ullrich
$title          = $pkg['step'][$stepid]['title'];
102
$description    = $pkg['step'][$stepid]['description'];
103
104 3f83de3d Scott Ullrich
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
105 e48fc17d Scott Ullrich
	global $config;
106
	$field_split = split("->",$field);
107
	foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
108
	if($field_conv == "") return;
109 3f83de3d Scott Ullrich
	if($field_type == "checkbox" and $updatetext <> "on") {
110
		/*
111
		    item is a checkbox, it should have the value "on"
112
		    if it was checked
113
                */
114
		$text = "unset(\$config" . $field_conv . ");";
115
		eval($text);
116
		return;
117 496f9155 Scott Ullrich
	}
118 e881d1f3 Scott Ullrich
119 496f9155 Scott Ullrich
	if($field_type == "interfaces_selection") {
120
		$text = "unset(\$config" . $field_conv . ");";
121
		eval($text);
122
		$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
123
		eval($text);
124
		return;
125
	}
126 e881d1f3 Scott Ullrich
127 e48fc17d Scott Ullrich
	if($unset <> "") {
128
		$text = "unset(\$config" . $field_conv . ");";
129
		eval($text);
130 46985f19 Scott Ullrich
		$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
131 e48fc17d Scott Ullrich
		eval($text);
132
	} else {
133 46985f19 Scott Ullrich
		if($arraynum <> "") {
134
			$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
135
		} else {
136
			$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
137
		}
138 e48fc17d Scott Ullrich
		eval($text);
139
	}
140 658292ef Scott Ullrich
}
141
142 34b5c5a0 Scott Ullrich
if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") {
143
	// handle before form display event.
144
        // good for modifying posted values, etc.
145
	eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
146
}
147
148 d88c6a9f Scott Ullrich
$pgtitle = array($title);
149 4df96eff Scott Ullrich
include("head.inc");
150 6bb5c9aa Bill Marquette
151 4df96eff Scott Ullrich
?>
152 fc7bea0e Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
153 33a56b27 Colin Smith
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
154
<script language="JavaScript">
155 f9e35766 Scott Ullrich
<!--
156 38e7d556 Scott Ullrich
157 e881d1f3 Scott Ullrich
function  FieldValidate(userinput,  regexp,  message)
158
{
159
                if(!userinput.match(regexp))
160
                                alert(message);
161
}
162 38e7d556 Scott Ullrich
163 33a56b27 Colin Smith
function enablechange() {
164
<?php
165
        foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
166
                if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
167
                        print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
168
                        if(isset($field['enablefields'])) {
169
                                $enablefields = explode(',', $field['enablefields']);
170
                                foreach($enablefields as $enablefield) {
171
                                        $enablefield = strtolower($enablefield);
172
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
173
                                }
174
                        }
175
                        if(isset($field['checkenablefields'])) {
176
                                $checkenablefields = explode(',', $field['checkenablefields']);
177
                                foreach($checkenablefields as $checkenablefield) {
178
                                        $checkenablefield = strtolower($checkenablefield);
179
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
180
                                }
181
                        }
182
                        print "\t" . '} else {' . "\n";
183
                        if(isset($field['enablefields'])) {
184
                                foreach($enablefields as $enablefield) {
185
                                        $enablefield = strtolower($enablefield);
186
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
187
                                }
188
                        }
189
                        if(isset($field['checkenablefields'])) {
190
                                foreach($checkenablefields as $checkenablefield) {
191
                                        $checkenablefield = strtolower($checkenablefield);
192
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
193
                                }
194 e881d1f3 Scott Ullrich
                        }
195 33a56b27 Colin Smith
                        print "\t" . '}' . "\n";
196
                }
197
        }
198
?>
199 6bb5c9aa Bill Marquette
}
200
//-->
201
</script>
202 33a56b27 Colin Smith
<?php } ?>
203 6bb5c9aa Bill Marquette
204 33a56b27 Colin Smith
<form action="wizard.php" method="post" name="iform" id="iform">
205 658292ef Scott Ullrich
<input type="hidden" name="xml" value="<?= $xml ?>">
206 e48fc17d Scott Ullrich
<input type="hidden" name="stepid" value="<?= $stepid ?>">
207 658292ef Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
208
209 e48fc17d Scott Ullrich
<center>
210
211
&nbsp;<br>
212 1c3d61fe Scott Ullrich
213 fe2bfbfc Scott Ullrich
<?php
214 1c3d61fe Scott Ullrich
	if($title == "Reload in progress") {
215 d1c844e1 Scott Ullrich
		$ip = "http://{$config['interfaces']['lan']['ipaddr']}";
216 1c3d61fe Scott Ullrich
	} else {
217 fe2bfbfc Scott Ullrich
		$ip = "/";
218 1c3d61fe Scott Ullrich
	}
219 2576dace Ermal Luçi
	echo "<a href='$ip'>";
220 fe2bfbfc Scott Ullrich
?>
221 1c3d61fe Scott Ullrich
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
222 d51f86e0 Scott Ullrich
<p>
223 85dc4438 Scott Ullrich
<div style="width:700px;background-color:#ffffff" id="roundme">
224 50f60bca Scott Ullrich
<table bgcolor="#ffffff" width="600" cellspacing="0" cellpadding="3">
225 34b5c5a0 Scott Ullrich
    <!-- wizard goes here -->
226
    <tr><td>&nbsp;</td></tr>
227 77851510 Scott Ullrich
    <tr><td colspan='2'>
228 55b8d602 Scott Ullrich
<?php
229
	if ($_GET['message'] != "")
230 d8c1a6c5 Scott Ullrich
		print_info_box(htmlspecialchars($_GET['message']));
231 55b8d602 Scott Ullrich
	if ($_POST['message'] != "")
232 d8c1a6c5 Scott Ullrich
		print_info_box(htmlspecialchars($_POST['message']));
233 77851510 Scott Ullrich
?></td></tr>
234 d51f86e0 Scott Ullrich
    <tr><td colspan='2'><center><b><?= fixup_string($description) ?></b></center></td></tr><tr><td>&nbsp;</td></tr>
235 34b5c5a0 Scott Ullrich
    <?php
236
	if(!$pkg['step'][$stepid]['disableheader'])
237 d51f86e0 Scott Ullrich
		echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
238 34b5c5a0 Scott Ullrich
    ?>
239
240
    <?php
241
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
242
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
243
244
		    $value = $field['value'];
245 2fbd6806 Scott Ullrich
		    $name  = $field['name'];
246 658292ef Scott Ullrich
247 2fbd6806 Scott Ullrich
		    $name = ereg_replace(" ", "", $name);
248
		    $name = strtolower($name);
249 658292ef Scott Ullrich
250 a8df0181 Scott Ullrich
		    if($field['bindstofield'] <> "") {
251 b1919dd0 Scott Ullrich
				$arraynum = "";
252
				$field_conv = "";
253
				$field_split = split("->", $field['bindstofield']);
254
				// arraynum is used in cases where there is an array of the same field
255
				// name such as dnsserver (2 of them)
256
				if($field['arraynum'] <> "") $arraynum = "[" . $field['arraynum'] . "]";
257
				foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
258
					$toeval = "\$value = \$config" . $field_conv . $arraynum . ";";
259
					eval($toeval);
260 33a56b27 Colin Smith
					if ($field['type'] == "checkbox") {
261 35fecd55 Scott Ullrich
						$toeval = "if(isset(\$config" . $field_conv . $arraynum . ")) \$value = \" CHECKED\";";
262 f2ec2c48 Scott Ullrich
						eval($toeval);
263
					}
264 a8df0181 Scott Ullrich
		    }
265
266 34b5c5a0 Scott Ullrich
		    if(!$field['combinefieldsend'])
267
			echo "<tr>";
268
269
		    if ($field['type'] == "input") {
270
			if(!$field['dontdisplayname']) {
271
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
272 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
273 34b5c5a0 Scott Ullrich
				echo ":</td>\n";
274
			}
275
			if(!$field['dontcombinecells'])
276
				echo "<td class=\"vtable\">\n";
277 6bb5c9aa Bill Marquette
278
			echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'";
279
			if($field['validate'])
280
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
281
			echo ">\n";
282 62a48760 Scott Ullrich
283
284 e881d1f3 Scott Ullrich
285 62a48760 Scott Ullrich
		    } else if ($field['type'] == "inputalias") {
286
			if(!$field['dontdisplayname']) {
287
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
288
				echo fixup_string($field['name']);
289
				echo ":</td>\n";
290
			}
291
			if(!$field['dontcombinecells'])
292
				echo "<td class=\"vtable\">\n";
293
294
			echo "<input  autocomplete='off' class='formfldalias' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
295
			if($field['validate'])
296
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
297 e881d1f3 Scott Ullrich
			echo ">\n";
298
299 62a48760 Scott Ullrich
300
301 496f9155 Scott Ullrich
		    } else if($field['type'] == "interfaces_selection") {
302
			$size = "";
303
			$multiple = "";
304
			$name = strtolower($name);
305
			echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
306 7b4710f9 Scott Ullrich
			echo fixup_string($field['name']) . ":\n";
307 496f9155 Scott Ullrich
			echo "</td>";
308
			echo "<td class=\"vtable\">\n";
309 7b4710f9 Scott Ullrich
			if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
310 496f9155 Scott Ullrich
			if($field['multiple'] <> "" and $field['multiple'] <> "0") {
311 7b4710f9 Scott Ullrich
			  $multiple = "multiple=\"multiple\"";
312 496f9155 Scott Ullrich
			  $name .= "[]";
313
			}
314 7b4710f9 Scott Ullrich
			echo "<select id='{$name}' name='{$name}' {$size} {$multiple}>\n";
315 496f9155 Scott Ullrich
			if($field['add_to_interfaces_selection'] <> "") {
316
				$SELECTED = "";
317
				if($field['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
318
				echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
319
			}
320 62a48760 Scott Ullrich
			$interfaces = $config['interfaces'];
321 496f9155 Scott Ullrich
			if($field['all_interfaces'] <> "") {
322
				$ints = split(" ", `/sbin/ifconfig -l`);
323
				$interfaces = array();
324
				foreach ($ints as $int) {
325
					$interfaces[]['descr'] = $int;
326
					$interfaces[] = $int;
327
				}
328
			}
329
			foreach ($interfaces as $ifname => $iface) {
330
			  if ($iface['descr'])
331
				  $ifdescr = $iface['descr'];
332
			  else
333
				  $ifdescr = strtoupper($ifname);
334
			  $ip = "";
335
			  if($field['all_interfaces'] <> "") {
336
				$ifdescr = $iface;
337
				$ip = " " . find_interface_ip($iface);
338
			  }
339
			  $SELECTED = "";
340 aecffb0a Scott Ullrich
			  if ($value == $ifname) $SELECTED = " SELECTED";
341
			  $to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $ifdescr . $ip . "</option>\n";
342 496f9155 Scott Ullrich
			  $to_echo .= "<!-- {$value} -->";
343
			  $canecho = 0;
344
			  if($field['interface_filter'] <> "") {
345
				if(stristr($iface, $field['interface_filter']) == true)
346
					$canecho = 1;
347
			  } else {
348
				$canecho = 1;
349
			  }
350 e881d1f3 Scott Ullrich
			  if($canecho == 1)
351 496f9155 Scott Ullrich
				echo $to_echo;
352
			}
353
				echo "</select>\n";
354
			} else if ($field['type'] == "password") {
355 34b5c5a0 Scott Ullrich
			if(!$field['dontdisplayname']) {
356
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
357 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
358 34b5c5a0 Scott Ullrich
				echo ":</td>\n";
359
			}
360
			if(!$field['dontcombinecells'])
361
				echo "<td class=\"vtable\">";
362
			echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "' type='password'>\n";
363
		    } else if ($field['type'] == "select") {
364
			if(!$field['dontdisplayname']) {
365
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
366 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
367 34b5c5a0 Scott Ullrich
				echo ":</td>\n";
368
			}
369
			if($field['size']) $size = " size='" . $field['size'] . "' ";
370
			if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
371
			if(!$field['dontcombinecells'])
372
				echo "<td class=\"vtable\">\n";
373
			$onchange = "";
374
			foreach ($field['options']['option'] as $opt) {
375
				if($opt['enablefields'] <> "") {
376
					$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
377
				}
378
			}
379
			echo "<select " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
380
			foreach ($field['options']['option'] as $opt) {
381 46985f19 Scott Ullrich
				$selected = "";
382
				if($value == $opt['value']) $selected = " SELECTED";
383 34b5c5a0 Scott Ullrich
			    echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">" . $opt['name'] . "</option>\n";
384
			}
385
			echo "</select>\n";
386
		    } else if ($field['type'] == "textarea") {
387
			if(!$field['dontdisplayname']) {
388
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
389 d51f86e0 Scott Ullrich
				echo fixup_string($field['name']);
390 34b5c5a0 Scott Ullrich
				echo ":</td>";
391
			}
392
			if(!$field['dontcombinecells'])
393
				echo "<td class=\"vtable\">";
394
			echo "<textarea id='" . $name . "' name='" . $name . ">" . $value . "</textarea>\n";
395
		    } else if ($field['type'] == "submit") {
396
			echo "<td>&nbsp;<br></td></tr>";
397 2fbd6806 Scott Ullrich
			echo "<tr><td colspan='2'><center>";
398
			echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
399 34b5c5a0 Scott Ullrich
		    } else if ($field['type'] == "listtopic") {
400
			echo "<td>&nbsp;</td><tr>";
401
			echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br></td>\n";
402 bd31336e Scott Ullrich
		    } else if ($field['type'] == "subnet_select") {
403
			if(!$field['dontdisplayname']) {
404
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
405
				echo fixup_string($field['name']);
406
				echo ":</td>";
407
			}
408
			if(!$field['dontcombinecells'])
409
				echo "<td class=\"vtable\">";
410
			echo "<select name='{$name}'>\n";
411
			for($x=1; $x<33; $x++) {
412
				$CHECKED = "";
413
				if($value == $x) $CHECKED = " SELECTED";
414
				if($x <> 31)
415
					echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
416
			}
417
			echo "</select>\n";
418
		    } else if ($field['type'] == "timezone_select") {
419
			if(!$field['dontdisplayname']) {
420
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
421
				echo fixup_string($field['name']);
422
				echo ":</td>";
423
			}
424
			if(!$field['dontcombinecells'])
425
				echo "<td class=\"vtable\">";
426
			echo "<select name='{$name}'>\n";
427
			foreach ($timezonelist as $tz) {
428
				$SELECTED = "";
429
				if ($value == $tz) $SELECTED = " SELECTED";
430
				echo "<option value='" . htmlspecialchars($tz) . "' {$SELECTED}>";
431
				echo htmlspecialchars($tz);
432
				echo "</option>\n";
433
			}
434
			echo "</select>\n";
435 34b5c5a0 Scott Ullrich
		    } else if ($field['type'] == "checkbox") {
436
			if(!$field['dontdisplayname']) {
437
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
438
				echo $field['name'];
439
				echo ":</td>";
440
			}
441
			$checked = "";
442 f2ec2c48 Scott Ullrich
			if($value <> "") $checked = " CHECKED";
443 33a56b27 Colin Smith
			echo "<td class=\"vtable\"><input type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
444
			if(isset($field['enablefields']) or isset($field['checkenablefields'])) echo " onClick=\"enablechange()\"";
445
			echo ">\n";
446 34b5c5a0 Scott Ullrich
		    }
447
448
		    if($field['typehint'] <> "") {
449
			echo $field['typehint'];
450 2fbd6806 Scott Ullrich
		    }
451 34b5c5a0 Scott Ullrich
452 788ff7cb Scott Ullrich
		    if($field['description'] <> "") {
453
			echo "<br>" . $field['description'];
454 34b5c5a0 Scott Ullrich
			echo "</td>";
455 788ff7cb Scott Ullrich
		    }
456 34b5c5a0 Scott Ullrich
457
		    if(!$field['combinefieldsbegin'])
458
			 echo "</tr>\n";
459 f3c6fdc0 Bill Marquette
460
		    if($field['warning'] <> "") {
461
			echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
462
		    }
463
464 34b5c5a0 Scott Ullrich
		}
465
	}
466
    ?>
467 658292ef Scott Ullrich
</table>
468 85dc4438 Scott Ullrich
<br>&nbsp;
469 5adb3375 Scott Ullrich
</div>
470 658292ef Scott Ullrich
</form>
471 62a48760 Scott Ullrich
<script language="JavaScript">
472
<!--
473
	if (typeof ext_change != 'undefined') {
474
		ext_change();
475
	}
476
	if (typeof proto_change != 'undefined') {
477
		ext_change();
478
	}
479
	if (typeof proto_change != 'undefined') {
480
		proto_change();
481
	}
482 5adb3375 Scott Ullrich
483 62a48760 Scott Ullrich
<?php
484
	$isfirst = 0;
485
	$aliases = "";
486
	$addrisfirst = 0;
487
	$aliasesaddr = "";
488
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
489
		foreach($config['aliases']['alias'] as $alias_name) {
490
			if(!stristr($alias_name['address'], ".")) {
491
				if($isfirst == 1) $aliases .= ",";
492
				$aliases .= "'" . $alias_name['name'] . "'";
493
				$isfirst = 1;
494
			} else {
495
				if($addrisfirst == 1) $aliasesaddr .= ",";
496
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
497
				$addrisfirst = 1;
498
			}
499
		}
500
?>
501
502
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
503
	var customarray=new Array(<?php echo $aliases; ?>);
504
505
//-->
506
</script>
507 5adb3375 Scott Ullrich
<script type="text/javascript">
508
NiftyCheck();
509 e881d1f3 Scott Ullrich
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
510
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
511 5adb3375 Scott Ullrich
</script>
512
513 34b5c5a0 Scott Ullrich
<?php
514
515
$fieldnames_array = Array();
516
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
517
	// create a fieldname loop that can be used with javascript
518
	// hide and enable features.
519
	echo "\n<script language=\"JavaScript\">\n";
520
	echo "function disableall() {\n";
521
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
522
		if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
523
			if(!$field['donotdisable'] <> "") {
524
				array_push($fieldnames_array, $field['name']);
525
				$fieldname = ereg_replace(" ", "", $field['name']);
526
				$fieldname = strtolower($fieldname);
527
				echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
528
			}
529
		}
530
	}
531
	echo "}\ndisableall();\n";
532
	echo "function enableitems(selectedindex) {\n";
533
	echo "disableall();\n";
534
	$idcounter = 0;
535
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
536
		echo "\tswitch(selectedindex) {\n";
537
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
538
			if($field['options']['option'] <> "") {
539
				foreach ($field['options']['option'] as $opt) {
540
					if($opt['enablefields'] <> "") {
541
						echo "\t\tcase " . $idcounter . ":\n";
542
						$enablefields_split = split(",", $opt['enablefields']);
543
						foreach ($enablefields_split as $efs) {
544
							$fieldname = ereg_replace(" ", "", $efs);
545
							$fieldname = strtolower($fieldname);
546
							if($fieldname <> "") {
547
								$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
548
								echo $onchange;
549
							}
550
						}
551
						echo "\t\t\tbreak;\n";
552
					}
553
					$idcounter = $idcounter + 1;
554
				}
555
			}
556
		}
557
		echo "\t}\n";
558
	}
559
	echo "}\n";
560
	echo "disableall();\n";
561
	echo "</script>\n\n";
562
}
563
564
565
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
566
	// handle after form display event.
567
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
568
}
569
570
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
571
	// handle after form display event.
572
        echo "\n<script language=\"JavaScript\">\n";
573
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
574
	echo "</script>\n\n";
575
}
576
577 d51f86e0 Scott Ullrich
/*
578
 *  HELPER FUNCTIONS
579
 */
580
581
function fixup_string($string) {
582 a0190b50 Scott Ullrich
	global $config, $myurl;
583 78818d7a Scott Ullrich
	$newstring = $string;
584 d51f86e0 Scott Ullrich
	// fixup #1: $myurl -> http[s]://ip_address:port/
585 037304d8 Scott Ullrich
	switch($config['system']['webguiproto']) {
586
		case "http":
587
			$proto = "http";
588
			break;
589
		case "https":
590
			$proto = "https";
591
			break;
592
		default:
593
			$proto = "http";
594
			break;
595
	}
596 d51f86e0 Scott Ullrich
	$port = $config['system']['webguiport'];
597 037304d8 Scott Ullrich
	if($port != "") {
598
		if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
599
			$urlport = ":" . $port;
600
		} elseif ($port != "80" and $port != "443") {
601
			$urlport = ":" . $port;
602
		} else {
603
			$urlport = "";
604
		}
605
	}
606
	$myurl = $proto . "://" . $config['interfaces']['lan']['ipaddr'] . $urlport . "/";
607 78818d7a Scott Ullrich
	$newstring = str_replace("\$myurl", $myurl, $newstring);
608 d2133701 Scott Ullrich
	// fixup #2: $wanip
609
	$curwanip = get_current_wan_address();
610 78818d7a Scott Ullrich
	$newstring = str_replace("\$wanip", $curwanip, $newstring);
611 d2133701 Scott Ullrich
	// fixup #3: $lanip
612 78818d7a Scott Ullrich
	$lanip = $config['interfaces']['lan']['ipaddr'];
613
	$newstring = str_replace("\$lanip", $lanip, $newstring);
614 d2133701 Scott Ullrich
	// fixup #4: fix'r'up here.
615 d51f86e0 Scott Ullrich
	return $newstring;
616
}
617
618 bd31336e Scott Ullrich
function is_timezone($elt) {
619
	return !preg_match("/\/$/", $elt);
620
}
621 d51f86e0 Scott Ullrich
622 c8000491 Scott Ullrich
?>
623
624
</body>
625
</html>