From fbd14b138290cbec77cd61ea04e0af31a1d8d599 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 7 Jun 2006 19:17:16 +0000 Subject: MFC more needed package improvements --- usr/local/www/pkg_edit.php | 217 ++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 122 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php index b4b2ae7..21823bf 100755 --- a/usr/local/www/pkg_edit.php +++ b/usr/local/www/pkg_edit.php @@ -30,10 +30,6 @@ require_once("guiconfig.inc"); require_once("pkg-utils.inc"); -function gettext($text) { - return $text; -} - function gentitle_pkg($pgname) { global $pfSense_config; return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname; @@ -74,8 +70,6 @@ if($pkg['custom_php_global_functions'] <> "") eval($pkg['custom_php_global_functions']); // grab the installedpackages->package_name section. -$a_pkg = &$config['installedpackages'][$name]['config']; - if(!is_array($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'])) $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'] = array(); @@ -109,8 +103,7 @@ if ($_POST) { -

- "; eval($pkg['custom_add_php_command']); @@ -162,22 +155,15 @@ if ($_POST) { } } } else { - // simply loop through all field names looking for posted - // values matching the fieldnames. if found, save to package - // configuration area. - if(is_array( $_POST[$fields['fieldname']] )) { - $pkgarr[$fields['fieldname']]=array(); - foreach($_POST[$fields['fieldname']] as $v) { - $pkgarr[$fields['fieldname']][] = trim($v); - eval($comd); - } - continue; - } $fieldname = $fields['fieldname']; - if ($fields['encoding'] == 'base64') - $fieldvalue = base64_encode(trim($_POST[$fieldname])); - else - $fieldvalue = trim($_POST[$fieldname]); + $fieldvalue = $_POST[$fieldname]; + if (is_array($fieldvalue)) + $fieldvalue = implode(',', $fieldvalue); + else { + $fieldvalue = trim($fieldvalue); + if ($fields['encoding'] == 'base64') + $fieldvalue = base64_encode($fieldvalue); + } $pkgarr[$fieldname] = $fieldvalue; } } @@ -210,11 +196,11 @@ if ($_POST) { exec($pkg['restart_command'] . ">/dev/null 2&>1"); if($pkg['aftersaveredirect'] <> "") { - header("Location: " . $pkg['aftersaveredirect']); + pfSenseHeader($pkg['aftersaveredirect']); } elseif(!$pkg['adddeleteeditpagefields']) { - header("Location: pkg_edit.php?xml={$xml}&id=0"); + pfSenseHeader("pkg_edit.php?xml={$xml}&id=0"); } elseif(!$pkg['preoutput']) { - header("Location: pkg.php?xml=" . $xml); + pfSenseHeader("pkg.php?xml=" . $xml); } exit; } @@ -243,39 +229,35 @@ if ($pkg['custom_php_after_head_command']) @@ -285,9 +267,10 @@ function enablechange() { -

+ + @@ -344,8 +327,10 @@ if ($pkg['tabs'] <> "") { echo "
"; // if user is editing a record, load in the data. $fieldname = $pkga['fieldname']; - if ($get_from_post) + if ($get_from_post) { $value = $_POST[$fieldname]; + if (is_array($value)) $value = implode(',', $value); + } else { if (isset($id) && $a_pkg[$id]) $value = $a_pkg[$id][$fieldname]; @@ -361,18 +346,27 @@ if ($pkg['tabs'] <> "") { echo "\n"; echo "
" . fixup_string($pkga['description']) . "\n"; } else if($pkga['type'] == "select") { - $multiple = ""; - if($pkga['size']) $size = " size='" . $pkga['size'] . "' "; - if($pkga['multiple'] == "yes") $multiple = 'multiple="MULTIPLE" '; - if ($pkga['onchange']) $onchange = 'onchange="' . $pkga['onchange'] . '" '; - echo "\n"; - echo "
" . fixup_string($pkga['description']) . "\n"; + $fieldname = $pkga['fieldname']; + if (isset($pkga['multiple'])) { + $multiple = 'multiple'; + $fieldname .= '[]'; + $items = explode(',', $value); + } + else { + $multiple = ''; + $items = array($value); + } + $size = (isset($pkga['size']) ? "size=\"{$pkga['size']}\"" : ''); + $onchange = (isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : ''); + + print("\n
\n" . fixup_string($pkga['description']) . "\n"); } else if($pkga['type'] == "vpn_selection") { echo "\n"; echo "
" . fixup_string($pkga['description']) . "\n"; } else if($pkga['type'] == "interfaces_selection") { - $size = ""; - $multiple = ""; + $size = ($pkga['size'] ? "size=\"{$pkga['size']}\"" : ''); + $multiple = ''; $fieldname = $pkga['fieldname']; - if($pkga['size'] <> "") $size = " size=\"" . $pkga['size'] . "\""; - if($pkga['multiple'] <> "" and $pkga['multiple'] <> "0") { - $multiple = ' multiple="MULTIPLE" '; - $fieldname .= "[]"; - } - echo "\n"); + + if (isset($pkga['all_interfaces'])) + $ifaces = explode(' ', trim(shell_exec('ifconfig -l'))); + else + $ifaces = $config['interfaces']; + + $additional_ifaces = $pkga['add_to_interfaces_selection']; + if (!empty($additional_ifaces)) + $ifaces = array_merge($ifaces, explode(',', $additional_ifaces)); + + $values = explode(',', $value); + foreach($ifaces as $ifname => $iface) { + if (isset($iface['descr'])) + $ifdescr = $iface['descr']; + else + $ifdescr = strtoupper($ifname); + if ($ip = find_interface_ip($iface)) + $ip = " ($ip)"; + $selected = (in_array($ifname, $values) ? 'selected' : ''); + print("\n"); } - echo "\n
" . fixup_string($pkga['description']) . "\n"; + + print("\n
" . fixup_string($pkga['description']) . "\n"); } else if($pkga['type'] == "radio") { echo ""; } else if($pkga['type'] == "rowhelper") { -- cgit v1.1