1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
pkg.php
|
6
|
Copyright (C) 2004, 2005 Scott Ullrich
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
|
31
|
require_once("guiconfig.inc");
|
32
|
require_once("pkg-utils.inc");
|
33
|
|
34
|
function gentitle_pkg($pgname) {
|
35
|
global $config;
|
36
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
37
|
}
|
38
|
|
39
|
$xml = $_GET['xml'];
|
40
|
|
41
|
if($xml == "") {
|
42
|
print_info_box_np("ERROR: No package defined.");
|
43
|
die;
|
44
|
} else {
|
45
|
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
|
46
|
}
|
47
|
|
48
|
if($pkg['donotsave'] <> "") {
|
49
|
header("Location: pkg_edit.php?xml=" . $xml);
|
50
|
}
|
51
|
|
52
|
$package_name = $pkg['menu'][0]['name'];
|
53
|
$section = $pkg['menu'][0]['section'];
|
54
|
$config_path = $pkg['configpath'];
|
55
|
$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
|
// 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
|
foreach ($evaledvar as $ip) {
|
65
|
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
|
}
|
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
|
if($pkg['custom_php_command_before_form'] <> "")
|
78
|
eval($pkg['custom_php_command_before_form']);
|
79
|
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
|
|
92
|
if($pkg['custom_php_global_functions'] <> "")
|
93
|
eval($pkg['custom_php_global_functions']);
|
94
|
|
95
|
if($pkg['custom_php_command_before_form'] <> "")
|
96
|
eval($pkg['custom_php_command_before_form']);
|
97
|
|
98
|
?>
|
99
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
100
|
<html>
|
101
|
<head>
|
102
|
<?php
|
103
|
if($pkg['title'] <> "") $title = $pkg['title'];
|
104
|
?>
|
105
|
<title><?=gentitle_pkg($title);?></title>
|
106
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
107
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
108
|
</head>
|
109
|
|
110
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
111
|
<?php
|
112
|
include("fbegin.inc");
|
113
|
?>
|
114
|
<p class="pgtitle"><?=$title?></p>
|
115
|
<form action="pkg.php" method="post">
|
116
|
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
|
117
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
118
|
|
119
|
<?php
|
120
|
if ($pkg['tabs'] <> "") {
|
121
|
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
|
122
|
echo "<tr><td>";
|
123
|
echo " <ul id=\"tabnav\">";
|
124
|
foreach($pkg['tabs']['tab'] as $tab) {
|
125
|
$active = "tabinact";
|
126
|
if(isset($tab['active'])) $active = "tabact";
|
127
|
$urltmp = "";
|
128
|
$title = $tab['text'];
|
129
|
if($tab['url'] <> "") $urltmp = $tab['url'];
|
130
|
if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
131
|
|
132
|
$toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n";
|
133
|
eval($toeval);
|
134
|
// eval url so that above $myurl item can be processed if need be.
|
135
|
$toeval = "\$url = \"" . $urltmp . "\"; \n";
|
136
|
eval($toeval);
|
137
|
|
138
|
if($active == "tabinact") {
|
139
|
echo "<li class=\"{$active}\">";
|
140
|
echo "<a href=\"";
|
141
|
echo $url;
|
142
|
echo "\">";
|
143
|
echo $title;
|
144
|
echo "</a>";
|
145
|
echo "</li>";
|
146
|
} else {
|
147
|
echo "<li class=\"{$active}\">";
|
148
|
echo $title;
|
149
|
echo "</li>";
|
150
|
}
|
151
|
}
|
152
|
echo " </ul>";
|
153
|
echo "</td></tr>";
|
154
|
echo "<tr>";
|
155
|
echo "<td class=\"tabcont\">";
|
156
|
}
|
157
|
?>
|
158
|
|
159
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
160
|
<tr>
|
161
|
<td class="tabcont">
|
162
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
163
|
<tr>
|
164
|
<?php
|
165
|
$cols = 0;
|
166
|
if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
|
167
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
168
|
echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
|
169
|
$cols++;
|
170
|
}
|
171
|
}
|
172
|
echo "</tr>";
|
173
|
$i=0;
|
174
|
if($evaledvar)
|
175
|
foreach ($evaledvar as $ip) {
|
176
|
echo "<tr valign=\"top\">\n";
|
177
|
if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
|
178
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
179
|
?>
|
180
|
<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
|
181
|
<?php
|
182
|
$toeval="\$fieldname = \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
|
183
|
eval($toeval);
|
184
|
if($column['type'] == "checkbox") {
|
185
|
if($fieldname == "") {
|
186
|
echo "No";
|
187
|
} else {
|
188
|
echo "Yes";
|
189
|
}
|
190
|
} else {
|
191
|
echo $column['prefix'] . $fieldname . $column['suffix'];
|
192
|
}
|
193
|
?>
|
194
|
</td>
|
195
|
<?php
|
196
|
}
|
197
|
?>
|
198
|
<td valign="middle" class="list" nowrap>
|
199
|
<table border="0" cellspacing="0" cellpadding="1">
|
200
|
<tr>
|
201
|
<td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a></td>
|
202
|
<td valign="middle"><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></td>
|
203
|
</tr>
|
204
|
</table>
|
205
|
</td>
|
206
|
<?php
|
207
|
echo "</tr>\n";
|
208
|
$i++;
|
209
|
}
|
210
|
?>
|
211
|
<tr>
|
212
|
<td colspan="<?=$cols?>"></td>
|
213
|
<td>
|
214
|
<table border="0" cellspacing="0" cellpadding="1">
|
215
|
<tr>
|
216
|
<td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>"><img src="plus.gif" width="17" height="17" border="0"></a></td>
|
217
|
</tr>
|
218
|
</table>
|
219
|
</td>
|
220
|
</tr>
|
221
|
</table>
|
222
|
</td>
|
223
|
</tr>
|
224
|
</table>
|
225
|
|
226
|
<?php
|
227
|
if ($pkg['tabs'] <> "") {
|
228
|
echo "</td></tr></table>";
|
229
|
}
|
230
|
?>
|
231
|
|
232
|
</form>
|
233
|
<?php include("fend.inc"); ?>
|
234
|
</body>
|
235
|
</html>
|