From 24caf10492066fa2c36c7aa9def0bcb1f94e029a Mon Sep 17 00:00:00 2001 From: sullrich Date: Sat, 28 Nov 2009 18:43:09 -0500 Subject: Automatically select the last known vhid + 1 when creating new entries --- usr/local/www/firewall_virtual_ip_edit.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index c388842..260e557 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -68,6 +68,16 @@ function return_first_two_octets($ip) { return $ip_split[0] . "." . $ip_split[1]; } +function find_last_used_vhid() { + global $config, $g; + $vhid = 0; + foreach($config['virtualip']['vip'] as $vip) { + if($vip['vhid'] > $vhid) + $vhid = $vip['vhid']; + } + return $vhid; +} + if (isset($id) && $a_vip[$id]) { $pconfig['mode'] = $a_vip[$id]['mode']; $pconfig['vhid'] = $a_vip[$id]['vhid']; @@ -79,6 +89,10 @@ if (isset($id) && $a_vip[$id]) { $pconfig['descr'] = $a_vip[$id]['descr']; $pconfig['type'] = $a_vip[$id]['type']; $pconfig['interface'] = $a_vip[$id]['interface']; +} else { + $lastvhid = find_last_used_vhid(); + $lastvhid++; + $pconfig['vhid'] = $lastvhid; } if ($_POST) { -- cgit v1.1