Project

General

Profile

Download (20.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * pkg.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
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
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * 3. All advertising materials mentioning features or use of this software
21
 *    must display the following acknowledgment:
22
 *    "This product includes software developed by the pfSense Project
23
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
24
 *
25
 * 4. The names "pfSense" and "pfSense Project" must not be used to
26
 *    endorse or promote products derived from this software without
27
 *    prior written permission. For written permission, please contact
28
 *    coreteam@pfsense.org.
29
 *
30
 * 5. Products derived from this software may not be called "pfSense"
31
 *    nor may "pfSense" appear in their names without prior written
32
 *    permission of the Electric Sheep Fencing, LLC.
33
 *
34
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36
 *
37
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 * OF THE POSSIBILITY OF SUCH DAMAGE.
52
 */
53

    
54
##|+PRIV
55
##|*IDENT=page-package-settings
56
##|*NAME=Package: Settings
57
##|*DESCR=Allow access to the 'Package: Settings' page.
58
##|*MATCH=pkg.php*
59
##|-PRIV
60

    
61
require_once("guiconfig.inc");
62
require_once("pkg-utils.inc");
63

    
64
function domTT_title($title_msg) {
65
	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');\"";
66
}
67

    
68
$xml = $_REQUEST['xml'];
69

    
70
if ($xml == "") {
71
	$pgtitle = array(gettext("Package"), gettext("Editor"));
72
	include("head.inc");
73
	print_info_box(gettext("No valid package defined."), 'danger', false);
74
	include("foot.inc");
75
	exit;
76
} else {
77
	$pkg_xml_prefix = "/usr/local/pkg/";
78
	$pkg_full_path = "{$pkg_xml_prefix}/{$xml}";
79
	$pkg_realpath = realpath($pkg_full_path);
80
	if (empty($pkg_realpath)) {
81
		$path_error = sprintf(gettext("Package path %s not found."), htmlspecialchars($pkg_full_path));
82
	} else if (substr_compare($pkg_realpath, $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) {
83
		$path_error = sprintf(gettext("Invalid path %s specified."), htmlspecialchars($pkg_full_path));
84
	}
85

    
86
	if (!empty($path_error)) {
87
		include("head.inc");
88
		print_info_box($path_error . "<br />" . gettext("Try reinstalling the package."), 'danger', false);
89
		include("foot.inc");
90
		die;
91
	}
92

    
93
	if (file_exists($pkg_full_path)) {
94
		$pkg = parse_xml_config_pkg($pkg_full_path, "packagegui");
95
	} else {
96
		include("head.inc");
97
		print_info_box(sprintf(gettext("File not found %s."), htmlspecialchars($xml)), 'danger', false);
98
		include("foot.inc");
99
		exit;
100
	}
101
}
102

    
103
if ($pkg['donotsave'] != "") {
104
	header("Location: pkg_edit.php?xml=" . $xml);
105
	exit;
106
}
107

    
108
if ($pkg['include_file'] != "") {
109
	require_once($pkg['include_file']);
110
}
111

    
112
if ($_REQUEST['startdisplayingat']) {
113
	$startdisplayingat = $_REQUEST['startdisplayingat'];
114
}
115

    
116
if ($_REQUEST['display_maximum_rows']) {
117
	if ($_REQUEST['display_maximum_rows']) {
118
		$display_maximum_rows = $_REQUEST['display_maximum_rows'];
119
	}
120
}
121

    
122
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
123

    
124
if ($_GET['act'] == "update") {
125

    
126
	if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
127
		#get current values
128
		$current_values=$config['installedpackages'][$pkg['name']]['config'];
129
		#get updated ids
130
		parse_str($_REQUEST['ids'], $update_list);
131
		#sort ids to know what to change
132
		#useful to do not lose data when using sorting and paging
133
		$sort_list=$update_list['ids'];
134
		sort($sort_list);
135
		#apply updates
136
		foreach ($update_list['ids'] as $key=> $value) {
137
			$config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
138
		}
139
		#save current config
140
		write_config();
141
		#sync package
142
		eval ("{$pkg['custom_php_resync_config_command']}");
143
	}
144
	#function called via jquery, no need to continue after save changes.
145
	exit;
146
}
147
if ($_GET['act'] == "del") {
148
	// loop through our fieldnames and automatically setup the fieldnames
149
	// in the environment.	ie: a fieldname of username with a value of
150
	// testuser would automatically eval $username = "testuser";
151
	foreach ($evaledvar as $ip) {
152
		if ($pkg['adddeleteeditpagefields']['columnitem']) {
153
			foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
154
				${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
155
			}
156
		}
157
	}
158

    
159
	$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
160

    
161
	if ($a_pkg[$_GET['id']]) {
162
		unset($a_pkg[$_GET['id']]);
163
		write_config();
164
		if ($pkg['custom_delete_php_command'] != "") {
165
			if ($pkg['custom_php_command_before_form'] != "") {
166
				eval($pkg['custom_php_command_before_form']);
167
			}
168
			eval($pkg['custom_delete_php_command']);
169
		}
170
		header("Location:  pkg.php?xml=" . $xml);
171
		exit;
172
	}
173
}
174

    
175
ob_start();
176

    
177
$iflist = get_configured_interface_with_descr(false, true);
178
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
179

    
180
if ($pkg['custom_php_global_functions'] != "") {
181
	eval($pkg['custom_php_global_functions']);
182
}
183

    
184
if ($pkg['custom_php_command_before_form'] != "") {
185
	eval($pkg['custom_php_command_before_form']);
186
}
187

    
188
// Breadcrumb
189
if ($pkg['title'] != "") {
190
	/*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
191
 		$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']; 
192
	}*/
193
	if (strpos($pkg['title'], '/')) {
194
		$title = explode('/', $pkg['title']);
195

    
196
		foreach ($title as $subtitle) {
197
			$pgtitle[] = gettext($subtitle);
198
		}
199
	} else {
200
		$pgtitle = array(gettext("Package"), gettext($pkg['title']));
201
	}
202
} else {
203
	$pgtitle = array(gettext("Package"), gettext("Editor"));
204
}
205

    
206
if ($pkg['tabs'] != "") {
207
	$tab_array = array();
208
	foreach ($pkg['tabs']['tab'] as $tab) {
209
		if ($tab['tab_level']) {
210
			$tab_level = $tab['tab_level'];
211
		} else {
212
			$tab_level = 1;
213
		}
214
		if (isset($tab['active'])) {
215
			$active = true;
216
			$pgtitle[] = $tab['text'];
217
		} else {
218
			$active = false;
219
		}
220
		if (isset($tab['no_drop_down'])) {
221
			$no_drop_down = true;
222
		}
223
		$urltmp = "";
224
		if ($tab['url'] != "") {
225
			$urltmp = $tab['url'];
226
		}
227
		if ($tab['xml'] != "") {
228
			$urltmp = "pkg_edit.php?xml=" . $tab['xml'];
229
		}
230

    
231
		$addresswithport = getenv("HTTP_HOST");
232
		$colonpos = strpos($addresswithport, ":");
233
		if ($colonpos !== False) {
234
			//my url is actually just the IP address of the pfsense box
235
			$myurl = substr($addresswithport, 0, $colonpos);
236
		} else {
237
			$myurl = $addresswithport;
238
		}
239
		// eval url so that above $myurl item can be processed if need be.
240
		$url = str_replace('$myurl', $myurl, $urltmp);
241

    
242
		$tab_array[$tab_level][] = array(
243
			$tab['text'],
244
			$active,
245
			$url
246
		);
247
	}
248

    
249
	ksort($tab_array);
250
}
251

    
252
include("head.inc");
253
if (isset($tab_array)) {
254
	foreach ($tab_array as $tabid => $tab) {
255
		display_top_tabs($tab); //, $no_drop_down, $tabid);
256
	}
257
}
258

    
259
?>
260

    
261
<script type="text/javascript">
262
//<![CDATA[
263
events.push(function() {
264

    
265
	function setFilter(filtertext) {
266
		$('#pkg_filter').val(filtertext);
267
		document.pkgform.submit();
268
	}
269

    
270
<?php
271
	if ($pkg['adddeleteeditpagefields']['movable']) {
272
?>
273
		$('#mainarea table tbody').sortable({
274
		items: 'tr.sortable',
275
			cursor: 'move',
276
			distance: 10,
277
			opacity: 0.8,
278
			helper: function(e, ui) {
279
				ui.children().each(function() {
280
					$(this).width($(this).width());
281
				});
282
			return ui;
283
			},
284
		});
285
<?php
286
	}
287
?>
288
});
289

    
290
function save_changes_to_xml(xml) {
291
	var ids = $('#mainarea table tbody').sortable('serialize', {key:"ids[]"});
292
	var strloading="<?=gettext('Saving changes...')?>";
293
	if (confirm("<?=gettext("Confirmation Required to save changes.")?>")) {
294
		$.ajax({
295
			type: 'get',
296
			cache: false,
297
			url: "<?=$_SERVER['SCRIPT_NAME']?>",
298
			data: {xml:'<?=$xml?>', act:'update', ids: ids},
299
			beforeSend: function() {
300
				$('#savemsg').empty().html(strloading);
301
			},
302
			error: function(data) {
303
				$('#savemsg').empty().html('Error:' + data);
304
			},
305
			success: function(data) {
306
				$('#savemsg').empty().html(data);
307
			}
308
		});
309
	}
310
}
311

    
312
//]]>
313
</script>
314

    
315
<?php
316
if ($_GET['savemsg'] != "") {
317
	$savemsg = htmlspecialchars($_GET['savemsg']);
318
}
319

    
320
if ($savemsg) {
321
	print_info_box($savemsg, 'success');
322
}
323
?>
324

    
325
<form action="pkg.php" name="pkgform" method="get">
326
	<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
327
		<div id="mainarea" class="panel panel-default">
328
			<table id="mainarea" class="table table-striped table-hover table-condensed">
329
				<thead>
330
<?php
331
	/* Handle filtering bar A-Z */
332
	$include_filtering_inputbox = false;
333
	$colspan = 0;
334
	if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
335
		foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
336
			$colspan++;
337
		}
338
	}
339
	if ($pkg['fields']['field']) {
340
		// First find the sorting type field if it exists
341
		foreach ($pkg['fields']['field'] as $field) {
342
			if ($field['type'] == "sorting") {
343
				if (isset($field['include_filtering_inputbox'])) {
344
					$include_filtering_inputbox = true;
345
				}
346
				if ($display_maximum_rows < 1) {
347
					if ($field['display_maximum_rows']) {
348
						$display_maximum_rows = $field['display_maximum_rows'];
349
					}
350
				}
351
				echo "<tr><td colspan='$colspan' class='text-center'>";
352
				echo gettext("Filter by: ");
353
				$isfirst = true;
354
				for ($char = 65; $char < 91; $char++) {
355
					if (!$isfirst) {
356
						echo " | ";
357
					}
358
					echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
359
					$isfirst = false;
360
				}
361
				echo "</td></tr>";
362
				echo "<tr><td colspan='$colspan' class='text-center'>";
363
				if ($field['sortablefields']) {
364
					echo gettext("Filter field: ") . "<select name='pkg_filter_type'>";
365
					foreach ($field['sortablefields']['item'] as $si) {
366
						if ($si['name'] == $_REQUEST['pkg_filter_type']) {
367
							$SELECTED = "selected";
368
						} else {
369
							$SELECTED = "";
370
						}
371
						echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
372
					}
373
					echo "</select>";
374
				}
375
				if ($include_filtering_inputbox) {
376
					echo '&nbsp;&nbsp;' . gettext("Filter text: ") . '<input id="pkg_filter" name="pkg_filter" value="' . $_REQUEST['pkg_filter'] . '" />';
377
					echo '&nbsp;<button type="submit" value="Filter" class="btn btn-primary btn-xs">';
378
					echo '<i class="fa fa-filter icon-embed-btn"></i>';
379
					echo gettext("Filter");
380
					echo "</button>";
381
				}
382
				echo "</td></tr><tr><td><font size='-3'>&nbsp;</font></td></tr>";
383
			}
384
		}
385
	}
386
?>
387
				<tr>
388

    
389
<?php
390
	if ($display_maximum_rows) {
391
		$totalpages = ceil(round((count($evaledvar) / $display_maximum_rows), 9));
392
		$page = 1;
393
		$tmpcount = 0;
394
		$tmppp = 0;
395
		if (is_array($evaledvar)) {
396
			foreach ($evaledvar as $ipa) {
397
				if ($tmpcount == $display_maximum_rows) {
398
					$page++;
399
					$tmpcount = 0;
400
				}
401
				if ($tmppp == $startdisplayingat) {
402
					break;
403
				}
404
				$tmpcount++;
405
				$tmppp++;
406
			}
407
		}
408
		echo "<tr><th colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
409
		echo "<table width='100%' summary=''>";
410
		echo "<tr>";
411
		echo "<td class='text-left'>" . sprintf(gettext('Displaying page %1$s of %2$s'), $page, $totalpages) . "</b></td>";
412
		echo "<td class='text-right'>" . gettext("Rows per page: ") . "<select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
413
		for ($x = 0; $x < 250; $x++) {
414
			if ($x == $display_maximum_rows) {
415
				$SELECTED = "selected";
416
			} else {
417
				$SELECTED = "";
418
			}
419
			echo "<option value='$x' $SELECTED>$x</option>\n";
420
			$x = $x + 4;
421
		}
422
		echo "</select></td></tr>";
423
		echo "</table>";
424
		echo "</th></tr>";
425
	}
426

    
427
	$cols = 0;
428
	if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
429
		foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
430
			echo "<th class=\"listhdrr\">" . $column['fielddescr'] . "</th>";
431
			$cols++;
432
		}
433
	}
434
?>
435
				</tr>
436
				</thead>
437
				<tbody>
438
<?php
439
	$i = 0;
440
	$pagination_counter = 0;
441
	if ($evaledvar) {
442
		foreach ($evaledvar as $ip) {
443
			if ($startdisplayingat) {
444
				if ($i < $startdisplayingat) {
445
					$i++;
446
					continue;
447
				}
448
			}
449
			if ($_REQUEST['pkg_filter']) {
450
				// Handle filtered items
451
				if ($pkg['fields']['field'] && !$filter_regex) {
452
					// First find the sorting type field if it exists
453
					foreach ($pkg['fields']['field'] as $field) {
454
						if ($field['type'] == "sorting") {
455
							if ($field['sortablefields']['item']) {
456
								foreach ($field['sortablefields']['item'] as $sf) {
457
									if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
458
										$filter_fieldname = $sf['fieldname'];
459
										#Use a default regex on sortable fields when none is declared
460
										if ($sf['regex']) {
461
											$filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
462
										} else {
463
											$filter_regex = "/{$_REQUEST['pkg_filter']}/i";
464
										}
465
									}
466
								}
467
							}
468
						}
469
					}
470
				}
471
				// Do we have something to filter on?
472
				unset($filter_matches);
473
				if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
474
					foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
475
						$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
476
						if ($column['fieldname'] == $filter_fieldname) {
477
							if ($filter_regex) {
478
								//echo "$filter_regex - $fieldname<p/>";
479
								preg_match($filter_regex, $fieldname, $filter_matches);
480
								break;
481
							}
482
						}
483
					}
484
				}
485
				if (!$filter_matches) {
486
					$i++;
487
					continue;
488
				}
489
			}
490
			if ($pkg['adddeleteeditpagefields']['movable']) {
491
				echo "<tr style=\"vertical-align: top\" class=\"sortable\" id=\"id_{$i}\">\n";
492
			} else {
493
				echo "<tr style=\"vertical-align: top\">\n";
494
			}
495
			if ($pkg['adddeleteeditpagefields']['columnitem'] != "") {
496
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
497
					if ($column['fieldname'] == "description") {
498
						$class = "listbg";
499
					} else {
500
						$class = "listlr";
501
					}
502
?>
503
					<td class="<?=$class?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i?>';">
504
<?php
505
					$fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
506
					#Check if columnitem has a type field declared
507
					if ($column['type'] == "checkbox") {
508
						if ($fieldname == "") {
509
							echo gettext("No");
510
						} else {
511
							echo gettext("Yes");
512
						}
513
					} else if ($column['type'] == "interface") {
514
						echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
515
					} else {
516
						$display_text = "";
517
						#Check if columnitem has an encoding field declared
518
						if ($column['encoding'] == "base64") {
519
							$display_text = $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
520
						#Check if there is a custom info to show when $fieldname is not empty
521
						} else if ($column['listmodeon'] && $fieldname != "") {
522
							$display_text = $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
523
						#Check if there is a custom info to show when $fieldname is empty
524
						} else if ($column['listmodeoff'] && $fieldname == "") {
525
							$display_text = $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
526
						} else {
527
							$display_text = $column['prefix'] . $fieldname ." ". $column['suffix'];
528
						}
529
						if (!isset($column['allow_html'])) {
530
							$display_text = htmlspecialchars($display_text);
531
						}
532
						echo $display_text;
533
					}
534
?>
535
					</td>
536
<?php
537
				} // foreach columnitem
538
			} // if columnitem
539
?>
540
					<td style="vertical-align: middle" class="list text-nowrap">
541
						<table border="0" cellspacing="0" cellpadding="1" summary="icons">
542
							<tr>
543
<?php
544
			#Show custom description to edit button if defined
545
			$edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:gettext("Edit this item"));
546
?>
547
								<td><a class="fa fa-pencil" href="pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i?>" title="<?=$edit_msg?>"></a></td>
548
<?php
549
			#Show custom description to delete button if defined
550
			$delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:gettext("Delete this item"));
551
?>
552
								<td>&nbsp;<a class="fa fa-trash" href="pkg.php?xml=<?=$xml?>&amp;act=del&amp;id=<?=$i?>" title="<?=$delete_msg?>"></a></td>
553
							</tr>
554
						</tbody>
555
					</table>
556
				</td>
557
<?php
558
			echo "</tr>\n"; // Pairs with an echo tr some way above
559
			// Handle pagination and display_maximum_rows
560
			if ($display_maximum_rows) {
561
				if ($pagination_counter == ($display_maximum_rows-1) or
562
					$i == (count($evaledvar)-1)) {
563
					$colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
564
					$final_footer = "";
565
					$final_footer .= "<tr><td colspan='$colcount'>";
566
					$final_footer .= "<table width='100%' summary=''><tr>";
567
					$final_footer .= "<td class='text-left'>";
568
					$startingat = $startdisplayingat - $display_maximum_rows;
569
					if ($startingat > -1) {
570
						$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat={$startingat}&amp;display_maximum_rows={$display_maximum_rows}'>";
571
					} else if ($startdisplayingat > 1) {
572
						$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=0&amp;display_maximum_rows={$display_maximum_rows}'>";
573
					}
574
					$final_footer .= "<font size='2'><< " . gettext("Previous page") . "</font></a>";
575
					if ($tmppp + $display_maximum_rows > count($evaledvar)) {
576
						$endingrecord = count($evaledvar);
577
					} else {
578
						$endingrecord = $tmppp + $display_maximum_rows;
579
					}
580
					$final_footer .= "</td><td class='text-center'>";
581
					$tmppp++;
582
					$final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
583
					$final_footer .= "</font></td><td class='text-right'>&nbsp;";
584
					if (($i+1) < count($evaledvar)) {
585
						$final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&amp;display_maximum_rows={$display_maximum_rows}'>";
586
					}
587
					$final_footer .= "<font size='2'>" . gettext("Next page") . " >></font></a>";
588
					$final_footer .= "</td></tr></table></td></tr>";
589
					$i = count($evaledvar);
590
					break;
591
				}
592
			}
593
			$i++;
594
			$pagination_counter++;
595
		} // foreach evaledvar
596
	} // if evaledvar
597
?>
598
				<tr>
599
					<td colspan="<?=$cols?>"></td>
600
					<td>
601
						<table border="0" cellspacing="0" cellpadding="1" summary="icons">
602
							<tr>
603
<?php
604
	#Show custom description to add button if defined
605
	$add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:gettext("Add a new item"));
606
?>
607
								<td><a href="pkg_edit.php?xml=<?=$xml?>&amp;id=<?=$i?>" class="btn btn-sm btn-success" title="<?=$add_msg?>"><i class="fa fa-plus icon-embed-btn"></i><?=gettext('Add')?></a></td>
608
<?php
609
	#Show description button and info if defined
610
	if ($pkg['adddeleteeditpagefields']['description']) {
611
?>
612
								<td>
613
									<i class="fa fa-info-circle"><?=$pkg['adddeleteeditpagefields']['description']?></i>
614
								</td>
615
<?php
616
	}
617
?>
618
							</tr>
619
						</table>
620
					</td>
621
				</tr>
622
				<?=$final_footer?>
623
			</table>
624
			</div>
625
		<button class="btn btn-primary" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')"><i class="fa fa-save icon-embed-btn"></i><?=gettext("Save")?></button>
626

    
627
</form>
628
<?php
629
echo "<!-- filter_fieldname: {$filter_fieldname} -->";
630
echo "<!-- filter_regex: {$filter_regex} -->";
631

    
632
include("foot.inc"); ?>
(99-99/227)