r2240 - fix scanIPv4Space() to load NAT rules correctly (ticket:176)
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 14 Oct 2008 07:31:15 +0000 (07:31 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 14 Oct 2008 07:31:15 +0000 (07:31 +0000)
ChangeLog
inc/database.php

index 2942ca150adc9094ea48a8d2a4da07d592e32b6c..d035904920c222f425630530eaee2fab3e2f2908 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 0.16.4
        bugfix: display VS/RS config block in RS pool view
        bugfix: fix a minor, but long-standing tabindex issue in forms
+       bugfix: NAT rules were not displayed for IP address
        update: enable user search by real name
        update: allow empty names for IPv4 networks
 0.16.3 2008-10-02
index 9a31dfbc8a3416490c0d5feb95e600488e4db421..673002a95c8111e692981b5921acb1d45b9b5bca 100644 (file)
@@ -1074,27 +1074,38 @@ function scanIPv4Space ($pairlist)
                "remoteport, " .
                "description " .
                "from PortForwarding " .
-               "where ${whereexpr5a} or " .
-               "${whereexpr5b} " .
+               "where ${whereexpr5a} " .
                "order by localip, localport, remoteip, remoteport, proto";
        $result = useSelectBlade ($query, __FUNCTION__);
        while ($row = $result->fetch (PDO::FETCH_ASSOC))
        {
                $remoteip_bin = ip2long ($row['remoteip']);
+               if (!isset ($ret[$remoteip_bin]))
+                       $ret[$remoteip_bin] = constructIPv4Address ($row['remoteip']);
+               $ret[$remoteip_bin]['inpf'][] = $row;
+       }
+       unset ($result);
+       // 5. add NAT rules, part 2
+       $query =
+               "select " .
+               "proto, " .
+               "INET_NTOA(localip) as localip, " .
+               "localport, " .
+               "INET_NTOA(remoteip) as remoteip, " .
+               "remoteport, " .
+               "description " .
+               "from PortForwarding " .
+               "where ${whereexpr5b} " .
+               "order by localip, localport, remoteip, remoteport, proto";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
                $localip_bin = ip2long ($row['localip']);
-               if ($i32_first <= $remoteip_bin and $remoteip_bin <= $i32_last)
-               {
-                       if (!isset ($ret[$remoteip_bin]))
-                               $ret[$remoteip_bin] = constructIPv4Address ($row['remoteip']);
-                       $ret[$remoteip_bin]['inpf'][] = $row;
-               }
-               if ($i32_first <= $localip_bin and $localip_bin <= $i32_last)
-               {
-                       if (!isset ($ret[$localip_bin]))
-                               $ret[$localip_bin] = constructIPv4Address ($row['localip']);
-                       $ret[$localip_bin]['outpf'][] = $row;
-               }
+               if (!isset ($ret[$localip_bin]))
+                       $ret[$localip_bin] = constructIPv4Address ($row['localip']);
+               $ret[$localip_bin]['outpf'][] = $row;
        }
+       unset ($result);
        return $ret;
 }