1 |
d47013e1
|
Scott Ullrich
|
#!/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 |
|
|
$pfSense_config = $config; // copy this since we will be parsing
|
34 |
|
|
// another xml file which will be clobbered.
|
35 |
|
|
|
36 |
|
|
function gentitle_pkg($pgname) {
|
37 |
|
|
global $pfSense_config;
|
38 |
|
|
return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
// XXX: Make this input safe.
|
42 |
|
|
$xml = $_GET['xml'];
|
43 |
|
|
|
44 |
|
|
if($xml == "") {
|
45 |
|
|
$xml = "not_defined";
|
46 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
47 |
|
|
die;
|
48 |
|
|
} else {
|
49 |
|
|
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
$package_name = $pkg['menu']['name'];
|
53 |
|
|
$section = $pkg['menu']['section'];
|
54 |
|
|
$config_path = $pkg['configpath'];
|
55 |
|
|
$title = $section . ": Edit " . $package_name
|
56 |
|
|
|
57 |
6483da5d
|
Scott Ullrich
|
if ($_POST) {
|
58 |
|
|
if($_GET['act'] == "del") {
|
59 |
|
|
if($pkg['custom_delete_php_command']) {
|
60 |
|
|
eval($pkg['custom_delete_php_command']);
|
61 |
|
|
}
|
62 |
|
|
// XXX: unset the xml value to config
|
63 |
|
|
} else {
|
64 |
|
|
if($pkg['custom_add_php_command']) {
|
65 |
|
|
eval($pkg['custom_add_php_command']);
|
66 |
|
|
}
|
67 |
|
|
// XXX: add the xml value to config
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
d47013e1
|
Scott Ullrich
|
?>
|
72 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
73 |
|
|
<html>
|
74 |
|
|
<head>
|
75 |
|
|
<title><?=gentitle_pkg($title);?></title>
|
76 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
77 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
78 |
|
|
</head>
|
79 |
|
|
|
80 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
81 |
|
|
<?php
|
82 |
|
|
$config_tmp = $config;
|
83 |
|
|
$config = $pfSense_config;
|
84 |
|
|
include("fbegin.inc");
|
85 |
|
|
$config = $config_tmp;
|
86 |
|
|
?>
|
87 |
|
|
<p class="pgtitle"><?=$title?></p>
|
88 |
|
|
<form action="firewall_nat_out_load_balancing.php" method="post">
|
89 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
90 |
|
|
|
91 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
92 |
|
|
<tr>
|
93 |
|
|
<?php
|
94 |
|
|
$cols = 0;
|
95 |
|
|
foreach ($pkg['fields']['field'] as $pkg) { ?>
|
96 |
|
|
</tr>
|
97 |
|
|
<tr valign="top">
|
98 |
|
|
<td width="22%" class="vncellreq">
|
99 |
|
|
<?= $pkg['fielddescr'] ?>
|
100 |
|
|
</td>
|
101 |
|
|
<td class="vtable">
|
102 |
|
|
<?php
|
103 |
|
|
if($pkg['type'] == "input") {
|
104 |
|
|
// XXX: TODO: set $value
|
105 |
2d27fa4f
|
Scott Ullrich
|
if($pkg['size']) $size = " size='" . $pkg['size'] . "' ";
|
106 |
|
|
echo "<input " . $size . " name='" . $pkg['fieldname'] . "' value='" . $value . "'>\n";
|
107 |
d47013e1
|
Scott Ullrich
|
echo "<br>" . $pkg['description'] . "\n";
|
108 |
6483da5d
|
Scott Ullrich
|
} else if($pkg['type'] == "password") {
|
109 |
|
|
echo "<input type='password' " . $size . " name='" . $pkg['fieldname'] . "' value='" . $value . "'>\n";
|
110 |
|
|
echo "<br>" . $pkg['description'] . "\n";
|
111 |
d47013e1
|
Scott Ullrich
|
} else if($pkg['type'] == "select") {
|
112 |
|
|
// XXX: TODO: set $selected
|
113 |
|
|
if($pkg['size']) $size = " size='" . $pkg['size'] . "' ";
|
114 |
|
|
if($pkg['multiple'] == "yes") $multiple = "MULTIPLE ";
|
115 |
|
|
echo "<select " . $multiple . $size . "id='" . $pkg['fieldname'] . "' name='" . $pkg['fieldname'] . "'>\n";
|
116 |
|
|
foreach ($pkg['options']['option'] as $opt) {
|
117 |
|
|
echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'>" . $opt['name'] . "</option>\n";
|
118 |
|
|
}
|
119 |
|
|
echo "</select>\n";
|
120 |
|
|
echo "<br>" . $pkg['description'] . "\n";
|
121 |
|
|
} else if($pkg['type'] == "checkbox") {
|
122 |
|
|
echo "<input type='checkbox' name='" . $pkg['fieldname'] . "' value='" . $value . "'>\n";
|
123 |
|
|
echo "<br>" . $pkg['description'] . "\n";
|
124 |
|
|
} else if($pkg['type'] == "textarea") {
|
125 |
9bc598ab
|
Scott Ullrich
|
if($pkg['rows']) $rows = " rows='" . $pkg['rows'] . "' ";
|
126 |
|
|
if($pkg['cols']) $cols = " cols='" . $pkg['cols'] . "' ";
|
127 |
2d27fa4f
|
Scott Ullrich
|
echo "<textarea " . $rows . $cols . " name='" . $pkg['fieldname'] . "'>" . $value . "</textarea>\n";
|
128 |
d47013e1
|
Scott Ullrich
|
echo "<br>" . $pkg['description'] . "\n";
|
129 |
|
|
}
|
130 |
|
|
?>
|
131 |
|
|
</td>
|
132 |
|
|
</tr>
|
133 |
|
|
<?php
|
134 |
|
|
$i++;
|
135 |
|
|
}
|
136 |
|
|
?>
|
137 |
|
|
<tr>
|
138 |
|
|
<td width="22%" valign="top"> </td>
|
139 |
|
|
<td width="78%">
|
140 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
141 |
|
|
<?php if (isset($id) && $a_pkg[$id]): ?>
|
142 |
|
|
<input name="id" type="hidden" value="<?=$id;?>">
|
143 |
|
|
<?php endif; ?>
|
144 |
|
|
</td>
|
145 |
|
|
</tr>
|
146 |
|
|
</table>
|
147 |
|
|
|
148 |
|
|
</form>
|
149 |
|
|
<?php include("fend.inc"); ?>
|
150 |
|
|
</body>
|
151 |
|
|
</html>
|