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
*/
##|+PRIV
##|*IDENT=page-package-settings
##|*NAME=Package: Settings page
##|*DESCR=Allow access to the 'Package: Settings' page.
##|*MATCH=pkg.php*
##|-PRIV
require_once("guiconfig.inc");
require_once("pkg-utils.inc");
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 == "") {
print_info_box_np(gettext("ERROR: No package defined."));
exit;
} else {
$pkg_xml_prefix = "/usr/local/pkg/";
$pkg_full_path = "{$pkg_xml_prefix}/{$xml}";
$pkg_realpath = realpath($pkg_full_path);
if (empty($pkg_realpath)) {
$path_error = sprintf(gettext("ERROR: Package path %s not found."), htmlspecialchars($pkg_full_path));
} else if (substr_compare($pkg_realpath, $pkg_xml_prefix, 0, strlen($pkg_xml_prefix))) {
$path_error = sprintf(gettext("ERROR: Invalid path %s specified."), htmlspecialchars($pkg_full_path));
}
if (!empty($path_error)) {
print_info_box_np($path_error . "
" . gettext("Try reinstalling the package.") . "
" . gettext("Use the back button on your browser to return to the previous page."));
die;
}
if(file_exists($pkg_full_path))
$pkg = parse_xml_config_pkg($pkg_full_path, "packagegui");
else {
echo "File not found " . htmlspecialchars($xml);
exit;
}
}
if($pkg['donotsave'] <> "") {
header("Location: pkg_edit.php?xml=" . $xml);
exit;
}
if ($pkg['include_file'] != "") {
require_once($pkg['include_file']);
}
$package_name = $pkg['menu'][0]['name'];
$section = $pkg['menu'][0]['section'];
$config_path = $pkg['configpath'];
$title = $pkg['title'];
if($_REQUEST['startdisplayingat'])
$startdisplayingat = $_REQUEST['startdisplayingat'];
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 ($_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'])];
}
}
$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']);
}
header("Location: pkg.php?xml=" . $xml);
exit;
}
}
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'] <> "")
eval($pkg['custom_php_global_functions']);
if($pkg['custom_php_command_before_form'] <> "")
eval($pkg['custom_php_command_before_form']);
$pgtitle = array($title);
include("head.inc");
?>