summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjon Hortensius <sjon@hortensius.net>2015-04-04 14:00:35 +0200
committerSjon Hortensius <sjon@hortensius.net>2015-04-04 14:00:35 +0200
commit9a4f7ab0d172e42fd3d1981b1d073f7e4d507a59 (patch)
tree81a8f10316dabda47dc82026af53e2e6fb5aff7d
parent1a87ef92382e5285ee8ce16de724fedbe22dbce6 (diff)
downloadpfsense-9a4f7ab0d172e42fd3d1981b1d073f7e4d507a59.zip
pfsense-9a4f7ab0d172e42fd3d1981b1d073f7e4d507a59.tar.gz
Convert fw_alias_import, 2 minor bugfixes in other files
fixes #44
-rw-r--r--usr/local/www/firewall_aliases.php2
-rwxr-xr-xusr/local/www/firewall_aliases_edit.php1
-rwxr-xr-xusr/local/www/firewall_aliases_import.php116
3 files changed, 42 insertions, 77 deletions
diff --git a/usr/local/www/firewall_aliases.php b/usr/local/www/firewall_aliases.php
index fee3f43..07c902b 100644
--- a/usr/local/www/firewall_aliases.php
+++ b/usr/local/www/firewall_aliases.php
@@ -260,4 +260,4 @@ display_top_tabs($tab_array);
</div>
</div>
-<?php include("foot.inc")?> \ No newline at end of file
+<?php include("foot.inc"); \ No newline at end of file
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php
index 442a668..53fde9c 100755
--- a/usr/local/www/firewall_aliases_edit.php
+++ b/usr/local/www/firewall_aliases_edit.php
@@ -257,7 +257,6 @@ if ($_POST) {
// Users can paste strings like "10.1.2.0/24 10.3.0.0/16 9.10.11.0/24" into an address box.
// They can also put an IP range.
// This loop expands out that stuff so it can easily be validated.
-var_dump($_POST['address']);
foreach ($_POST['address'] as $idx => $post_address) {
if ($post_address != "") {
if ((strpos($post_address, "||") === false) && (substr($post_address, 0, 1) != "|") && (substr($post_address, -1, 1) != "|")) {
diff --git a/usr/local/www/firewall_aliases_import.php b/usr/local/www/firewall_aliases_import.php
index 40bdf20..3b6efb2 100755
--- a/usr/local/www/firewall_aliases_import.php
+++ b/usr/local/www/firewall_aliases_import.php
@@ -63,7 +63,7 @@ if (!is_array($config['aliases']['alias']))
$config['aliases']['alias'] = array();
$a_aliases = &$config['aliases']['alias'];
-if($_POST['aliasimport'] <> "") {
+if($_POST['aliasimport'] != "") {
$reqdfields = explode(" ", "name aliasimport");
$reqdfieldsn = array(gettext("Name"),gettext("Aliases"));
@@ -128,7 +128,7 @@ if($_POST['aliasimport'] <> "") {
else {
if (!$desc_len_err_found) {
/* Note: The 200 character limit is just a practical check to avoid accidents */
- /* if the user pastes a large number of IP addresses without line breaks. */
+ /* if the user pastes a large number of IP addresses without line breaks. */
$input_errors[] = gettext("Descriptions must be less than 200 characters long.");
$desc_len_err_found = true;
}
@@ -160,76 +160,42 @@ if($_POST['aliasimport'] <> "") {
include("head.inc");
-?>
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<div id="niftyOutter">
-<form action="firewall_aliases_import.php" method="post" name="iform" id="iform">
-<div id="inputerrors"></div>
-<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall alias import">
- <tr>
- <td colspan="2" valign="top" class="listtopic"><?=gettext("Alias Import"); ?></td>
- </tr>
- <tr>
- <td valign="top" class="vncellreq"><?=gettext("Alias Name"); ?></td>
- <td class="vtable">
- <input name="name" type="text" class="formfld unknown" id="name" size="40" maxlength="31" value="<?=htmlspecialchars($_POST['name']);?>" />
- <br />
- <span class="vexpl">
- <?=gettext("The name of the alias may only consist of the characters \"a-z, A-Z and 0-9\"."); ?>
- </span>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
- <td width="78%" class="vtable">
- <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($_POST['descr']);?>" />
- <br />
- <span class="vexpl">
- <?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
- </span>
- </td>
- </tr>
- <tr>
- <td valign="top" class="vncellreq"><?=gettext("Aliases to import"); ?></td>
- <td class="vtable">
- <textarea name="aliasimport" rows="15" cols="40"><?php echo $_POST['aliasimport']; ?></textarea>
- <br />
- <span class="vexpl">
- <?=gettext("Paste in the aliases to import separated by a carriage return. Common examples are lists of IPs, networks, blacklists, etc."); ?>
- <br />
- <?=gettext("The list may contain IP addresses, with or without CIDR prefix, IP ranges, blank lines (ignored) and an optional description after each IP. e.g.:"); ?>
- <br />172.16.1.2
- <br />172.16.0.0/24
- <br />10.11.12.100-10.11.12.200
- <br />192.168.1.254 Home router
- <br />10.20.0.0/16 Office network
- <br />10.40.1.10-10.40.1.19 Managed switches
- </span>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
- <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
- </td>
- </tr>
-</table>
-
-
-</form>
-</div>
-
-<?php include("fend.inc"); ?>
-
-<script type="text/javascript">
-//<![CDATA[
- NiftyCheck();
- Rounded("div#nifty","top","#FFF","#EEEEEE","smooth");
-//]]>
-</script>
-
-</body>
-</html>
+if ($input_errors)
+ print_input_errors($input_errors);
+
+require('classes/Form.class.php');
+$form = new Form;
+$section = new Form_Section('Alias details');
+
+$section->addInput(new Form_Input(
+ 'name',
+ 'Alias Name',
+ 'text',
+ $_POST['name']
+))->setPattern('[a-zA-Z0-9_]+')->setHelp('The name of the alias may only consist '.
+ 'of the characters "a-z, A-Z, 0-9 and _".');
+
+$section->addInput(new Form_Input(
+ 'descr',
+ 'Description',
+ 'text',
+ $_POST['descr']
+))->setHelp('You may enter a description here for your reference (not '.
+ 'parsed).');
+
+$section->addInput(new Form_Textarea(
+ 'aliasimport',
+ 'Aliases to import',
+ $_POST["aliasimport"]
+))->setHelp('Paste in the aliases to '.
+ 'import separated by a carriage return. Common examples are lists of IPs, '.
+ 'networks, blacklists, etc.The list may contain IP addresses, with or without '.
+ 'CIDR prefix, IP ranges, blank lines (ignored) and an optional description after '.
+ 'each IP. e.g.:<ul><li>172.16.1.2</li><li>172.16.0.0/24</li><li>10.11.12.100-'.
+ '10.11.12.200</li><li>192.168.1.254 Home router</li><li>10.20.0.0/16 Office '.
+ 'network</li><li>10.40.1.10-10.40.1.19 Managed switches</li></ul>');
+
+$form->add($section);
+print $form;
+
+include("foot.inc"); \ No newline at end of file
OpenPOWER on IntegriCloud