Move helper function to correct area

This commit is contained in:
Scott Ullrich 2006-09-22 14:39:57 +00:00
parent e7933a2bb4
commit 920cafaf0b
2 changed files with 25 additions and 25 deletions

View File

@ -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;
}
?>

View File

@ -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;
}
?>