1 |
a7f908db
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
f8ac4407
|
Phil Davis
|
pkg.php
|
4 |
1d333258
|
Scott Ullrich
|
/*
|
5 |
f5dbca0d
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
|
|
*
|
8 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
9 |
|
|
* 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
|
16 |
|
|
* the documentation and/or other materials provided with the
|
17 |
|
|
* distribution.
|
18 |
|
|
*
|
19 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
20 |
|
|
* must display the following acknowledgment:
|
21 |
|
|
* "This product includes software developed by the pfSense Project
|
22 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
23 |
|
|
*
|
24 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
25 |
|
|
* endorse or promote products derived from this software without
|
26 |
|
|
* prior written permission. For written permission, please contact
|
27 |
|
|
* coreteam@pfsense.org.
|
28 |
|
|
*
|
29 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
30 |
|
|
* nor may "pfSense" appear in their names without prior written
|
31 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
32 |
|
|
*
|
33 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
34 |
|
|
* acknowledgment:
|
35 |
|
|
*
|
36 |
|
|
* "This product includes software developed by the pfSense Project
|
37 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
38 |
|
|
*
|
39 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
40 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
41 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
43 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
44 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
45 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
46 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
48 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
49 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
50 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
51 |
|
|
*
|
52 |
|
|
* ====================================================================
|
53 |
|
|
*
|
54 |
|
|
*/
|
55 |
a7f908db
|
Scott Ullrich
|
|
56 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
57 |
|
|
##|*IDENT=page-package-settings
|
58 |
5230f468
|
jim-p
|
##|*NAME=Package: Settings
|
59 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Package: Settings' page.
|
60 |
|
|
##|*MATCH=pkg.php*
|
61 |
|
|
##|-PRIV
|
62 |
|
|
|
63 |
e4bf1c19
|
Colin Smith
|
require_once("guiconfig.inc");
|
64 |
|
|
require_once("pkg-utils.inc");
|
65 |
a7f908db
|
Scott Ullrich
|
|
66 |
2c2fed92
|
Stephen Beaver
|
function domTT_title($title_msg) {
|
67 |
|
|
print "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '".gettext($title_msg)."', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\"";
|
68 |
|
|
}
|
69 |
|
|
|
70 |
98bcf1f8
|
Scott Ullrich
|
$xml = $_REQUEST['xml'];
|
71 |
a7f908db
|
Scott Ullrich
|
|
72 |
f8ac4407
|
Phil Davis
|
if ($xml == "") {
|
73 |
f5dbca0d
|
Stephen Beaver
|
include("head.inc");
|
74 |
|
|
print_info_box_np(gettext("ERROR: No valid package defined."));
|
75 |
|
|
include("foot.inc");
|
76 |
b000f96f
|
Scott Ullrich
|
exit;
|
77 |
a7f908db
|
Scott Ullrich
|
} else {
|
78 |
44bcf766
|
jim-p
|
$pkg_xml_prefix = "/usr/local/pkg/";
|
79 |
|
|
$pkg_full_path = "{$pkg_xml_prefix}/{$xml}";
|
80 |
|
|
if (substr_compare(realpath($pkg_full_path), $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) {
|
81 |
|
|
print_info_box_np(gettext("ERROR: Invalid path specified."));
|
82 |
|
|
die;
|
83 |
|
|
}
|
84 |
|
|
if (file_exists($pkg_full_path)) {
|
85 |
|
|
$pkg = parse_xml_config_pkg($pkg_full_path, "packagegui");
|
86 |
f8ac4407
|
Phil Davis
|
} else {
|
87 |
f5dbca0d
|
Stephen Beaver
|
include("head.inc");
|
88 |
|
|
print_info_box_np(gettext("File not found ") . htmlspecialchars($xml));
|
89 |
|
|
include("foot.inc");
|
90 |
98bcf1f8
|
Scott Ullrich
|
exit;
|
91 |
|
|
}
|
92 |
a7f908db
|
Scott Ullrich
|
}
|
93 |
|
|
|
94 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['donotsave'] != "") {
|
95 |
6f3d2063
|
Renato Botelho
|
header("Location: pkg_edit.php?xml=" . $xml);
|
96 |
b000f96f
|
Scott Ullrich
|
exit;
|
97 |
3eaeb703
|
Scott Ullrich
|
}
|
98 |
|
|
|
99 |
7c172009
|
Scott Ullrich
|
if ($pkg['include_file'] != "") {
|
100 |
|
|
require_once($pkg['include_file']);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
f8ac4407
|
Phil Davis
|
if ($_REQUEST['startdisplayingat']) {
|
104 |
32c477c5
|
Scott Ullrich
|
$startdisplayingat = $_REQUEST['startdisplayingat'];
|
105 |
f8ac4407
|
Phil Davis
|
}
|
106 |
32c477c5
|
Scott Ullrich
|
|
107 |
f8ac4407
|
Phil Davis
|
if ($_REQUEST['display_maximum_rows']) {
|
108 |
|
|
if ($_REQUEST['display_maximum_rows']) {
|
109 |
3ca50a15
|
Scott Ullrich
|
$display_maximum_rows = $_REQUEST['display_maximum_rows'];
|
110 |
f8ac4407
|
Phil Davis
|
}
|
111 |
|
|
}
|
112 |
3ca50a15
|
Scott Ullrich
|
|
113 |
ce696feb
|
Colin Smith
|
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
114 |
e3c4b6b7
|
Scott Ullrich
|
|
115 |
05a42cce
|
Marcello Coutinho
|
if ($_GET['act'] == "update") {
|
116 |
f8ac4407
|
Phil Davis
|
|
117 |
|
|
if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
|
118 |
|
|
#get current values
|
119 |
|
|
$current_values=$config['installedpackages'][$pkg['name']]['config'];
|
120 |
|
|
#get updated ids
|
121 |
|
|
parse_str($_REQUEST['ids'], $update_list);
|
122 |
|
|
#sort ids to know what to change
|
123 |
|
|
#useful to do not lose data when using sorting and paging
|
124 |
|
|
$sort_list=$update_list['ids'];
|
125 |
|
|
sort($sort_list);
|
126 |
|
|
#apply updates
|
127 |
|
|
foreach ($update_list['ids'] as $key=> $value) {
|
128 |
|
|
$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
|
129 |
|
|
}
|
130 |
|
|
#save current config
|
131 |
|
|
write_config();
|
132 |
|
|
#sync package
|
133 |
|
|
eval ("{$pkg['custom_php_resync_config_command']}");
|
134 |
|
|
}
|
135 |
|
|
#function called via jquery, no need to continue after save changes.
|
136 |
|
|
exit;
|
137 |
05a42cce
|
Marcello Coutinho
|
}
|
138 |
e3c4b6b7
|
Scott Ullrich
|
if ($_GET['act'] == "del") {
|
139 |
f8ac4407
|
Phil Davis
|
// loop through our fieldnames and automatically setup the fieldnames
|
140 |
f5dbca0d
|
Stephen Beaver
|
// in the environment. ie: a fieldname of username with a value of
|
141 |
f8ac4407
|
Phil Davis
|
// testuser would automatically eval $username = "testuser";
|
142 |
|
|
foreach ($evaledvar as $ip) {
|
143 |
|
|
if ($pkg['adddeleteeditpagefields']['columnitem']) {
|
144 |
|
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
145 |
|
|
${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
|
146 |
|
|
}
|
147 |
ef2029df
|
Scott Ullrich
|
}
|
148 |
f8ac4407
|
Phil Davis
|
}
|
149 |
e3c4b6b7
|
Scott Ullrich
|
|
150 |
f8ac4407
|
Phil Davis
|
$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
151 |
e3c4b6b7
|
Scott Ullrich
|
|
152 |
f8ac4407
|
Phil Davis
|
if ($a_pkg[$_GET['id']]) {
|
153 |
|
|
unset($a_pkg[$_GET['id']]);
|
154 |
|
|
write_config();
|
155 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['custom_delete_php_command'] != "") {
|
156 |
|
|
if ($pkg['custom_php_command_before_form'] != "") {
|
157 |
f8ac4407
|
Phil Davis
|
eval($pkg['custom_php_command_before_form']);
|
158 |
8060d89a
|
Scott Ullrich
|
}
|
159 |
f8ac4407
|
Phil Davis
|
eval($pkg['custom_delete_php_command']);
|
160 |
|
|
}
|
161 |
|
|
header("Location: pkg.php?xml=" . $xml);
|
162 |
|
|
exit;
|
163 |
|
|
}
|
164 |
e3c4b6b7
|
Scott Ullrich
|
}
|
165 |
|
|
|
166 |
4b5976b5
|
Scott Ullrich
|
ob_start();
|
167 |
|
|
|
168 |
d3ab36dc
|
Ermal Lu?i
|
$iflist = get_configured_interface_with_descr(false, true);
|
169 |
ce696feb
|
Colin Smith
|
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
170 |
a7f908db
|
Scott Ullrich
|
|
171 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['custom_php_global_functions'] != "") {
|
172 |
ef2029df
|
Scott Ullrich
|
eval($pkg['custom_php_global_functions']);
|
173 |
f8ac4407
|
Phil Davis
|
}
|
174 |
194b4e0a
|
Colin Smith
|
|
175 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['custom_php_command_before_form'] != "") {
|
176 |
194b4e0a
|
Colin Smith
|
eval($pkg['custom_php_command_before_form']);
|
177 |
f8ac4407
|
Phil Davis
|
}
|
178 |
f9a91638
|
Scott Ullrich
|
|
179 |
8cfdeb2e
|
BBcan177
|
// Breadcrumb
|
180 |
|
|
if ($pkg['title'] != "") {
|
181 |
3ad27058
|
heper
|
/*if (!$only_edit) { // Is any package still making use of this?? Is this something that is still wanted, considering the breadcrumb policy https://redmine.pfsense.org/issues/5527
|
182 |
|
|
$pkg['title'] = $pkg['title'] . '/Edit'; // If this needs to live on, then it has to be moved to run AFTER "foreach ($pkg['tabs']['tab'] as $tab)"-loop. This due to $pgtitle[] = $tab['text'];
|
183 |
|
|
}*/
|
184 |
8cfdeb2e
|
BBcan177
|
if (strpos($pkg['title'], '/')) {
|
185 |
|
|
$title = explode('/', $pkg['title']);
|
186 |
|
|
|
187 |
|
|
foreach ($title as $subtitle) {
|
188 |
|
|
$pgtitle[] = gettext($subtitle);
|
189 |
|
|
}
|
190 |
|
|
} else {
|
191 |
|
|
$pgtitle = array(gettext("Package"), gettext($pkg['title']));
|
192 |
|
|
}
|
193 |
|
|
} else {
|
194 |
|
|
$pgtitle = array(gettext("Package"), gettext("Editor"));
|
195 |
|
|
}
|
196 |
|
|
|
197 |
3ad27058
|
heper
|
if ($pkg['tabs'] != "") {
|
198 |
|
|
$tab_array = array();
|
199 |
|
|
foreach ($pkg['tabs']['tab'] as $tab) {
|
200 |
|
|
if ($tab['tab_level']) {
|
201 |
|
|
$tab_level = $tab['tab_level'];
|
202 |
|
|
} else {
|
203 |
|
|
$tab_level = 1;
|
204 |
|
|
}
|
205 |
|
|
if (isset($tab['active'])) {
|
206 |
|
|
$active = true;
|
207 |
|
|
$pgtitle[] = $tab['text'];
|
208 |
|
|
} else {
|
209 |
|
|
$active = false;
|
210 |
|
|
}
|
211 |
|
|
if (isset($tab['no_drop_down'])) {
|
212 |
|
|
$no_drop_down = true;
|
213 |
|
|
}
|
214 |
|
|
$urltmp = "";
|
215 |
|
|
if ($tab['url'] != "") {
|
216 |
|
|
$urltmp = $tab['url'];
|
217 |
|
|
}
|
218 |
|
|
if ($tab['xml'] != "") {
|
219 |
|
|
$urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
$addresswithport = getenv("HTTP_HOST");
|
223 |
|
|
$colonpos = strpos($addresswithport, ":");
|
224 |
|
|
if ($colonpos !== False) {
|
225 |
|
|
//my url is actually just the IP address of the pfsense box
|
226 |
|
|
$myurl = substr($addresswithport, 0, $colonpos);
|
227 |
|
|
} else {
|
228 |
|
|
$myurl = $addresswithport;
|
229 |
|
|
}
|
230 |
|
|
// eval url so that above $myurl item can be processed if need be.
|
231 |
|
|
$url = str_replace('$myurl', $myurl, $urltmp);
|
232 |
|
|
|
233 |
|
|
$tab_array[$tab_level][] = array(
|
234 |
|
|
$tab['text'],
|
235 |
|
|
$active,
|
236 |
|
|
$url
|
237 |
|
|
);
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
ksort($tab_array);
|
241 |
|
|
}
|
242 |
|
|
|
243 |
83ddedcd
|
Scott Ullrich
|
include("head.inc");
|
244 |
3ad27058
|
heper
|
if (isset($tab_array)) {
|
245 |
|
|
foreach ($tab_array as $tabid => $tab) {
|
246 |
|
|
display_top_tabs($tab); //, $no_drop_down, $tabid);
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
83ddedcd
|
Scott Ullrich
|
|
250 |
a7f908db
|
Scott Ullrich
|
?>
|
251 |
|
|
|
252 |
44507df4
|
Colin Fleming
|
<script type="text/javascript">
|
253 |
|
|
//<![CDATA[
|
254 |
0f649c97
|
Phil Davis
|
events.push(function() {
|
255 |
2ef13b6c
|
Stephen Beaver
|
|
256 |
44507df4
|
Colin Fleming
|
function setFilter(filtertext) {
|
257 |
|
|
jQuery('#pkg_filter').val(filtertext);
|
258 |
|
|
document.pkgform.submit();
|
259 |
f8ac4407
|
Phil Davis
|
}
|
260 |
44507df4
|
Colin Fleming
|
|
261 |
2ef13b6c
|
Stephen Beaver
|
<?php
|
262 |
|
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
263 |
|
|
?>
|
264 |
|
|
$('#mainarea table tbody').sortable({
|
265 |
|
|
items: 'tr.sortable',
|
266 |
|
|
cursor: 'move',
|
267 |
|
|
distance: 10,
|
268 |
|
|
opacity: 0.8,
|
269 |
|
|
helper: function(e, ui) {
|
270 |
|
|
ui.children().each(function() {
|
271 |
|
|
jQuery(this).width(jQuery(this).width());
|
272 |
44507df4
|
Colin Fleming
|
});
|
273 |
2ef13b6c
|
Stephen Beaver
|
return ui;
|
274 |
|
|
},
|
275 |
|
|
});
|
276 |
|
|
<?php
|
277 |
|
|
}
|
278 |
|
|
?>
|
279 |
|
|
});
|
280 |
b51d272c
|
Stephen Beaver
|
|
281 |
15281e44
|
Stephen Beaver
|
function save_changes_to_xml(xml) {
|
282 |
|
|
var ids = $('#mainarea table tbody').sortable('serialize', {key:"ids[]"});
|
283 |
|
|
var strloading="<?=gettext('Saving changes...')?>";
|
284 |
|
|
if (confirm("<?=gettext("Do you really want to save changes?")?>")) {
|
285 |
|
|
$.ajax({
|
286 |
|
|
type: 'get',
|
287 |
|
|
cache: false,
|
288 |
|
|
url: "<?=$_SERVER['SCRIPT_NAME']?>",
|
289 |
|
|
data: {xml:'<?=$xml?>', act:'update', ids: ids},
|
290 |
|
|
beforeSend: function() {
|
291 |
|
|
$('#savemsg').empty().html(strloading);
|
292 |
|
|
},
|
293 |
|
|
error: function(data) {
|
294 |
|
|
$('#savemsg').empty().html('Error:' + data);
|
295 |
|
|
},
|
296 |
|
|
success: function(data) {
|
297 |
|
|
$('#savemsg').empty().html(data);
|
298 |
|
|
}
|
299 |
|
|
});
|
300 |
2ef13b6c
|
Stephen Beaver
|
}
|
301 |
|
|
}
|
302 |
|
|
|
303 |
44507df4
|
Colin Fleming
|
//]]>
|
304 |
|
|
</script>
|
305 |
f5dbca0d
|
Stephen Beaver
|
|
306 |
|
|
<?php
|
307 |
0f649c97
|
Phil Davis
|
if ($_GET['savemsg'] != "") {
|
308 |
f5dbca0d
|
Stephen Beaver
|
$savemsg = htmlspecialchars($_GET['savemsg']);
|
309 |
0f649c97
|
Phil Davis
|
}
|
310 |
f5dbca0d
|
Stephen Beaver
|
|
311 |
0f649c97
|
Phil Davis
|
if ($savemsg) {
|
312 |
f5dbca0d
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
313 |
0f649c97
|
Phil Davis
|
}
|
314 |
f5dbca0d
|
Stephen Beaver
|
?>
|
315 |
|
|
|
316 |
5aa9a4f2
|
Scott Ullrich
|
<form action="pkg.php" name="pkgform" method="get">
|
317 |
f5dbca0d
|
Stephen Beaver
|
<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
|
318 |
c24bb3fc
|
Stephen Beaver
|
<div id="mainarea" class="panel panel-default">
|
319 |
b51d272c
|
Stephen Beaver
|
<table id="mainarea" class="table table-striped table-hover table-condensed">
|
320 |
c24bb3fc
|
Stephen Beaver
|
<thead>
|
321 |
32c477c5
|
Scott Ullrich
|
<?php
|
322 |
f8ac4407
|
Phil Davis
|
/* Handle filtering bar A-Z */
|
323 |
|
|
$include_filtering_inputbox = false;
|
324 |
|
|
$colspan = 0;
|
325 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
326 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
327 |
|
|
$colspan++;
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
if ($pkg['fields']['field']) {
|
331 |
|
|
// First find the sorting type field if it exists
|
332 |
|
|
foreach ($pkg['fields']['field'] as $field) {
|
333 |
|
|
if ($field['type'] == "sorting") {
|
334 |
|
|
if (isset($field['include_filtering_inputbox'])) {
|
335 |
|
|
$include_filtering_inputbox = true;
|
336 |
|
|
}
|
337 |
|
|
if ($display_maximum_rows < 1) {
|
338 |
|
|
if ($field['display_maximum_rows']) {
|
339 |
|
|
$display_maximum_rows = $field['display_maximum_rows'];
|
340 |
|
|
}
|
341 |
|
|
}
|
342 |
f5dbca0d
|
Stephen Beaver
|
echo "<tr><td colspan='$colspan' align='center'>";
|
343 |
f8ac4407
|
Phil Davis
|
echo "Filter by: ";
|
344 |
|
|
$isfirst = true;
|
345 |
|
|
for ($char = 65; $char < 91; $char++) {
|
346 |
|
|
if (!$isfirst) {
|
347 |
|
|
echo " | ";
|
348 |
|
|
}
|
349 |
|
|
echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
|
350 |
|
|
$isfirst = false;
|
351 |
|
|
}
|
352 |
|
|
echo "</td></tr>";
|
353 |
f5dbca0d
|
Stephen Beaver
|
echo "<tr><td colspan='$colspan' align='center'>";
|
354 |
f8ac4407
|
Phil Davis
|
if ($field['sortablefields']) {
|
355 |
|
|
echo "Filter field: <select name='pkg_filter_type'>";
|
356 |
|
|
foreach ($field['sortablefields']['item'] as $si) {
|
357 |
|
|
if ($si['name'] == $_REQUEST['pkg_filter_type']) {
|
358 |
c4b60a9a
|
Colin Fleming
|
$SELECTED = "selected";
|
359 |
f8ac4407
|
Phil Davis
|
} else {
|
360 |
|
|
$SELECTED = "";
|
361 |
32c477c5
|
Scott Ullrich
|
}
|
362 |
f8ac4407
|
Phil Davis
|
echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
|
363 |
32c477c5
|
Scott Ullrich
|
}
|
364 |
f8ac4407
|
Phil Davis
|
echo "</select>";
|
365 |
32c477c5
|
Scott Ullrich
|
}
|
366 |
f8ac4407
|
Phil Davis
|
if ($include_filtering_inputbox) {
|
367 |
f5dbca0d
|
Stephen Beaver
|
echo " Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /><input type='submit' value='Filter' />";
|
368 |
f8ac4407
|
Phil Davis
|
}
|
369 |
|
|
echo "</td></tr><tr><td><font size='-3'> </font></td></tr>";
|
370 |
|
|
}
|
371 |
|
|
}
|
372 |
|
|
}
|
373 |
32c477c5
|
Scott Ullrich
|
?>
|
374 |
|
|
<tr>
|
375 |
c24bb3fc
|
Stephen Beaver
|
|
376 |
32c477c5
|
Scott Ullrich
|
<?php
|
377 |
f8ac4407
|
Phil Davis
|
if ($display_maximum_rows) {
|
378 |
6c07db48
|
Phil Davis
|
$totalpages = ceil(round((count($evaledvar) / $display_maximum_rows), 9));
|
379 |
f8ac4407
|
Phil Davis
|
$page = 1;
|
380 |
|
|
$tmpcount = 0;
|
381 |
|
|
$tmppp = 0;
|
382 |
|
|
if (is_array($evaledvar)) {
|
383 |
|
|
foreach ($evaledvar as $ipa) {
|
384 |
|
|
if ($tmpcount == $display_maximum_rows) {
|
385 |
|
|
$page++;
|
386 |
37da0c50
|
Scott Ullrich
|
$tmpcount = 0;
|
387 |
|
|
}
|
388 |
f8ac4407
|
Phil Davis
|
if ($tmppp == $startdisplayingat) {
|
389 |
|
|
break;
|
390 |
32c477c5
|
Scott Ullrich
|
}
|
391 |
f8ac4407
|
Phil Davis
|
$tmpcount++;
|
392 |
|
|
$tmppp++;
|
393 |
|
|
}
|
394 |
|
|
}
|
395 |
c24bb3fc
|
Stephen Beaver
|
echo "<tr><th colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
|
396 |
f8ac4407
|
Phil Davis
|
echo "<table width='100%' summary=''>";
|
397 |
|
|
echo "<tr>";
|
398 |
|
|
echo "<td align='left'>Displaying page $page of $totalpages</b></td>";
|
399 |
|
|
echo "<td align='right'>Rows per page: <select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
|
400 |
6c07db48
|
Phil Davis
|
for ($x = 0; $x < 250; $x++) {
|
401 |
f8ac4407
|
Phil Davis
|
if ($x == $display_maximum_rows) {
|
402 |
c4b60a9a
|
Colin Fleming
|
$SELECTED = "selected";
|
403 |
f8ac4407
|
Phil Davis
|
} else {
|
404 |
|
|
$SELECTED = "";
|
405 |
|
|
}
|
406 |
|
|
echo "<option value='$x' $SELECTED>$x</option>\n";
|
407 |
|
|
$x = $x + 4;
|
408 |
|
|
}
|
409 |
|
|
echo "</select></td></tr>";
|
410 |
|
|
echo "</table>";
|
411 |
c24bb3fc
|
Stephen Beaver
|
echo "</th></tr>";
|
412 |
f8ac4407
|
Phil Davis
|
}
|
413 |
2ef13b6c
|
Stephen Beaver
|
|
414 |
f8ac4407
|
Phil Davis
|
$cols = 0;
|
415 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
416 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
417 |
c24bb3fc
|
Stephen Beaver
|
echo "<th class=\"listhdrr\">" . $column['fielddescr'] . "</th>";
|
418 |
f8ac4407
|
Phil Davis
|
$cols++;
|
419 |
|
|
}
|
420 |
|
|
}
|
421 |
|
|
?>
|
422 |
|
|
</tr>
|
423 |
c24bb3fc
|
Stephen Beaver
|
</thead>
|
424 |
|
|
<tbody>
|
425 |
f8ac4407
|
Phil Davis
|
<?php
|
426 |
|
|
$i = 0;
|
427 |
6c07db48
|
Phil Davis
|
$pagination_counter = 0;
|
428 |
f8ac4407
|
Phil Davis
|
if ($evaledvar) {
|
429 |
|
|
foreach ($evaledvar as $ip) {
|
430 |
|
|
if ($startdisplayingat) {
|
431 |
|
|
if ($i < $startdisplayingat) {
|
432 |
|
|
$i++;
|
433 |
|
|
continue;
|
434 |
32c477c5
|
Scott Ullrich
|
}
|
435 |
f8ac4407
|
Phil Davis
|
}
|
436 |
|
|
if ($_REQUEST['pkg_filter']) {
|
437 |
|
|
// Handle filtered items
|
438 |
|
|
if ($pkg['fields']['field'] && !$filter_regex) {
|
439 |
|
|
// First find the sorting type field if it exists
|
440 |
|
|
foreach ($pkg['fields']['field'] as $field) {
|
441 |
|
|
if ($field['type'] == "sorting") {
|
442 |
|
|
if ($field['sortablefields']['item']) {
|
443 |
|
|
foreach ($field['sortablefields']['item'] as $sf) {
|
444 |
|
|
if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
|
445 |
|
|
$filter_fieldname = $sf['fieldname'];
|
446 |
|
|
#Use a default regex on sortable fields when none is declared
|
447 |
|
|
if ($sf['regex']) {
|
448 |
|
|
$filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
|
449 |
|
|
} else {
|
450 |
|
|
$filter_regex = "/{$_REQUEST['pkg_filter']}/i";
|
451 |
32c477c5
|
Scott Ullrich
|
}
|
452 |
|
|
}
|
453 |
|
|
}
|
454 |
|
|
}
|
455 |
|
|
}
|
456 |
|
|
}
|
457 |
f8ac4407
|
Phil Davis
|
}
|
458 |
|
|
// Do we have something to filter on?
|
459 |
|
|
unset($filter_matches);
|
460 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
461 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
462 |
|
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
463 |
|
|
if ($column['fieldname'] == $filter_fieldname) {
|
464 |
|
|
if ($filter_regex) {
|
465 |
|
|
//echo "$filter_regex - $fieldname<p/>";
|
466 |
|
|
preg_match($filter_regex, $fieldname, $filter_matches);
|
467 |
|
|
break;
|
468 |
32c477c5
|
Scott Ullrich
|
}
|
469 |
|
|
}
|
470 |
|
|
}
|
471 |
|
|
}
|
472 |
f8ac4407
|
Phil Davis
|
if (!$filter_matches) {
|
473 |
|
|
$i++;
|
474 |
|
|
continue;
|
475 |
|
|
}
|
476 |
|
|
}
|
477 |
|
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
478 |
|
|
echo "<tr valign=\"top\" class=\"sortable\" id=\"id_{$i}\">\n";
|
479 |
|
|
} else {
|
480 |
|
|
echo "<tr valign=\"top\">\n";
|
481 |
|
|
}
|
482 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
483 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
484 |
|
|
if ($column['fieldname'] == "description") {
|
485 |
|
|
$class = "listbg";
|
486 |
|
|
} else {
|
487 |
|
|
$class = "listlr";
|
488 |
|
|
}
|
489 |
32c477c5
|
Scott Ullrich
|
?>
|
490 |
f5dbca0d
|
Stephen Beaver
|
<td class="<?=$class?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>';">
|
491 |
32c477c5
|
Scott Ullrich
|
<?php
|
492 |
f8ac4407
|
Phil Davis
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
493 |
|
|
#Check if columnitem has a type field declared
|
494 |
|
|
if ($column['type'] == "checkbox") {
|
495 |
|
|
if ($fieldname == "") {
|
496 |
|
|
echo gettext("No");
|
497 |
|
|
} else {
|
498 |
|
|
echo gettext("Yes");
|
499 |
|
|
}
|
500 |
|
|
} else if ($column['type'] == "interface") {
|
501 |
6c07db48
|
Phil Davis
|
echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
|
502 |
f8ac4407
|
Phil Davis
|
} else {
|
503 |
|
|
#Check if columnitem has an encoding field declared
|
504 |
|
|
if ($column['encoding'] == "base64") {
|
505 |
6c07db48
|
Phil Davis
|
echo $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
|
506 |
f8ac4407
|
Phil Davis
|
#Check if there is a custom info to show when $fieldname is not empty
|
507 |
|
|
} else if ($column['listmodeon'] && $fieldname != "") {
|
508 |
|
|
echo $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
|
509 |
|
|
#Check if there is a custom info to show when $fieldname is empty
|
510 |
|
|
} else if ($column['listmodeoff'] && $fieldname == "") {
|
511 |
|
|
echo $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
|
512 |
|
|
} else {
|
513 |
|
|
echo $column['prefix'] . $fieldname ." ". $column['suffix'];
|
514 |
|
|
}
|
515 |
32c477c5
|
Scott Ullrich
|
}
|
516 |
|
|
?>
|
517 |
f8ac4407
|
Phil Davis
|
</td>
|
518 |
32c477c5
|
Scott Ullrich
|
<?php
|
519 |
f8ac4407
|
Phil Davis
|
} // foreach columnitem
|
520 |
|
|
} // if columnitem
|
521 |
|
|
?>
|
522 |
b77cef66
|
Colin Fleming
|
<td valign="middle" class="list text-nowrap">
|
523 |
f8ac4407
|
Phil Davis
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
524 |
|
|
<tr>
|
525 |
|
|
<?php
|
526 |
|
|
#Show custom description to edit button if defined
|
527 |
|
|
$edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:"Edit this item");
|
528 |
|
|
?>
|
529 |
1dfa60c5
|
Stephen Beaver
|
<td><a class="fa fa-pencil" href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>" title="<?=$edit_msg?>"></a></td>
|
530 |
f8ac4407
|
Phil Davis
|
<?php
|
531 |
|
|
#Show custom description to delete button if defined
|
532 |
|
|
$delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:"Delete this item");
|
533 |
|
|
?>
|
534 |
1dfa60c5
|
Stephen Beaver
|
<td> <a class="fa fa-trash" href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i?>" title="<?=gettext("Delete")?>"></a></td>
|
535 |
f8ac4407
|
Phil Davis
|
</tr>
|
536 |
c24bb3fc
|
Stephen Beaver
|
</tbody>
|
537 |
|
|
</table>
|
538 |
b51d272c
|
Stephen Beaver
|
</td>
|
539 |
f8ac4407
|
Phil Davis
|
<?php
|
540 |
f5dbca0d
|
Stephen Beaver
|
echo "</tr>\n"; // Pairs with an echo tr some way above
|
541 |
f8ac4407
|
Phil Davis
|
// Handle pagination and display_maximum_rows
|
542 |
|
|
if ($display_maximum_rows) {
|
543 |
|
|
if ($pagination_counter == ($display_maximum_rows-1) or
|
544 |
f5dbca0d
|
Stephen Beaver
|
$i == (count($evaledvar)-1)) {
|
545 |
f8ac4407
|
Phil Davis
|
$colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
|
546 |
|
|
$final_footer = "";
|
547 |
|
|
$final_footer .= "<tr><td colspan='$colcount'>";
|
548 |
6c07db48
|
Phil Davis
|
$final_footer .= "<table width='100%' summary=''><tr>";
|
549 |
|
|
$final_footer .= "<td align='left'>";
|
550 |
f8ac4407
|
Phil Davis
|
$startingat = $startdisplayingat - $display_maximum_rows;
|
551 |
|
|
if ($startingat > -1) {
|
552 |
6c07db48
|
Phil Davis
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat={$startingat}&display_maximum_rows={$display_maximum_rows}'>";
|
553 |
f8ac4407
|
Phil Davis
|
} else if ($startdisplayingat > 1) {
|
554 |
6c07db48
|
Phil Davis
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=0&display_maximum_rows={$display_maximum_rows}'>";
|
555 |
32c477c5
|
Scott Ullrich
|
}
|
556 |
6c07db48
|
Phil Davis
|
$final_footer .= "<font size='2'><< Previous page</font></a>";
|
557 |
f8ac4407
|
Phil Davis
|
if ($tmppp + $display_maximum_rows > count($evaledvar)) {
|
558 |
|
|
$endingrecord = count($evaledvar);
|
559 |
|
|
} else {
|
560 |
|
|
$endingrecord = $tmppp + $display_maximum_rows;
|
561 |
|
|
}
|
562 |
6c07db48
|
Phil Davis
|
$final_footer .= "</td><td align='center'>";
|
563 |
f8ac4407
|
Phil Davis
|
$tmppp++;
|
564 |
6c07db48
|
Phil Davis
|
$final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
|
565 |
|
|
$final_footer .= "</font></td><td align='right'> ";
|
566 |
f8ac4407
|
Phil Davis
|
if (($i+1) < count($evaledvar)) {
|
567 |
6c07db48
|
Phil Davis
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&display_maximum_rows={$display_maximum_rows}'>";
|
568 |
f8ac4407
|
Phil Davis
|
}
|
569 |
6c07db48
|
Phil Davis
|
$final_footer .= "<font size='2'>Next page >></font></a>";
|
570 |
|
|
$final_footer .= "</td></tr></table></td></tr>";
|
571 |
f8ac4407
|
Phil Davis
|
$i = count($evaledvar);
|
572 |
|
|
break;
|
573 |
549912e3
|
Scott Ullrich
|
}
|
574 |
f8ac4407
|
Phil Davis
|
}
|
575 |
|
|
$i++;
|
576 |
|
|
$pagination_counter++;
|
577 |
|
|
} // foreach evaledvar
|
578 |
|
|
} // if evaledvar
|
579 |
32c477c5
|
Scott Ullrich
|
?>
|
580 |
|
|
<tr>
|
581 |
|
|
<td colspan="<?=$cols?>"></td>
|
582 |
|
|
<td>
|
583 |
44507df4
|
Colin Fleming
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
584 |
32c477c5
|
Scott Ullrich
|
<tr>
|
585 |
f8ac4407
|
Phil Davis
|
<?php
|
586 |
|
|
#Show custom description to add button if defined
|
587 |
|
|
$add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:"Add a new item");
|
588 |
|
|
?>
|
589 |
c405d4f0
|
Stephen Beaver
|
<td><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>" class="btn btn-sm btn-success" title="<?=$add_msg?>"><?=gettext('Add')?></a></td>
|
590 |
f8ac4407
|
Phil Davis
|
<?php
|
591 |
|
|
#Show description button and info if defined
|
592 |
|
|
if ($pkg['adddeleteeditpagefields']['description']) {
|
593 |
|
|
?>
|
594 |
995df6c3
|
Stephen Beaver
|
<td>
|
595 |
7ea65674
|
Jared Dillard
|
<i class="fa fa-info-circle"><?=$pkg['adddeleteeditpagefields']['description']?></i>
|
596 |
995df6c3
|
Stephen Beaver
|
</td>
|
597 |
f8ac4407
|
Phil Davis
|
<?php
|
598 |
|
|
}
|
599 |
|
|
?>
|
600 |
32c477c5
|
Scott Ullrich
|
</tr>
|
601 |
|
|
</table>
|
602 |
|
|
</td>
|
603 |
|
|
</tr>
|
604 |
37da0c50
|
Scott Ullrich
|
<?=$final_footer?>
|
605 |
f8ac4407
|
Phil Davis
|
<?php
|
606 |
|
|
#Show save button only when movable is defined
|
607 |
|
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
608 |
|
|
?>
|
609 |
c24bb3fc
|
Stephen Beaver
|
|
610 |
|
|
|
611 |
|
|
|
612 |
f8ac4407
|
Phil Davis
|
<?php
|
613 |
|
|
}
|
614 |
|
|
?>
|
615 |
|
|
</table>
|
616 |
c24bb3fc
|
Stephen Beaver
|
</div>
|
617 |
|
|
<input class="btn btn-primary" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')" />
|
618 |
3d335c4d
|
Scott Ullrich
|
|
619 |
a7f908db
|
Scott Ullrich
|
</form>
|
620 |
b000f96f
|
Scott Ullrich
|
<?php
|
621 |
f5dbca0d
|
Stephen Beaver
|
echo "<!-- filter_fieldname: {$filter_fieldname} -->";
|
622 |
|
|
echo "<!-- filter_regex: {$filter_regex} -->";
|
623 |
b000f96f
|
Scott Ullrich
|
|
624 |
f5dbca0d
|
Stephen Beaver
|
include("foot.inc"); ?>
|