From a4698195baff618dfa9f1c04d4461a1281521aa8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Aug 2009 23:53:44 +0300 Subject: Added support for automatically managing firewall rules with NAT rules. --- etc/inc/itemid.inc | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 etc/inc/itemid.inc 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 @@ + $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 -- cgit v1.1