Project

General

Profile

Download (21.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    wizard.php
5
    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
	global $config;
34
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
35
}
36

    
37
$stepid = $_GET['stepid'];
38
if (isset($_POST['stepid']))
39
    $stepid = htmlspecialchars($_POST['stepid']);
40
if (!$stepid) $stepid = "0";
41

    
42
$xml = htmlspecialchars($_GET['xml']);
43
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
44

    
45
if($xml == "") {
46
	$xml = "not_defined";
47
	print_info_box_np("ERROR:  Could not open " . $xml . ".");
48
	die;
49
} else {
50
	if (file_exists("{$g['www_path']}/wizards/{$xml}"))
51
		$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
52
	else {
53
		print_info_box_np("ERROR:  Could not open " . $xml . ".");
54
		die;
55
	}
56
}
57

    
58
$title          = $pkg['step'][$stepid]['title'];
59
$description    = $pkg['step'][$stepid]['description'];
60
$totalsteps     = $pkg['totalsteps'];
61

    
62
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
63
$timezonelist = array_filter($timezonelist, 'is_timezone');
64
sort($timezonelist);
65

    
66
/* kill carriage returns */
67
for($x=0; $x<count($timezonelist); $x++)
68
		$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
69

    
70
if ($pkg['step'][$stepid]['includefile'])
71
	require($pkg['step'][$stepid]['includefile']);
72

    
73
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
74
		eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
75
}
76

    
77
if ($_POST) {
78
    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
		if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
87
		if($field['bindstofield'])
88
			update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
89
        }
90

    
91
    }
92
    // 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
    $stepid++;
98
    if($stepid > $totalsteps) $stepid = $totalsteps;
99
}
100

    
101
$title          = $pkg['step'][$stepid]['title'];
102
$description    = $pkg['step'][$stepid]['description'];
103

    
104
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
105
	global $config;
106
	$field_split = split("->",$field);
107
	foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
108
	if($field_conv == "") return;
109
	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
	}
118

    
119
	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

    
127
	if($unset <> "") {
128
		$text = "unset(\$config" . $field_conv . ");";
129
		eval($text);
130
		$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
131
		eval($text);
132
	} else {
133
		if($arraynum <> "") {
134
			$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
135
		} else {
136
			$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
137
		}
138
		eval($text);
139
	}
140
}
141

    
142
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
$pgtitle = $title;
149
include("head.inc");
150

    
151
?>
152
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
153
<?php
154
	if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
155
		echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
156
	else 
157
		echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
158
?>
159
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
160
<script language="JavaScript">
161
<!--
162

    
163
function  FieldValidate(userinput,  regexp,  message)
164
{
165
                if(!userinput.match(regexp))
166
                                alert(message);
167
}
168

    
169
function enablechange() {
170
<?php
171
        foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
172
                if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
173
                        print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
174
                        if(isset($field['enablefields'])) {
175
                                $enablefields = explode(',', $field['enablefields']);
176
                                foreach($enablefields as $enablefield) {
177
                                        $enablefield = strtolower($enablefield);
178
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
179
                                }
180
                        }
181
                        if(isset($field['checkenablefields'])) {
182
                                $checkenablefields = explode(',', $field['checkenablefields']);
183
                                foreach($checkenablefields as $checkenablefield) {
184
                                        $checkenablefield = strtolower($checkenablefield);
185
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
186
                                }
187
                        }
188
                        print "\t" . '} else {' . "\n";
189
                        if(isset($field['enablefields'])) {
190
                                foreach($enablefields as $enablefield) {
191
                                        $enablefield = strtolower($enablefield);
192
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
193
                                }
194
                        }
195
                        if(isset($field['checkenablefields'])) {
196
                                foreach($checkenablefields as $checkenablefield) {
197
                                        $checkenablefield = strtolower($checkenablefield);
198
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
199
                                }
200
                        }
201
                        print "\t" . '}' . "\n";
202
                }
203
        }
204
?>
205
}
206
//-->
207
</script>
208
<?php } ?>
209

    
210
<form action="wizard.php" method="post" name="iform" id="iform">
211
<input type="hidden" name="xml" value="<?= $xml ?>">
212
<input type="hidden" name="stepid" value="<?= $stepid ?>">
213
<?php if ($savemsg) print_info_box($savemsg); ?>
214

    
215
<center>
216

    
217
&nbsp;<br>
218

    
219
<?php
220
	if($title == "Reload in progress") {
221
		$ip = "http://{$config['interfaces']['lan']['ipaddr']}";
222
	} else {
223
		$ip = "/";
224
	}
225
	if($xml == "traffic_shaper_wizard.xml" && $_REQUEST['stepid'] > "0") {
226
		echo "<a href='/firewall_shaper.php?remove=remove'>";
227
	} else {
228
		echo "<a href='$ip'>";
229
	}
230
?>
231
<img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
232
<p>
233
<div style="width:700px;background-color:#ffffff" id="roundme">
234
<table bgcolor="#ffffff" width="600" cellspacing="0" cellpadding="3">
235
    <!-- wizard goes here -->
236
    <tr><td>&nbsp;</td></tr>
237
    <tr><td colspan='2'>
238
<?php
239
	if ($_GET['message'] != "")
240
		print_info_box(htmlspecialchars($_GET['message']));
241
	if ($_POST['message'] != "")
242
		print_info_box(htmlspecialchars($_POST['message']));
243
?></td></tr>
244
    <tr><td colspan='2'><center><b><?= fixup_string($description) ?></b></center></td></tr><tr><td>&nbsp;</td></tr>
245
    <?php
246
	if(!$pkg['step'][$stepid]['disableheader'])
247
		echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
248
    ?>
249

    
250
    <?php
251
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
252
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
253

    
254
		    $value = $field['value'];
255
		    $name  = $field['name'];
256

    
257
		    $name = ereg_replace(" ", "", $name);
258
		    $name = strtolower($name);
259

    
260
		    if($field['bindstofield'] <> "") {
261
				$arraynum = "";
262
				$field_conv = "";
263
				$field_split = split("->", $field['bindstofield']);
264
				// arraynum is used in cases where there is an array of the same field
265
				// name such as dnsserver (2 of them)
266
				if($field['arraynum'] <> "") $arraynum = "[" . $field['arraynum'] . "]";
267
				foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
268
					$toeval = "\$value = \$config" . $field_conv . $arraynum . ";";
269
					eval($toeval);
270
					if ($field['type'] == "checkbox") {
271
						$toeval = "if(isset(\$config" . $field_conv . $arraynum . ")) \$value = \" CHECKED\";";
272
						eval($toeval);
273
					}
274
		    }
275

    
276
		    if(!$field['combinefieldsend'])
277
			echo "<tr>";
278

    
279
		    if ($field['type'] == "input") {
280
			if(!$field['dontdisplayname']) {
281
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
282
				echo fixup_string($field['name']);
283
				echo ":</td>\n";
284
			}
285
			if(!$field['dontcombinecells'])
286
				echo "<td class=\"vtable\">\n";
287

    
288
			echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'";
289
			if($field['validate'])
290
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
291
			echo ">\n";
292

    
293

    
294

    
295
		    } else if ($field['type'] == "inputalias") {
296
			if(!$field['dontdisplayname']) {
297
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
298
				echo fixup_string($field['name']);
299
				echo ":</td>\n";
300
			}
301
			if(!$field['dontcombinecells'])
302
				echo "<td class=\"vtable\">\n";
303

    
304
			echo "<input  autocomplete='off' class='formfldalias' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
305
			if($field['validate'])
306
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
307
			echo ">\n";
308

    
309

    
310

    
311
		    } else if($field['type'] == "interfaces_selection") {
312
			$size = "";
313
			$multiple = "";
314
			$name = strtolower($name);
315
			echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
316
			echo fixup_string($field['name']) . ":\n";
317
			echo "</td>";
318
			echo "<td class=\"vtable\">\n";
319
			if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
320
			if($field['multiple'] <> "" and $field['multiple'] <> "0") {
321
			  $multiple = "multiple=\"multiple\"";
322
			  $name .= "[]";
323
			}
324
			echo "<select id='{$name}' name='{$name}' {$size} {$multiple}>\n";
325
			if($field['add_to_interfaces_selection'] <> "") {
326
				$SELECTED = "";
327
				if($field['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
328
				echo "<option value='" . $field['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $field['add_to_interfaces_selection'] . "</option>\n";
329
			}
330
			$interfaces = $config['interfaces'];
331
			if($field['all_interfaces'] <> "") {
332
				$ints = split(" ", `/sbin/ifconfig -l`);
333
				$interfaces = array();
334
				foreach ($ints as $int) {
335
					$interfaces[]['descr'] = $int;
336
					$interfaces[] = $int;
337
				}
338
			}
339
			foreach ($interfaces as $ifname => $iface) {
340
			  if ($iface['descr'])
341
				  $ifdescr = $iface['descr'];
342
			  else
343
				  $ifdescr = strtoupper($ifname);
344
			  $ip = "";
345
			  if($field['all_interfaces'] <> "") {
346
				$ifdescr = $iface;
347
				$ip = " " . find_interface_ip($iface);
348
			  }
349
			  $SELECTED = "";
350
			  if ($value == $ifname) $SELECTED = " SELECTED";
351
			  $to_echo = "<option value='" . $ifname . "'" . $SELECTED . ">" . $ifdescr . $ip . "</option>\n";
352
			  $to_echo .= "<!-- {$value} -->";
353
			  $canecho = 0;
354
			  if($field['interface_filter'] <> "") {
355
				if(stristr($iface, $field['interface_filter']) == true)
356
					$canecho = 1;
357
			  } else {
358
				$canecho = 1;
359
			  }
360
			  if($canecho == 1)
361
				echo $to_echo;
362
			}
363
				echo "</select>\n";
364
			} else if ($field['type'] == "password") {
365
			if(!$field['dontdisplayname']) {
366
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
367
				echo fixup_string($field['name']);
368
				echo ":</td>\n";
369
			}
370
			if(!$field['dontcombinecells'])
371
				echo "<td class=\"vtable\">";
372
			echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "' type='password'>\n";
373
		    } else if ($field['type'] == "select") {
374
			if(!$field['dontdisplayname']) {
375
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
376
				echo fixup_string($field['name']);
377
				echo ":</td>\n";
378
			}
379
			if($field['size']) $size = " size='" . $field['size'] . "' ";
380
			if($field['multiple'] == "yes") $multiple = "MULTIPLE ";
381
			if(!$field['dontcombinecells'])
382
				echo "<td class=\"vtable\">\n";
383
			$onchange = "";
384
			foreach ($field['options']['option'] as $opt) {
385
				if($opt['enablefields'] <> "") {
386
					$onchange = "onchange=\"enableitems(this.selectedIndex);\" ";
387
				}
388
			}
389
			echo "<select " . $onchange . $multiple . $size . "id='" . $name . "' name='" . $name . "'>\n";
390
			foreach ($field['options']['option'] as $opt) {
391
				$selected = "";
392
				if($value == $opt['value']) $selected = " SELECTED";
393
			    echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">" . $opt['name'] . "</option>\n";
394
			}
395
			echo "</select>\n";
396
		    } else if ($field['type'] == "textarea") {
397
			if(!$field['dontdisplayname']) {
398
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
399
				echo fixup_string($field['name']);
400
				echo ":</td>";
401
			}
402
			if(!$field['dontcombinecells'])
403
				echo "<td class=\"vtable\">";
404
			echo "<textarea id='" . $name . "' name='" . $name . ">" . $value . "</textarea>\n";
405
		    } else if ($field['type'] == "submit") {
406
			echo "<td>&nbsp;<br></td></tr>";
407
			echo "<tr><td colspan='2'><center>";
408
			echo "<input type='submit' name='" . $name . "' value='" . $field['name'] . "'>\n";
409
		    } else if ($field['type'] == "listtopic") {
410
			echo "<td>&nbsp;</td><tr>";
411
			echo "<tr><td colspan=\"2\" class=\"listtopic\">" . $field['name'] . "<br></td>\n";
412
		    } else if ($field['type'] == "subnet_select") {
413
			if(!$field['dontdisplayname']) {
414
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
415
				echo fixup_string($field['name']);
416
				echo ":</td>";
417
			}
418
			if(!$field['dontcombinecells'])
419
				echo "<td class=\"vtable\">";
420
			echo "<select name='{$name}'>\n";
421
			for($x=1; $x<33; $x++) {
422
				$CHECKED = "";
423
				if($value == $x) $CHECKED = " SELECTED";
424
				if($x <> 31)
425
					echo "<option value='{$x}' {$CHECKED}>{$x}</option>\n";
426
			}
427
			echo "</select>\n";
428
		    } else if ($field['type'] == "timezone_select") {
429
			if(!$field['dontdisplayname']) {
430
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
431
				echo fixup_string($field['name']);
432
				echo ":</td>";
433
			}
434
			if(!$field['dontcombinecells'])
435
				echo "<td class=\"vtable\">";
436
			echo "<select name='{$name}'>\n";
437
			foreach ($timezonelist as $tz) {
438
				$SELECTED = "";
439
				if ($value == $tz) $SELECTED = " SELECTED";
440
				echo "<option value='" . htmlspecialchars($tz) . "' {$SELECTED}>";
441
				echo htmlspecialchars($tz);
442
				echo "</option>\n";
443
			}
444
			echo "</select>\n";
445
		    } else if ($field['type'] == "checkbox") {
446
			if(!$field['dontdisplayname']) {
447
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
448
				echo $field['name'];
449
				echo ":</td>";
450
			}
451
			$checked = "";
452
			if($value <> "") $checked = " CHECKED";
453
			echo "<td class=\"vtable\"><input type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked;
454
			if(isset($field['enablefields']) or isset($field['checkenablefields'])) echo " onClick=\"enablechange()\"";
455
			echo ">\n";
456
		    }
457

    
458
		    if($field['typehint'] <> "") {
459
			echo $field['typehint'];
460
		    }
461

    
462
		    if($field['description'] <> "") {
463
			echo "<br>" . $field['description'];
464
			echo "</td>";
465
		    }
466

    
467
		    if(!$field['combinefieldsbegin'])
468
			 echo "</tr>\n";
469

    
470
		    if($field['warning'] <> "") {
471
			echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
472
		    }
473

    
474
		}
475
	}
476
    ?>
477
</table>
478
<br>&nbsp;
479
</div>
480
</form>
481
<script language="JavaScript">
482
<!--
483
	if (typeof ext_change != 'undefined') {
484
		ext_change();
485
	}
486
	if (typeof proto_change != 'undefined') {
487
		ext_change();
488
	}
489
	if (typeof proto_change != 'undefined') {
490
		proto_change();
491
	}
492

    
493
<?php
494
	$isfirst = 0;
495
	$aliases = "";
496
	$addrisfirst = 0;
497
	$aliasesaddr = "";
498
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
499
		foreach($config['aliases']['alias'] as $alias_name) {
500
			if(!stristr($alias_name['address'], ".")) {
501
				if($isfirst == 1) $aliases .= ",";
502
				$aliases .= "'" . $alias_name['name'] . "'";
503
				$isfirst = 1;
504
			} else {
505
				if($addrisfirst == 1) $aliasesaddr .= ",";
506
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
507
				$addrisfirst = 1;
508
			}
509
		}
510
?>
511

    
512
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
513
	var customarray=new Array(<?php echo $aliases; ?>);
514

    
515
//-->
516
</script>
517
<script type="text/javascript">
518
NiftyCheck();
519
var bgcolor = document.getElementsByTagName("body")[0].style.backgroundColor;
520
Rounded("div#roundme","all",bgcolor,"#FFFFFF","smooth");
521
</script>
522

    
523
<?php
524

    
525
$fieldnames_array = Array();
526
if($pkg['step'][$stepid]['disableallfieldsbydefault'] <> "") {
527
	// create a fieldname loop that can be used with javascript
528
	// hide and enable features.
529
	echo "\n<script language=\"JavaScript\">\n";
530
	echo "function disableall() {\n";
531
	foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
532
		if($field['type'] <> "submit" and $field['type'] <> "listtopic") {
533
			if(!$field['donotdisable'] <> "") {
534
				array_push($fieldnames_array, $field['name']);
535
				$fieldname = ereg_replace(" ", "", $field['name']);
536
				$fieldname = strtolower($fieldname);
537
				echo "\tdocument.forms[0]." . $fieldname . ".disabled = 1;\n";
538
			}
539
		}
540
	}
541
	echo "}\ndisableall();\n";
542
	echo "function enableitems(selectedindex) {\n";
543
	echo "disableall();\n";
544
	$idcounter = 0;
545
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
546
		echo "\tswitch(selectedindex) {\n";
547
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
548
			if($field['options']['option'] <> "") {
549
				foreach ($field['options']['option'] as $opt) {
550
					if($opt['enablefields'] <> "") {
551
						echo "\t\tcase " . $idcounter . ":\n";
552
						$enablefields_split = split(",", $opt['enablefields']);
553
						foreach ($enablefields_split as $efs) {
554
							$fieldname = ereg_replace(" ", "", $efs);
555
							$fieldname = strtolower($fieldname);
556
							if($fieldname <> "") {
557
								$onchange = "\t\t\tdocument.forms[0]." . $fieldname . ".disabled = 0; \n";
558
								echo $onchange;
559
							}
560
						}
561
						echo "\t\t\tbreak;\n";
562
					}
563
					$idcounter = $idcounter + 1;
564
				}
565
			}
566
		}
567
		echo "\t}\n";
568
	}
569
	echo "}\n";
570
	echo "disableall();\n";
571
	echo "</script>\n\n";
572
}
573

    
574

    
575
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
576
	// handle after form display event.
577
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
578
}
579

    
580
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
581
	// handle after form display event.
582
        echo "\n<script language=\"JavaScript\">\n";
583
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
584
	echo "</script>\n\n";
585
}
586

    
587
/*
588
 *  HELPER FUNCTIONS
589
 */
590

    
591
function fixup_string($string) {
592
	global $config, $myurl;
593
	$newstring = $string;
594
	// fixup #1: $myurl -> http[s]://ip_address:port/
595
	switch($config['system']['webguiproto']) {
596
		case "http":
597
			$proto = "http";
598
			break;
599
		case "https":
600
			$proto = "https";
601
			break;
602
		default:
603
			$proto = "http";
604
			break;
605
	}
606
	$port = $config['system']['webguiport'];
607
	if($port != "") {
608
		if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
609
			$urlport = ":" . $port;
610
		} elseif ($port != "80" and $port != "443") {
611
			$urlport = ":" . $port;
612
		} else {
613
			$urlport = "";
614
		}
615
	}
616
	$myurl = $proto . "://" . $config['interfaces']['lan']['ipaddr'] . $urlport . "/";
617
	$newstring = str_replace("\$myurl", $myurl, $newstring);
618
	// fixup #2: $wanip
619
	$curwanip = get_current_wan_address();
620
	$newstring = str_replace("\$wanip", $curwanip, $newstring);
621
	// fixup #3: $lanip
622
	$lanip = $config['interfaces']['lan']['ipaddr'];
623
	$newstring = str_replace("\$lanip", $lanip, $newstring);
624
	// fixup #4: fix'r'up here.
625
	return $newstring;
626
}
627

    
628
function is_timezone($elt) {
629
	return !preg_match("/\/$/", $elt);
630
}
631

    
632
?>
633

    
634
</body>
635
</html>
636

    
(173-173/174)