diff options
author | unknown <lietu@.(none)> | 2009-08-14 23:53:44 +0300 |
---|---|---|
committer | unknown <lietu@.(none)> | 2009-08-14 23:53:44 +0300 |
commit | a4698195baff618dfa9f1c04d4461a1281521aa8 (patch) | |
tree | be88698559fd31dfda8c7257af7e4c078dc9f2dd /etc/inc | |
parent | 9568c1a1b8535f38e9eff3b393b5a4552d0335e1 (diff) | |
download | pfsense-a4698195baff618dfa9f1c04d4461a1281521aa8.zip pfsense-a4698195baff618dfa9f1c04d4461a1281521aa8.tar.gz |
Added support for automatically managing firewall rules with NAT rules.
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/itemid.inc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/etc/inc/itemid.inc b/etc/inc/itemid.inc new file mode 100644 index 0000000..c2ac4e1 --- /dev/null +++ b/etc/inc/itemid.inc @@ -0,0 +1,53 @@ +<?php + +/** +* Delete an item with ['id'] = $id from $array +* @param int The ID to delete +* @param array The list of items to search for the ID from +* @return boolean If the item was found or not +* @author Janne Enberg +*/ +function delete_id($id, &$array){ + // Index to delete + $delete_index = NULL; + + // Search for the item in the array + foreach ($array as $key => $item){ + // If this item is the one we want to delete + if(isset($item['id']) && $item['id']==$id ){ + $delete_index = $key; + break; + } + } + + // If we found the item, unset it + if( $delete_index!==NULL ){ + unset($array[$delete_index]); + return true; + } else { + return false; + } + +} + +/** +* Get the next available ID from an item list +* @param array The list of items to generate the ID for +* @return int The next available ID +* @author Janne Enberg +*/ +function get_next_id($array){ + // Default value + $next_id = 1; + + // Search for IDs + foreach ($array as $item){ + // If this item has an ID, and it's higher or equal to the current "next ID", use that + 1 as the next ID + if(isset($item['id']) && $item['id']>=$next_id ){ + $next_id = $item['id'] + 1; + } + } + return $next_id; +} + +?>
\ No newline at end of file |