r5050 bugfix: IPV4_AUTO_RELEASE config var was not working since 0.19.11
authorAlexey Andriyanov <alan@al-an.info>
Mon, 16 Apr 2012 15:59:42 +0000 (15:59 +0000)
committerAlexey Andriyanov <alan@al-an.info>
Mon, 16 Apr 2012 15:59:42 +0000 (15:59 +0000)
maintenance functions:
bindIpToObject: IPV4_AUTO_RELEASE-related code moved here from ophandler
bindIPv6ToObject: idem
addIPv4Allocation: IPV4_AUTO_RELEASE-related code moved into database.php
addIPv6Allocation: idem

trunk functions:
bindIPToObject: IPV4_AUTO_RELEASE-related code moved here from ophandler
addIPAllocation: IPV4_AUTO_RELEASE-related code moved into database.php

ChangeLog
wwwroot/inc/database.php
wwwroot/inc/ophandlers.php

index 82478fd1e3f1d8dda763dff9c661842c981125f1..b1816eedb6a10c88bf3ae9bcf0681ab4c61cfeb8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
        new feature: IPv6 SLB support
 0.19.13
        update: IE spoils JPEG uploads, work around
+       bugfix: IPV4_AUTO_RELEASE config var was not working since 0.19.11
 0.19.12 2012-04-12
        bugfix: Could not delete objects' log entries
        new feature: initial D-Link and Linux gateway support by Ilya Evseev
index bc585bca7ce3e0055c4ffd17ceb28046abc270af..8844162e3da29b28109c812b109bbe564fe5c9c6 100644 (file)
@@ -2004,13 +2004,23 @@ function bindIPToObject ($ip_bin, $object_id = 0, $name = '', $type = '')
                case 4:
                        $db_ip = ip4_bin2db ($ip_bin);
                        $table = 'IPv4Allocation';
+                       $table2 = 'IPv4Address';
                        break;
                case 16:
                        $db_ip = $ip_bin;
                        $table = 'IPv6Allocation';
+                       $table2 = 'IPv6Address';
                        break;
                default: throw new InvalidArgException ('ip_bin', $ip_bin, "Invalid binary IP");
        }
+
+       // release IP reservation and/or comment if configured
+       $release = getConfigVar ('IPV4_AUTO_RELEASE');
+       if ($release >= 2)
+               usePreparedExecuteBlade ("DELETE FROM $table2 WHERE ip = ?", array ($db_ip));
+       elseif ($release >= 1)
+               usePreparedExecuteBlade ("UPDATE $table2 SET reserved = 'no' WHERE ip = ?", array ($db_ip));
+
        usePreparedInsertBlade
        (
                $table,
index c2c131355e99253af3930a2e6ba5ff99ffdae67d..461805bebfdb29aca1d736e090dd8f5310861ff0 100644 (file)
@@ -750,16 +750,7 @@ function addIPAllocation ()
                return showFuncMessage (__FUNCTION__, 'ERR1', array (ip_format ($ip_bin)));
 
        bindIPToObject ($ip_bin, $_REQUEST['object_id'], $_REQUEST['bond_name'], $_REQUEST['bond_type']);
-       $address = getIPAddress ($ip_bin);
-       if ($address['reserved'] == 'yes' or strlen ($address['name']))
-       {
-               $release = getConfigVar ('IPV4_AUTO_RELEASE');
-               if ($release >= 1)
-                       $address['reserved'] = 'no';
-               if ($release >= 2)
-                       $address['name'] = '';
-               updateAddress ($ip_bin, $address['name'], $address['reserved']);
-       }
+
        showFuncMessage (__FUNCTION__, 'OK');
        return buildRedirectURL (NULL, NULL, array ('hl_ip' => ip_format ($ip_bin)));
 }