summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2004-12-13 00:58:59 +0000
committerScott Ullrich <sullrich@pfsense.org>2004-12-13 00:58:59 +0000
commitd47013e119abaf3c29ff4f088ce6711fd48fb60e (patch)
treebcc35040e5c2edad7fb3d1404fd7be895cde64f8
parent8bcf4cd2628cf79b0433d406349c5babcf7a9062 (diff)
downloadpfsense-d47013e119abaf3c29ff4f088ce6711fd48fb60e.zip
pfsense-d47013e119abaf3c29ff4f088ce6711fd48fb60e.tar.gz
Say hello to the pkg_edit.php automated gui creation utility!
http://www.pfsense.com/screens/pkg_mgr.JPG http://www.pfsense.com/screens/pkg_edit.JPG
-rwxr-xr-xusr/local/www/pkg.php5
-rwxr-xr-xusr/local/www/pkg_edit.php132
2 files changed, 136 insertions, 1 deletions
diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php
index a4c00b5..5e31dcf 100755
--- a/usr/local/www/pkg.php
+++ b/usr/local/www/pkg.php
@@ -93,13 +93,16 @@ $config = $config_tmp;
<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>
+ </td>
</tr>
<?php
}
}
$i++;
?>
- <tr><td colspan=<?=$cols?></td><td><a href="pkg_add.php?xml=<?=$xml?>&id=<?=$i;?>"><img src="plus.gif" width="17" height="17" border="0"></a></td></tr>
+ <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>
</tr>
diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php
new file mode 100755
index 0000000..e5e6186
--- /dev/null
+++ b/usr/local/www/pkg_edit.php
@@ -0,0 +1,132 @@
+#!/usr/local/bin/php
+<?php
+/*
+ pkg_edit.php
+ Copyright (C) 2004 Scott Ullrich
+ 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.
+*/
+
+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;
+}
+
+// XXX: Make this input safe.
+$xml = $_GET['xml'];
+
+if($xml == "") {
+ $xml = "not_defined";
+ print_info_box_np("ERROR: Could not open " . $xml . ".");
+ die;
+} else {
+ $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 . ": Edit " . $package_name
+
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title><?=gentitle_pkg($title);?></title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link href="gui.css" rel="stylesheet" type="text/css">
+</head>
+
+<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">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+
+<table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <?php
+ $cols = 0;
+ foreach ($pkg['fields']['field'] as $pkg) { ?>
+ </tr>
+ <tr valign="top">
+ <td width="22%" class="vncellreq">
+ <?= $pkg['fielddescr'] ?>
+ </td>
+ <td class="vtable">
+ <?php
+ if($pkg['type'] == "input") {
+ // XXX: TODO: set $value
+ echo "<input name='" . $pkg['fieldname'] . "' value='" . $value . "'>\n";
+ echo "<br>" . $pkg['description'] . "\n";
+ } else if($pkg['type'] == "select") {
+ // XXX: TODO: set $selected
+ if($pkg['size']) $size = " size='" . $pkg['size'] . "' ";
+ if($pkg['multiple'] == "yes") $multiple = "MULTIPLE ";
+ echo "<select " . $multiple . $size . "id='" . $pkg['fieldname'] . "' name='" . $pkg['fieldname'] . "'>\n";
+ foreach ($pkg['options']['option'] as $opt) {
+ echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'>" . $opt['name'] . "</option>\n";
+ }
+ echo "</select>\n";
+ echo "<br>" . $pkg['description'] . "\n";
+ } else if($pkg['type'] == "checkbox") {
+ echo "<input type='checkbox' name='" . $pkg['fieldname'] . "' value='" . $value . "'>\n";
+ echo "<br>" . $pkg['description'] . "\n";
+ } else if($pkg['type'] == "textarea") {
+ echo "<textarea name='" . $pkg['fieldname'] . "'>" . $value . "</textarea>\n";
+ echo "<br>" . $pkg['description'] . "\n";
+ }
+ ?>
+ </td>
+ </tr>
+ <?php
+ $i++;
+ }
+ ?>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save">
+ <?php if (isset($id) && $a_pkg[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+</table>
+
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
+
OpenPOWER on IntegriCloud