diff options
author | Bill Marquette <billm@pfsense.org> | 2005-05-15 22:35:06 +0000 |
---|---|---|
committer | Bill Marquette <billm@pfsense.org> | 2005-05-15 22:35:06 +0000 |
commit | 23a8ad04474bfdba690024314ccf2097b8ee754f (patch) | |
tree | c05d717299273613928d76fd072956d5d667a8d7 /usr/local/www/guiconfig.inc | |
parent | e2cb6b50972de11c26f8a6eb482e37893d65d526 (diff) | |
download | pfsense-23a8ad04474bfdba690024314ccf2097b8ee754f.zip pfsense-23a8ad04474bfdba690024314ccf2097b8ee754f.tar.gz |
Remove duplicate code
Diffstat (limited to 'usr/local/www/guiconfig.inc')
-rwxr-xr-x | usr/local/www/guiconfig.inc | 64 |
1 files changed, 64 insertions, 0 deletions
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; + } +} + ?> |