1 |
a7f908db
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* pkg.php
|
4 |
|
|
*
|
5 |
|
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
a68f7a3d
|
Luiz Otavio O Souza
|
* Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
|
|
*
|
11 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12 |
|
|
* you may not use this file except in compliance with the License.
|
13 |
|
|
* You may obtain a copy of the License at
|
14 |
c5d81585
|
Renato Botelho
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16 |
c5d81585
|
Renato Botelho
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
18 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20 |
|
|
* See the License for the specific language governing permissions and
|
21 |
|
|
* limitations under the License.
|
22 |
f5dbca0d
|
Stephen Beaver
|
*/
|
23 |
a7f908db
|
Scott Ullrich
|
|
24 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
25 |
|
|
##|*IDENT=page-package-settings
|
26 |
5230f468
|
jim-p
|
##|*NAME=Package: Settings
|
27 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Package: Settings' page.
|
28 |
|
|
##|*MATCH=pkg.php*
|
29 |
|
|
##|-PRIV
|
30 |
|
|
|
31 |
e4bf1c19
|
Colin Smith
|
require_once("guiconfig.inc");
|
32 |
|
|
require_once("pkg-utils.inc");
|
33 |
a7f908db
|
Scott Ullrich
|
|
34 |
2c2fed92
|
Stephen Beaver
|
function domTT_title($title_msg) {
|
35 |
|
|
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');\"";
|
36 |
|
|
}
|
37 |
|
|
|
38 |
98bcf1f8
|
Scott Ullrich
|
$xml = $_REQUEST['xml'];
|
39 |
a7f908db
|
Scott Ullrich
|
|
40 |
f8ac4407
|
Phil Davis
|
if ($xml == "") {
|
41 |
84320769
|
k-paulius
|
$pgtitle = array(gettext("Package"), gettext("Editor"));
|
42 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "@self");
|
43 |
f5dbca0d
|
Stephen Beaver
|
include("head.inc");
|
44 |
8545adde
|
k-paulius
|
print_info_box(gettext("No valid package defined."), 'danger', false);
|
45 |
f5dbca0d
|
Stephen Beaver
|
include("foot.inc");
|
46 |
b000f96f
|
Scott Ullrich
|
exit;
|
47 |
a7f908db
|
Scott Ullrich
|
} else {
|
48 |
44bcf766
|
jim-p
|
$pkg_xml_prefix = "/usr/local/pkg/";
|
49 |
|
|
$pkg_full_path = "{$pkg_xml_prefix}/{$xml}";
|
50 |
74817ee2
|
Phil Davis
|
$pkg_realpath = realpath($pkg_full_path);
|
51 |
|
|
if (empty($pkg_realpath)) {
|
52 |
8545adde
|
k-paulius
|
$path_error = sprintf(gettext("Package path %s not found."), htmlspecialchars($pkg_full_path));
|
53 |
ae2915a4
|
Phil Davis
|
} else if (substr_compare($pkg_realpath, $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) {
|
54 |
8545adde
|
k-paulius
|
$path_error = sprintf(gettext("Invalid path %s specified."), htmlspecialchars($pkg_full_path));
|
55 |
74817ee2
|
Phil Davis
|
}
|
56 |
|
|
|
57 |
|
|
if (!empty($path_error)) {
|
58 |
|
|
include("head.inc");
|
59 |
8545adde
|
k-paulius
|
print_info_box($path_error . "<br />" . gettext("Try reinstalling the package."), 'danger', false);
|
60 |
74817ee2
|
Phil Davis
|
include("foot.inc");
|
61 |
44bcf766
|
jim-p
|
die;
|
62 |
|
|
}
|
63 |
74817ee2
|
Phil Davis
|
|
64 |
44bcf766
|
jim-p
|
if (file_exists($pkg_full_path)) {
|
65 |
|
|
$pkg = parse_xml_config_pkg($pkg_full_path, "packagegui");
|
66 |
f8ac4407
|
Phil Davis
|
} else {
|
67 |
f5dbca0d
|
Stephen Beaver
|
include("head.inc");
|
68 |
8545adde
|
k-paulius
|
print_info_box(sprintf(gettext("File not found %s."), htmlspecialchars($xml)), 'danger', false);
|
69 |
f5dbca0d
|
Stephen Beaver
|
include("foot.inc");
|
70 |
98bcf1f8
|
Scott Ullrich
|
exit;
|
71 |
|
|
}
|
72 |
a7f908db
|
Scott Ullrich
|
}
|
73 |
|
|
|
74 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['donotsave'] != "") {
|
75 |
6f3d2063
|
Renato Botelho
|
header("Location: pkg_edit.php?xml=" . $xml);
|
76 |
b000f96f
|
Scott Ullrich
|
exit;
|
77 |
3eaeb703
|
Scott Ullrich
|
}
|
78 |
|
|
|
79 |
7c172009
|
Scott Ullrich
|
if ($pkg['include_file'] != "") {
|
80 |
|
|
require_once($pkg['include_file']);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
f8ac4407
|
Phil Davis
|
if ($_REQUEST['startdisplayingat']) {
|
84 |
32c477c5
|
Scott Ullrich
|
$startdisplayingat = $_REQUEST['startdisplayingat'];
|
85 |
f8ac4407
|
Phil Davis
|
}
|
86 |
32c477c5
|
Scott Ullrich
|
|
87 |
f8ac4407
|
Phil Davis
|
if ($_REQUEST['display_maximum_rows']) {
|
88 |
|
|
if ($_REQUEST['display_maximum_rows']) {
|
89 |
3ca50a15
|
Scott Ullrich
|
$display_maximum_rows = $_REQUEST['display_maximum_rows'];
|
90 |
f8ac4407
|
Phil Davis
|
}
|
91 |
|
|
}
|
92 |
3ca50a15
|
Scott Ullrich
|
|
93 |
63d6bb4f
|
Marcos Mendoza
|
$pkg_config_path = sprintf('installedpackages/%s', xml_safe_fieldname($pkg['name']));
|
94 |
|
|
config_init_path("{$pkg_config_path}/config");
|
95 |
44b93616
|
Christian McDonald
|
|
96 |
63d6bb4f
|
Marcos Mendoza
|
$evaledvar = config_get_path("{$pkg_config_path}/config");
|
97 |
e3c4b6b7
|
Scott Ullrich
|
|
98 |
0de394c9
|
jim-p
|
if ($_POST['act'] == "update") {
|
99 |
f8ac4407
|
Phil Davis
|
|
100 |
63d6bb4f
|
Marcos Mendoza
|
if (is_array(config_get_path($pkg_config_path)) && $pkg['name'] != "" && $_POST['ids'] !="") {
|
101 |
0baf52bb
|
doktornotor
|
// get current values
|
102 |
63d6bb4f
|
Marcos Mendoza
|
$current_values = config_get_path("{$pkg_config_path}/config");
|
103 |
0baf52bb
|
doktornotor
|
// get updated ids
|
104 |
0de394c9
|
jim-p
|
parse_str($_POST['ids'], $update_list);
|
105 |
0baf52bb
|
doktornotor
|
// sort ids to know what to change
|
106 |
|
|
// useful to do not lose data when using sorting and paging
|
107 |
f8ac4407
|
Phil Davis
|
$sort_list=$update_list['ids'];
|
108 |
|
|
sort($sort_list);
|
109 |
0baf52bb
|
doktornotor
|
// apply updates
|
110 |
f8ac4407
|
Phil Davis
|
foreach ($update_list['ids'] as $key=> $value) {
|
111 |
63d6bb4f
|
Marcos Mendoza
|
config_set_path("{$pkg_config_path}/config/{$sort_list[$key]}", $current_values[$update_list['ids'][$key]]);
|
112 |
f8ac4407
|
Phil Davis
|
}
|
113 |
0baf52bb
|
doktornotor
|
// save current config
|
114 |
|
|
write_config(gettext("Package configuration changes saved from package settings page."));
|
115 |
|
|
// sync package
|
116 |
f8ac4407
|
Phil Davis
|
eval ("{$pkg['custom_php_resync_config_command']}");
|
117 |
|
|
}
|
118 |
0baf52bb
|
doktornotor
|
// function called via jquery, no need to continue after save changes.
|
119 |
f8ac4407
|
Phil Davis
|
exit;
|
120 |
05a42cce
|
Marcello Coutinho
|
}
|
121 |
8d58ebae
|
Steve Beaver
|
if ($_REQUEST['act'] == "del") {
|
122 |
f8ac4407
|
Phil Davis
|
// loop through our fieldnames and automatically setup the fieldnames
|
123 |
f5dbca0d
|
Stephen Beaver
|
// in the environment. ie: a fieldname of username with a value of
|
124 |
f8ac4407
|
Phil Davis
|
// testuser would automatically eval $username = "testuser";
|
125 |
|
|
foreach ($evaledvar as $ip) {
|
126 |
|
|
if ($pkg['adddeleteeditpagefields']['columnitem']) {
|
127 |
|
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
128 |
|
|
${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
|
129 |
|
|
}
|
130 |
ef2029df
|
Scott Ullrich
|
}
|
131 |
f8ac4407
|
Phil Davis
|
}
|
132 |
e3c4b6b7
|
Scott Ullrich
|
|
133 |
63d6bb4f
|
Marcos Mendoza
|
if (config_get_path("{$pkg_config_path}/config/{$_REQUEST['id']}")) {
|
134 |
|
|
config_del_path("{$pkg_config_path}/config/{$_REQUEST['id']}");
|
135 |
0baf52bb
|
doktornotor
|
write_config(gettext("Package configuration item deleted from package settings page."));
|
136 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['custom_delete_php_command'] != "") {
|
137 |
|
|
if ($pkg['custom_php_command_before_form'] != "") {
|
138 |
f8ac4407
|
Phil Davis
|
eval($pkg['custom_php_command_before_form']);
|
139 |
8060d89a
|
Scott Ullrich
|
}
|
140 |
f8ac4407
|
Phil Davis
|
eval($pkg['custom_delete_php_command']);
|
141 |
|
|
}
|
142 |
|
|
header("Location: pkg.php?xml=" . $xml);
|
143 |
|
|
exit;
|
144 |
|
|
}
|
145 |
e3c4b6b7
|
Scott Ullrich
|
}
|
146 |
|
|
|
147 |
4b5976b5
|
Scott Ullrich
|
ob_start();
|
148 |
|
|
|
149 |
f593f80b
|
Phil Davis
|
$iflist = get_configured_interface_with_descr(true);
|
150 |
63d6bb4f
|
Marcos Mendoza
|
$evaledvar = config_get_path("{$pkg_config_path}/config");
|
151 |
a7f908db
|
Scott Ullrich
|
|
152 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['custom_php_global_functions'] != "") {
|
153 |
ef2029df
|
Scott Ullrich
|
eval($pkg['custom_php_global_functions']);
|
154 |
f8ac4407
|
Phil Davis
|
}
|
155 |
194b4e0a
|
Colin Smith
|
|
156 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['custom_php_command_before_form'] != "") {
|
157 |
194b4e0a
|
Colin Smith
|
eval($pkg['custom_php_command_before_form']);
|
158 |
f8ac4407
|
Phil Davis
|
}
|
159 |
f9a91638
|
Scott Ullrich
|
|
160 |
8cfdeb2e
|
BBcan177
|
// Breadcrumb
|
161 |
|
|
if ($pkg['title'] != "") {
|
162 |
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
|
163 |
8d58ebae
|
Steve Beaver
|
$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'];
|
164 |
3ad27058
|
heper
|
}*/
|
165 |
8cfdeb2e
|
BBcan177
|
if (strpos($pkg['title'], '/')) {
|
166 |
|
|
$title = explode('/', $pkg['title']);
|
167 |
|
|
|
168 |
|
|
foreach ($title as $subtitle) {
|
169 |
|
|
$pgtitle[] = gettext($subtitle);
|
170 |
edcd7535
|
Phil Davis
|
$pglinks[] = "@self";
|
171 |
8cfdeb2e
|
BBcan177
|
}
|
172 |
|
|
} else {
|
173 |
|
|
$pgtitle = array(gettext("Package"), gettext($pkg['title']));
|
174 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "@self");
|
175 |
8cfdeb2e
|
BBcan177
|
}
|
176 |
|
|
} else {
|
177 |
|
|
$pgtitle = array(gettext("Package"), gettext("Editor"));
|
178 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "@self");
|
179 |
8cfdeb2e
|
BBcan177
|
}
|
180 |
|
|
|
181 |
3ad27058
|
heper
|
if ($pkg['tabs'] != "") {
|
182 |
|
|
$tab_array = array();
|
183 |
|
|
foreach ($pkg['tabs']['tab'] as $tab) {
|
184 |
|
|
if ($tab['tab_level']) {
|
185 |
|
|
$tab_level = $tab['tab_level'];
|
186 |
|
|
} else {
|
187 |
|
|
$tab_level = 1;
|
188 |
|
|
}
|
189 |
|
|
if (isset($tab['active'])) {
|
190 |
|
|
$active = true;
|
191 |
|
|
$pgtitle[] = $tab['text'];
|
192 |
edcd7535
|
Phil Davis
|
$pglinks[] = "@self";
|
193 |
3ad27058
|
heper
|
} else {
|
194 |
|
|
$active = false;
|
195 |
|
|
}
|
196 |
|
|
$urltmp = "";
|
197 |
|
|
if ($tab['url'] != "") {
|
198 |
|
|
$urltmp = $tab['url'];
|
199 |
|
|
}
|
200 |
|
|
if ($tab['xml'] != "") {
|
201 |
|
|
$urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
$addresswithport = getenv("HTTP_HOST");
|
205 |
|
|
$colonpos = strpos($addresswithport, ":");
|
206 |
|
|
if ($colonpos !== False) {
|
207 |
|
|
//my url is actually just the IP address of the pfsense box
|
208 |
|
|
$myurl = substr($addresswithport, 0, $colonpos);
|
209 |
|
|
} else {
|
210 |
|
|
$myurl = $addresswithport;
|
211 |
|
|
}
|
212 |
|
|
// eval url so that above $myurl item can be processed if need be.
|
213 |
|
|
$url = str_replace('$myurl', $myurl, $urltmp);
|
214 |
|
|
|
215 |
|
|
$tab_array[$tab_level][] = array(
|
216 |
|
|
$tab['text'],
|
217 |
|
|
$active,
|
218 |
|
|
$url
|
219 |
|
|
);
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
ksort($tab_array);
|
223 |
|
|
}
|
224 |
|
|
|
225 |
3abcd547
|
jim-p
|
if (!empty($pkg['tabs'])) {
|
226 |
|
|
$shortcut_section = $pkg['shortcut_section'];
|
227 |
|
|
}
|
228 |
|
|
|
229 |
83ddedcd
|
Scott Ullrich
|
include("head.inc");
|
230 |
3ad27058
|
heper
|
if (isset($tab_array)) {
|
231 |
d35a18fc
|
Christian McDonald
|
foreach ($tab_array as $tab) {
|
232 |
cbbb8fdb
|
doktornotor
|
display_top_tabs($tab);
|
233 |
3ad27058
|
heper
|
}
|
234 |
|
|
}
|
235 |
83ddedcd
|
Scott Ullrich
|
|
236 |
a7f908db
|
Scott Ullrich
|
?>
|
237 |
|
|
|
238 |
44507df4
|
Colin Fleming
|
<script type="text/javascript">
|
239 |
|
|
//<![CDATA[
|
240 |
0f649c97
|
Phil Davis
|
events.push(function() {
|
241 |
2ef13b6c
|
Stephen Beaver
|
|
242 |
44507df4
|
Colin Fleming
|
function setFilter(filtertext) {
|
243 |
3f98044a
|
Francisco Cavalcante
|
$('#pkg_filter').val(filtertext);
|
244 |
44507df4
|
Colin Fleming
|
document.pkgform.submit();
|
245 |
f8ac4407
|
Phil Davis
|
}
|
246 |
44507df4
|
Colin Fleming
|
|
247 |
2ef13b6c
|
Stephen Beaver
|
<?php
|
248 |
|
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
249 |
|
|
?>
|
250 |
|
|
$('#mainarea table tbody').sortable({
|
251 |
|
|
items: 'tr.sortable',
|
252 |
|
|
cursor: 'move',
|
253 |
|
|
distance: 10,
|
254 |
|
|
opacity: 0.8,
|
255 |
|
|
helper: function(e, ui) {
|
256 |
|
|
ui.children().each(function() {
|
257 |
3f98044a
|
Francisco Cavalcante
|
$(this).width($(this).width());
|
258 |
44507df4
|
Colin Fleming
|
});
|
259 |
2ef13b6c
|
Stephen Beaver
|
return ui;
|
260 |
|
|
},
|
261 |
|
|
});
|
262 |
|
|
<?php
|
263 |
|
|
}
|
264 |
|
|
?>
|
265 |
|
|
});
|
266 |
b51d272c
|
Stephen Beaver
|
|
267 |
15281e44
|
Stephen Beaver
|
function save_changes_to_xml(xml) {
|
268 |
|
|
var ids = $('#mainarea table tbody').sortable('serialize', {key:"ids[]"});
|
269 |
|
|
var strloading="<?=gettext('Saving changes...')?>";
|
270 |
34ee6639
|
NOYB
|
if (confirm("<?=gettext("Confirmation Required to save changes.")?>")) {
|
271 |
15281e44
|
Stephen Beaver
|
$.ajax({
|
272 |
0de394c9
|
jim-p
|
type: 'post',
|
273 |
15281e44
|
Stephen Beaver
|
cache: false,
|
274 |
|
|
url: "<?=$_SERVER['SCRIPT_NAME']?>",
|
275 |
|
|
data: {xml:'<?=$xml?>', act:'update', ids: ids},
|
276 |
|
|
beforeSend: function() {
|
277 |
|
|
$('#savemsg').empty().html(strloading);
|
278 |
|
|
},
|
279 |
|
|
error: function(data) {
|
280 |
|
|
$('#savemsg').empty().html('Error:' + data);
|
281 |
|
|
},
|
282 |
|
|
success: function(data) {
|
283 |
|
|
$('#savemsg').empty().html(data);
|
284 |
|
|
}
|
285 |
|
|
});
|
286 |
2ef13b6c
|
Stephen Beaver
|
}
|
287 |
|
|
}
|
288 |
|
|
|
289 |
44507df4
|
Colin Fleming
|
//]]>
|
290 |
|
|
</script>
|
291 |
f5dbca0d
|
Stephen Beaver
|
|
292 |
|
|
<?php
|
293 |
8d58ebae
|
Steve Beaver
|
if ($_REQUEST['savemsg'] != "") {
|
294 |
|
|
$savemsg = htmlspecialchars($_REQUEST['savemsg']);
|
295 |
0f649c97
|
Phil Davis
|
}
|
296 |
f5dbca0d
|
Stephen Beaver
|
|
297 |
0f649c97
|
Phil Davis
|
if ($savemsg) {
|
298 |
f5dbca0d
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
299 |
0f649c97
|
Phil Davis
|
}
|
300 |
f5dbca0d
|
Stephen Beaver
|
?>
|
301 |
|
|
|
302 |
5aa9a4f2
|
Scott Ullrich
|
<form action="pkg.php" name="pkgform" method="get">
|
303 |
f5dbca0d
|
Stephen Beaver
|
<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
|
304 |
c24bb3fc
|
Stephen Beaver
|
<div id="mainarea" class="panel panel-default">
|
305 |
b51d272c
|
Stephen Beaver
|
<table id="mainarea" class="table table-striped table-hover table-condensed">
|
306 |
c24bb3fc
|
Stephen Beaver
|
<thead>
|
307 |
32c477c5
|
Scott Ullrich
|
<?php
|
308 |
f8ac4407
|
Phil Davis
|
/* Handle filtering bar A-Z */
|
309 |
|
|
$include_filtering_inputbox = false;
|
310 |
|
|
$colspan = 0;
|
311 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
312 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
313 |
|
|
$colspan++;
|
314 |
|
|
}
|
315 |
|
|
}
|
316 |
|
|
if ($pkg['fields']['field']) {
|
317 |
|
|
// First find the sorting type field if it exists
|
318 |
|
|
foreach ($pkg['fields']['field'] as $field) {
|
319 |
|
|
if ($field['type'] == "sorting") {
|
320 |
|
|
if (isset($field['include_filtering_inputbox'])) {
|
321 |
|
|
$include_filtering_inputbox = true;
|
322 |
|
|
}
|
323 |
|
|
if ($display_maximum_rows < 1) {
|
324 |
|
|
if ($field['display_maximum_rows']) {
|
325 |
|
|
$display_maximum_rows = $field['display_maximum_rows'];
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
79563cb6
|
Colin Fleming
|
echo "<tr><td colspan='$colspan' class='text-center'>";
|
329 |
cadeb9fd
|
Phil Davis
|
echo gettext("Filter by: ");
|
330 |
f8ac4407
|
Phil Davis
|
$isfirst = true;
|
331 |
|
|
for ($char = 65; $char < 91; $char++) {
|
332 |
|
|
if (!$isfirst) {
|
333 |
|
|
echo " | ";
|
334 |
|
|
}
|
335 |
|
|
echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
|
336 |
|
|
$isfirst = false;
|
337 |
|
|
}
|
338 |
|
|
echo "</td></tr>";
|
339 |
79563cb6
|
Colin Fleming
|
echo "<tr><td colspan='$colspan' class='text-center'>";
|
340 |
f8ac4407
|
Phil Davis
|
if ($field['sortablefields']) {
|
341 |
cadeb9fd
|
Phil Davis
|
echo gettext("Filter field: ") . "<select name='pkg_filter_type'>";
|
342 |
f8ac4407
|
Phil Davis
|
foreach ($field['sortablefields']['item'] as $si) {
|
343 |
|
|
if ($si['name'] == $_REQUEST['pkg_filter_type']) {
|
344 |
c4b60a9a
|
Colin Fleming
|
$SELECTED = "selected";
|
345 |
f8ac4407
|
Phil Davis
|
} else {
|
346 |
|
|
$SELECTED = "";
|
347 |
32c477c5
|
Scott Ullrich
|
}
|
348 |
f8ac4407
|
Phil Davis
|
echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
|
349 |
32c477c5
|
Scott Ullrich
|
}
|
350 |
f8ac4407
|
Phil Davis
|
echo "</select>";
|
351 |
32c477c5
|
Scott Ullrich
|
}
|
352 |
f8ac4407
|
Phil Davis
|
if ($include_filtering_inputbox) {
|
353 |
6ac61204
|
jim-p
|
echo ' ' . gettext("Filter text: ") . '<input id="pkg_filter" name="pkg_filter" value="' . htmlspecialchars($_REQUEST['pkg_filter']) . '" />';
|
354 |
27d6a45b
|
jim-p
|
echo ' <button type="submit" value="Filter" class="btn btn-primary btn-xs">';
|
355 |
e0cb987c
|
Marcos Mendoza
|
echo '<i class="fa-solid fa-filter icon-embed-btn"></i>';
|
356 |
27d6a45b
|
jim-p
|
echo gettext("Filter");
|
357 |
|
|
echo "</button>";
|
358 |
f8ac4407
|
Phil Davis
|
}
|
359 |
|
|
echo "</td></tr><tr><td><font size='-3'> </font></td></tr>";
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
|
|
}
|
363 |
32c477c5
|
Scott Ullrich
|
?>
|
364 |
|
|
<tr>
|
365 |
c24bb3fc
|
Stephen Beaver
|
|
366 |
32c477c5
|
Scott Ullrich
|
<?php
|
367 |
f8ac4407
|
Phil Davis
|
if ($display_maximum_rows) {
|
368 |
6c07db48
|
Phil Davis
|
$totalpages = ceil(round((count($evaledvar) / $display_maximum_rows), 9));
|
369 |
f8ac4407
|
Phil Davis
|
$page = 1;
|
370 |
|
|
$tmpcount = 0;
|
371 |
|
|
$tmppp = 0;
|
372 |
|
|
if (is_array($evaledvar)) {
|
373 |
|
|
foreach ($evaledvar as $ipa) {
|
374 |
|
|
if ($tmpcount == $display_maximum_rows) {
|
375 |
|
|
$page++;
|
376 |
37da0c50
|
Scott Ullrich
|
$tmpcount = 0;
|
377 |
|
|
}
|
378 |
f8ac4407
|
Phil Davis
|
if ($tmppp == $startdisplayingat) {
|
379 |
|
|
break;
|
380 |
32c477c5
|
Scott Ullrich
|
}
|
381 |
f8ac4407
|
Phil Davis
|
$tmpcount++;
|
382 |
|
|
$tmppp++;
|
383 |
|
|
}
|
384 |
|
|
}
|
385 |
c24bb3fc
|
Stephen Beaver
|
echo "<tr><th colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
|
386 |
f8ac4407
|
Phil Davis
|
echo "<table width='100%' summary=''>";
|
387 |
|
|
echo "<tr>";
|
388 |
cadeb9fd
|
Phil Davis
|
echo "<td class='text-left'>" . sprintf(gettext('Displaying page %1$s of %2$s'), $page, $totalpages) . "</b></td>";
|
389 |
|
|
echo "<td class='text-right'>" . gettext("Rows per page: ") . "<select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
|
390 |
6c07db48
|
Phil Davis
|
for ($x = 0; $x < 250; $x++) {
|
391 |
f8ac4407
|
Phil Davis
|
if ($x == $display_maximum_rows) {
|
392 |
c4b60a9a
|
Colin Fleming
|
$SELECTED = "selected";
|
393 |
f8ac4407
|
Phil Davis
|
} else {
|
394 |
|
|
$SELECTED = "";
|
395 |
|
|
}
|
396 |
|
|
echo "<option value='$x' $SELECTED>$x</option>\n";
|
397 |
|
|
$x = $x + 4;
|
398 |
|
|
}
|
399 |
|
|
echo "</select></td></tr>";
|
400 |
|
|
echo "</table>";
|
401 |
c24bb3fc
|
Stephen Beaver
|
echo "</th></tr>";
|
402 |
f8ac4407
|
Phil Davis
|
}
|
403 |
2ef13b6c
|
Stephen Beaver
|
|
404 |
f8ac4407
|
Phil Davis
|
$cols = 0;
|
405 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
406 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
407 |
c24bb3fc
|
Stephen Beaver
|
echo "<th class=\"listhdrr\">" . $column['fielddescr'] . "</th>";
|
408 |
f8ac4407
|
Phil Davis
|
$cols++;
|
409 |
|
|
}
|
410 |
|
|
}
|
411 |
|
|
?>
|
412 |
|
|
</tr>
|
413 |
c24bb3fc
|
Stephen Beaver
|
</thead>
|
414 |
|
|
<tbody>
|
415 |
f8ac4407
|
Phil Davis
|
<?php
|
416 |
|
|
$i = 0;
|
417 |
6c07db48
|
Phil Davis
|
$pagination_counter = 0;
|
418 |
d43354d2
|
Steve Beaver
|
if ($evaledvar && is_array($evaledvar)) {
|
419 |
f8ac4407
|
Phil Davis
|
foreach ($evaledvar as $ip) {
|
420 |
|
|
if ($startdisplayingat) {
|
421 |
|
|
if ($i < $startdisplayingat) {
|
422 |
|
|
$i++;
|
423 |
|
|
continue;
|
424 |
32c477c5
|
Scott Ullrich
|
}
|
425 |
f8ac4407
|
Phil Davis
|
}
|
426 |
|
|
if ($_REQUEST['pkg_filter']) {
|
427 |
|
|
// Handle filtered items
|
428 |
|
|
if ($pkg['fields']['field'] && !$filter_regex) {
|
429 |
|
|
// First find the sorting type field if it exists
|
430 |
|
|
foreach ($pkg['fields']['field'] as $field) {
|
431 |
|
|
if ($field['type'] == "sorting") {
|
432 |
|
|
if ($field['sortablefields']['item']) {
|
433 |
|
|
foreach ($field['sortablefields']['item'] as $sf) {
|
434 |
|
|
if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
|
435 |
|
|
$filter_fieldname = $sf['fieldname'];
|
436 |
|
|
#Use a default regex on sortable fields when none is declared
|
437 |
5d82cce0
|
jim-p
|
$pkg_filter = cleanup_regex_pattern(htmlspecialchars(strip_tags($_REQUEST['pkg_filter'])));
|
438 |
f8ac4407
|
Phil Davis
|
if ($sf['regex']) {
|
439 |
5d82cce0
|
jim-p
|
$filter_regex = str_replace("%FILTERTEXT%", $pkg_filter, trim($sf['regex']));
|
440 |
f8ac4407
|
Phil Davis
|
} else {
|
441 |
5d82cce0
|
jim-p
|
$filter_regex = "/{$pkg_filter}/i";
|
442 |
32c477c5
|
Scott Ullrich
|
}
|
443 |
|
|
}
|
444 |
|
|
}
|
445 |
|
|
}
|
446 |
|
|
}
|
447 |
|
|
}
|
448 |
f8ac4407
|
Phil Davis
|
}
|
449 |
|
|
// Do we have something to filter on?
|
450 |
|
|
unset($filter_matches);
|
451 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
452 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
453 |
|
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
454 |
|
|
if ($column['fieldname'] == $filter_fieldname) {
|
455 |
|
|
if ($filter_regex) {
|
456 |
|
|
preg_match($filter_regex, $fieldname, $filter_matches);
|
457 |
|
|
break;
|
458 |
32c477c5
|
Scott Ullrich
|
}
|
459 |
|
|
}
|
460 |
|
|
}
|
461 |
|
|
}
|
462 |
f8ac4407
|
Phil Davis
|
if (!$filter_matches) {
|
463 |
|
|
$i++;
|
464 |
|
|
continue;
|
465 |
|
|
}
|
466 |
|
|
}
|
467 |
|
|
if ($pkg['adddeleteeditpagefields']['movable']) {
|
468 |
8d659bf1
|
NOYB
|
echo "<tr style=\"vertical-align: top\" class=\"sortable\" id=\"id_{$i}\">\n";
|
469 |
f8ac4407
|
Phil Davis
|
} else {
|
470 |
8d659bf1
|
NOYB
|
echo "<tr style=\"vertical-align: top\">\n";
|
471 |
f8ac4407
|
Phil Davis
|
}
|
472 |
f5dbca0d
|
Stephen Beaver
|
if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
|
473 |
f8ac4407
|
Phil Davis
|
foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
|
474 |
|
|
if ($column['fieldname'] == "description") {
|
475 |
|
|
$class = "listbg";
|
476 |
|
|
} else {
|
477 |
|
|
$class = "listlr";
|
478 |
|
|
}
|
479 |
32c477c5
|
Scott Ullrich
|
?>
|
480 |
f5dbca0d
|
Stephen Beaver
|
<td class="<?=$class?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>';">
|
481 |
32c477c5
|
Scott Ullrich
|
<?php
|
482 |
f8ac4407
|
Phil Davis
|
$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
|
483 |
|
|
#Check if columnitem has a type field declared
|
484 |
|
|
if ($column['type'] == "checkbox") {
|
485 |
|
|
if ($fieldname == "") {
|
486 |
|
|
echo gettext("No");
|
487 |
|
|
} else {
|
488 |
|
|
echo gettext("Yes");
|
489 |
|
|
}
|
490 |
|
|
} else if ($column['type'] == "interface") {
|
491 |
6c07db48
|
Phil Davis
|
echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
|
492 |
f8ac4407
|
Phil Davis
|
} else {
|
493 |
d6ab7496
|
jim-p
|
$display_text = "";
|
494 |
f8ac4407
|
Phil Davis
|
#Check if columnitem has an encoding field declared
|
495 |
|
|
if ($column['encoding'] == "base64") {
|
496 |
d6ab7496
|
jim-p
|
$display_text = $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
|
497 |
f8ac4407
|
Phil Davis
|
#Check if there is a custom info to show when $fieldname is not empty
|
498 |
|
|
} else if ($column['listmodeon'] && $fieldname != "") {
|
499 |
d6ab7496
|
jim-p
|
$display_text = $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
|
500 |
f8ac4407
|
Phil Davis
|
#Check if there is a custom info to show when $fieldname is empty
|
501 |
|
|
} else if ($column['listmodeoff'] && $fieldname == "") {
|
502 |
d6ab7496
|
jim-p
|
$display_text = $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
|
503 |
f8ac4407
|
Phil Davis
|
} else {
|
504 |
d6ab7496
|
jim-p
|
$display_text = $column['prefix'] . $fieldname ." ". $column['suffix'];
|
505 |
f8ac4407
|
Phil Davis
|
}
|
506 |
d6ab7496
|
jim-p
|
if (!isset($column['allow_html'])) {
|
507 |
|
|
$display_text = htmlspecialchars($display_text);
|
508 |
|
|
}
|
509 |
|
|
echo $display_text;
|
510 |
32c477c5
|
Scott Ullrich
|
}
|
511 |
|
|
?>
|
512 |
f8ac4407
|
Phil Davis
|
</td>
|
513 |
32c477c5
|
Scott Ullrich
|
<?php
|
514 |
f8ac4407
|
Phil Davis
|
} // foreach columnitem
|
515 |
|
|
} // if columnitem
|
516 |
|
|
?>
|
517 |
8d659bf1
|
NOYB
|
<td style="vertical-align: middle" class="list text-nowrap">
|
518 |
f8ac4407
|
Phil Davis
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
519 |
|
|
<tr>
|
520 |
|
|
<?php
|
521 |
|
|
#Show custom description to edit button if defined
|
522 |
cadeb9fd
|
Phil Davis
|
$edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:gettext("Edit this item"));
|
523 |
f8ac4407
|
Phil Davis
|
?>
|
524 |
e0cb987c
|
Marcos Mendoza
|
<td><a class="fa-solid fa-pencil" href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i?>" title="<?=$edit_msg?>"></a></td>
|
525 |
f8ac4407
|
Phil Davis
|
<?php
|
526 |
|
|
#Show custom description to delete button if defined
|
527 |
cadeb9fd
|
Phil Davis
|
$delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:gettext("Delete this item"));
|
528 |
f8ac4407
|
Phil Davis
|
?>
|
529 |
c1d304b3
|
Marcos Mendoza
|
<td> <a class="fa-solid fa-trash-can" href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i?>" title="<?=$delete_msg?>"></a></td>
|
530 |
f8ac4407
|
Phil Davis
|
</tr>
|
531 |
c24bb3fc
|
Stephen Beaver
|
</tbody>
|
532 |
|
|
</table>
|
533 |
b51d272c
|
Stephen Beaver
|
</td>
|
534 |
f8ac4407
|
Phil Davis
|
<?php
|
535 |
f5dbca0d
|
Stephen Beaver
|
echo "</tr>\n"; // Pairs with an echo tr some way above
|
536 |
f8ac4407
|
Phil Davis
|
// Handle pagination and display_maximum_rows
|
537 |
|
|
if ($display_maximum_rows) {
|
538 |
|
|
if ($pagination_counter == ($display_maximum_rows-1) or
|
539 |
f5dbca0d
|
Stephen Beaver
|
$i == (count($evaledvar)-1)) {
|
540 |
f8ac4407
|
Phil Davis
|
$colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
|
541 |
|
|
$final_footer = "";
|
542 |
|
|
$final_footer .= "<tr><td colspan='$colcount'>";
|
543 |
6c07db48
|
Phil Davis
|
$final_footer .= "<table width='100%' summary=''><tr>";
|
544 |
79563cb6
|
Colin Fleming
|
$final_footer .= "<td class='text-left'>";
|
545 |
f8ac4407
|
Phil Davis
|
$startingat = $startdisplayingat - $display_maximum_rows;
|
546 |
|
|
if ($startingat > -1) {
|
547 |
6c07db48
|
Phil Davis
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat={$startingat}&display_maximum_rows={$display_maximum_rows}'>";
|
548 |
f8ac4407
|
Phil Davis
|
} else if ($startdisplayingat > 1) {
|
549 |
6c07db48
|
Phil Davis
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=0&display_maximum_rows={$display_maximum_rows}'>";
|
550 |
32c477c5
|
Scott Ullrich
|
}
|
551 |
cadeb9fd
|
Phil Davis
|
$final_footer .= "<font size='2'><< " . gettext("Previous page") . "</font></a>";
|
552 |
f8ac4407
|
Phil Davis
|
if ($tmppp + $display_maximum_rows > count($evaledvar)) {
|
553 |
|
|
$endingrecord = count($evaledvar);
|
554 |
|
|
} else {
|
555 |
|
|
$endingrecord = $tmppp + $display_maximum_rows;
|
556 |
|
|
}
|
557 |
79563cb6
|
Colin Fleming
|
$final_footer .= "</td><td class='text-center'>";
|
558 |
f8ac4407
|
Phil Davis
|
$tmppp++;
|
559 |
6c07db48
|
Phil Davis
|
$final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
|
560 |
79563cb6
|
Colin Fleming
|
$final_footer .= "</font></td><td class='text-right'> ";
|
561 |
f8ac4407
|
Phil Davis
|
if (($i+1) < count($evaledvar)) {
|
562 |
6c07db48
|
Phil Davis
|
$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&display_maximum_rows={$display_maximum_rows}'>";
|
563 |
f8ac4407
|
Phil Davis
|
}
|
564 |
cadeb9fd
|
Phil Davis
|
$final_footer .= "<font size='2'>" . gettext("Next page") . " >></font></a>";
|
565 |
6c07db48
|
Phil Davis
|
$final_footer .= "</td></tr></table></td></tr>";
|
566 |
f8ac4407
|
Phil Davis
|
$i = count($evaledvar);
|
567 |
|
|
break;
|
568 |
549912e3
|
Scott Ullrich
|
}
|
569 |
f8ac4407
|
Phil Davis
|
}
|
570 |
|
|
$i++;
|
571 |
|
|
$pagination_counter++;
|
572 |
|
|
} // foreach evaledvar
|
573 |
|
|
} // if evaledvar
|
574 |
32c477c5
|
Scott Ullrich
|
?>
|
575 |
|
|
<tr>
|
576 |
|
|
<td colspan="<?=$cols?>"></td>
|
577 |
|
|
<td>
|
578 |
44507df4
|
Colin Fleming
|
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
|
579 |
32c477c5
|
Scott Ullrich
|
<tr>
|
580 |
f8ac4407
|
Phil Davis
|
<?php
|
581 |
|
|
#Show custom description to add button if defined
|
582 |
cadeb9fd
|
Phil Davis
|
$add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:gettext("Add a new item"));
|
583 |
f8ac4407
|
Phil Davis
|
?>
|
584 |
e0cb987c
|
Marcos Mendoza
|
<td><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>" class="btn btn-sm btn-success" title="<?=$add_msg?>"><i class="fa-solid fa-plus icon-embed-btn"></i><?=gettext('Add')?></a></td>
|
585 |
f8ac4407
|
Phil Davis
|
<?php
|
586 |
|
|
#Show description button and info if defined
|
587 |
|
|
if ($pkg['adddeleteeditpagefields']['description']) {
|
588 |
|
|
?>
|
589 |
995df6c3
|
Stephen Beaver
|
<td>
|
590 |
e0cb987c
|
Marcos Mendoza
|
<i class="fa-solid fa-info-circle"><?=$pkg['adddeleteeditpagefields']['description']?></i>
|
591 |
995df6c3
|
Stephen Beaver
|
</td>
|
592 |
f8ac4407
|
Phil Davis
|
<?php
|
593 |
|
|
}
|
594 |
|
|
?>
|
595 |
32c477c5
|
Scott Ullrich
|
</tr>
|
596 |
|
|
</table>
|
597 |
|
|
</td>
|
598 |
|
|
</tr>
|
599 |
37da0c50
|
Scott Ullrich
|
<?=$final_footer?>
|
600 |
f8ac4407
|
Phil Davis
|
</table>
|
601 |
c24bb3fc
|
Stephen Beaver
|
</div>
|
602 |
e0cb987c
|
Marcos Mendoza
|
<button class="btn btn-primary" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')"><i class="fa-solid fa-save icon-embed-btn"></i><?=gettext("Save")?></button>
|
603 |
3d335c4d
|
Scott Ullrich
|
|
604 |
a7f908db
|
Scott Ullrich
|
</form>
|
605 |
b000f96f
|
Scott Ullrich
|
<?php
|
606 |
f5dbca0d
|
Stephen Beaver
|
include("foot.inc"); ?>
|