summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2004-12-21 01:46:29 +0000
committerScott Ullrich <sullrich@pfsense.org>2004-12-21 01:46:29 +0000
commite3c4b6b767d3610774a2be78d4389908ede98807 (patch)
treeb67350133467b1e9cccbfaa812d0591536d88ffd /usr
parent98bbf05a82a4b45c1a37542979310c22c4ba17a1 (diff)
downloadpfsense-e3c4b6b767d3610774a2be78d4389908ede98807.zip
pfsense-e3c4b6b767d3610774a2be78d4389908ede98807.tar.gz
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.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/firewall_rules_edit.php18
-rwxr-xr-xusr/local/www/pkg.php83
-rwxr-xr-xusr/local/www/pkg_edit.php77
3 files changed, 79 insertions, 99 deletions
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() {
</select> <input name="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>"></td>
</tr>
</table>
- <span class="vexpl">Specify the port or port range for
+ <span class="vexpl">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 &quot;any&quot;). <br>
Hint: you can leave the <em>'to'</em> field empty if you only
want to filter a single port</span></td>
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);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -64,10 +90,7 @@ $title = $section . ": " . $package_name
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php
-$config_tmp = $config;
-$config = $pfSense_config;
include("fbegin.inc");
-$config = $config_tmp;
?>
<p class="pgtitle"><?=$title?></p>
<form action="firewall_nat_out_load_balancing.php" method="post">
@@ -84,24 +107,30 @@ $config = $config_tmp;
$cols++;
}
echo "</tr>";
- if($pfSense_config[$config_path]['item']) {
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) { ?>
- <tr valign="top">
- <td class="listlr">
- XXX: TODO
- </td>
- <td valign="middle" class="list" nowrap>
- &nbsp;<a href="pkg_del.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this item?')"><img src="x.gif" width="17" height="17" border="0"></a>
- </td>
- <td>
- <a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>"><img src="plus.gif" width="17" height="17" border="0"></a>
+ $i=0;
+ if($evaledvar)
+ foreach ($evaledvar as $ip) {
+ echo "<tr valign=\"top\">\n";
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ ?>
+ <td class="listlr">
+ <?php
+ $toeval="echo \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
+ eval($toeval);
+ ?>
+ </td>
+ <?php
+ }
+ ?>
+ <td valign="middle" class="list" nowrap>
+ &nbsp;<a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this item?')"><img src="x.gif" width="17" height="17" border="0"></a>
</td>
- </tr>
- <?php
- }
- }
- $i++;
- ?>
+ <?php
+ echo "</tr>\n";
+ $i++;
+ }
+ ?>
+
<tr><td colspan="<?=$cols?>"></td><td><a href="pkg_edit.php?xml=<?=$xml?>"><img src="plus.gif" width="17" height="17" border="0"></a></td></tr>
</table>
</td>
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);
+ }
}
?>
OpenPOWER on IntegriCloud