1 |
a7f908db
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
|
|
/*
|
4 |
|
|
pkg.php
|
5 |
b49448ac
|
Scott Ullrich
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6 |
a7f908db
|
Scott Ullrich
|
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 |
e3c4b6b7
|
Scott Ullrich
|
global $config;
|
35 |
|
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
36 |
a7f908db
|
Scott Ullrich
|
}
|
37 |
|
|
|
38 |
|
|
$xml = $_GET['xml'];
|
39 |
|
|
|
40 |
|
|
if($xml == "") {
|
41 |
|
|
$xml = "not_defined";
|
42 |
|
|
print_info_box_np("ERROR: Could not open " . $xml . ".");
|
43 |
|
|
die;
|
44 |
|
|
} else {
|
45 |
e3c4b6b7
|
Scott Ullrich
|
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
|
46 |
a7f908db
|
Scott Ullrich
|
}
|
47 |
|
|
|
48 |
3eaeb703
|
Scott Ullrich
|
if($pkg['donotsave'] <> "") {
|
49 |
|
|
header("Location: pkg_edit.php?xml=" . $xml);
|
50 |
|
|
}
|
51 |
|
|
|
52 |
a28c8b59
|
Scott Ullrich
|
$package_name = $pkg['menu'][0]['name'];
|
53 |
|
|
$section = $pkg['menu'][0]['section'];
|
54 |
a7f908db
|
Scott Ullrich
|
$config_path = $pkg['configpath'];
|
55 |
e3c4b6b7
|
Scott Ullrich
|
$title = $section . ": " . $package_name;
|
56 |
|
|
|
57 |
|
|
$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
|
58 |
|
|
eval($toeval);
|
59 |
|
|
|
60 |
|
|
if ($_GET['act'] == "del") {
|
61 |
0bb335f4
|
Scott Ullrich
|
// loop through our fieldnames and automatically setup the fieldnames
|
62 |
|
|
// in the environment. ie: a fieldname of username with a value of
|
63 |
|
|
// testuser would automatically eval $username = "testuser";
|
64 |
e3c4b6b7
|
Scott Ullrich
|
foreach ($evaledvar as $ip) {
|
65 |
e55a0a25
|
Scott Ullrich
|
if($pkg['adddeleteeditpagefields']['columnitem'])
|
66 |
|
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
67 |
|
|
$toeval = "\$" . xml_safe_fieldname($column['fielddescr']) . " = " . "\$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
|
68 |
|
|
eval($toeval);
|
69 |
|
|
}
|
70 |
e3c4b6b7
|
Scott Ullrich
|
}
|
71 |
|
|
|
72 |
|
|
$toeval = "\$a_pkg = &\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
|
73 |
|
|
eval($toeval);
|
74 |
|
|
|
75 |
|
|
if ($a_pkg[$_GET['id']]) {
|
76 |
|
|
if($pkg['custom_delete_php_command'] <> "") {
|
77 |
5cd30ac3
|
Scott Ullrich
|
if($pkg['custom_php_command_before_form'] <> "")
|
78 |
|
|
eval($pkg['custom_php_command_before_form']);
|
79 |
e3c4b6b7
|
Scott Ullrich
|
eval($pkg['custom_delete_php_command']);
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
unset($a_pkg[$_GET['id']]);
|
83 |
|
|
write_config();
|
84 |
|
|
header("Location: pkg.php?xml=" . $xml);
|
85 |
|
|
exit;
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
|
90 |
|
|
eval($toeval);
|
91 |
a7f908db
|
Scott Ullrich
|
|
92 |
f9a91638
|
Scott Ullrich
|
if($pkg['custom_php_command_before_form'] <> "")
|
93 |
|
|
eval($pkg['custom_php_command_before_form']);
|
94 |
|
|
|
95 |
a7f908db
|
Scott Ullrich
|
?>
|
96 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
97 |
|
|
<html>
|
98 |
|
|
<head>
|
99 |
64fba011
|
Scott Ullrich
|
<?php
|
100 |
|
|
if($pkg['title'] <> "") $title = $pkg['title'];
|
101 |
|
|
?>
|
102 |
a7f908db
|
Scott Ullrich
|
<title><?=gentitle_pkg($title);?></title>
|
103 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
104 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
105 |
|
|
</head>
|
106 |
|
|
|
107 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
108 |
859329c8
|
Scott Ullrich
|
<?php
|
109 |
|
|
include("fbegin.inc");
|
110 |
|
|
?>
|
111 |
a7f908db
|
Scott Ullrich
|
<p class="pgtitle"><?=$title?></p>
|
112 |
64fba011
|
Scott Ullrich
|
<form action="pkg.php" method="post">
|
113 |
8596e0a4
|
Scott Ullrich
|
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
|
114 |
a7f908db
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
115 |
7c061036
|
Scott Ullrich
|
|
116 |
|
|
<?php
|
117 |
|
|
if ($pkg['tabs'] <> "") {
|
118 |
|
|
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
|
119 |
|
|
echo "<tr><td>";
|
120 |
|
|
echo " <ul id=\"tabnav\">";
|
121 |
|
|
foreach($pkg['tabs']['tab'] as $tab) {
|
122 |
|
|
$active = "tabinact";
|
123 |
|
|
if(isset($tab['active'])) $active = "tabact";
|
124 |
e17ce934
|
Scott Ullrich
|
$urltmp = "";
|
125 |
3d335c4d
|
Scott Ullrich
|
$title = $tab['text'];
|
126 |
e17ce934
|
Scott Ullrich
|
if($tab['url'] <> "") $urltmp = $tab['url'];
|
127 |
|
|
if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
128 |
|
|
|
129 |
|
|
$toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n";
|
130 |
|
|
eval($toeval);
|
131 |
|
|
// eval url so that above $myurl item can be processed if need be.
|
132 |
|
|
$toeval = "\$url = \"" . $urltmp . "\"; \n";
|
133 |
|
|
eval($toeval);
|
134 |
|
|
|
135 |
3d335c4d
|
Scott Ullrich
|
if($active == "tabinact") {
|
136 |
|
|
echo "<li class=\"{$active}\">";
|
137 |
|
|
echo "<a href=\"";
|
138 |
|
|
echo $url;
|
139 |
|
|
echo "\">";
|
140 |
|
|
echo $title;
|
141 |
|
|
echo "</a>";
|
142 |
|
|
echo "</li>";
|
143 |
|
|
} else {
|
144 |
|
|
echo "<li class=\"{$active}\">";
|
145 |
|
|
echo $title;
|
146 |
|
|
echo "</li>";
|
147 |
|
|
}
|
148 |
7c061036
|
Scott Ullrich
|
}
|
149 |
|
|
echo " </ul>";
|
150 |
|
|
echo "</td></tr>";
|
151 |
|
|
echo "<tr>";
|
152 |
|
|
echo "<td class=\"tabcont\">";
|
153 |
|
|
}
|
154 |
|
|
?>
|
155 |
|
|
|
156 |
a7f908db
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
157 |
|
|
<tr>
|
158 |
|
|
<td class="tabcont">
|
159 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
160 |
|
|
<tr>
|
161 |
|
|
<?php
|
162 |
|
|
$cols = 0;
|
163 |
2d512c84
|
Scott Ullrich
|
if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
|
164 |
|
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
165 |
|
|
echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
|
166 |
|
|
$cols++;
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
a7f908db
|
Scott Ullrich
|
echo "</tr>";
|
170 |
2cf712c4
|
Scott Ullrich
|
$i=0;
|
171 |
|
|
if($evaledvar)
|
172 |
|
|
foreach ($evaledvar as $ip) {
|
173 |
|
|
echo "<tr valign=\"top\">\n";
|
174 |
7c061036
|
Scott Ullrich
|
if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
|
175 |
549912e3
|
Scott Ullrich
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
176 |
|
|
?>
|
177 |
|
|
<td class="listlr">
|
178 |
|
|
<?php
|
179 |
|
|
$toeval="\$fieldname = \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
|
180 |
|
|
eval($toeval);
|
181 |
|
|
if($column['type'] == "checkbox") {
|
182 |
|
|
if($fieldname == "") {
|
183 |
|
|
echo "No";
|
184 |
|
|
} else {
|
185 |
|
|
echo "Yes";
|
186 |
|
|
}
|
187 |
|
|
} else {
|
188 |
009c7905
|
Colin Smith
|
echo $column['prefix'] . $fieldname . $column['suffix'];
|
189 |
549912e3
|
Scott Ullrich
|
}
|
190 |
|
|
?>
|
191 |
|
|
</td>
|
192 |
|
|
<?php
|
193 |
|
|
}
|
194 |
2cf712c4
|
Scott Ullrich
|
?>
|
195 |
|
|
<td valign="middle" class="list" nowrap>
|
196 |
2c634bdd
|
Scott Ullrich
|
<a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
|
197 |
|
|
<a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this item?')"><img src="x.gif" width="17" height="17" border="0"></a>
|
198 |
2cf712c4
|
Scott Ullrich
|
</td>
|
199 |
|
|
<?php
|
200 |
|
|
echo "</tr>\n";
|
201 |
|
|
$i++;
|
202 |
|
|
}
|
203 |
|
|
?>
|
204 |
d47013e1
|
Scott Ullrich
|
<tr><td colspan="<?=$cols?>"></td><td><a href="pkg_edit.php?xml=<?=$xml?>"><img src="plus.gif" width="17" height="17" border="0"></a></td></tr>
|
205 |
a7f908db
|
Scott Ullrich
|
</table>
|
206 |
|
|
</td>
|
207 |
|
|
</tr>
|
208 |
|
|
</table>
|
209 |
3d335c4d
|
Scott Ullrich
|
|
210 |
|
|
<?php
|
211 |
|
|
if ($pkg['tabs'] <> "") {
|
212 |
|
|
echo "</td></tr></table>";
|
213 |
|
|
}
|
214 |
|
|
?>
|
215 |
|
|
|
216 |
a7f908db
|
Scott Ullrich
|
</form>
|
217 |
|
|
<?php include("fend.inc"); ?>
|
218 |
|
|
</body>
|
219 |
|
|
</html>
|