From 920cafaf0b7ab5116a683fe05a8e70ac0b2bef01 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 22 Sep 2006 14:39:57 +0000 Subject: [PATCH] Move helper function to correct area --- etc/inc/captiveportal.inc | 25 +++++++++++++++++++++++++ usr/local/captiveportal/index.php | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index e09a027b3a..1c44870756 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -940,4 +940,29 @@ function captiveportal_write_elements() { return 0; } +/* + * This function will calculate the lowest free firewall ruleno + * within the range specified based on the actual installed rules + * + */ + +function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000, $rulenos_range_max = 9899) { + + exec("/sbin/ipfw show", $fwrules); + foreach ($fwrules as $fwrule) { + preg_match("/^(\d+)\s+/", $fwrule, $matches); + $rulenos_used[] = $matches[1]; + } + $rulenos_used = array_unique($rulenos_used); + $rulenos_range = count($rulenos_used); + if ($rulenos_range > $rulenos_range_max) { + return NULL; + } + $rulenos_pool = range($rulenos_start, ($rulenos_start + $rulenos_range)); + $rulenos_free = array_diff($rulenos_pool, $rulenos_used); + $ruleno = array_shift($rulenos_free); + + return $ruleno; +} + ?> \ No newline at end of file diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php index c74e5936b7..b6b76599c5 100755 --- a/usr/local/captiveportal/index.php +++ b/usr/local/captiveportal/index.php @@ -430,29 +430,4 @@ function disconnect_client($sessionid, $logoutReason = "LOGOUT", $term_cause = 1 captiveportal_unlock(); } -/* - * This function will calculate the lowest free firewall ruleno - * within the range specified based on the actual installed rules - * - */ - -function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000, $rulenos_range_max = 9899) { - - exec("/sbin/ipfw show", $fwrules); - foreach ($fwrules as $fwrule) { - preg_match("/^(\d+)\s+/", $fwrule, $matches); - $rulenos_used[] = $matches[1]; - } - $rulenos_used = array_unique($rulenos_used); - $rulenos_range = count($rulenos_used); - if ($rulenos_range > $rulenos_range_max) { - return NULL; - } - $rulenos_pool = range($rulenos_start, ($rulenos_start + $rulenos_range)); - $rulenos_free = array_diff($rulenos_pool, $rulenos_used); - $ruleno = array_shift($rulenos_free); - - return $ruleno; -} - ?> \ No newline at end of file