From e3c4b6b767d3610774a2be78d4389908ede98807 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 21 Dec 2004 01:46:29 +0000 Subject: Finish packaging storage mechanism. Upon package deletin the package manager will loop through the variables and set them so that you can invoke commands such as system("pw userdel " . $username); from the xml configuration file. --- usr/local/www/firewall_rules_edit.php | 18 ++++---- usr/local/www/pkg.php | 83 +++++++++++++++++++++++------------ usr/local/www/pkg_edit.php | 77 ++++++-------------------------- 3 files changed, 79 insertions(+), 99 deletions(-) (limited to 'usr') diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php index 21186eb..4eaba1b 100755 --- a/usr/local/www/firewall_rules_edit.php +++ b/usr/local/www/firewall_rules_edit.php @@ -322,6 +322,14 @@ if ($_POST) { $filterent['frags'] = $_POST['frags'] ? true : false; $filterent['descr'] = $_POST['descr']; + /* ALTQ */ + $filterent['direction'] = $_POST['direction']; + $filterent['queue'] = $_POST['queue']; + + /* Advanced options */ + $filterent['max-src-nodes'] = $_POST['max-src-nodes']; + $filterent['max-src-states'] = $_POST['max-src-states']; + if (isset($id) && $a_filter[$id]) $a_filter[$id] = $filterent; else { @@ -331,14 +339,6 @@ if ($_POST) { $a_filter[] = $filterent; } - /* ALTQ */ - $filterent['direction'] = $_POST['direction']; - $filterent['queue'] = $_POST['queue']; - - /* Advanced options */ - $filterent['max-src-nodes'] = $_POST['max-src-nodes']; - $filterent['max-src-states'] = $_POST['max-src-states']; - write_config(); touch($d_filterconfdirty_path); @@ -652,7 +652,7 @@ function dst_rep_change() { - Specify the port or port range for + Specify the port or port range for the source of the packet for this rule. This is usually not equal to the destination port range (and is often "any").
Hint: you can leave the 'to' field empty if you only want to filter a single port
diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php index 5e31dcf..c725704 100755 --- a/usr/local/www/pkg.php +++ b/usr/local/www/pkg.php @@ -30,12 +30,9 @@ require("guiconfig.inc"); require("xmlparse_pkg.inc"); -$pfSense_config = $config; // copy this since we will be parsing - // another xml file which will be clobbered. - function gentitle_pkg($pgname) { - global $pfSense_config; - return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname; + global $config; + return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname; } $xml = $_GET['xml']; @@ -45,13 +42,42 @@ if($xml == "") { print_info_box_np("ERROR: Could not open " . $xml . "."); die; } else { - $pkg = parse_xml_config("/usr/local/pkg/" . $xml, "packagegui"); + $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui"); } $package_name = $pkg['menu']['name']; $section = $pkg['menu']['section']; $config_path = $pkg['configpath']; -$title = $section . ": " . $package_name +$title = $section . ": " . $package_name; + +$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];"; +eval($toeval); + +if ($_GET['act'] == "del") { + foreach ($evaledvar as $ip) { + foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) { + $toeval = "\$" . xml_safe_fieldname($column['fielddescr']) . " = " . "\$ip['" . xml_safe_fieldname($column['fieldname']) . "'];"; + eval($toeval); + } + } + + $toeval = "\$a_pkg = &\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];"; + eval($toeval); + + if ($a_pkg[$_GET['id']]) { + if($pkg['custom_delete_php_command'] <> "") { + eval($pkg['custom_delete_php_command']); + } + + unset($a_pkg[$_GET['id']]); + write_config(); + header("Location: pkg.php?xml=" . $xml); + exit; + } +} + +$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];"; +eval($toeval); ?> @@ -64,10 +90,7 @@ $title = $section . ": " . $package_name

@@ -84,24 +107,30 @@ $config = $config_tmp; $cols++; } echo ""; - if($pfSense_config[$config_path]['item']) { - foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) { ?> - - - XXX: TODO - - -   - - - + $i=0; + if($evaledvar) + foreach ($evaledvar as $ip) { + echo "\n"; + foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) { + ?> + + + + + +   - - + \n"; + $i++; + } + ?> + diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php index 628eca6..1d3ed5a 100755 --- a/usr/local/www/pkg_edit.php +++ b/usr/local/www/pkg_edit.php @@ -59,93 +59,44 @@ $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; -$toeval = "\$a_pkg = &\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];"; +$toeval = "if (!is_array(\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'])) \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'] = array();"; eval($toeval); -if (isset($id) && $a_pkg[$id]) { - foreach ($pkg['fields'] as $fields) { - $fieldname = $fields['fieldname']; - $fieldvalue = $fields[$_POST[$fieldname]]; - $toeval = "\$pconfig[" . $fieldname . "] = \"" . $fieldvalue . "\";"; - //echo $toeval . "\n"; - //eval($toeval); - } -} +$toeval = "\$a_pkg = &\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];"; +eval($toeval); if ($_POST) { if($_POST['act'] == "del") { if($pkg['custom_delete_php_command']) { eval($pkg['custom_delete_php_command']); } + write_config(); } else { if($pkg['custom_add_php_command']) { eval($pkg['custom_add_php_command']); } } - + // store values in xml configration file. if (!$input_errors) { $pkgarr = array(); - - /* - if (isset($id) && $a_pkg[$id]) - $pkgarr[$id] = $pkgarr; - else - $pkgarr[] = $pkgarr; - */ - + foreach ($pkg['fields']['field'] as $fields) { $fieldname = $fields['fieldname']; $fieldvalue = $_POST[$fieldname]; $toeval = "\$pkgarr['" . $fieldname . "'] = \"" . $fieldvalue . "\";"; - //echo $toeval . "\n"; eval($toeval); - } - - //$toeval = "\$config['installedpackages']['package']['" . $pkg['name'] . "']['config'][] = \$pkgarr;"; - $toeval = "\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'] = \$pkgarr;"; - echo $toeval; - eval($toeval); - + + if (isset($id) && $a_pkg[$id]) + $a_pkg[$id] = $pkgarr; + else + $a_pkg[] = $pkgarr; + write_config(); - } -} -function xml_safe_fieldname($fieldname) { - $fieldname = str_replace("/","",$fieldname); - $fieldname = str_replace("-","",$fieldname); - $fieldname = str_replace(" ","",$fieldname); - $fieldname = str_replace("!","",$fieldname); - $fieldname = str_replace("@","",$fieldname); - $fieldname = str_replace("#","",$fieldname); - $fieldname = str_replace("$","",$fieldname); - $fieldname = str_replace("%","",$fieldname); - $fieldname = str_replace("^","",$fieldname); - $fieldname = str_replace("&","",$fieldname); - $fieldname = str_replace("*","",$fieldname); - $fieldname = str_replace("(","",$fieldname); - $fieldname = str_replace(")","",$fieldname); - $fieldname = str_replace("_","",$fieldname); - $fieldname = str_replace("+","",$fieldname); - $fieldname = str_replace("=","",$fieldname); - $fieldname = str_replace("{","",$fieldname); - $fieldname = str_replace("}","",$fieldname); - $fieldname = str_replace("[","",$fieldname); - $fieldname = str_replace("]","",$fieldname); - $fieldname = str_replace("|","",$fieldname); - $fieldname = str_replace("\\","",$fieldname); - $fieldname = str_replace("/","",$fieldname); - $fieldname = str_replace("<","",$fieldname); - $fieldname = str_replace(">","",$fieldname); - $fieldname = str_replace("?","",$fieldname); - $fieldname = str_replace(":","",$fieldname); - $fieldname = str_replace(",","",$fieldname); - $fieldname = str_replace(".","",$fieldname); - $fieldname = str_replace("'","",$fieldname); - $fieldname = str_replace("\"","",$fieldname); - $fieldname = strtolower($fieldname); - return $fieldname; + header("Location: pkg.php?xml=" . $xml); + } } ?> -- cgit v1.1