Revision 658292ef
Added by Scott Ullrich over 20 years ago
usr/local/www/wizard.php | ||
---|---|---|
1 |
#!/usr/local/bin/php |
|
2 |
<?php |
|
3 |
/* |
|
4 |
pkg_edit.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 |
require("xmlparse_pkg.inc"); |
|
32 |
|
|
33 |
function gentitle_pkg($pgname) { |
|
34 |
global $pfSense_config; |
|
35 |
return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname; |
|
36 |
} |
|
37 |
|
|
38 |
$stepid = $_GET['stepid']; |
|
39 |
if (isset($_POST['stepid'])) |
|
40 |
$stepid = $_POST['stepid']; |
|
41 |
if (!$stepid) $stepid = "1"; |
|
42 |
|
|
43 |
// XXX: Make this input safe. |
|
44 |
$xml = $_GET['xml']; |
|
45 |
if($_POST['xml']) $xml = $_POST['xml']; |
|
46 |
|
|
47 |
if($xml == "") { |
|
48 |
$xml = "not_defined"; |
|
49 |
print_info_box_np("ERROR: Could not open " . $xml . "."); |
|
50 |
die; |
|
51 |
} else { |
|
52 |
$pkg = parse_xml_config_pkg("/usr/local/www/wizard/" . $xml, "packagegui"); |
|
53 |
} |
|
54 |
|
|
55 |
$title = $pkg['step'][$stepid]['title']; |
|
56 |
$description = $pkg['step'][$stepid]['description']; |
|
57 |
|
|
58 |
if ($_POST) { |
|
59 |
foreach ($pkg['step'][$stepid]['fields'] as $field) { |
|
60 |
if($field['bindtofield'] <> "") { |
|
61 |
// update field with posted values. |
|
62 |
|
|
63 |
} |
|
64 |
if($pkg['step'][$stepid]['stepsubmitphpaction']) { |
|
65 |
eval($pkg['step'][$stepid]['stepsubmitphpaction']); |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
function update_config_field($field, $updatetext) { |
|
71 |
$config[$field] = $updatetext; |
|
72 |
} |
|
73 |
|
|
74 |
?> |
|
75 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
76 |
<html> |
|
77 |
<head> |
|
78 |
<title><?=gentitle_pkg($title);?></title> |
|
79 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
|
80 |
<link href="gui.css" rel="stylesheet" type="text/css"> |
|
81 |
</head> |
|
82 |
|
|
83 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> |
|
84 |
<?php |
|
85 |
$config_tmp = $config; |
|
86 |
$config = $pfSense_config; |
|
87 |
include("fbegin.inc"); |
|
88 |
$config = $config_tmp; |
|
89 |
?> |
|
90 |
<p class="pgtitle"><?=$title?></p> |
|
91 |
<form action="wizard.php" method="post"> |
|
92 |
<input type="hidden" name="xml" value="<?= $xml ?>"> |
|
93 |
<?php if ($savemsg) print_info_box($savemsg); ?> |
|
94 |
|
|
95 |
<table width="100%" border="0" cellpadding="6" cellspacing="0"> |
|
96 |
<tr> |
|
97 |
<td bgcolor="#FF0000"> |
|
98 |
<font color="white"><?= $title ?></font> |
|
99 |
</td> |
|
100 |
<td> |
|
101 |
<table> |
|
102 |
<!-- wizard goes here --> |
|
103 |
<tr><td colspan='2'><center><?= $description ?></center></td></tr> |
|
104 |
<?php |
|
105 |
foreach ($pkg['step'][$stepid]['fields'] as $field) { |
|
106 |
echo "<tr><td>"; |
|
107 |
echo $field['name']; |
|
108 |
echo "</td><td>"; |
|
109 |
|
|
110 |
$value = ""; |
|
111 |
|
|
112 |
if ($field['type'] == "input") { |
|
113 |
echo "<input name='" . $field['name'] . " value='" . $value . "'>\n"; |
|
114 |
} else if ($field['type'] == "password") { |
|
115 |
echo "<input name='" . $field['name'] . " value='" . $value . "' type='password'>\n"; |
|
116 |
} else if ($field['type'] == "select") { |
|
117 |
// XXX: TODO: set $selected |
|
118 |
if($field['size']) $size = " size='" . $field['size'] . "' "; |
|
119 |
if($field['multiple'] == "yes") $multiple = "MULTIPLE "; |
|
120 |
echo "<select " . $multiple . $size . "id='" . $field['fieldname'] . "' name='" . $field['fieldname'] . "'>\n"; |
|
121 |
foreach ($field['options']['option'] as $opt) { |
|
122 |
echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'>" . $opt['name'] . "</option>\n"; |
|
123 |
} |
|
124 |
echo "</select>\n"; |
|
125 |
} else if ($field['type'] == "textarea") { |
|
126 |
echo "<textarea name='" . $field['name'] . ">" . $value . "</textarea>\n"; |
|
127 |
} |
|
128 |
|
|
129 |
echo "</td></tr>"; |
|
130 |
} |
|
131 |
?> |
|
132 |
</table> |
|
133 |
</td> |
|
134 |
</tr> |
|
135 |
</table> |
|
136 |
|
|
137 |
</form> |
|
138 |
<?php include("fend.inc"); ?> |
|
139 |
</body> |
|
140 |
</html> |
Also available in: Unified diff
Introduce wizard system.