Project

General

Profile

Download (20.3 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
if($pkg['step'][$stepid]['stepsubmitbeforesave']) {
68
		eval($pkg['step'][$stepid]['stepsubmitbeforesave']);
69
}
70

    
71
if ($_POST) {
72
    foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
73
        if($field['bindstofield'] <> "" and $field['type'] <> "submit") {
74
		$fieldname = $field['name'];
75
		$unset_fields = "";
76
		$fieldname = ereg_replace(" ", "", $fieldname);
77
		$fieldname = strtolower($fieldname);
78
		// update field with posted values.
79
                if($field['unsetfield'] <> "") $unset_fields = "yes";
80
		if($field['arraynum'] <> "") $arraynum = $field['arraynum'];
81
		if($field['bindstofield'])
82
			update_config_field( $field['bindstofield'], $_POST[$fieldname], $unset_fields, $arraynum, $field['type']);
83
        }
84

    
85
    }
86
    // run custom php code embedded in xml config.
87
    if($pkg['step'][$stepid]['stepsubmitphpaction'] <> "") {
88
		eval($pkg['step'][$stepid]['stepsubmitphpaction']);
89
    }
90
	write_config();
91
    $stepid++;
92
    if($stepid > $totalsteps) $stepid = $totalsteps;
93
}
94

    
95
$title          = $pkg['step'][$stepid]['title'];
96
$description    = $pkg['step'][$stepid]['description'];
97

    
98
function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) {
99
	global $config;
100
	$field_split = split("->",$field);
101
	foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
102
	if($field_conv == "") return;
103
	if($field_type == "checkbox" and $updatetext <> "on") {
104
		/*
105
		    item is a checkbox, it should have the value "on"
106
		    if it was checked
107
                */
108
		$text = "unset(\$config" . $field_conv . ");";
109
		eval($text);
110
		return;
111
	}
112
	
113
	if($field_type == "interfaces_selection") {
114
		$text = "unset(\$config" . $field_conv . ");";
115
		eval($text);
116
		$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
117
		eval($text);
118
		return;
119
	}
120
	
121
	if($unset <> "") {
122
		$text = "unset(\$config" . $field_conv . ");";
123
		eval($text);
124
		$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
125
		eval($text);
126
	} else {
127
		if($arraynum <> "") {
128
			$text = "\$config" . $field_conv . "[" . $arraynum . "] = \"" . $updatetext . "\";";
129
		} else {
130
			$text = "\$config" . $field_conv . " = \"" . $updatetext . "\";";
131
		}
132
		eval($text);
133
	}
134
}
135

    
136
if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") {
137
	// handle before form display event.
138
        // good for modifying posted values, etc.
139
	eval($pkg['step'][$stepid]['stepbeforeformdisplay']);
140
}
141

    
142
$pgtitle = $title;
143
include("head.inc");
144

    
145
?>
146
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
147
<?php if($pkg['step'][$stepid]['fields']['field'] <> "") { ?>
148
<script language="JavaScript">
149
<!--
150

    
151
function  FieldValidate(userinput,  regexp,  message) 
152
{ 
153
                if(!userinput.match(regexp)) 
154
                                alert(message); 
155
} 
156

    
157
function enablechange() {
158
<?php
159
        foreach($pkg['step'][$stepid]['fields']['field'] as $field) {
160
                if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
161
                        print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
162
                        if(isset($field['enablefields'])) {
163
                                $enablefields = explode(',', $field['enablefields']);
164
                                foreach($enablefields as $enablefield) {
165
                                        $enablefield = strtolower($enablefield);
166
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
167
                                }
168
                        }
169
                        if(isset($field['checkenablefields'])) {
170
                                $checkenablefields = explode(',', $field['checkenablefields']);
171
                                foreach($checkenablefields as $checkenablefield) {
172
                                        $checkenablefield = strtolower($checkenablefield);
173
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
174
                                }
175
                        }
176
                        print "\t" . '} else {' . "\n";
177
                        if(isset($field['enablefields'])) {
178
                                foreach($enablefields as $enablefield) {
179
                                        $enablefield = strtolower($enablefield);
180
                                        print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
181
                                }
182
                        }
183
                        if(isset($field['checkenablefields'])) {
184
                                foreach($checkenablefields as $checkenablefield) {
185
                                        $checkenablefield = strtolower($checkenablefield);
186
                                        print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
187
                                }
188
                        }   
189
                        print "\t" . '}' . "\n";
190
                }
191
        }
192
?>
193
}
194
//-->
195
</script>
196
<?php } ?>
197

    
198
<form action="wizard.php" method="post" name="iform" id="iform">
199
<input type="hidden" name="xml" value="<?= $xml ?>">
200
<input type="hidden" name="stepid" value="<?= $stepid ?>">
201
<?php if ($savemsg) print_info_box($savemsg); ?>
202

    
203
<center>
204

    
205
&nbsp;<br>
206
<?php
207
	if($title == "Reload in progress")
208
		$ip = "http://{$config['interfaces']['lan']['ipaddr']}";
209
	else
210
		$ip = "/";
211

    
212
?>
213

    
214
<a href="<?php echo $ip; ?>"><img border="0" src="./themes/<?= $g['theme']; ?>/images/logo.gif"></a>
215
<p>
216
<div style="width:700px;background-color:#ffffff" id="roundme">
217
<table bgcolor="#ffffff" width="600" cellspacing="0" cellpadding="3">
218
    <!-- wizard goes here -->
219
    <tr><td>&nbsp;</td></tr>
220
    <tr><td colspan='2'>
221
<?php	if ($_GET['message'] != "") {
222
		print_info_box($_GET['message']);
223
	}
224
?></td></tr>
225
    <tr><td colspan='2'><center><b><?= fixup_string($description) ?></b></center></td></tr><tr><td>&nbsp;</td></tr>
226
    <?php
227
	if(!$pkg['step'][$stepid]['disableheader'])
228
		echo "<tr><td colspan=\"2\" class=\"listtopic\">" . fixup_string($title) . "</td></tr>";
229
    ?>
230

    
231
    <?php
232
	if($pkg['step'][$stepid]['fields']['field'] <> "") {
233
		foreach ($pkg['step'][$stepid]['fields']['field'] as $field) {
234

    
235
		    $value = $field['value'];
236
		    $name  = $field['name'];
237

    
238
		    $name = ereg_replace(" ", "", $name);
239
		    $name = strtolower($name);
240

    
241
		    if($field['bindstofield'] <> "") {
242
				$arraynum = "";
243
				$field_conv = "";
244
				$field_split = split("->", $field['bindstofield']);
245
				// arraynum is used in cases where there is an array of the same field
246
				// name such as dnsserver (2 of them)
247
				if($field['arraynum'] <> "") $arraynum = "[" . $field['arraynum'] . "]";
248
				foreach ($field_split as $f) $field_conv .= "['" . $f . "']";
249
					$toeval = "\$value = \$config" . $field_conv . $arraynum . ";";
250
					eval($toeval);
251
					if ($field['type'] == "checkbox") {
252
						$toeval = "if(isset(\$config" . $field_conv . $arraynum . ")) \$value = \" CHECKED\";";
253
						eval($toeval);
254
					}
255
		    }
256

    
257
		    if(!$field['combinefieldsend'])
258
			echo "<tr>";
259

    
260
		    if ($field['type'] == "input") {
261
			if(!$field['dontdisplayname']) {
262
				echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
263
				echo fixup_string($field['name']);
264
				echo ":</td>\n";
265
			}
266
			if(!$field['dontcombinecells'])
267
				echo "<td class=\"vtable\">\n";
268

    
269
			echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'";
270
			if($field['validate'])
271
				echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'";
272
			echo ">\n";
273

    
274

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

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

    
290

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

    
439
		    if($field['typehint'] <> "") {
440
			echo $field['typehint'];
441
		    }
442

    
443
		    if($field['description'] <> "") {
444
			echo "<br>" . $field['description'];
445
			echo "</td>";
446
		    }
447

    
448
		    if(!$field['combinefieldsbegin'])
449
			 echo "</tr>\n";
450

    
451
		    if($field['warning'] <> "") {
452
			echo "<br><b><font color=\"red\">" . $field['warning'] . "</font></b>";
453
		    }
454

    
455
		}
456
	}
457
    ?>
458
</table>
459
<br>&nbsp;
460
</div>
461
</form>
462
<script language="JavaScript">
463
<!--
464
	if (typeof ext_change != 'undefined') {
465
		ext_change();
466
	}
467
	if (typeof proto_change != 'undefined') {
468
		ext_change();
469
	}
470
	if (typeof proto_change != 'undefined') {
471
		proto_change();
472
	}
473

    
474
<?php
475
	$isfirst = 0;
476
	$aliases = "";
477
	$addrisfirst = 0;
478
	$aliasesaddr = "";
479
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
480
		foreach($config['aliases']['alias'] as $alias_name) {
481
			if(!stristr($alias_name['address'], ".")) {
482
				if($isfirst == 1) $aliases .= ",";
483
				$aliases .= "'" . $alias_name['name'] . "'";
484
				$isfirst = 1;
485
			} else {
486
				if($addrisfirst == 1) $aliasesaddr .= ",";
487
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
488
				$addrisfirst = 1;
489
			}
490
		}
491
?>
492

    
493
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
494
	var customarray=new Array(<?php echo $aliases; ?>);
495

    
496
//-->
497
</script>
498
<script type="text/javascript">
499
NiftyCheck();
500
Rounded("div#roundme","all","#333333","#FFFFFF","smooth");
501
</script>
502

    
503
</body>
504
</html>
505

    
506
<?php
507

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

    
557

    
558
if($pkg['step'][$stepid]['stepafterformdisplay'] <> "") {
559
	// handle after form display event.
560
	eval($pkg['step'][$stepid]['stepafterformdisplay']);
561
}
562

    
563
if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
564
	// handle after form display event.
565
        echo "\n<script language=\"JavaScript\">\n";
566
	echo $pkg['step'][$stepid]['javascriptafterformdisplay'] . "\n";
567
	echo "</script>\n\n";
568
}
569

    
570
/*
571
 *  HELPER FUNCTIONS
572
 */
573

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

    
611
function is_timezone($elt) {
612
	return !preg_match("/\/$/", $elt);
613
}
614

    
615
?>
(159-159/160)