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