summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-15 17:47:00 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-15 17:47:00 +0545
commitf8ac4407a8817d9513ffb7fd491f929b6232f487 (patch)
treed5c0a88dbb08aa5b5e5b52648f8f5b55ab244acd /usr
parent83c380c3eb0ee38f591a455aabee40d0a543bb95 (diff)
downloadpfsense-f8ac4407a8817d9513ffb7fd491f929b6232f487.zip
pfsense-f8ac4407a8817d9513ffb7fd491f929b6232f487.tar.gz
Code style WWW pkg
The syntax of these all seems good. Because the 2.3-DEVELOPMENT master does not currently have get_pkg_info implemented, the available packages tab always says "Unable to retrieve package info...". But I don't think I broke any code. This is integrated with the little changes for startdisplayingat var in pkg.php
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/pkg.php776
-rw-r--r--usr/local/www/pkg_edit.php769
-rw-r--r--usr/local/www/pkg_mgr.php180
-rw-r--r--usr/local/www/pkg_mgr_install.php144
-rw-r--r--usr/local/www/pkg_mgr_installed.php154
-rw-r--r--usr/local/www/pkg_mgr_settings.php94
6 files changed, 1151 insertions, 966 deletions
diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php
index 9173965..9b0ae61 100755
--- a/usr/local/www/pkg.php
+++ b/usr/local/www/pkg.php
@@ -1,31 +1,31 @@
<?php
/* $Id$ */
/*
- pkg.php
- Copyright (C) 2013-2015 Electric Sheep Fencing, LP
- Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ pkg.php
+ Copyright (C) 2013-2015 Electric Sheep Fencing, LP
+ Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_MODULE: pkgs
@@ -46,25 +46,25 @@ function gentitle_pkg($pgname) {
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
}
-function domTT_title($title_msg){
+function domTT_title($title_msg) {
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');\"";
}
$xml = $_REQUEST['xml'];
-if($xml == "") {
+if ($xml == "") {
print_info_box_np(gettext("ERROR: No package defined."));
exit;
} else {
- if(file_exists("/usr/local/pkg/" . $xml))
+ if (file_exists("/usr/local/pkg/" . $xml)) {
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
- else {
+ } else {
echo "File not found " . htmlspecialchars($xml);
exit;
}
}
-if($pkg['donotsave'] <> "") {
+if ($pkg['donotsave'] <> "") {
header("Location: pkg_edit.php?xml=" . $xml);
exit;
}
@@ -78,62 +78,67 @@ $section = $pkg['menu'][0]['section'];
$config_path = $pkg['configpath'];
$title = $pkg['title'];
-if($_REQUEST['startdisplayingat'])
+if ($_REQUEST['startdisplayingat']) {
$startdisplayingat = $_REQUEST['startdisplayingat'];
+}
-if($_REQUEST['display_maximum_rows'])
- if($_REQUEST['display_maximum_rows'])
+if ($_REQUEST['display_maximum_rows']) {
+ if ($_REQUEST['display_maximum_rows']) {
$display_maximum_rows = $_REQUEST['display_maximum_rows'];
+ }
+}
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
if ($_GET['act'] == "update") {
-
- if(is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !=""){
- #get current values
- $current_values=$config['installedpackages'][$pkg['name']]['config'];
- #get updated ids
- parse_str($_REQUEST['ids'], $update_list);
- #sort ids to know what to change
- #usefull to do not loose data when using sorting and paging
- $sort_list=$update_list['ids'];
- sort($sort_list);
- #apply updates
- foreach($update_list['ids'] as $key=> $value){
- $config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
- }
- #save current config
- write_config();
- #sync package
- eval ("{$pkg['custom_php_resync_config_command']}");
- }
- #function called via jquery, no need to continue after save changes.
- exit;
+
+ if (is_array($config['installedpackages'][$pkg['name']]) && $pkg['name'] != "" && $_REQUEST['ids'] !="") {
+ #get current values
+ $current_values=$config['installedpackages'][$pkg['name']]['config'];
+ #get updated ids
+ parse_str($_REQUEST['ids'], $update_list);
+ #sort ids to know what to change
+ #useful to do not lose data when using sorting and paging
+ $sort_list=$update_list['ids'];
+ sort($sort_list);
+ #apply updates
+ foreach ($update_list['ids'] as $key=> $value) {
+ $config['installedpackages'][$pkg['name']]['config'][$sort_list[$key]]=$current_values[$update_list['ids'][$key]];
+ }
+ #save current config
+ write_config();
+ #sync package
+ eval ("{$pkg['custom_php_resync_config_command']}");
+ }
+ #function called via jquery, no need to continue after save changes.
+ exit;
}
if ($_GET['act'] == "del") {
- // loop through our fieldnames and automatically setup the fieldnames
- // in the environment. ie: a fieldname of username with a value of
- // testuser would automatically eval $username = "testuser";
- foreach ($evaledvar as $ip) {
- if($pkg['adddeleteeditpagefields']['columnitem'])
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
- ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
- }
+ // loop through our fieldnames and automatically setup the fieldnames
+ // in the environment. ie: a fieldname of username with a value of
+ // testuser would automatically eval $username = "testuser";
+ foreach ($evaledvar as $ip) {
+ if ($pkg['adddeleteeditpagefields']['columnitem']) {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
+ }
}
+ }
- $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
+ $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
- if ($a_pkg[$_GET['id']]) {
- unset($a_pkg[$_GET['id']]);
- write_config();
- if($pkg['custom_delete_php_command'] <> "") {
- if($pkg['custom_php_command_before_form'] <> "")
- eval($pkg['custom_php_command_before_form']);
- eval($pkg['custom_delete_php_command']);
+ if ($a_pkg[$_GET['id']]) {
+ unset($a_pkg[$_GET['id']]);
+ write_config();
+ if ($pkg['custom_delete_php_command'] <> "") {
+ if ($pkg['custom_php_command_before_form'] <> "") {
+ eval($pkg['custom_php_command_before_form']);
}
- header("Location: pkg.php?xml=" . $xml);
- exit;
- }
+ eval($pkg['custom_delete_php_command']);
+ }
+ header("Location: pkg.php?xml=" . $xml);
+ exit;
+ }
}
ob_start();
@@ -141,11 +146,13 @@ ob_start();
$iflist = get_configured_interface_with_descr(false, true);
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
-if($pkg['custom_php_global_functions'] <> "")
+if ($pkg['custom_php_global_functions'] <> "") {
eval($pkg['custom_php_global_functions']);
+}
-if($pkg['custom_php_command_before_form'] <> "")
+if ($pkg['custom_php_command_before_form'] <> "") {
eval($pkg['custom_php_command_before_form']);
+}
$pgtitle = array($title);
include("head.inc");
@@ -163,368 +170,405 @@ include("head.inc");
function setFilter(filtertext) {
jQuery('#pkg_filter').val(filtertext);
document.pkgform.submit();
- }
+ }
<?php
- if($pkg['adddeleteeditpagefields']['movable']){
+ if ($pkg['adddeleteeditpagefields']['movable']) {
?>
- jQuery(document).ready(function(){
+ jQuery(document).ready(function() {
jQuery('#mainarea table tbody').sortable({
items: 'tr.sortable',
cursor: 'move',
distance: 10,
opacity: 0.8,
- helper: function(e,ui){
- ui.children().each(function(){
- jQuery(this).width(jQuery(this).width());
+ helper: function(e,ui) {
+ ui.children().each(function() {
+ jQuery(this).width(jQuery(this).width());
});
- return ui;
+ return ui;
},
});
});
function save_changes_to_xml(xml) {
- var ids=jQuery('#mainarea table tbody').sortable('serialize',{key:"ids[]"});
- var strloading="<img src='/themes/<?= $g['theme']; ?>/images/misc/loader.gif' alt='loader' /> " + "<?=gettext('Saving changes...');?>";
- if(confirm("<?=gettext("Do you really want to save changes?");?>")){
- jQuery.ajax({
- type: 'get',
- cache: false,
- url: "<?=$_SERVER['SCRIPT_NAME'];?>",
- data: {xml:'<?=$xml?>', act:'update', ids: ids},
- beforeSend: function(){
- jQuery('#savemsg').empty().html(strloading);
- },
- error: function(data){
- jQuery('#savemsg').empty().html('Error:' + data);
- },
- success: function(data){
- jQuery('#savemsg').empty().html(data);
- }
- });
- }
+ var ids=jQuery('#mainarea table tbody').sortable('serialize',{key:"ids[]"});
+ var strloading="<img src='/themes/<?= $g['theme']; ?>/images/misc/loader.gif' alt='loader' /> " + "<?=gettext('Saving changes...');?>";
+ if (confirm("<?=gettext("Do you really want to save changes?");?>")) {
+ jQuery.ajax({
+ type: 'get',
+ cache: false,
+ url: "<?=$_SERVER['SCRIPT_NAME'];?>",
+ data: {xml:'<?=$xml?>', act:'update', ids: ids},
+ beforeSend: function() {
+ jQuery('#savemsg').empty().html(strloading);
+ },
+ error: function(data) {
+ jQuery('#savemsg').empty().html('Error:' + data);
+ },
+ success: function(data) {
+ jQuery('#savemsg').empty().html(data);
+ }
+ });
+ }
}
- <?php
+ <?php
}
?>
//]]>
</script>
<form action="pkg.php" name="pkgform" method="get">
<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>' />
-<?php if($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
+<?php if ($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
<div id="savemsg"></div>
<?php if ($savemsg) print_info_box($savemsg); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package settings">
<?php
-if ($pkg['tabs'] <> "") {
- $tab_array = array();
- foreach($pkg['tabs']['tab'] as $tab) {
- if($tab['tab_level'])
- $tab_level = $tab['tab_level'];
- else
- $tab_level = 1;
- if(isset($tab['active'])) {
- $active = true;
- } else {
- $active = false;
- }
- if(isset($tab['no_drop_down']))
- $no_drop_down = true;
- $urltmp = "";
- if($tab['url'] <> "") $urltmp = $tab['url'];
- if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
-
- $addresswithport = getenv("HTTP_HOST");
- $colonpos = strpos($addresswithport, ":");
- if ($colonpos !== False) {
- //my url is actually just the IP address of the pfsense box
- $myurl = substr($addresswithport, 0, $colonpos);
- } else {
- $myurl = $addresswithport;
- }
- // eval url so that above $myurl item can be processed if need be.
- $url = str_replace('$myurl', $myurl, $urltmp);
-
- $tab_array[$tab_level][] = array(
- $tab['text'],
- $active,
- $url
- );
- }
-
- ksort($tab_array);
- foreach($tab_array as $tab) {
- echo '<tr><td>';
- display_top_tabs($tab, $no_drop_down);
- echo '</td></tr>';
- }
-}
+ if ($pkg['tabs'] <> "") {
+ $tab_array = array();
+ foreach ($pkg['tabs']['tab'] as $tab) {
+ if ($tab['tab_level']) {
+ $tab_level = $tab['tab_level'];
+ } else {
+ $tab_level = 1;
+ }
+ if (isset($tab['active'])) {
+ $active = true;
+ } else {
+ $active = false;
+ }
+ if (isset($tab['no_drop_down'])) {
+ $no_drop_down = true;
+ }
+ $urltmp = "";
+ if ($tab['url'] <> "") {
+ $urltmp = $tab['url'];
+ }
+ if ($tab['xml'] <> "") {
+ $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
+ }
+
+ $addresswithport = getenv("HTTP_HOST");
+ $colonpos = strpos($addresswithport, ":");
+ if ($colonpos !== False) {
+ //my url is actually just the IP address of the pfsense box
+ $myurl = substr($addresswithport, 0, $colonpos);
+ } else {
+ $myurl = $addresswithport;
+ }
+ // eval url so that above $myurl item can be processed if need be.
+ $url = str_replace('$myurl', $myurl, $urltmp);
+
+ $tab_array[$tab_level][] = array(
+ $tab['text'],
+ $active,
+ $url
+ );
+ }
+
+ ksort($tab_array);
+ foreach ($tab_array as $tab) {
+ echo '<tr><td>';
+ display_top_tabs($tab, $no_drop_down);
+ echo '</td></tr>';
+ }
+ }
?>
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
<tr>
<td class="tabcont">
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
<?php
- /* Handle filtering bar A-Z */
- $include_filtering_inputbox = false;
- $colspan = 0;
- if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column)
- $colspan++;
- if($pkg['fields']['field']) {
- // First find the sorting type field if it exists
- foreach($pkg['fields']['field'] as $field) {
- if($field['type'] == "sorting") {
- if(isset($field['include_filtering_inputbox']))
- $include_filtering_inputbox = true;
- if($display_maximum_rows < 1)
- if($field['display_maximum_rows'])
- $display_maximum_rows = $field['display_maximum_rows'];
- echo "<tr><td class='listhdrr' colspan='$colspan' align='center'>";
- echo "Filter by: ";
- $isfirst = true;
- for($char = 65; $char < 91; $char++) {
- if(!$isfirst)
- echo " | ";
- echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
- $isfirst = false;
- }
- echo "</td></tr>";
- echo "<tr><td class='listhdrr' colspan='$colspan' align='center'>";
- if($field['sortablefields']) {
- echo "Filter field: <select name='pkg_filter_type'>";
- foreach($field['sortablefields']['item'] as $si) {
- if($si['name'] == $_REQUEST['pkg_filter_type'])
- $SELECTED = "selected=\"selected\"";
- else
- $SELECTED = "";
- echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
- }
- echo "</select>";
- }
- if($include_filtering_inputbox)
- echo "&nbsp;&nbsp;Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /> <input type='submit' value='Filter' />";
- echo "</td></tr><tr><td><font size='-3'>&nbsp;</font></td></tr>";
+ /* Handle filtering bar A-Z */
+ $include_filtering_inputbox = false;
+ $colspan = 0;
+ if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ $colspan++;
+ }
+ }
+ if ($pkg['fields']['field']) {
+ // First find the sorting type field if it exists
+ foreach ($pkg['fields']['field'] as $field) {
+ if ($field['type'] == "sorting") {
+ if (isset($field['include_filtering_inputbox'])) {
+ $include_filtering_inputbox = true;
+ }
+ if ($display_maximum_rows < 1) {
+ if ($field['display_maximum_rows']) {
+ $display_maximum_rows = $field['display_maximum_rows'];
+ }
+ }
+ echo "<tr><td class='listhdrr' colspan='$colspan' align='center'>";
+ echo "Filter by: ";
+ $isfirst = true;
+ for ($char = 65; $char < 91; $char++) {
+ if (!$isfirst) {
+ echo " | ";
+ }
+ echo "<a href=\"#\" onclick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
+ $isfirst = false;
+ }
+ echo "</td></tr>";
+ echo "<tr><td class='listhdrr' colspan='$colspan' align='center'>";
+ if ($field['sortablefields']) {
+ echo "Filter field: <select name='pkg_filter_type'>";
+ foreach ($field['sortablefields']['item'] as $si) {
+ if ($si['name'] == $_REQUEST['pkg_filter_type']) {
+ $SELECTED = "selected=\"selected\"";
+ } else {
+ $SELECTED = "";
}
+ echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
}
+ echo "</select>";
}
+ if ($include_filtering_inputbox) {
+ echo "&nbsp;&nbsp;Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "' /> <input type='submit' value='Filter' />";
+ }
+ echo "</td></tr><tr><td><font size='-3'>&nbsp;</font></td></tr>";
+ }
+ }
+ }
?>
<tr>
<?php
- if($display_maximum_rows) {
- $totalpages = ceil(round((count($evaledvar) / $display_maximum_rows),9));
- $page = 1;
+ if ($display_maximum_rows) {
+ $totalpages = ceil(round((count($evaledvar) / $display_maximum_rows),9));
+ $page = 1;
+ $tmpcount = 0;
+ $tmppp = 0;
+ if (is_array($evaledvar)) {
+ foreach ($evaledvar as $ipa) {
+ if ($tmpcount == $display_maximum_rows) {
+ $page++;
$tmpcount = 0;
- $tmppp = 0;
- if(is_array($evaledvar)) {
- foreach ($evaledvar as $ipa) {
- if($tmpcount == $display_maximum_rows) {
- $page++;
- $tmpcount = 0;
- }
- if($tmppp == $startdisplayingat)
- break;
- $tmpcount++;
- $tmppp++;
- }
- }
- echo "<tr><td colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
- echo "<table width='100%' summary=''>";
- echo "<tr>";
- echo "<td align='left'>Displaying page $page of $totalpages</b></td>";
- echo "<td align='right'>Rows per page: <select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
- for($x=0; $x<250; $x++) {
- if($x == $display_maximum_rows)
- $SELECTED = "selected=\"selected\"";
- else
- $SELECTED = "";
- echo "<option value='$x' $SELECTED>$x</option>\n";
- $x=$x+4;
- }
- echo "</select></td></tr>";
- echo "</table>";
- echo "</td></tr>";
}
- $cols = 0;
- if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
- echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
- $cols++;
- }
+ if ($tmppp == $startdisplayingat) {
+ break;
}
- echo "</tr>";
- $i=0;
- $pagination_startingrow=0;
- $pagination_counter=0;
- if($evaledvar)
- foreach ($evaledvar as $ip) {
- if($startdisplayingat) {
- if($i < $startdisplayingat) {
- $i++;
- continue;
- }
+ $tmpcount++;
+ $tmppp++;
+ }
+ }
+ echo "<tr><td colspan='" . count($pkg['adddeleteeditpagefields']['columnitem']) . "'>";
+ echo "<table width='100%' summary=''>";
+ echo "<tr>";
+ echo "<td align='left'>Displaying page $page of $totalpages</b></td>";
+ echo "<td align='right'>Rows per page: <select onchange='document.pkgform.submit();' name='display_maximum_rows'>";
+ for ($x=0; $x<250; $x++) {
+ if ($x == $display_maximum_rows) {
+ $SELECTED = "selected=\"selected\"";
+ } else {
+ $SELECTED = "";
+ }
+ echo "<option value='$x' $SELECTED>$x</option>\n";
+ $x = $x + 4;
+ }
+ echo "</select></td></tr>";
+ echo "</table>";
+ echo "</td></tr>";
+ }
+ $cols = 0;
+ if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
+ $cols++;
+ }
+ }
+?>
+ </tr>
+<?php
+ $i = 0;
+ $pagination_startingrow=0;
+ $pagination_counter=0;
+ if ($evaledvar) {
+ foreach ($evaledvar as $ip) {
+ if ($startdisplayingat) {
+ if ($i < $startdisplayingat) {
+ $i++;
+ continue;
}
- if($_REQUEST['pkg_filter']) {
- // Handle filterered items
- if($pkg['fields']['field'] && !$filter_regex) {
- // First find the sorting type field if it exists
- foreach($pkg['fields']['field'] as $field) {
- if($field['type'] == "sorting") {
- if($field['sortablefields']['item']) {
- foreach($field['sortablefields']['item'] as $sf) {
- if($sf['name'] == $_REQUEST['pkg_filter_type']) {
- $filter_fieldname = $sf['fieldname'];
- #Use a default regex on sortable fields when none is declared
- if($sf['regex'])
- $filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
- else
- $filter_regex = "/{$_REQUEST['pkg_filter']}/i";
+ }
+ if ($_REQUEST['pkg_filter']) {
+ // Handle filtered items
+ if ($pkg['fields']['field'] && !$filter_regex) {
+ // First find the sorting type field if it exists
+ foreach ($pkg['fields']['field'] as $field) {
+ if ($field['type'] == "sorting") {
+ if ($field['sortablefields']['item']) {
+ foreach ($field['sortablefields']['item'] as $sf) {
+ if ($sf['name'] == $_REQUEST['pkg_filter_type']) {
+ $filter_fieldname = $sf['fieldname'];
+ #Use a default regex on sortable fields when none is declared
+ if ($sf['regex']) {
+ $filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
+ } else {
+ $filter_regex = "/{$_REQUEST['pkg_filter']}/i";
}
}
}
}
}
}
- // Do we have something to filter on?
- unset($filter_matches);
- if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
- $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
- if($column['fieldname'] == $filter_fieldname) {
- if($filter_regex) {
- //echo "$filter_regex - $fieldname<p/>";
- preg_match($filter_regex, $fieldname, $filter_matches);
- break;
- }
+ }
+ // Do we have something to filter on?
+ unset($filter_matches);
+ if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
+ if ($column['fieldname'] == $filter_fieldname) {
+ if ($filter_regex) {
+ //echo "$filter_regex - $fieldname<p/>";
+ preg_match($filter_regex, $fieldname, $filter_matches);
+ break;
}
}
}
- if(!$filter_matches) {
- $i++;
- continue;
- }
}
- if($pkg['adddeleteeditpagefields']['movable'])
- echo "<tr valign=\"top\" class=\"sortable\" id=\"id_{$i}\">\n";
- else
- echo "<tr valign=\"top\">\n";
- if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
- if ($column['fieldname'] == "description")
- $class = "listbg";
- else
- $class = "listlr";
+ if (!$filter_matches) {
+ $i++;
+ continue;
+ }
+ }
+ if ($pkg['adddeleteeditpagefields']['movable']) {
+ echo "<tr valign=\"top\" class=\"sortable\" id=\"id_{$i}\">\n";
+ } else {
+ echo "<tr valign=\"top\">\n";
+ }
+ if ($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ if ($column['fieldname'] == "description") {
+ $class = "listbg";
+ } else {
+ $class = "listlr";
+ }
?>
- <td class="<?=$class;?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i;?>';">
- <?php
- $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
- #Check if columnitem has a type field declared
- if($column['type'] == "checkbox") {
- if($fieldname == "") {
- echo gettext("No");
- } else {
- echo gettext("Yes");
- }
- } else if ($column['type'] == "interface") {
- echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
- } else {
- #Check if columnitem has an encoding field declared
- if ($column['encoding'] == "base64")
- echo $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
- #Check if there is a custom info to show when $fieldname is not empty
- else if($column['listmodeon'] && $fieldname != "")
- echo $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
- #Check if there is a custom info to show when $fieldname is empty
- else if($column['listmodeoff'] && $fieldname == "")
- echo $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
- else
- echo $column['prefix'] . $fieldname ." ". $column['suffix'];
- }
- ?>
- </td>
+ <td class="<?=$class;?>" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i;?>';">
<?php
+ $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
+ #Check if columnitem has a type field declared
+ if ($column['type'] == "checkbox") {
+ if ($fieldname == "") {
+ echo gettext("No");
+ } else {
+ echo gettext("Yes");
+ }
+ } else if ($column['type'] == "interface") {
+ echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
+ } else {
+ #Check if columnitem has an encoding field declared
+ if ($column['encoding'] == "base64") {
+ echo $column['prefix'] . base64_decode($fieldname) . $column['suffix'];
+ #Check if there is a custom info to show when $fieldname is not empty
+ } else if ($column['listmodeon'] && $fieldname != "") {
+ echo $column['prefix'] . gettext($column['listmodeon']). $column['suffix'];
+ #Check if there is a custom info to show when $fieldname is empty
+ } else if ($column['listmodeoff'] && $fieldname == "") {
+ echo $column['prefix'] .gettext($column['listmodeoff']). $column['suffix'];
+ } else {
+ echo $column['prefix'] . $fieldname ." ". $column['suffix'];
+ }
}
?>
- <td valign="middle" class="list nowrap">
- <table border="0" cellspacing="0" cellpadding="1" summary="icons">
- <tr>
- <?php
- #Show custom description to edit button if defined
- $edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:"Edit this item");?>
- <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" <?=domTT_title($edit_msg)?> alt="edit" /></a></td>
- <?php
- #Show custom description to delete button if defined
- $delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:"Delete this item");?>
- <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&amp;act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this item?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" <?=domTT_title($delete_msg)?> alt="delete" /></a></td>
- </tr>
- </table>
- </td>
+ </td>
<?php
- echo "</tr>\n";
- // Handle pagination and display_maximum_rows
- if($display_maximum_rows) {
- if($pagination_counter == ($display_maximum_rows-1) or
- $i == (count($evaledvar)-1)) {
- $colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
- $final_footer = "";
- $final_footer .= "<tr><td colspan='$colcount'>";
- $final_footer .= "<table width='100%' summary=''><tr>";
- $final_footer .= "<td align='left'>";
- $startingat = $startdisplayingat - $display_maximum_rows;
- if($startingat > -1) {
- $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat={$startingat}&amp;display_maximum_rows={$display_maximum_rows}'>";
- } else if ($startdisplayingat > 1) {
- $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=0&amp;display_maximum_rows={$display_maximum_rows}'>";
- }
- $final_footer .= "<font size='2'><< Previous page</font></a>";
- if($tmppp + $display_maximum_rows > count($evaledvar))
- $endingrecord = count($evaledvar);
- else
- $endingrecord = $tmppp + $display_maximum_rows;
- $final_footer .= "</td><td align='center'>";
- $tmppp++;
- $final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
- $final_footer .= "</font></td><td align='right'>&nbsp;";
- if(($i+1) < count($evaledvar))
- $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&amp;display_maximum_rows={$display_maximum_rows}'>";
- $final_footer .= "<font size='2'>Next page >></font></a>";
- $final_footer .= "</td></tr></table></td></tr>";
- $i = count($evaledvar);
- break;
+ } // foreach columnitem
+ } // if columnitem
+?>
+ <td valign="middle" class="list nowrap">
+ <table border="0" cellspacing="0" cellpadding="1" summary="icons">
+ <tr>
+<?php
+ #Show custom description to edit button if defined
+ $edit_msg=($pkg['adddeleteeditpagefields']['edittext']?$pkg['adddeleteeditpagefields']['edittext']:"Edit this item");
+?>
+ <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&amp;act=edit&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" <?=domTT_title($edit_msg)?> alt="edit" /></a></td>
+<?php
+ #Show custom description to delete button if defined
+ $delete_msg=($pkg['adddeleteeditpagefields']['deletetext']?$pkg['adddeleteeditpagefields']['deletetext']:"Delete this item");
+?>
+ <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&amp;act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this item?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" <?=domTT_title($delete_msg)?> alt="delete" /></a></td>
+ </tr>
+ </table>
+ </td>
+<?php
+ echo "</tr>\n"; // Pairs with an echo tr some way above
+ // Handle pagination and display_maximum_rows
+ if ($display_maximum_rows) {
+ if ($pagination_counter == ($display_maximum_rows-1) or
+ $i == (count($evaledvar)-1)) {
+ $colcount = count($pkg['adddeleteeditpagefields']['columnitem']);
+ $final_footer = "";
+ $final_footer .= "<tr><td colspan='$colcount'>";
+ $final_footer .= "<table width='100%' summary=''><tr>";
+ $final_footer .= "<td align='left'>";
+ $startingat = $startdisplayingat - $display_maximum_rows;
+ if ($startingat > -1) {
+ $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat={$startingat}&amp;display_maximum_rows={$display_maximum_rows}'>";
+ } else if ($startdisplayingat > 1) {
+ $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=0&amp;display_maximum_rows={$display_maximum_rows}'>";
}
+ $final_footer .= "<font size='2'><< Previous page</font></a>";
+ if ($tmppp + $display_maximum_rows > count($evaledvar)) {
+ $endingrecord = count($evaledvar);
+ } else {
+ $endingrecord = $tmppp + $display_maximum_rows;
+ }
+ $final_footer .= "</td><td align='center'>";
+ $tmppp++;
+ $final_footer .= "<font size='2'>Displaying {$tmppp} - {$endingrecord} / " . count($evaledvar) . " records";
+ $final_footer .= "</font></td><td align='right'>&nbsp;";
+ if (($i+1) < count($evaledvar)) {
+ $final_footer .= "<a href='pkg.php?xml=" . $_REQUEST['xml'] . "&amp;startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "&amp;display_maximum_rows={$display_maximum_rows}'>";
+ }
+ $final_footer .= "<font size='2'>Next page >></font></a>";
+ $final_footer .= "</td></tr></table></td></tr>";
+ $i = count($evaledvar);
+ break;
}
- $i++;
- $pagination_counter++;
- }
+ }
+ $i++;
+ $pagination_counter++;
+ } // foreach evaledvar
+ } // if evaledvar
?>
<tr>
<td colspan="<?=$cols?>"></td>
<td>
<table border="0" cellspacing="0" cellpadding="1" summary="icons">
<tr>
- <?php
- #Show custom description to add button if defined
- $add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:"Add a new item");?>
+<?php
+ #Show custom description to add button if defined
+ $add_msg=($pkg['adddeleteeditpagefields']['addtext']?$pkg['adddeleteeditpagefields']['addtext']:"Add a new item");
+?>
<td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&amp;id=<?=$i?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" <?=domTT_title($add_msg)?> alt="add" /></a></td>
- <?php
- #Show description button and info if defined
- if($pkg['adddeleteeditpagefields']['description']){?>
+<?php
+ #Show description button and info if defined
+ if ($pkg['adddeleteeditpagefields']['description']) {
+?>
<td valign="middle"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" width="17" height="17" border="0" <?=domTT_title($pkg['adddeleteeditpagefields']['description'])?> alt="info" /></td>
- <?php }?>
+<?php
+ }
+?>
</tr>
</table>
</td>
</tr>
<?=$final_footer?>
- <?php
- #Show save button only when movable is defined
- if($pkg['adddeleteeditpagefields']['movable']){?>
- <tr><td><input class="formbtn" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')" /></td></tr>
- <?php }?>
- </table>
- </td>
-</tr>
+<?php
+ #Show save button only when movable is defined
+ if ($pkg['adddeleteeditpagefields']['movable']) {
+?>
+ <tr>
+ <td><input class="formbtn" type="button" value="Save" name="Submit" onclick="save_changes_to_xml('<?=$xml?>')" /></td>
+ </tr>
+<?php
+ }
+?>
+ </table>
+ </td>
+ </tr>
+</table></div></td></tr>
</table>
-</div></td></tr></table>
</form>
<?php include("fend.inc"); ?>
diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php
index 7a58d81..44cf3f5 100644
--- a/usr/local/www/pkg_edit.php
+++ b/usr/local/www/pkg_edit.php
@@ -1,31 +1,31 @@
<?php
/* $Id$ */
/*
- pkg_edit.php
- Copyright (C) 2013-2015 Electric Sheep Fencing, LP
- Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ pkg_edit.php
+ Copyright (C) 2013-2015 Electric Sheep Fencing, LP
+ Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_BUILDER_BINARIES: /sbin/ifconfig
@@ -48,42 +48,47 @@ require_once("shaper.inc");
require_once("pkg-utils.inc");
/* dummy stubs needed by some code that was MFC'd */
-function pfSenseHeader($location) { header("Location: " . $location); }
+function pfSenseHeader($location) {
+ header("Location: " . $location);
+}
function gentitle_pkg($pgname) {
global $pfSense_config;
return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname;
}
-function domTT_title($title_msg){
- if (!empty($title_msg)){
+function domTT_title($title_msg) {
+ if (!empty($title_msg)) {
$title_msg=preg_replace("/\s+/"," ",$title_msg);
- $title_msg=preg_replace("/'/","\'",$title_msg);
+ $title_msg=preg_replace("/'/","\'",$title_msg);
return "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'delay',300,'styleClass', 'niceTitle');\"";
}
}
$xml = htmlspecialchars($_GET['xml']);
-if($_POST['xml']) $xml = htmlspecialchars($_POST['xml']);
+if ($_POST['xml']) {
+ $xml = htmlspecialchars($_POST['xml']);
+}
$xml_fullpath = realpath('/usr/local/pkg/' . $xml);
if ($xml == "" || $xml_fullpath === false ||
substr($xml_fullpath, 0, strlen('/usr/local/pkg/')) != '/usr/local/pkg/') {
- print_info_box_np(gettext("ERROR: No valid package defined."));
- die;
+ print_info_box_np(gettext("ERROR: No valid package defined."));
+ die;
} else {
- $pkg = parse_xml_config_pkg($xml_fullpath, "packagegui");
+ $pkg = parse_xml_config_pkg($xml_fullpath, "packagegui");
}
-if($pkg['include_file'] <> "") {
+if ($pkg['include_file'] <> "") {
require_once($pkg['include_file']);
}
-if (!isset($pkg['adddeleteeditpagefields']))
+if (!isset($pkg['adddeleteeditpagefields'])) {
$only_edit = true;
-else
+} else {
$only_edit = false;
+}
$package_name = $pkg['menu'][0]['name'];
$section = $pkg['menu'][0]['section'];
@@ -93,38 +98,45 @@ $title = $pkg['title'];
$pgtitle = $title;
$id = $_GET['id'];
-if (isset($_POST['id']))
+if (isset($_POST['id'])) {
$id = htmlspecialchars($_POST['id']);
+}
// Not posting? Then user is editing a record. There must be a valid id
// when editing a record.
-if(!$id && !$_POST)
+if (!$id && !$_POST) {
$id = "0";
+}
-if(!is_numeric($id)) {
+if (!is_numeric($id)) {
header("Location: /");
exit;
}
-if($pkg['custom_php_global_functions'] <> "")
- eval($pkg['custom_php_global_functions']);
+if ($pkg['custom_php_global_functions'] <> "") {
+ eval($pkg['custom_php_global_functions']);
+}
// grab the installedpackages->package_name section.
-if($config['installedpackages'] && !is_array($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']))
+if ($config['installedpackages'] && !is_array($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'])) {
$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'] = array();
+}
// If the first entry in the array is an empty <config/> tag, kill it.
-if ($config['installedpackages'] && (count($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']) > 0)
- && ($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'][0] == ""))
+if ($config['installedpackages'] && (count($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']) > 0)
+ && ($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'][0] == "")) {
array_shift($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']);
+}
$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
-if($_GET['savemsg'] <> "")
+if ($_GET['savemsg'] <> "") {
$savemsg = htmlspecialchars($_GET['savemsg']);
+}
-if($pkg['custom_php_command_before_form'] <> "")
+if ($pkg['custom_php_command_before_form'] <> "") {
eval($pkg['custom_php_command_before_form']);
+}
if ($_POST) {
$firstfield = "";
@@ -135,33 +147,38 @@ if ($_POST) {
$reqfieldsn = array();
foreach ($pkg['fields']['field'] as $field) {
if (($field['type'] == 'input') && isset($field['required'])) {
- if($field['fieldname'])
+ if ($field['fieldname']) {
$reqfields[] = $field['fieldname'];
- if($field['fielddescr'])
+ }
+ if ($field['fielddescr']) {
$reqfieldsn[] = $field['fielddescr'];
+ }
}
}
do_input_validation($_POST, $reqfields, $reqfieldsn, $input_errors);
- if ($pkg['custom_php_validation_command'])
+ if ($pkg['custom_php_validation_command']) {
eval($pkg['custom_php_validation_command']);
+ }
- if($_POST['act'] == "del") {
- if($pkg['custom_delete_php_command']) {
- if($pkg['custom_php_command_before_form'] <> "")
- eval($pkg['custom_php_command_before_form']);
- eval($pkg['custom_delete_php_command']);
+ if ($_POST['act'] == "del") {
+ if ($pkg['custom_delete_php_command']) {
+ if ($pkg['custom_php_command_before_form'] <> "") {
+ eval($pkg['custom_php_command_before_form']);
+ }
+ eval($pkg['custom_delete_php_command']);
}
write_config($pkg['delete_string']);
// resync the configuration file code if defined.
- if($pkg['custom_php_resync_config_command'] <> "") {
- if($pkg['custom_php_command_before_form'] <> "")
+ if ($pkg['custom_php_resync_config_command'] <> "") {
+ if ($pkg['custom_php_command_before_form'] <> "") {
eval($pkg['custom_php_command_before_form']);
+ }
eval($pkg['custom_php_resync_config_command']);
}
} else {
- if(!$input_errors && $pkg['custom_add_php_command']) {
- if($pkg['donotsave'] <> "" or $pkg['preoutput'] <> "") {
+ if (!$input_errors && $pkg['custom_add_php_command']) {
+ if ($pkg['donotsave'] <> "" or $pkg['preoutput'] <> "") {
?>
<?php include("head.inc"); ?>
@@ -169,29 +186,34 @@ if ($_POST) {
<?php include("fbegin.inc"); ?>
<?php
}
- if($pkg['preoutput']) echo "<pre>";
+ if ($pkg['preoutput']) {
+ echo "<pre>";
+ }
eval($pkg['custom_add_php_command']);
- if($pkg['preoutput']) echo "</pre>";
+ if ($pkg['preoutput']) {
+ echo "</pre>";
+ }
}
}
// donotsave is enabled. lets simply exit.
- if(empty($pkg['donotsave'])) {
+ if (empty($pkg['donotsave'])) {
- // store values in xml configration file.
+ // store values in xml configuration file.
if (!$input_errors) {
$pkgarr = array();
foreach ($pkg['fields']['field'] as $fields) {
- switch($fields['type']){
+ switch ($fields['type']) {
case "rowhelper":
// save rowhelper items.
#$rowhelpername=($fields['fieldname'] ? $fields['fieldname'] : "row");
$rowhelpername="row";
- foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield)
- foreach($_POST as $key => $value){
+ foreach ($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) {
+ foreach ($_POST as $key => $value) {
if (preg_match("/^{$rowhelperfield['fieldname']}(\d+)$/",$key,$matches))
$pkgarr[$rowhelpername][$matches[1]][$rowhelperfield['fieldname']]=$value;
}
+ }
break;
default:
$fieldname = $fields['fieldname'];
@@ -201,49 +223,55 @@ if ($_POST) {
$fieldvalue = implode(',', $_POST[$fieldname]);
} else {
$fieldvalue = trim($_POST[$fieldname]);
- if ($fields['encoding'] == 'base64')
+ if ($fields['encoding'] == 'base64') {
$fieldvalue = base64_encode($fieldvalue);
+ }
}
- if($fieldname)
+ if ($fieldname) {
$pkgarr[$fieldname] = $fieldvalue;
+ }
}
}
- if (isset($id) && $a_pkg[$id])
+ if (isset($id) && $a_pkg[$id]) {
$a_pkg[$id] = $pkgarr;
- else
+ } else {
$a_pkg[] = $pkgarr;
+ }
write_config($pkg['addedit_string']);
// late running code
- if($pkg['custom_add_php_command_late'] <> "") {
- eval($pkg['custom_add_php_command_late']);
+ if ($pkg['custom_add_php_command_late'] <> "") {
+ eval($pkg['custom_add_php_command_late']);
}
- if (isset($pkg['filter_rules_needed']))
+ if (isset($pkg['filter_rules_needed'])) {
filter_configure();
+ }
// resync the configuration file code if defined.
- if($pkg['custom_php_resync_config_command'] <> "") {
- eval($pkg['custom_php_resync_config_command']);
+ if ($pkg['custom_php_resync_config_command'] <> "") {
+ eval($pkg['custom_php_resync_config_command']);
}
parse_package_templates();
/* if start_command is defined, restart w/ this */
- if($pkg['start_command'] <> "")
- exec($pkg['start_command'] . ">/dev/null 2&>1");
+ if ($pkg['start_command'] <> "") {
+ exec($pkg['start_command'] . ">/dev/null 2&>1");
+ }
/* if restart_command is defined, restart w/ this */
- if($pkg['restart_command'] <> "")
- exec($pkg['restart_command'] . ">/dev/null 2&>1");
-
- if($pkg['aftersaveredirect'] <> "") {
- pfSenseHeader($pkg['aftersaveredirect']);
- } elseif(!$pkg['adddeleteeditpagefields']) {
- pfSenseHeader("pkg_edit.php?xml={$xml}&amp;id=0");
- } elseif(!$pkg['preoutput']) {
- pfSenseHeader("pkg.php?xml=" . $xml);
+ if ($pkg['restart_command'] <> "") {
+ exec($pkg['restart_command'] . ">/dev/null 2&>1");
+ }
+
+ if ($pkg['aftersaveredirect'] <> "") {
+ pfSenseHeader($pkg['aftersaveredirect']);
+ } elseif (!$pkg['adddeleteeditpagefields']) {
+ pfSenseHeader("pkg_edit.php?xml={$xml}&amp;id=0");
+ } elseif (!$pkg['preoutput']) {
+ pfSenseHeader("pkg.php?xml=" . $xml);
}
exit;
} else {
@@ -254,12 +282,12 @@ if ($_POST) {
}
}
-if($pkg['title'] <> "") {
+if ($pkg['title'] <> "") {
$edit = ($only_edit ? '' : ": " . gettext("Edit"));
$title = $pkg['title'] . $edit;
-}
-else
+} else {
$title = gettext("Package Editor");
+}
$pgtitle = $title;
@@ -268,9 +296,9 @@ if ($pkg['custom_php_after_head_command']) {
include("head.inc");
eval($pkg['custom_php_after_head_command']);
echo "</head>\n";
-}
-else
+} else {
include("head.inc");
+}
?>
@@ -281,35 +309,35 @@ else
<script type="text/javascript" src="/javascript/autosuggest.js?rev=1"></script>
<script type="text/javascript" src="/javascript/suggestions.js"></script>
-<?php if($pkg['fields']['field'] <> "") { ?>
+<?php if ($pkg['fields']['field'] <> "") { ?>
<script type="text/javascript">
//<![CDATA[
//Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded
jQuery(document).ready(function() {
-
+
//Sortable function
jQuery('#mainarea table tbody').sortable({
items: 'tr.sortable',
cursor: 'move',
distance: 10,
opacity: 0.8,
- helper: function(e,ui){
- ui.children().each(function(){
- jQuery(this).width(jQuery(this).width());
+ helper: function(e,ui) {
+ ui.children().each(function() {
+ jQuery(this).width(jQuery(this).width());
});
- return ui;
+ return ui;
},
});
-
+
//delete current line jQuery function
jQuery('#maintable td .delete').live('click', function() {
//do not remove first line
- if (jQuery("#maintable tr").length > 2){
+ if (jQuery("#maintable tr").length > 2) {
jQuery(this).parent().parent().remove();
return false;
}
- });
-
+ });
+
//add new line jQuery function
jQuery('#mainarea table .add').click(function() {
//get table size and assign as new id
@@ -318,7 +346,7 @@ else
//apply new id to created line rowhelperid
jQuery("table#maintable tr:last").after("<tr>"+new_row+"<\/tr>");
return false;
- });
+ });
// Call enablechange function
enablechange();
});
@@ -356,7 +384,7 @@ else
}
if (isset($field['checkenablefields'])) {
- foreach(explode(',', $field['checkenablefields']) as $checkenablefield) {
+ foreach (explode(',', $field['checkenablefields']) as $checkenablefield) {
echo "\t\tif (jQuery('form[name=\"iform\"] input[name=\"{$checkenablefield}\"]').length > 0) {\n";
echo "\t\t\tjQuery('form[name=\"iform\"] input[name=\"{$checkenablefield}\"]').prop('checked',false);\n";
echo "\t\t}\n";
@@ -367,7 +395,7 @@ else
}
}
?>
-}
+ }
//]]>
</script>
<?php } ?>
@@ -385,23 +413,29 @@ else
<?php
if ($pkg['tabs'] <> "") {
$tab_array = array();
- foreach($pkg['tabs']['tab'] as $tab) {
- if($tab['tab_level'])
+ foreach ($pkg['tabs']['tab'] as $tab) {
+ if ($tab['tab_level']) {
$tab_level = $tab['tab_level'];
- else
+ } else {
$tab_level = 1;
- if(isset($tab['active'])) {
+ }
+ if (isset($tab['active'])) {
$active = true;
} else {
$active = false;
}
- if(isset($tab['no_drop_down']))
+ if (isset($tab['no_drop_down'])) {
$no_drop_down = true;
+ }
$urltmp = "";
- if($tab['url'] <> "") $urltmp = $tab['url'];
- if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
+ if ($tab['url'] <> "") {
+ $urltmp = $tab['url'];
+ }
+ if ($tab['xml'] <> "") {
+ $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
+ }
- $addresswithport = getenv("HTTP_HOST");
+ $addresswithport = getenv("HTTP_HOST");
$colonpos = strpos($addresswithport, ":");
if ($colonpos !== False) {
//my url is actually just the IP address of the pfsense box
@@ -413,14 +447,14 @@ if ($pkg['tabs'] <> "") {
$url = str_replace('$myurl', $myurl, $urltmp);
$tab_array[$tab_level][] = array(
- $tab['text'],
- $active,
- $url
- );
- }
+ $tab['text'],
+ $active,
+ $url
+ );
+ }
ksort($tab_array);
- foreach($tab_array as $tabid => $tab) {
+ foreach ($tab_array as $tabid => $tab) {
echo '<tr><td>';
display_top_tabs($tab, $no_drop_down, $tabid);
echo '</td></tr>';
@@ -432,10 +466,12 @@ if ($pkg['tabs'] <> "") {
<?php
$cols = 0;
$savevalue = gettext("Save");
- if($pkg['savetext'] <> "") $savevalue = $pkg['savetext'];
- /* If a package's XML has <advanced_options/> configured, then setup
+ if ($pkg['savetext'] <> "") { {
+ $savevalue = $pkg['savetext'];
+ }
+ /* If a package's XML has <advanced_options/> configured, then setup
* the table rows for the fields that have <advancedfield/> set.
- * These fields will be placed below other fields in a seprate area titled 'Advanced Features'.
+ * These fields will be placed below other fields in a separate area titled 'Advanced Features'.
* These advanced fields are not normally configured and generally left to default to 'default settings'.
*/
@@ -443,124 +479,132 @@ if ($pkg['tabs'] <> "") {
$adv_filed_count = 0;
$advanced = "<td>&nbsp;</td>";
$advanced .= "<tr><td colspan=\"2\" class=\"listtopic\">". gettext("Advanced features") . "<br /></td></tr>\n";
- }
+ }
foreach ($pkg['fields']['field'] as $pkga) {
- if ($pkga['type'] == "sorting")
+ if ($pkga['type'] == "sorting") {
continue;
+ }
if ($pkga['type'] == "listtopic") {
$input = "<tr id='td_{$pkga['fieldname']}'><td>&nbsp;</td></tr>";
$input .= "<tr id='tr_{$pkga['fieldname']}'><td colspan=\"2\" class=\"listtopic\">{$pkga['name']}<br /></td></tr>\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
$adv_filed_count++;
- }
- else
+ } else {
echo $input;
+ }
continue;
}
- if($pkga['combinefields']=="begin"){
+ if ($pkga['combinefields']=="begin") {
$input="<tr valign='top' id='tr_{$pkga['fieldname']}'>";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count))
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
- else
- echo $input;
+ } else {
+ echo $input;
}
+ }
$size = "";
- if (isset($pkga['dontdisplayname'])){
+ if (isset($pkga['dontdisplayname'])) {
$input="";
- if(!isset($pkga['combinefields']))
+ if (!isset($pkga['combinefields'])) {
$input .= "<tr valign='top' id='tr_{$pkga['fieldname']}'>";
- if(isset($pkga['usecolspan2']))
+ }
+ if (isset($pkga['usecolspan2'])) {
$colspan="colspan='2'";
- else
+ } else {
$input .= "<td width='22%' class='vncell{$req}'>&nbsp;</td>";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ }
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
$adv_filed_count++;
- }
- else
+ } else {
echo $input;
}
- else if (!isset($pkga['placeonbottom'])){
+ } else if (!isset($pkga['placeonbottom'])) {
unset($req);
- if (isset($pkga['required']))
+ if (isset($pkga['required'])) {
$req = 'req';
+ }
$input= "<tr><td valign='top' width=\"22%\" class=\"vncell{$req}\">";
$input .= fixup_string($pkga['fielddescr']);
$input .= "</td>";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
$adv_filed_count++;
- }
- else
+ } else {
echo $input;
+ }
}
- if($pkga['combinefields']=="begin"){
+ if ($pkga['combinefields']=="begin") {
$input="<td class=\"vncell\"><table summary=\"advanced\">";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count))
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
- else
- echo $input;
+ } else {
+ echo $input;
}
+ }
$class=(isset($pkga['combinefields']) ? '' : 'class="vtable"');
- if (!isset($pkga['placeonbottom'])){
+ if (!isset($pkga['placeonbottom'])) {
$input="<td valign='top' {$colspan} {$class}>";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)){
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
$adv_filed_count++;
- }
- else
+ } else {
echo $input;
+ }
}
// if user is editing a record, load in the data.
$fieldname = $pkga['fieldname'];
if ($get_from_post) {
$value = $_POST[$fieldname];
- if (is_array($value)) $value = implode(',', $value);
+ if (is_array($value)) {
+ $value = implode(',', $value);
+ }
} else {
- if (isset($id) && $a_pkg[$id])
+ if (isset($id) && $a_pkg[$id]) {
$value = $a_pkg[$id][$fieldname];
- else
+ } else {
$value = $pkga['default_value'];
+ }
}
- switch($pkga['type']){
+ switch ($pkga['type']) {
case "input":
$size = ($pkga['size'] ? " size='{$pkga['size']}' " : "");
$input = "<input {$size} id='{$pkga['fieldname']}' name='{$pkga['fieldname']}' class='formfld unknown' value=\"" . htmlspecialchars($value) ."\" />\n";
$input .= "<br />" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input ."</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "password":
$size = ($pkga['size'] ? " size='{$pkga['size']}' " : "");
$input = "<input " . $size . " id='" . $pkga['fieldname'] . "' type='password' name='" . $pkga['fieldname'] . "' class='formfld pwd' value=\"" . htmlspecialchars($value) . "\" />\n";
$input .= "<br />" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input ."</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "info":
$input = fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input ."</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "select":
@@ -579,15 +623,15 @@ if ($pkg['tabs'] <> "") {
foreach ($pkga['options']['option'] as $opt) {
$selected = (in_array($opt['value'], $items) ? 'selected="selected"' : '');
$input .= "\t<option value=\"{$opt['value']}\" {$selected}>{$opt['name']}</option>\n";
- }
+ }
$input .= "</select>\n<br />\n" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input;
$advanced .= "</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "select_source":
@@ -604,7 +648,7 @@ if ($pkg['tabs'] <> "") {
$onchange = (isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : '');
$input = "<select id='{$pkga['fieldname']}' {$multiple} {$size} {$onchange} name=\"{$fieldname}\">\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']) .$input;
$advanced .= "</div>\n";
@@ -615,74 +659,79 @@ if ($pkg['tabs'] <> "") {
eval("\$pkg_source_txt = &$source_url;");
$input="";
#check if show disable option is present on xml
- if(isset($pkga['show_disable_value'])){
- array_push($pkg_source_txt, array(($pkga['source_name']? $pkga['source_name'] : $pkga['name'])=> $pkga['show_disable_value'],
- ($pkga['source_value']? $pkga['source_value'] : $pkga['value'])=> $pkga['show_disable_value']));
- }
+ if (isset($pkga['show_disable_value'])) {
+ array_push($pkg_source_txt,
+ array(($pkga['source_name']? $pkga['source_name'] : $pkga['name'])=> $pkga['show_disable_value'], ($pkga['source_value']? $pkga['source_value'] : $pkga['value'])=> $pkga['show_disable_value']));
+ }
foreach ($pkg_source_txt as $opt) {
$source_name =($pkga['source_name']? $opt[$pkga['source_name']] : $opt[$pkga['name']]);
$source_value =($pkga['source_value'] ? $opt[$pkga['source_value']] : $opt[$pkga['value']]);
- $selected = (in_array($source_value, $items)? 'selected="selected"' : '' );
+ $selected = (in_array($source_value, $items)? 'selected="selected"' : '');
$input .= "\t<option value=\"{$source_value}\" $selected>{$source_name}</option>\n";
- }
+ }
$input .= "</select>\n<br />\n" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count))
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
- else
+ } else {
echo $input;
+ }
break;
case "vpn_selection" :
$input = "<select id='{$pkga['fieldname']}' name='{$vpn['name']}'>\n";
foreach ($config['ipsec']['phase1'] as $vpn) {
$input .= "\t<option value=\"{$vpn['descr']}\">{$vpn['descr']}</option>\n";
- }
+ }
$input .= "</select>\n";
$input .= "<br />" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input;
$advanced .= "</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "checkbox":
$checkboxchecked =($value == "on" ? " checked=\"checked\"" : "");
$onchange = (isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : '');
- if (isset($pkga['enablefields']) || isset($pkga['checkenablefields']))
+ if (isset($pkga['enablefields']) || isset($pkga['checkenablefields'])) {
$onclick = ' onclick="javascript:enablechange();"';
+ }
$input = "<input id='{$pkga['fieldname']}' type='checkbox' name='{$pkga['fieldname']}' {$checkboxchecked} {$onclick} {$onchange} />\n";
$input .= "<br />" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input;
$advanced .= "</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "textarea":
- if($pkga['rows'])
+ if ($pkga['rows']) {
$rows = " rows='{$pkga['rows']}' ";
- if($pkga['cols'])
+ }
+ if ($pkga['cols']) {
$cols = " cols='{$pkga['cols']}' ";
- if (($pkga['encoding'] == 'base64') && !$get_from_post && !empty($value))
+ }
+ if (($pkga['encoding'] == 'base64') && !$get_from_post && !empty($value)) {
$value = base64_decode($value);
- $wrap =($pkga['wrap'] == "off" ? 'wrap="off" style="white-space:nowrap;"' : '');
+ }
+ $wrap =($pkga['wrap'] == "off" ? 'wrap="off" style="white-space:nowrap;"' : '');
$input = "<textarea {$rows} {$cols} name='{$pkga['fieldname']}'{$wrap}>{$value}</textarea>\n";
$input .= "<br />" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input;
$advanced .= "</div>\n";
- }
- else
+ } else {
echo $input;
+ }
break;
case "aliases":
@@ -694,17 +743,22 @@ if ($pkg['tabs'] <> "") {
$aliasesaddr = "";
$value = "value='{$value}'";
- if(isset($a_aliases)) {
- if(!empty($pkga['typealiases'])) {
- foreach($a_aliases as $alias)
- if($alias['type'] == $pkga['typealiases']) {
- if($addrisfirst == 1) $aliasesaddr .= ",";
+ if (isset($a_aliases)) {
+ if (!empty($pkga['typealiases'])) {
+ foreach ($a_aliases as $alias) {
+ if ($alias['type'] == $pkga['typealiases']) {
+ if ($addrisfirst == 1) {
+ $aliasesaddr .= ",";
+ }
$aliasesaddr .= "'" . $alias['name'] . "'";
$addrisfirst = 1;
}
+ }
} else {
- foreach($a_aliases as $alias) {
- if($addrisfirst == 1) $aliasesaddr .= ",";
+ foreach ($a_aliases as $alias) {
+ if ($addrisfirst == 1) {
+ $aliasesaddr .= ",";
+ }
$aliasesaddr .= "'" . $alias['name'] . "'";
$addrisfirst = 1;
}
@@ -723,50 +777,55 @@ if ($pkg['tabs'] <> "") {
echo $input;
echo $script;
- break;
+ break;
case "interfaces_selection":
$ips=array();
$interface_regex=(isset($pkga['hideinterfaceregex']) ? $pkga['hideinterfaceregex'] : "nointerfacestohide");
- if (is_array($config['interfaces']))
- foreach ($config['interfaces'] as $iface_key=>$iface_value){
- if (isset($iface_value['enable']) && ! preg_match("/$interface_regex/",$iface_key)){
+ if (is_array($config['interfaces'])) {
+ foreach ($config['interfaces'] as $iface_key=>$iface_value) {
+ if (isset($iface_value['enable']) && !preg_match("/$interface_regex/",$iface_key)) {
$iface_description=($iface_value['descr'] !="" ? strtoupper($iface_value['descr']) : strtoupper($iface_key));
- if (isset($pkga['showips']))
+ if (isset($pkga['showips'])) {
$iface_description .= " address";
- $ips[]=array('ip'=> $iface_key, 'description'=> $iface_description);
}
+ $ips[]=array('ip'=> $iface_key, 'description'=> $iface_description);
+ }
}
- if (is_array($config['virtualip']) && isset($pkga['showvirtualips']))
- foreach ($config['virtualip']['vip'] as $vip){
- if (! preg_match("/$interface_regex/",$vip['interface']))
- $vip_description=($vip['descr'] !="" ? " ({$vip['descr']}) " : " ");
- switch ($vip['mode']){
+ }
+ if (is_array($config['virtualip']) && isset($pkga['showvirtualips'])) {
+ foreach ($config['virtualip']['vip'] as $vip) {
+ if (!preg_match("/$interface_regex/",$vip['interface'])) {
+ $vip_description=($vip['descr'] !="" ? " ({$vip['descr']}) " : " ");
+ }
+ switch ($vip['mode']) {
case "ipalias":
case "carp":
- $ips[]=array( 'ip'=> $vip['subnet'],'description' => "{$vip['subnet']} $vip_description");
+ $ips[]=array('ip'=> $vip['subnet'],'description' => "{$vip['subnet']} $vip_description");
break;
case "proxyarp":
- if ($vip['type']=="network"){
+ if ($vip['type']=="network") {
$start = ip2long32(gen_subnet($vip['subnet'], $vip['subnet_bits']));
$end = ip2long32(gen_subnet_max($vip['subnet'], $vip['subnet_bits']));
$len = $end - $start;
- for ($i = 0; $i <= $len; $i++)
+ for ($i = 0; $i <= $len; $i++) {
$ips[]= array('ip'=>long2ip32($start+$i),'description'=> long2ip32($start+$i)." from {$vip['subnet']}/{$vip['subnet_bits']} {$vip_description}");
}
- else{
+ } else {
$ips[]= array('ip'=>$vip['subnet'],'description'=> "{$vip['subnet']} $vip_description");
- }
+ }
break;
- }
+ }
}
+ }
sort($ips);
- if (isset($pkga['showlistenall']))
+ if (isset($pkga['showlistenall'])) {
array_unshift($ips,array('ip'=> 'All', 'description'=> 'Listen on All interfaces/ip addresses '));
- if (! preg_match("/$interface_regex/","loopback")){
+ }
+ if (!preg_match("/$interface_regex/","loopback")) {
$iface_description=(isset($pkga['showips']) ? "127.0.0.1 (loopback)" : "loopback");
array_push($ips,array('ip'=> 'lo0', 'description'=> $iface_description));
- }
+ }
#show interfaces array on gui
$size = ($pkga['size'] ? "size=\"{$pkga['size']}\"" : '');
@@ -775,65 +834,72 @@ if ($pkg['tabs'] <> "") {
if (isset($pkga['multiple'])) {
$fieldname .= '[]';
$multiple = 'multiple="multiple"';
- }
+ }
$input = "<select id='{$pkga['fieldname']}' name=\"{$fieldname}\" {$size} {$multiple}>\n";
- if(is_array($value))
+ if (is_array($value)) {
$values = $value;
- else
+ } else {
$values = explode(',', $value);
- foreach($ips as $iface){
+ }
+ foreach ($ips as $iface) {
$selected = (in_array($iface['ip'], $values) ? 'selected="selected"' : '');
$input .= "<option value=\"{$iface['ip']}\" {$selected}>{$iface['description']}</option>\n";
- }
+ }
$input .= "</select>\n<br />" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count))
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
- else
+ } else {
echo $input;
+ }
break;
case "radio":
$input = "<input type='radio' id='{$pkga['fieldname']}' name='{$pkga['fieldname']}' value='{$value}' />";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count))
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= $input;
- else
+ } else {
echo $input;
- break;
+ }
+ break;
case "button":
$input = "<input type='submit' id='{$pkga['fieldname']}' name='{$pkga['fieldname']}' class='formbtn' value='{$pkga['fieldname']}' />\n";
- if(isset($pkga['placeonbottom']))
+ if (isset($pkga['placeonbottom'])) {
$pkg_buttons .= $input;
- else
+ } else {
echo $input ."\n<br />" . fixup_string($pkga['description']) . "\n";
+ }
break;
case "schedule_selection":
$input = "<select id='{$pkga['fieldname']}' name='{$pkga['fieldname']}'>\n";
$schedules = array();
$schedules[] = "none";
- if(is_array($config['schedules']['schedule'])) {
+ if (is_array($config['schedules']['schedule'])) {
foreach ($config['schedules']['schedule'] as $schedule) {
- if ($schedule['name'] <> "")
+ if ($schedule['name'] <> "") {
$schedules[] = $schedule['name'];
+ }
}
}
- foreach($schedules as $schedule) {
+ foreach ($schedules as $schedule) {
$selected = ($value == $schedule ? "selected=\"selected\"" : "");
- if($schedule == "none")
+ if ($schedule == "none") {
$input .= "<option value=\"\" {$selected}>{$schedule}</option>\n";
- else
+ } else {
$input .= "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
+ }
}
$input .= "</select>\n<br />\n" . fixup_string($pkga['description']) . "\n";
- if(isset($pkga['advancedfield']) && isset($adv_filed_count)) {
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$js_array[] = $pkga['fieldname'];
$advanced .= display_advanced_field($pkga['fieldname']).$input;
$advanced .= "</div>\n";
- } else
+ } else {
echo $input;
+ }
break;
-
+
case "rowhelper":
#$rowhelpername=($fields['fieldname'] ? $fields['fieldname'] : "row");
$rowhelpername="row";
@@ -843,7 +909,7 @@ if ($pkg['tabs'] <> "") {
<?php
$rowcounter = 0;
$fieldcounter = 0;
- foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
+ foreach ($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
echo "rowname[{$fieldcounter}] = \"{$rowhelper['fieldname']}\";\n";
echo "rowtype[{$fieldcounter}] = \"{$rowhelper['type']}\";\n";
echo "rowsize[{$fieldcounter}] = \"{$rowhelper['size']}\";\n";
@@ -855,24 +921,27 @@ if ($pkg['tabs'] <> "") {
<table id="maintable" summary="main table">
<tr id='<?="tr_{$pkga['fieldname']}";?>'>
<?php
- foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
- echo "<td ".domTT_title($rowhelper['description'])."><b>" . fixup_string($rowhelper['fielddescr']) . "</b></td>\n";
+ foreach ($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
+ echo "<td ".domTT_title($rowhelper['description'])."><b>" . fixup_string($rowhelper['fielddescr']) . "</b></td>\n";
}
$rowcounter = 0;
$trc = 0;
//Use assigned $a_pkg or create an empty array to enter loop
- if(isset($a_pkg[$id][$rowhelpername]))
+ if (isset($a_pkg[$id][$rowhelpername])) {
$saved_rows=$a_pkg[$id][$rowhelpername];
- else
+ } else {
$saved_rows[]=array();
+ }
- foreach($saved_rows as $row) {
+ foreach ($saved_rows as $row) {
echo "</tr>\n<tr class=\"sortable\" id=\"id_{$rowcounter}\">\n";
- foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
+ foreach ($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
unset($value);
- if($rowhelper['value'] <> "") $value = $rowhelper['value'];
+ if ($rowhelper['value'] <> "") {
+ $value = $rowhelper['value'];
+ }
$fieldname = $rowhelper['fieldname'];
// if user is editing a record, load in the data.
if (isset($id) && $a_pkg[$id]) {
@@ -882,33 +951,35 @@ if ($pkg['tabs'] <> "") {
$type = $rowhelper['type'];
$description = $rowhelper['description'];
$fieldname = $rowhelper['fieldname'];
- if($type == "option")
+ if ($type == "option") {
$options = &$rowhelper['options']['option'];
- if($rowhelper['size'])
+ }
+ if ($rowhelper['size']) {
$size = $rowhelper['size'];
- else if ($pkga['size'])
+ } else if ($pkga['size']) {
$size = $pkga['size'];
- else
+ } else {
$size = "8";
+ }
display_row($rowcounter, $value, $fieldname, $type, $rowhelper, $size);
$text = "";
$trc++;
- }
+ }
$rowcounter++;
echo "<td>";
#echo "<a onclick=\"removeRow(this); return false;\" href=\"#\"><img border=\"0\" src=\"./themes/".$g['theme']."/images/icons/icon_x.gif\" alt=\"remove\" /></a>";
echo "<a class='delete' href=\"#\"><img border='0' src='./themes/{$g['theme']}/images/icons/icon_x.gif' alt='delete' /></a>";
echo "</td>\n";
- }
+ }
?>
</tr>
<tbody></tbody>
</table>
-
+
<!-- <br /><a onclick="javascript:addRowTo('maintable'); return false;" href="#"><img border="0" src="./themes/<?#= $g['theme']; ?>/images/icons/icon_plus.gif" alt="add" /></a>-->
<br /><a class="add" href="#"><img border="0" src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="add" /></a>
- <br /><?php if($pkga['description'] != "") echo $pkga['description']; ?>
+ <br /><?php if ($pkga['description'] != "") echo $pkga['description']; ?>
<script type="text/javascript">
//<![CDATA[
field_counter_js = <?= $fieldcounter ?>;
@@ -918,58 +989,62 @@ if ($pkg['tabs'] <> "") {
//typesel_change();
//]]>
</script>
-
+
<?php
break;
- }
+ }
#check typehint value
- if($pkga['typehint'])
- echo " " . $pkga['typehint'];
- #check combinefields options
- if (isset($pkga['combinefields'])){
- $input="</td>";
- if ($pkga['combinefields']=="end")
- $input.="</table></td></tr>";
- }
- else{
+ if ($pkga['typehint']) {
+ echo " " . $pkga['typehint'];
+ }
+ #check combinefields options
+ if (isset($pkga['combinefields'])) {
+ $input="</td>";
+ if ($pkga['combinefields']=="end") {
+ $input.="</table></td></tr>";
+ }
+ } else {
$input= "</td></tr>";
- if($pkga['usecolspan2'])
+ if ($pkga['usecolspan2']) {
$input.= "</tr><br />";
- }
- if(isset($pkga['advancedfield']) && isset($adv_filed_count))
+ }
+ }
+ if (isset($pkga['advancedfield']) && isset($adv_filed_count)) {
$advanced .= "{$input}\n";
- else
+ } else {
echo "{$input}\n";
+ }
#increment counter
$i++;
- }
+ }
- #print advanced settings if any after reading all fields
- if (isset($advanced) && $adv_filed_count > 0)
+ #print advanced settings if any after reading all fields
+ if (isset($advanced) && $adv_filed_count > 0) {
echo $advanced;
-
+ }
+
?>
- <tr>
- <td>&nbsp;</td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <div id="buttons">
- <?php
- if($pkg['note'] != ""){
- echo "<p><span class=\"red\"><strong>" . gettext("Note") . ":</strong></span> {$pkg['note']}</p>";
- }
- //if (isset($id) && $a_pkg[$id]) // We'll always have a valid ID in our hands
- echo "<input name='id' type='hidden' value=\"" . htmlspecialchars($id) . "\" />";
- echo "<input name='Submit' type='submit' class='formbtn' value=\"" . htmlspecialchars($savevalue) . "\" />\n{$pkg_buttons}\n";
- if (!$only_edit){
- echo "<input class=\"formbtn\" type=\"button\" value=\"".gettext("Cancel")."\" onclick=\"window.location.href='" . $_SERVER['HTTP_REFERER'] . "'\" />";
- }
- ?>
- </div>
- </td>
- </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <div id="buttons">
+ <?php
+ if ($pkg['note'] != "") {
+ echo "<p><span class=\"red\"><strong>" . gettext("Note") . ":</strong></span> {$pkg['note']}</p>";
+ }
+ //if (isset($id) && $a_pkg[$id]) // We'll always have a valid ID in our hands
+ echo "<input name='id' type='hidden' value=\"" . htmlspecialchars($id) . "\" />";
+ echo "<input name='Submit' type='submit' class='formbtn' value=\"" . htmlspecialchars($savevalue) . "\" />\n{$pkg_buttons}\n";
+ if (!$only_edit) {
+ echo "<input class=\"formbtn\" type=\"button\" value=\"".gettext("Cancel")."\" onclick=\"window.location.href='" . $_SERVER['HTTP_REFERER'] . "'\" />";
+ }
+ ?>
+ </div>
+ </td>
+ </tr>
</table>
</div></td></tr>
@@ -983,7 +1058,7 @@ if ($pkg['tabs'] <> "") {
if ($pkg['advanced_options'] == "enabled") {
echo "<script type=\"text/javascript\">\n";
echo "//<![CDATA[\n";
- foreach($js_array as $advfieldname) {
+ foreach ($js_array as $advfieldname) {
echo "function show_" . $advfieldname . "() {\n";
echo "\tjQuery('#showadv_{$advfieldname}').empty();\n";
echo "\tjQuery('#show_{$advfieldname}').css('display', 'block');\n";
@@ -1005,7 +1080,7 @@ if ($pkg['tabs'] <> "") {
function display_row($trc, $value, $fieldname, $type, $rowhelper, $size) {
global $text, $config;
echo "<td>\n";
- switch($type){
+ switch ($type) {
case "input":
echo "<input size='{$size}' name='{$fieldname}{$trc}' id='{$fieldname}{$trc}' class='formfld unknown' value=\"" . htmlspecialchars($value) . "\" />\n";
break;
@@ -1019,10 +1094,10 @@ function display_row($trc, $value, $fieldname, $type, $rowhelper, $size) {
echo "<textarea rows='2' cols='12' id='{$fieldname}{$trc}' class='formfld unknown' name='{$fieldname}{$trc}'>{$value}</textarea>\n";
case "select":
echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$title}>\n";
- foreach($rowhelper['options']['option'] as $rowopt) {
+ foreach ($rowhelper['options']['option'] as $rowopt) {
$text .= "<option value='{$rowopt['value']}'>{$rowopt['name']}</option>";
echo "<option value='{$rowopt['value']}'".($rowopt['value'] == $value?" selected=\"selected\"":"").">{$rowopt['name']}</option>\n";
- }
+ }
echo "</select>\n";
break;
case "interfaces_selection":
@@ -1035,35 +1110,38 @@ function display_row($trc, $value, $fieldname, $type, $rowhelper, $size) {
echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}' {$size} {$multiple}>\n";
$ifaces = get_configured_interface_with_descr();
$additional_ifaces = $rowhelper['add_to_interfaces_selection'];
- if (!empty($additional_ifaces))
+ if (!empty($additional_ifaces)) {
$ifaces = array_merge($ifaces, explode(',', $additional_ifaces));
- if(is_array($value))
+ }
+ if (is_array($value)) {
$values = $value;
- else
+ } else {
$values = explode(',', $value);
+ }
$ifaces["lo0"] = "loopback";
echo "<option><name></name><value></value></option>/n";
- foreach($ifaces as $ifname => $iface) {
+ foreach ($ifaces as $ifname => $iface) {
$text .="<option value=\"{$ifname}\">$iface</option>";
echo "<option value=\"{$ifname}\" ".(in_array($ifname, $values) ? 'selected="selected"' : '').">{$iface}</option>\n";
- }
+ }
echo "</select>\n";
break;
case "select_source":
echo "<select style='height:22px;' id='{$fieldname}{$trc}' name='{$fieldname}{$trc}'>\n";
- if(isset($rowhelper['show_disable_value']))
+ if (isset($rowhelper['show_disable_value'])) {
echo "<option value='{$rowhelper['show_disable_value']}'>{$rowhelper['show_disable_value']}</option>\n";
+ }
$source_url = $rowhelper['source'];
eval("\$pkg_source_txt = &$source_url;");
- foreach($pkg_source_txt as $opt) {
+ foreach ($pkg_source_txt as $opt) {
$source_name = ($rowhelper['source_name'] ? $opt[$rowhelper['source_name']] : $opt[$rowhelper['name']]);
$source_value = ($rowhelper['source_value'] ? $opt[$rowhelper['source_value']] : $opt[$rowhelper['value']]);
$text .= "<option value='{$source_value}'>{$source_name}</option>";
echo "<option value='{$source_value}'".($source_value == $value?" selected=\"selected\"":"").">{$source_name}</option>\n";
- }
+ }
echo "</select>\n";
- break;
- }
+ break;
+ }
echo "</td>\n";
}
@@ -1072,12 +1150,15 @@ function fixup_string($string) {
// fixup #1: $myurl -> http[s]://ip_address:port/
$https = "";
$port = $config['system']['webguiport'];
- if($port <> "443" and $port <> "80")
+ if ($port <> "443" and $port <> "80") {
$urlport = ":" . $port;
- else
+ } else {
$urlport = "";
+ }
- if($config['system']['webgui']['protocol'] == "https") $https = "s";
+ if ($config['system']['webgui']['protocol'] == "https") {
+ $https = "s";
+ }
$myurl = "http" . $https . "://" . getenv("HTTP_HOST") . $urlport;
$newstring = str_replace("\$myurl", $myurl, $string);
$string = $newstring;
@@ -1100,52 +1181,56 @@ function fixup_string($string) {
function parse_package_templates() {
global $pkg, $config;
$rows = 0;
- if($pkg['templates']['template'] <> "")
- foreach($pkg['templates']['template'] as $pkg_template_row) {
+ if ($pkg['templates']['template'] <> "") {
+ foreach ($pkg['templates']['template'] as $pkg_template_row) {
$filename = $pkg_template_row['filename'];
$template_text = $pkg_template_row['templatecontents'];
$firstfield = "";
/* calculate total row helpers count and */
/* change fields defined as fieldname_fieldvalue to their value */
foreach ($pkg['fields']['field'] as $fields) {
- switch($fields['type']){
+ switch ($fields['type']) {
case "rowhelper":
- // save rowhelper items.
- $row_helper_total_rows = 0;
- $row_helper_data = "";
- foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield)
- foreach($_POST as $key => $value){
- if (preg_match("/^{$rowhelperfield['fieldname']}(\d+)$/",$key,$matches)){
- $row_helper_total_rows++;
- $row_helper_data .= $value;
- $sep = "";
- ereg($rowhelperfield['fieldname'] . "_fieldvalue\[(.*)\]", $template_text, $sep);
- foreach ($sep as $se) $separator = $se;
- if($separator <> "") {
- $row_helper_data = ereg_replace(" ", $separator, $row_helper_data);
- $template_text = ereg_replace("\[{$separator}\]", "", $template_text);
+ // save rowhelper items.
+ $row_helper_total_rows = 0;
+ $row_helper_data = "";
+ foreach ($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) {
+ foreach ($_POST as $key => $value) {
+ if (preg_match("/^{$rowhelperfield['fieldname']}(\d+)$/",$key,$matches)) {
+ $row_helper_total_rows++;
+ $row_helper_data .= $value;
+ $sep = "";
+ ereg($rowhelperfield['fieldname'] . "_fieldvalue\[(.*)\]", $template_text, $sep);
+ foreach ($sep as $se) {
+ $separator = $se;
+ }
+ if ($separator <> "") {
+ $row_helper_data = ereg_replace(" ", $separator, $row_helper_data);
+ $template_text = ereg_replace("\[{$separator}\]", "", $template_text);
}
- $template_text = str_replace($rowhelperfield['fieldname'] . "_fieldvalue", $row_helper_data, $template_text);
+ $template_text = str_replace($rowhelperfield['fieldname'] . "_fieldvalue", $row_helper_data, $template_text);
}
}
- break;
- default:
- $fieldname = $fields['fieldname'];
- $fieldvalue = $_POST[$fieldname];
- $template_text = str_replace($fieldname . "_fieldvalue", $fieldvalue, $template_text);
+ }
+ break;
+ default:
+ $fieldname = $fields['fieldname'];
+ $fieldvalue = $_POST[$fieldname];
+ $template_text = str_replace($fieldname . "_fieldvalue", $fieldvalue, $template_text);
}
}
- /* replace $domain_total_rows with total rows */
- $template_text = str_replace("$domain_total_rows", $row_helper_total_rows, $template_text);
+ /* replace $domain_total_rows with total rows */
+ $template_text = str_replace("$domain_total_rows", $row_helper_total_rows, $template_text);
- /* replace cr's */
- $template_text = str_replace("\\n", "\n", $template_text);
+ /* replace cr's */
+ $template_text = str_replace("\\n", "\n", $template_text);
- /* write out new template file */
- $fout = fopen($filename,"w");
- fwrite($fout, $template_text);
- fclose($fout);
- }
+ /* write out new template file */
+ $fout = fopen($filename,"w");
+ fwrite($fout, $template_text);
+ fclose($fout);
+ }
+ }
}
/* Return html div fields */
diff --git a/usr/local/www/pkg_mgr.php b/usr/local/www/pkg_mgr.php
index 9eab26c..8979a08 100644
--- a/usr/local/www/pkg_mgr.php
+++ b/usr/local/www/pkg_mgr.php
@@ -48,13 +48,14 @@ require_once("guiconfig.inc");
require_once("pkg-utils.inc");
$timezone = $config['system']['timezone'];
-if (!$timezone)
+if (!$timezone) {
$timezone = "Etc/UTC";
+}
date_default_timezone_set($timezone);
/* if upgrade in progress, alert user */
-if(is_subsystem_dirty('packagelock')) {
+if (is_subsystem_dirty('packagelock')) {
$pgtitle = array(gettext("System"),gettext("Package Manager"));
include("head.inc");
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
@@ -79,13 +80,13 @@ $xmlrpc_base_url = get_active_xml_rpc_base_url();
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
//create cache file after get_pkg_info
- if($pkg_info) {
+ if ($pkg_info) {
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
fwrite($fout, serialize($pkg_info));
fclose($fout);
} else {
$using_cache = true;
- if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
+ if (file_exists("{$g['tmp_path']}/pkg_info.cache")) {
$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
} else {
@@ -96,9 +97,11 @@ if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g[
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
}
-if (! empty($_GET))
- if (isset($_GET['ver']))
+if (!empty($_GET)) {
+ if (isset($_GET['ver'])) {
$requested_version = htmlspecialchars($_GET['ver']);
+ }
+}
$closehead = false;
$pgtitle = array(gettext("System"),gettext("Package Manager"));
@@ -117,15 +120,18 @@ include("head.inc");
include("fbegin.inc");
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
- if (!verify_all_package_servers())
+ if (!verify_all_package_servers()) {
print_info_box(package_server_mismatch_message());
+ }
/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
- if (check_package_server_ssl() === false)
+ if (check_package_server_ssl() === false) {
print_info_box(package_server_ssl_failure_message());
+ }
- if ($savemsg)
+ if ($savemsg) {
print_info_box($savemsg);
+ }
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
<tr><td>
@@ -141,14 +147,14 @@ include("head.inc");
<tr><td>
<?php
$version = rtrim(file_get_contents("/etc/version"));
- if($pkg_info) {
+ if ($pkg_info) {
$pkg_keys = array_keys($pkg_info);
natcasesort($pkg_keys);
//Check categories
$categories=array();
- if(is_array($pkg_keys)) {
- foreach($pkg_keys as $key) {
+ if (is_array($pkg_keys)) {
+ foreach ($pkg_keys as $key) {
$categories[$pkg_info[$key]['category']]++;
}
}
@@ -160,12 +166,13 @@ include("head.inc");
$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
/* check selected category or define default category to show */
- if (isset($_REQUEST['category']))
+ if (isset($_REQUEST['category'])) {
$menu_category = $_REQUEST['category'];
- else if (isset($g['pkg_default_category']))
+ } else if (isset($g['pkg_default_category'])) {
$menu_category = $g['pkg_default_category'];
- else
+ } else {
$menu_category = "All";
+ }
$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
$show_category = ($menu_category == "Other" || $menu_category == "All");
@@ -179,104 +186,115 @@ include("head.inc");
}
}
$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
- if (count($categories) > 1)
+ if (count($categories) > 1) {
display_top_tabs($tab_array);
+ }
}
?>
</td></tr>
- <tr><td>
- <div id="mainarea">
- <table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
- <tr><td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
+ <tr>
+ <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
<?php
- if ($show_category)
- print '<td width="18%" class="listhdr">'.gettext("Category").'</td>'."\n";
+ if ($show_category) {
+ print '<td width="18%" class="listhdr">'.gettext("Category").'</td>'."\n";
+ }
?>
- <td width="<?php print $show_category ? "15%" : "20%"; ?>" class="listhdr"><?=gettext("Status"); ?></td>
- <td width="<?php print $show_category ? "58%" : "70%"; ?>" class="listhdr"><?=gettext("Description"); ?></td>
- <td width="17">&nbsp;</td></tr>
+ <td width="<?php print $show_category ? "15%" : "20%"; ?>" class="listhdr"><?=gettext("Status"); ?></td>
+ <td width="<?php print $show_category ? "58%" : "70%"; ?>" class="listhdr"><?=gettext("Description"); ?></td>
+ <td width="17">&nbsp;</td>
+ </tr>
<?php
- if(!$pkg_info) {
- echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
- } else {
- if(is_array($pkg_keys)) {
- foreach($pkg_keys as $key):
- $index = &$pkg_info[$key];
- if(get_package_id($index['name']) >= 0 )
- continue;
+ if (!$pkg_info) {
+ echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
+ } else {
+ if (is_array($pkg_keys)) {
+ foreach ($pkg_keys as $key):
+ $index = &$pkg_info[$key];
+ if (get_package_id($index['name']) >= 0) {
+ continue;
+ }
- /* get history/changelog git dir */
- $commit_dir=explode("/",$index['config_file']);
- $changeloglink = "https://github.com/pfsense/pfsense-packages/commits/master/config/";
- if ($commit_dir[(count($commit_dir)-2)] == "config")
- $changeloglink .= $commit_dir[(count($commit_dir)-1)];
- else
- $changeloglink .= $commit_dir[(count($commit_dir)-2)];
+ /* get history/changelog git dir */
+ $commit_dir=explode("/",$index['config_file']);
+ $changeloglink = "https://github.com/pfsense/pfsense-packages/commits/master/config/";
+ if ($commit_dir[(count($commit_dir)-2)] == "config") {
+ $changeloglink .= $commit_dir[(count($commit_dir)-1)];
+ } else {
+ $changeloglink .= $commit_dir[(count($commit_dir)-2)];
+ }
- /* Check package info link */
- if($index['pkginfolink']) {
- $pkginfolink = $index['pkginfolink'];
- $pkginfo=gettext("Package info");
- } else {
- $pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
- $pkginfo=gettext("No package info, check the forum");
- }
+ /* Check package info link */
+ if ($index['pkginfolink']) {
+ $pkginfolink = $index['pkginfolink'];
+ $pkginfo=gettext("Package info");
+ } else {
+ $pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
+ $pkginfo=gettext("No package info, check the forum");
+ }
- if ($menu_category == "All" || $index['category'] == $menu_category || ($menu_category == "Other" && !in_array($index['category'],$visible_categories)) ):
+ if ($menu_category == "All" || $index['category'] == $menu_category || ($menu_category == "Other" && !in_array($index['category'],$visible_categories))):
?>
- <tr valign="top" class="<?= $index['category'] ?>">
+ <tr valign="top" class="<?= $index['category'] ?>">
<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
<a target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
</td>
<?php
- if ($show_category)
- print '<td class="listr">'.gettext($index['category']).'</td>'."\n";
+ if ($show_category) {
+ print '<td class="listr">'.gettext($index['category']).'</td>'."\n";
+ }
- if ($g['disablepackagehistory']) {
- print '<td class="listr">'."\n";
- } else {
- print '<td class="listr" ';
- domTT_title(gettext("Click ").ucfirst($index['name']).gettext(" version to check its change log."));
- print ">\n";
- }
+ if ($g['disablepackagehistory']) {
+ print '<td class="listr">'."\n";
+ } else {
+ print '<td class="listr" ';
+ domTT_title(gettext("Click ").ucfirst($index['name']).gettext(" version to check its change log."));
+ print ">\n";
+ }
- print "{$index['status']} <br />\n";
+ print "{$index['status']} <br />\n";
- if ($g['disablepackagehistory'])
- echo"<a>{$index['version']}</a>";
- else
- echo "<a target='_blank' href='{$changeloglink}'>{$index['version']}</a>";
+ if ($g['disablepackagehistory']) {
+ echo"<a>{$index['version']}</a>";
+ } else {
+ echo "<a target='_blank' href='{$changeloglink}'>{$index['version']}</a>";
+ }
?>
- <br />
- <?=gettext("platform") .": ". $index['required_version'] ?>
- <br />
- <?=$index['maximum_version'] ?>
+ <br />
+ <?=gettext("platform") .": ". $index['required_version'] ?>
+ <br />
+ <?=$index['maximum_version'] ?>
</td>
<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($index['name'])." package."))?>>
- <?= $index['descr'] ?>
+ <?= $index['descr'] ?>
<?php
- if (! $g['disablepackageinfo']):
+ if (!$g['disablepackageinfo']):
?>
<br /><br />
<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
<?php
- endif;
+ endif;
?>
</td>
<td valign="middle" class="list nowrap" width="17">
<a href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img <?=domTT_title(gettext("Install ".ucfirst($index['name'])." package."))?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a>
- </td></tr>
+ </td>
+ </tr>
<?php
- endif;
- endforeach;
- } else {
- echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
- } /* if(is_array($pkg_keys)) */
- } /* if(!$pkg_info) */
+ endif;
+ endforeach;
+ } else {
+ echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
+ } /* if (is_array($pkg_keys)) */
+ } /* if (!$pkg_info) */
?>
- </table>
- </div>
- </td></tr>
+ </table>
+ </div>
+ </td>
+ </tr>
</table>
<?php include("fend.inc"); ?>
</body>
diff --git a/usr/local/www/pkg_mgr_install.php b/usr/local/www/pkg_mgr_install.php
index 9c5b8b2..ceb4f75 100644
--- a/usr/local/www/pkg_mgr_install.php
+++ b/usr/local/www/pkg_mgr_install.php
@@ -5,7 +5,7 @@
part of pfSense (https://www.pfsense.org)
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
Copyright (C) 2004-2010 Scott Ullrich <sullrich@gmail.com>
- Copyright (C) 2005 Colin Smith
+ Copyright (C) 2005 Colin Smith
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -65,24 +65,24 @@ if ($_POST) {
}
} else if ($_GET) {
switch ($_GET['mode']) {
- case 'reinstallall':
- case 'showlog':
- break;
- case 'installedinfo':
- case 'reinstallxml':
- case 'reinstallpkg':
- case 'delete':
- if (empty($_GET['pkg'])) {
- header("Location: pkg_mgr_installed.php");
- return;
- }
- break;
- default:
- if (empty($_GET['id'])) {
- header("Location: pkg_mgr_installed.php");
- return;
- }
- break;
+ case 'reinstallall':
+ case 'showlog':
+ break;
+ case 'installedinfo':
+ case 'reinstallxml':
+ case 'reinstallpkg':
+ case 'delete':
+ if (empty($_GET['pkg'])) {
+ header("Location: pkg_mgr_installed.php");
+ return;
+ }
+ break;
+ default:
+ if (empty($_GET['id'])) {
+ header("Location: pkg_mgr_installed.php");
+ return;
+ }
+ break;
}
}
@@ -104,7 +104,8 @@ if ($_POST) {
?>
</td>
</tr>
-<?php if ((empty($_GET['mode']) && $_GET['id']) || (!empty($_GET['mode']) && (!empty($_GET['pkg']) || $_GET['mode'] == 'reinstallall') && ($_GET['mode'] != 'installedinfo' && $_GET['mode'] != 'showlog'))):
+<?php
+if ((empty($_GET['mode']) && $_GET['id']) || (!empty($_GET['mode']) && (!empty($_GET['pkg']) || $_GET['mode'] == 'reinstallall') && ($_GET['mode'] != 'installedinfo' && $_GET['mode'] != 'showlog'))):
if (empty($_GET['mode']) && $_GET['id']) {
$pkgname = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['id'], ENT_QUOTES | ENT_HTML401));
$pkgmode = 'installed';
@@ -115,20 +116,20 @@ if ($_POST) {
$pkgmode = 'reinstallall';
}
switch ($pkgmode) {
- case 'reinstallall':
- $pkgname = 'All packages';
- $pkgtxt = 'reinstalled';
- break;
- case 'reinstallxml':
- case 'reinstallpkg':
- $pkgtxt = 'reinstalled';
- break;
- case 'delete':
- $pkgtxt = 'deleted';
- break;
- default:
- $pkgtxt = $pkgmode;
- break;
+ case 'reinstallall':
+ $pkgname = 'All packages';
+ $pkgtxt = 'reinstalled';
+ break;
+ case 'reinstallxml':
+ case 'reinstallpkg':
+ $pkgtxt = 'reinstalled';
+ break;
+ case 'delete':
+ $pkgtxt = 'deleted';
+ break;
+ default:
+ $pkgtxt = $pkgmode;
+ break;
}
?>
<tr>
@@ -136,7 +137,7 @@ if ($_POST) {
<table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images">
<tr>
<td class="tabcont" align="center">Package: <b><?=$pkgname;?></b> will be <?=$pkgtxt;?>.<br/>
- Please confirm the action.<br/>
+ Please confirm the action.<br/>
</td>
<td class="tabcont" align="center">
<input type="hidden" name="id" value="<?=$pkgname;?>" />
@@ -148,7 +149,10 @@ if ($_POST) {
</table>
</td>
</tr>
-<?php endif; if (!empty($_POST['id']) || $_GET['mode'] == 'showlog' || ($_GET['mode'] == 'installedinfo' && !empty($_GET['pkg']))): ?>
+<?php
+endif;
+if (!empty($_POST['id']) || $_GET['mode'] == 'showlog' || ($_GET['mode'] == 'installedinfo' && !empty($_GET['pkg']))):
+?>
<tr>
<td class="tabcont" align="center">
<table style="height:15;colspacing:0" width="420" border="0" cellpadding="0" cellspacing="0" summary="images">
@@ -156,9 +160,11 @@ if ($_POST) {
<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_left.gif')" height="15" width="5"></td>
<td>
<table id="progholder" style="height:15;colspacing:0" width="410" border="0" cellpadding="0" cellspacing="0" summary="progress bar">
- <tr><td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
- <img src='./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif' width="0" height="15" name="progressbar" id="progressbar" alt="progress bar" />
- </td></tr>
+ <tr>
+ <td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_gray.gif')" valign="top" align="left">
+ <img src='./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif' width="0" height="15" name="progressbar" id="progressbar" alt="progress bar" />
+ </td>
+ </tr>
</table>
</td>
<td style="background:url('./themes/<?=$g['theme'];?>/images/misc/bar_right.gif')" height="15" width="5">
@@ -191,25 +197,27 @@ ob_flush();
if ($_GET) {
$pkgname = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_GET['pkg'], ENT_QUOTES | ENT_HTML401));
- switch($_GET['mode']) {
- case 'showlog':
- if (strpos($pkgname, ".")) {
- update_output_window(gettext("Something is wrong on the request."));
- } else if (file_exists("/tmp/pkg_mgr_{$pkgname}.log"))
- update_output_window(@file_get_contents("/tmp/pkg_mgr_{$pkgname}.log"));
- else
- update_output_window(gettext("Log was not retrievable."));
- break;
- case 'installedinfo':
- if (file_exists("/tmp/{$pkgname}.info")) {
- $status = @file_get_contents("/tmp/{$pkgname}.info");
- update_status("{$pkgname} " . gettext("installation completed."));
- update_output_window($status);
- } else
- update_output_window(sprintf(gettext("Could not find %s."), $pkgname));
- break;
- default:
- break;
+ switch ($_GET['mode']) {
+ case 'showlog':
+ if (strpos($pkgname, ".")) {
+ update_output_window(gettext("Something is wrong on the request."));
+ } else if (file_exists("/tmp/pkg_mgr_{$pkgname}.log")) {
+ update_output_window(@file_get_contents("/tmp/pkg_mgr_{$pkgname}.log"));
+ } else {
+ update_output_window(gettext("Log was not retrievable."));
+ }
+ break;
+ case 'installedinfo':
+ if (file_exists("/tmp/{$pkgname}.info")) {
+ $status = @file_get_contents("/tmp/{$pkgname}.info");
+ update_status("{$pkgname} " . gettext("installation completed."));
+ update_output_window($status);
+ } else {
+ update_output_window(sprintf(gettext("Could not find %s."), $pkgname));
+ }
+ break;
+ default:
+ break;
}
} else if ($_POST) {
$pkgid = str_replace(array("<", ">", ";", "&", "'", '"', '.', '/'), "", htmlspecialchars_decode($_POST['id'], ENT_QUOTES | ENT_HTML401));
@@ -250,11 +258,12 @@ if ($_GET) {
case 'reinstallall':
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['package'])) {
$todo = array();
- foreach($config['installedpackages']['package'] as $package)
+ foreach ($config['installedpackages']['package'] as $package) {
$todo[] = array('name' => $package['name'], 'version' => $package['version']);
- foreach($todo as $pkgtodo) {
+ }
+ foreach ($todo as $pkgtodo) {
$static_output = "";
- if($pkgtodo['name']) {
+ if ($pkgtodo['name']) {
update_output_window($static_output);
uninstall_package($pkgtodo['name']);
install_package($pkgtodo['name'], '', true);
@@ -265,13 +274,14 @@ if ($_GET) {
update_output_window($static_output);
filter_configure();
send_event("service restart packages");
- } else
+ } else {
update_output_window(gettext("No packages are installed."));
+ }
break;
case 'installed':
default:
$status = install_package($pkgid);
- if($status == -1) {
+ if ($status == -1) {
update_status(gettext("Installation of") . " {$pkgid} " . gettext("FAILED!"));
$static_output .= "\n" . gettext("Installation halted.");
update_output_window($static_output);
@@ -279,10 +289,11 @@ if ($_GET) {
$status_a = gettext(sprintf("Installation of %s completed.", $pkgid));
update_status($status_a);
$status = get_after_install_info($pkgid);
- if($status)
+ if ($status) {
$static_output .= "\n" . gettext("Installation completed.") . "\n{$pkgid} " . gettext("setup instructions") . ":\n{$status}";
- else
+ } else {
$static_output .= "\n" . gettext("Installation completed. Please check to make sure that the package is configured from the respective menu then start the package.");
+ }
@file_put_contents("/tmp/{$pkgid}.info", $static_output);
echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$pkgid}\";</script>";
@@ -296,8 +307,9 @@ if ($_GET) {
rmdir_recursive("/var/tmp/instmp*");
// close log
- if($fd_log)
+ if ($fd_log) {
fclose($fd_log);
+ }
/* Restore to read only fs */
conf_mount_ro();
diff --git a/usr/local/www/pkg_mgr_installed.php b/usr/local/www/pkg_mgr_installed.php
index cd86295..119df9c 100644
--- a/usr/local/www/pkg_mgr_installed.php
+++ b/usr/local/www/pkg_mgr_installed.php
@@ -1,31 +1,31 @@
<?php
/* $Id$ */
/*
- pkg_mgr_installed.php
- Copyright (C) 2013-2015 Electric Sheep Fencing, LP
- Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ pkg_mgr_installed.php
+ Copyright (C) 2013-2015 Electric Sheep Fencing, LP
+ Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_MODULE: pkgs
@@ -42,13 +42,14 @@ require_once("guiconfig.inc");
require_once("pkg-utils.inc");
$timezone = $config['system']['timezone'];
-if (!$timezone)
+if (!$timezone) {
$timezone = "Etc/UTC";
+}
date_default_timezone_set($timezone);
/* if upgrade in progress, alert user */
-if(is_subsystem_dirty('packagelock')) {
+if (is_subsystem_dirty('packagelock')) {
$pgtitle = array(gettext("System"),gettext("Package Manager"));
include("head.inc");
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
@@ -60,19 +61,20 @@ if(is_subsystem_dirty('packagelock')) {
exit;
}
-function domTT_title($title_msg, $return="echo"){
- if (!empty($title_msg)){
+function domTT_title($title_msg, $return="echo") {
+ if (!empty($title_msg)) {
$title_msg=preg_replace("/\s+/"," ",$title_msg);
- $title_msg=preg_replace("/'/","\'",$title_msg);
- $title= "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\"";
- if ($return =="echo")
- echo $title;
- else
- return $title;
+ $title_msg=preg_replace("/'/","\'",$title_msg);
+ $title= "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\"";
+ if ($return =="echo") {
+ echo $title;
+ } else {
+ return $title;
+ }
}
}
-if(is_array($config['installedpackages']['package'])) {
- foreach($config['installedpackages']['package'] as $instpkg) {
+if (is_array($config['installedpackages']['package'])) {
+ foreach ($config['installedpackages']['package'] as $instpkg) {
$tocheck[] = $instpkg['name'];
}
$currentvers = get_pkg_info($tocheck, array('version', 'xmlver', 'pkginfolink','descr'));
@@ -90,15 +92,18 @@ include("head.inc");
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
- <?php include("fbegin.inc");
+ <?php include("fbegin.inc");
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
- if (!verify_all_package_servers())
+ if (!verify_all_package_servers()) {
print_info_box(package_server_mismatch_message());
+ }
/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
- if (check_package_server_ssl() === false)
- print_info_box(package_server_ssl_failure_message()); ?>
+ if (check_package_server_ssl() === false) {
+ print_info_box(package_server_ssl_failure_message());
+ }
+?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="packages installed">
<tr>
@@ -127,10 +132,10 @@ include("head.inc");
<td width="40">&nbsp;</td>
</tr>
<?php
- if(is_array($config['installedpackages']['package'])):
+ if (is_array($config['installedpackages']['package'])):
$instpkgs = array();
- foreach($config['installedpackages']['package'] as $instpkg) {
+ foreach ($config['installedpackages']['package'] as $instpkg) {
$instpkgs[] = $instpkg['name'];
}
natcasesort($instpkgs);
@@ -138,62 +143,66 @@ include("head.inc");
foreach ($instpkgs as $index => $pkgname):
$pkg = $config['installedpackages']['package'][$index];
- if(!$pkg['name'])
+ if (!$pkg['name']) {
continue;
+ }
// get history/changelog git dir
$commit_dir=explode("/",$pkg['config_file']);
- $changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
+ $changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
#check package version
$latest_package = $currentvers[$pkg['name']]['version'];
if ($latest_package) {
// we're running a newer version of the package
- if(strcmp($pkg['version'], $latest_package) > 0) {
+ if (strcmp($pkg['version'], $latest_package) > 0) {
$tdclass = "listbggrey";
- if ($g['disablepackagehistory'])
+ if ($g['disablepackagehistory']) {
$pkgver = "<a>".gettext("Available") .": ". $latest_package . "<br />";
- else
+ } else {
$pkgver = "<a target='_blank' href='$changeloglink'>".gettext("Available") .": ". $latest_package . "<br />";
+ }
$pkgver .= gettext("Installed") .": ". $pkg['version']. "</a>";
}
// we're running an older version of the package
- if(strcmp($pkg['version'], $latest_package) < 0) {
+ if (strcmp($pkg['version'], $latest_package) < 0) {
$tdclass = "listbg";
- if ($g['disablepackagehistory'])
+ if ($g['disablepackagehistory']) {
$pkgver = "<a><font color='#ffffff'>" . gettext("Available") .": ". $latest_package . "</font><br />";
- else
+ } else {
$pkgver = "<a target='_blank' href='$changeloglink'><font color='#ffffff'>" . gettext("Available") .": ". $latest_package . "<br />";
+ }
$pkgver .= gettext("Installed") .": ". $pkg['version']."</font></a>";
}
// we're running the current version
- if(!strcmp($pkg['version'], $latest_package)) {
+ if (!strcmp($pkg['version'], $latest_package)) {
$tdclass = "listr";
- if ($g['disablepackagehistory'])
+ if ($g['disablepackagehistory']) {
$pkgver = "<a>{$pkg['version']}</a>";
- else
+ } else {
$pkgver = "<a target='_blank' href='$changeloglink'>{$pkg['version']}</a>";
+ }
}
$pkgdescr = $currentvers[$pkg['name']]['descr'];
} else {
// unknown available package version
$tdclass = "listbg";
- if ($g['disablepackagehistory'])
+ if ($g['disablepackagehistory']) {
$pkgver = "<a><font color='#ffffff'>" . gettext("Latest") .": ". gettext("N/A") . "</font><br />";
- else
+ } else {
$pkgver = "<a target='_blank' href='$changeloglink'><font color='#ffffff'>" . gettext("Latest") .": ". gettext("N/A") . "<br />";
+ }
$pkgver .= gettext("Installed") .": ". $pkg['version']."</font></a>";
$pkgdescr = $pkg['descr'];
}
/* Check package info link */
- if($pkg['pkginfolink']){
+ if ($pkg['pkginfolink']) {
$pkginfolink = $pkg['pkginfolink'];
$pkginfo=gettext("Package info");
- }
- else{
+ } else {
$pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
$pkginfo=gettext("No package info, check the forum");
- }
-
+ }
+
?>
<tr valign="top">
<td class="listlr">
@@ -202,17 +211,18 @@ include("head.inc");
<td class="listr">
<?=$pkg['category'];?>
</td>
- <?php
- if (isset($g['disablepackagehistory']))
- echo "<td class='{$tdclass}'>{$pkgver}</td>";
- else
- echo "<td class='{$tdclass}' ".domTT_title(gettext("Click on ".ucfirst($pkg['name'])." version to check its change log."),"return").">{$pkgver}</td>";
+ <?php
+ if (isset($g['disablepackagehistory'])) {
+ echo "<td class='{$tdclass}'>{$pkgver}</td>";
+ } else {
+ echo "<td class='{$tdclass}' ".domTT_title(gettext("Click on ".ucfirst($pkg['name'])." version to check its change log."),"return").">{$pkgver}</td>";
+ }
?>
<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($pkg['name'])." package."))?>>
- <?=$pkgdescr;?>
- <?php if (! $g['disablepackageinfo']): ?>
- <br /><br />
- <a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
+ <?=$pkgdescr;?>
+ <?php if (!$g['disablepackageinfo']): ?>
+ <br /><br />
+ <a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
<?php endif; ?>
</td>
<td valign="middle" class="list nowrap">
@@ -237,7 +247,9 @@ include("head.inc");
<?=gettext("There are no packages currently installed."); ?>
</td>
</tr>
- <?php endif; ?>
+ <?php
+ endif;
+ ?>
</table>
</div>
</td>
diff --git a/usr/local/www/pkg_mgr_settings.php b/usr/local/www/pkg_mgr_settings.php
index 0a7d004..39ef58c 100644
--- a/usr/local/www/pkg_mgr_settings.php
+++ b/usr/local/www/pkg_mgr_settings.php
@@ -48,7 +48,7 @@ require_once("pkg-utils.inc");
if ($_POST) {
if (!$input_errors) {
- if($_POST['alturlenable'] == "yes") {
+ if ($_POST['alturlenable'] == "yes") {
$config['system']['altpkgrepo']['enable'] = true;
$config['system']['altpkgrepo']['xmlrpcbaseurl'] = $_POST['pkgrepourl'];
} else {
@@ -81,18 +81,21 @@ function enable_altpkgrepourl(enable_over) {
<?php include("fbegin.inc");
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
- if (!verify_all_package_servers())
- print_info_box(package_server_mismatch_message());
+ if (!verify_all_package_servers()) {
+ print_info_box(package_server_mismatch_message());
+ }
/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
- if (check_package_server_ssl() === false)
- print_info_box(package_server_ssl_failure_message()); ?>
+ if (check_package_server_ssl() === false) {
+ print_info_box(package_server_ssl_failure_message());
+ }
+?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="pkg_mgr_settings.php" method="post" name="iform" id="iform">
- <?php if ($savemsg) print_info_box($savemsg); ?>
- <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager settings">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager settings">
<tr>
<td>
<?php
@@ -105,45 +108,56 @@ function enable_altpkgrepourl(enable_over) {
?>
</td>
</tr>
- <tr><td><div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
- <tr>
- <td colspan="2" valign="top" class="vncell">
- <?PHP echo gettext("This page allows an alternate package repository to be configured, primarily for temporary use as a testing mechanism."); ?>
- <?PHP echo gettext("The contents of unofficial packages servers cannot be verified and may contain malicious files."); ?>
- <?PHP echo gettext("The package server settings should remain at their default values to ensure that verifiable and trusted packages are recevied."); ?>
- <br/><br/>
- <?PHP echo gettext("A warning is printed on the Dashboard and in the package manager when an unofficial package server is in use."); ?>
- <br/><br/>
- </td>
- </tr>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?=gettext("Package Repository URL");?></td>
- </tr>
- <tr>
- <td valign="top" class="vncell"><?=gettext("Package Repository URL");?></td>
- <td class="vtable">
- <input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onclick="enable_altpkgrepourl()" <?php if(isset($curcfg['enable'])) echo "checked=\"checked\""; ?> /> <?=gettext("Use a non-official server for packages");?> <br />
- <table summary="alternative URL">
- <tr><td><?=gettext("Base URL:");?></td><td><input name="pkgrepourl" type="text" class="formfld url" id="pkgrepourl" size="64" value="<?php if($curcfg['xmlrpcbaseurl']) echo $curcfg['xmlrpcbaseurl']; else echo $g['']; ?>" /></td></tr>
- </table>
- <span class="vexpl">
- <?php printf(gettext("This is where %s will check for packages when the"),$g['product_name']);?> <a href="pkg_mgr.php"><?=gettext("System: Packages");?></a> <?=gettext("page is viewed.");?>
- </span>
- </td>
- </tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
+ <tr>
+ <td colspan="2" valign="top" class="vncell">
+ <?php echo gettext("This page allows an alternate package repository to be configured, primarily for temporary use as a testing mechanism."); ?>
+ <?php echo gettext("The contents of unofficial packages servers cannot be verified and may contain malicious files."); ?>
+ <?php echo gettext("The package server settings should remain at their default values to ensure that verifiable and trusted packages are recevied."); ?>
+ <br/><br/>
+ <?php echo gettext("A warning is printed on the Dashboard and in the package manager when an unofficial package server is in use."); ?>
+ <br/><br/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Package Repository URL");?></td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?=gettext("Package Repository URL");?></td>
+ <td class="vtable">
+ <input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onclick="enable_altpkgrepourl()" <?php if (isset($curcfg['enable'])) echo "checked=\"checked\""; ?> /> <?=gettext("Use a non-official server for packages");?> <br />
+ <table summary="alternative URL">
+ <tr>
+ <td><?=gettext("Base URL:");?></td>
+ <td>
+ <input name="pkgrepourl" type="text" class="formfld url" id="pkgrepourl" size="64" value="<?php if ($curcfg['xmlrpcbaseurl']) echo $curcfg['xmlrpcbaseurl']; else echo $g['']; ?>" />
+ </td>
+ </tr>
+ </table>
+ <span class="vexpl">
+ <?php printf(gettext("This is where %s will check for packages when the"),$g['product_name']);?> <a href="pkg_mgr.php"><?=gettext("System: Packages");?></a> <?=gettext("page is viewed.");?>
+ </span>
+ </td>
+ </tr>
<script type="text/javascript">
//<![CDATA[
enable_altpkgrepourl();
//]]>
</script>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
- </td>
- </tr>
- </table></div></td></tr></table>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
</form>
<?php include("fend.inc"); ?>
</body>
OpenPOWER on IntegriCloud