Project

General

Profile

Download (20.6 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 = $_POST['stepid'];
40
if (!$stepid) $stepid = "0";
41

    
42
// XXX: Make this input safe.
43
$xml = $_GET['xml'];
44
if($_POST['xml']) $xml = $_POST['xml'];
45

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

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

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

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

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

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

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

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

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

    
105
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
106
	global $config;
107
	$field_split = split("->",$field);
108
	foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
109
	if($field_conv == "") return;
110
	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
	}
119
	
120
	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
	
128
	if($unset <> "") {
129
		$text = "unset(\$config" . $field_conv . ");";
130
		eval($text);
131
		$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
132
		eval($text);
133
	} else {
134
		if($arraynum <> "") {
135
			$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
136
		} else {
137
			$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
138
		}
139
		eval($text);
140
	}
141
}
142

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

    
152
?>
153
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
154
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
155
<script language="JavaScript">
156
<!--
157

    
158
function  FieldValidate(userinput,  regexp,  message) 
159
{ 
160
                if(!userinput.match(regexp)) 
161
                                alert(message); 
162
} 
163

    
164
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
                        }   
196
                        print "\t" . '}' . "\n";
197
                }
198
        }
199
?>
200
}
201
//-->
202
</script>
203
<?php } ?>
204

    
205
<form action="wizard.php" method="post" name="iform" id="iform">
206
<input type="hidden" name="xml" value="<?= $xml ?>">
207
<input type="hidden" name="stepid" value="<?= $stepid ?>">
208
<?php if ($savemsg) print_info_box($savemsg); ?>
209

    
210
<center>
211

    
212
&nbsp;<br>
213

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

    
243
    <?php
244
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
245
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
246

    
247
		    $value = $field['value'];
248
		    $name  = $field['name'];
249

    
250
		    $name = ereg_replace(" ", "", $name);
251
		    $name = strtolower($name);
252

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

    
269
		    if(!$field['combinefieldsend'])
270
			echo "<tr>";
271

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

    
281
			echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'";
282
			if($field['validate'])
283
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
284
			echo ">\n";
285

    
286

    
287
			
288
		    } else if ($field['type'] == "inputalias") {
289
			if(!$field['dontdisplayname']) {
290
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
291
				echo fixup_string($field['name']);
292
				echo ":</td>\n";
293
			}
294
			if(!$field['dontcombinecells'])
295
				echo "<td class=\"vtable\">\n";
296

    
297
			echo "<input  autocomplete='off' class='formfldalias' id='" . $name . "' name='" . $name . "' value='" . $value . "'";
298
			if($field['validate'])
299
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
300
			echo ">\n";			
301

    
302

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

    
451
		    if($field['typehint'] <> "") {
452
			echo $field['typehint'];
453
		    }
454

    
455
		    if($field['description'] <> "") {
456
			echo "<br>" . $field['description'];
457
			echo "</td>";
458
		    }
459

    
460
		    if(!$field['combinefieldsbegin'])
461
			 echo "</tr>\n";
462

    
463
		    if($field['warning'] <> "") {
464
			echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
465
		    }
466

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

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

    
505
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
506
	var customarray=new Array(<?php echo $aliases; ?>);
507

    
508
//-->
509
</script>
510
<script type="text/javascript">
511
NiftyCheck();
512
Rounded("div#roundme","all","#333333","#FFFFFF","smooth");
513
</script>
514

    
515
<?php
516

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

    
566

    
567
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
568
	// handle after form display event.
569
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
570
}
571

    
572
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
573
	// handle after form display event.
574
        echo "\n<script language=\"JavaScript\">\n";
575
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
576
	echo "</script>\n\n";
577
}
578

    
579
/*
580
 *  HELPER FUNCTIONS
581
 */
582

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

    
620
function is_timezone($elt) {
621
	return !preg_match("/\/$/", $elt);
622
}
623

    
624
?>
625

    
626
</body>
627
</html>
628

    
(163-163/164)