Author: jfthomps
Date: Thu Dec 11 14:40:18 2014
New Revision: 1644655

URL: http://svn.apache.org/r1644655
Log:
VCL-174 - NAT - support for sites that have small IP address ranges

managementnode.php: modified AJsaveResource and addResource: added code to add 
to/update nathost table when updating managementnode information; this is only 
for 2.4 and will be removed when a section is added to the site for managing 
nat hosts

Modified:
    vcl/trunk/web/.ht-inc/managementnode.php

Modified: vcl/trunk/web/.ht-inc/managementnode.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/managementnode.php?rev=1644655&r1=1644654&r2=1644655&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/managementnode.php (original)
+++ vcl/trunk/web/.ht-inc/managementnode.php Thu Dec 11 14:40:18 2014
@@ -520,6 +520,30 @@ class ManagementNode extends Resource {
                                else
                                        
setVariable("timesource|{$data['name']}", $data['timeservers'], 'none');
                        }
+                       # update nathost (TODO change in release after 2.4 when 
section added to manage nat hosts)
+                       if($data['ipaddress'] != $olddata['IPaddress']) {
+                               $query = "SELECT id "
+                                      . "FROM resource "
+                                      . "WHERE resourcetypeid = 16 AND "
+                                      .       "subid = {$data['rscid']}";
+                               $qh = doQuery($query);
+                               if($row = mysql_fetch_assoc($qh)) {
+                                       $resourceid = $row['id'];
+                                       $query = "UPDATE nathost "
+                                              . "SET natIP = 
'{$data['ipaddress']}' "
+                                              . "WHERE resourceid = 
$resourceid";
+                                       doQuery($query);
+                                       if(! 
mysql_affected_rows($GLOBALS['mysql_link_vcl'])) {
+                                               $query = "INSERT INTO nathost "
+                                                      .        "(resourceid, "
+                                                      .        "natIP) "
+                                                      . "VALUES "
+                                                      .        "($resourceid, "
+                                                      .        
"'{$data['ipaddress']}')";
+                                               doQuery($query);
+                                       }
+                               }
+                       }
                }
 
                # clear user resource cache for this type
@@ -903,6 +927,16 @@ class ManagementNode extends Resource {
                                 .         "$rscid)";
                doQuery($query);
 
+               $resourceid = dbLastInsertID();
+
+               // add entry to nathost table (TODO change in release after 2.4 
when section added to manage nat hosts)
+               $query = "INSERT INTO nathost "
+                                .        "(resourceid, "
+                                .        "natIP) "
+                                . "VALUES ($resourceid, "
+                                .         "'{$data['ipaddress']}')";
+               doQuery($query);
+
                # time server
                $globalval = getVariable('timesource|global');
                if($data['timeservers'] != $globalval)


Reply via email to