summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-05-15 22:35:06 +0000
committerBill Marquette <billm@pfsense.org>2005-05-15 22:35:06 +0000
commit23a8ad04474bfdba690024314ccf2097b8ee754f (patch)
treec05d717299273613928d76fd072956d5d667a8d7 /usr
parente2cb6b50972de11c26f8a6eb482e37893d65d526 (diff)
downloadpfsense-23a8ad04474bfdba690024314ccf2097b8ee754f.zip
pfsense-23a8ad04474bfdba690024314ccf2097b8ee754f.tar.gz
Remove duplicate code
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/firewall_rules_edit.php62
-rwxr-xr-xusr/local/www/firewall_shaper_edit.php51
-rwxr-xr-xusr/local/www/guiconfig.inc64
-rwxr-xr-xusr/local/www/vpn_ipsec_edit.php26
4 files changed, 65 insertions, 138 deletions
diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php
index d5e0100..02e9d05 100755
--- a/usr/local/www/firewall_rules_edit.php
+++ b/usr/local/www/firewall_rules_edit.php
@@ -63,68 +63,6 @@ function is_specialnet($net) {
return false;
}
-function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
-
- if (isset($adr['any']))
- $padr = "any";
- else if ($adr['network'])
- $padr = $adr['network'];
- else if ($adr['address']) {
- list($padr, $pmask) = explode("/", $adr['address']);
- if (!$pmask)
- $pmask = 32;
- }
-
- if (isset($adr['not']))
- $pnot = 1;
- else
- $pnot = 0;
-
- if ($adr['port']) {
- list($pbeginport, $pendport) = explode("-", $adr['port']);
- if (!$pendport)
- $pendport = $pbeginport;
- } else {
- if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
- /* Item is a port alias */
- } else {
- $pbeginport = "any";
- $pendport = "any";
- }
- }
-}
-
-function pconfig_to_address(&$adr, $padr, $pmask, $pnot, $pbeginport, $pendport) {
-
- $adr = array();
-
- if ($padr == "any")
- $adr['any'] = true;
- else if (is_specialnet($padr))
- $adr['network'] = $padr;
- else {
- $adr['address'] = $padr;
- if ($pmask != 32)
- $adr['address'] .= "/" . $pmask;
- }
-
- if ($pnot)
- $adr['not'] = true;
- else
- unset($addr['not']);
-
- if (($pbeginport != 0) && ($pbeginport != "any")) {
- if ($pbeginport != $pendport)
- $adr['port'] = $pbeginport . "-" . $pendport;
- else
- $adr['port'] = $pbeginport;
- }
-
- if(alias_expand($pbeginport)) {
- $adr['port'] = $pbeginport;
- }
-}
-
if (isset($id) && $a_filter[$id]) {
$pconfig['interface'] = $a_filter[$id]['interface'];
diff --git a/usr/local/www/firewall_shaper_edit.php b/usr/local/www/firewall_shaper_edit.php
index b3f6e02..059a6a9 100755
--- a/usr/local/www/firewall_shaper_edit.php
+++ b/usr/local/www/firewall_shaper_edit.php
@@ -61,57 +61,6 @@ function is_specialnet($net) {
return false;
}
-function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
-
- if (isset($adr['any']))
- $padr = "any";
- else if ($adr['network'])
- $padr = $adr['network'];
- else if ($adr['address']) {
- list($padr, $pmask) = explode("/", $adr['address']);
- if (!$pmask)
- $pmask = 32;
- }
-
- if (isset($adr['not']))
- $pnot = 1;
- else
- $pnot = 0;
-
- if ($adr['port']) {
- list($pbeginport, $pendport) = explode("-", $adr['port']);
- if (!$pendport)
- $pendport = $pbeginport;
- } else {
- $pbeginport = "any";
- $pendport = "any";
- }
-}
-
-function pconfig_to_address(&$adr, $padr, $pmask, $pnot, $pbeginport, $pendport) {
-
- $adr = array();
-
- if ($padr == "any")
- $adr['any'] = true;
- else if (is_specialnet($padr))
- $adr['network'] = $padr;
- else {
- $adr['address'] = $padr;
- if ($pmask != 32)
- $adr['address'] .= "/" . $pmask;
- }
-
- $adr['not'] = $pnot ? true : false;
-
- if (($pbeginport != 0) && ($pbeginport != "any")) {
- if ($pbeginport != $pendport)
- $adr['port'] = $pbeginport . "-" . $pendport;
- else
- $adr['port'] = $pbeginport;
- }
-}
-
if (isset($id) && $a_shaper[$id]) {
$pconfig['interface'] = $a_shaper[$id]['interface'];
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index 838f2eb..78b0f7c 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -611,4 +611,68 @@ function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url =
fwrite($fd_log, $pkgname . " " . print_r($pkgaddout, true) . "\n");
return true;
}
+
+function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
+
+ if (isset($adr['any']))
+ $padr = "any";
+ else if ($adr['network'])
+ $padr = $adr['network'];
+ else if ($adr['address']) {
+ list($padr, $pmask) = explode("/", $adr['address']);
+ if (!$pmask)
+ $pmask = 32;
+ }
+
+ if (isset($adr['not']))
+ $pnot = 1;
+ else
+ $pnot = 0;
+
+ if ($adr['port']) {
+ list($pbeginport, $pendport) = explode("-", $adr['port']);
+ if (!$pendport)
+ $pendport = $pbeginport;
+ } else {
+ if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
+ /* Item is a port alias */
+ } else {
+ $pbeginport = "any";
+ $pendport = "any";
+ }
+ }
+}
+
+
+function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
+
+ $adr = array();
+
+ if ($padr == "any")
+ $adr['any'] = true;
+ else if (is_specialnet($padr))
+ $adr['network'] = $padr;
+ else {
+ $adr['address'] = $padr;
+ if ($pmask != 32)
+ $adr['address'] .= "/" . $pmask;
+ }
+
+ if ($pnot)
+ $adr['not'] = true;
+ else
+ unset($addr['not']);
+
+ if (($pbeginport != 0) && ($pbeginport != "any")) {
+ if ($pbeginport != $pendport)
+ $adr['port'] = $pbeginport . "-" . $pendport;
+ else
+ $adr['port'] = $pbeginport;
+ }
+
+ if(alias_expand($pbeginport)) {
+ $adr['port'] = $pbeginport;
+ }
+}
+
?>
diff --git a/usr/local/www/vpn_ipsec_edit.php b/usr/local/www/vpn_ipsec_edit.php
index a0fecfb..b290bb9 100755
--- a/usr/local/www/vpn_ipsec_edit.php
+++ b/usr/local/www/vpn_ipsec_edit.php
@@ -54,30 +54,6 @@ function is_specialnet($net) {
return false;
}
-function address_to_pconfig($adr, &$padr, &$pmask) {
-
- if ($adr['network'])
- $padr = $adr['network'];
- else if ($adr['address']) {
- list($padr, $pmask) = explode("/", $adr['address']);
- if (is_null($pmask))
- $pmask = 32;
- }
-}
-
-function pconfig_to_address(&$adr, $padr, $pmask) {
-
- $adr = array();
-
- if (is_specialnet($padr))
- $adr['network'] = $padr;
- else {
- $adr['address'] = $padr;
- if ($pmask != 32)
- $adr['address'] .= "/" . $pmask;
- }
-}
-
if (isset($id) && $a_ipsec[$id]) {
$pconfig['disabled'] = isset($a_ipsec[$id]['disabled']);
$pconfig['auto'] = isset($a_ipsec[$id]['auto']);
@@ -86,7 +62,7 @@ if (isset($id) && $a_ipsec[$id]) {
if (!isset($a_ipsec[$id]['local-subnet']))
$pconfig['localnet'] = "lan";
else
- address_to_pconfig($a_ipsec[$id]['local-subnet'], $pconfig['localnet'], $pconfig['localnetmask']);
+ address_to_pconfig($a_ipsec[$id]['local-subnet'], $pconfig['localnet'], $pconfig['localnetmask'], null, null, null);
if ($a_ipsec[$id]['interface'])
$pconfig['interface'] = $a_ipsec[$id]['interface'];
OpenPOWER on IntegriCloud