Project

General

Profile

Download (20.9 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
##|+PRIV
31
##|*IDENT=page-pfsensewizardsubsystem
32
##|*NAME=pfSense wizard subsystem page
33
##|*DESCR=Allow access to the 'pfSense wizard subsystem' page.
34
##|*MATCH=wizard.php*
35
##|-PRIV
36

    
37

    
38
require("guiconfig.inc");
39

    
40
function gentitle_pkg($pgname) {
41
	global $config;
42
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
43
}
44

    
45
$stepid = htmlspecialchars($_GET['stepid']);
46
if (isset($_POST['stepid']))
47
    $stepid = htmlspecialchars($_POST['stepid']);
48
if (!$stepid) $stepid = "0";
49

    
50
$xml = htmlspecialchars($_GET['xml']);
51
if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
52

    
53
if($xml == "") {
54
	$xml = "not_defined";
55
	print_info_box_np("ERROR:  Could not open " . $xml . ".");
56
	die;
57
} else {
58
	if (file_exists("{$g['www_path']}/wizards/{$xml}"))
59
		$pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
60
	else {
61
		print_info_box_np("ERROR:  Could not open " . $xml . ".");
62
		die;
63
	}
64
}
65

    
66
$title          = $pkg['step'][$stepid]['title'];
67
$description    = $pkg['step'][$stepid]['description'];
68
$totalsteps     = $pkg['totalsteps'];
69

    
70
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
71
$timezonelist = array_filter($timezonelist, 'is_timezone');
72
sort($timezonelist);
73

    
74
/* kill carriage returns */
75
for($x=0; $x<count($timezonelist); $x++)
76
		$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
77

    
78
if ($pkg['step'][$stepid]['includefile'])
79
	require($pkg['step'][$stepid]['includefile']);
80

    
81
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
82
		eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
83
}
84

    
85
if ($_POST) {
86
    foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
87
        if($field['bindstofield'] <> "" and $field['type'] <> "submit") {
88
		$fieldname = $field['name'];
89
		$unset_fields = "";
90
		$fieldname = ereg_replace(" ", "", $fieldname);
91
		$fieldname = strtolower($fieldname);
92
		// update field with posted values.
93
                if($field['unsetfield'] <> "") $unset_fields = "yes";
94
		if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
95
		if($field['bindstofield'])
96
			update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
97
        }
98

    
99
    }
100
    // run custom php code embedded in xml config.
101
    if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
102
		eval($pkg['step'][$stepid]['stepsubmitphpaction']);
103
    }
104
	write_config();
105
    $stepid++;
106
    if($stepid > $totalsteps) $stepid = $totalsteps;
107
}
108

    
109
$title          = $pkg['step'][$stepid]['title'];
110
$description    = $pkg['step'][$stepid]['description'];
111

    
112
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
113
	global $config;
114
	$field_split = split("->",$field);
115
	foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
116
	if($field_conv == "") return;
117
	if($field_type == "checkbox" and $updatetext <> "on") {
118
		/*
119
		    item is a checkbox, it should have the value "on"
120
		    if it was checked
121
                */
122
		$text = "unset(\$config" . $field_conv . ");";
123
		eval($text);
124
		return;
125
	}
126

    
127
	if($field_type == "interfaces_selection") {
128
		$text = "unset(\$config" . $field_conv . ");";
129
		eval($text);
130
		$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
131
		eval($text);
132
		return;
133
	}
134

    
135
	if($unset <> "") {
136
		$text = "unset(\$config" . $field_conv . ");";
137
		eval($text);
138
		$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
139
		eval($text);
140
	} else {
141
		if($arraynum <> "") {
142
			$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
143
		} else {
144
			$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
145
		}
146
		eval($text);
147
	}
148
}
149

    
150
if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") {
151
	// handle before form display event.
152
        // good for modifying posted values, etc.
153
	eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
154
}
155

    
156
$pgtitle = array($title);
157
include("head.inc");
158

    
159
?>
160
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
161
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
162
<script language="JavaScript">
163
<!--
164

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

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

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

    
217
<center>
218

    
219
&nbsp;<br>
220

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

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

    
252
		    $value = $field['value'];
253
		    $name  = $field['name'];
254

    
255
		    $name = ereg_replace(" ", "", $name);
256
		    $name = strtolower($name);
257

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

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

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

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

    
291

    
292

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

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

    
307

    
308

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

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

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

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

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

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

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

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

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

    
521
<?php
522

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

    
572

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

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

    
585
/*
586
 *  HELPER FUNCTIONS
587
 */
588

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

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

    
630
?>
631

    
632
</body>
633
</html>
634

    
(208-208/209)