r2091 + restore more lost messages
authorDenis Ovsienko <infrastation@yandex.ru>
Wed, 30 Jul 2008 09:50:48 +0000 (09:50 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Wed, 30 Jul 2008 09:50:48 +0000 (09:50 +0000)
+ move getIPAddress(), getIPRange() and bindIpToObject() to database.php

inc/database.php
inc/functions.php
inc/interface.php
inc/navigation.php
inc/ophandlers.php
pi.css

index 82c93ce640d930bcdc61fdde374dc32484261088..1e518b697679fabb468dec74b32ed5e4386663e1 100644 (file)
@@ -959,6 +959,131 @@ function getObjectAddresses ($object_id = 0)
        return $ret;
 }
 
+// Don't require any records in database, but if there are any,
+// merge all available data in one structure.
+function getIPAddress ($ip = 0)
+{
+       $ret = array
+       (
+               'bonds' => array(),
+               'outpf' => array(),
+               'inpf' => array(),
+               'vslist' => array(),
+               'rslist' => array(),
+               'exists' => 0,
+               'name' => '',
+               'reserved' => 'no'
+       );
+       $query =
+               "select ".
+               "name, reserved ".
+               "from IPAddress ".
+               "where ip = INET_ATON('$ip') and (reserved = 'yes' or name != '')";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       if ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $ret['exists'] = 1;
+               $ret['name'] = $row['name'];
+               $ret['reserved'] = $row['reserved'];
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query =
+               "select ".
+               "IPBonds.object_id as object_id, ".
+               "IPBonds.name as name, ".
+               "IPBonds.type as type, ".
+               "objtype_id, dict_value as objtype_name, " .
+               "RackObject.name as object_name ".
+               "from IPBonds join RackObject on IPBonds.object_id=RackObject.id ".
+               "left join Dictionary on objtype_id=dict_key natural join Chapter " .
+               "where IPBonds.ip=INET_ATON('$ip') ".
+               "and chapter_name = 'RackObjectType' " .
+               "order by RackObject.id, IPBonds.name";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       $count = 0;
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $ret['bonds'][$count]['object_id'] = $row['object_id'];
+               $ret['bonds'][$count]['name'] = $row['name'];
+               $ret['bonds'][$count]['type'] = $row['type'];
+               $qo = array();
+               $qo['name'] = $row['object_name'];
+               $qo['objtype_id'] = $row['objtype_id'];
+               $qo['objtype_name'] = $row['objtype_name'];
+               $ret['bonds'][$count]['object_name'] = displayedName ($qo);
+               $count++;
+               $ret['exists'] = 1;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query = "select id, vport, proto, name from IPVirtualService where vip = inet_aton('${ip}')";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $new = $row;
+               $new['vip'] = $ip;
+               $ret['vslist'][] = $new;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query = "select inservice, rsport, IPRSPool.id as pool_id, IPRSPool.name as poolname from " .
+               "IPRealServer inner join IPRSPool on rspool_id = IPRSPool.id " .
+               "where rsip = inet_aton('${ip}')";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $new = $row;
+               $new['rsip'] = $ip;
+               $ret['rslist'][] = $new;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query =
+               "select " .
+               "proto, " .
+               "INET_NTOA(localip) as localip, " .
+               "localport, " .
+               "INET_NTOA(remoteip) as remoteip, " .
+               "remoteport, " .
+               "description " .
+               "from PortForwarding " .
+               "where remoteip = inet_aton('${ip}') or localip = inet_aton('${ip}') " .
+               "order by localip, localport, remoteip, remoteport, proto";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               if ($row['remoteip'] == $ip)
+                       $ret['inpf'][] = $row;
+               if ($row['localip'] == $ip)
+                       $ret['outpf'][] = $row;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       return $ret;
+}
+
+function bindIpToObject ($ip = '', $object_id = 0, $name = '', $type = '')
+{
+       $result = useInsertBlade
+       (
+               'IPBonds',
+               array
+               (
+                       'ip' => "INET_ATON('$ip')",
+                       'object_id' => "'${object_id}'",
+                       'name' => "'${name}'",
+                       'type' => "'${type}'"
+               )
+       );
+       return $result ? '' : (__FUNCTION__ . '(): useInsertBlade() failed');
+}
+
 function getAddressspaceList ($tagfilter = array(), $tfmode = 'any')
 {
        $whereclause = getWhereClause ($tagfilter);
@@ -990,6 +1115,156 @@ function getAddressspaceList ($tagfilter = array(), $tfmode = 'any')
 
 }
 
+function getIPRange ($id = 0)
+{
+       global $dbxlink;
+       $query =
+               "select ".
+               "id as IPRanges_id, ".
+               "INET_NTOA(ip) as IPRanges_ip, ".
+               "mask as IPRanges_mask, ".
+               "name as IPRanges_name ".
+               "from IPRanges ".
+               "where id = '$id'";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       $ret = array();
+       $row = $result->fetch (PDO::FETCH_ASSOC);
+       if ($row == NULL)
+               return $ret;
+       $ret['id'] = $row['IPRanges_id'];
+       $ret['ip'] = $row['IPRanges_ip'];
+       $ret['ip_bin'] = ip2long ($row['IPRanges_ip']);
+       $ret['mask_bin'] = binMaskFromDec($row['IPRanges_mask']);
+       $ret['mask_bin_inv'] = binInvMaskFromDec($row['IPRanges_mask']);
+       $ret['name'] = $row['IPRanges_name'];
+       $ret['mask'] = $row['IPRanges_mask'];
+       $ret['addrlist'] = array();
+       $result->closeCursor();
+       unset ($result);
+       // We risk losing some significant bits in an unsigned 32bit integer,
+       // unless it is converted to a string.
+       $db_first = "'" . sprintf ('%u', 0x00000000 + $ret['ip_bin'] & $ret['mask_bin']) . "'";
+       $db_last  = "'" . sprintf ('%u', 0x00000000 + $ret['ip_bin'] | ($ret['mask_bin_inv'])) . "'";
+
+       // Don't try to build up the whole structure in a single pass. Request
+       // the list of user comments and reservations and merge allocations in
+       // at a latter point.
+       $query =
+               "select INET_NTOA(ip) as ip, name, reserved from IPAddress " .
+               "where ip between ${db_first} and ${db_last} " .
+               "and (reserved = 'yes' or name != '')";
+       $result = $dbxlink->query ($query);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $ip_bin = ip2long ($row['ip']);
+               $ret['addrlist'][$ip_bin] = $row;
+               $tmp = array();
+               foreach (array ('ip', 'name', 'reserved') as $cname)
+                       $tmp[$cname] = $row[$cname];
+               $tmp['references'] = array();
+               $tmp['lbrefs'] = array();
+               $tmp['rsrefs'] = array();
+               $ret['addrlist'][$ip_bin] = $tmp;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query =
+               "select INET_NTOA(ipb.ip) as ip, ro.id as object_id, " .
+               "ro.name as object_name, ipb.name, ipb.type, objtype_id, " .
+               "dict_value as objtype_name from " .
+               "IPBonds as ipb inner join RackObject as ro on ipb.object_id = ro.id " .
+               "left join Dictionary on objtype_id=dict_key natural join Chapter " .
+               "where ip between ${db_first} and ${db_last} " .
+               "and chapter_name = 'RackObjectType'" .
+               "order by ipb.type, object_name";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $ip_bin = ip2long ($row['ip']);
+               if (!isset ($ret['addrlist'][$ip_bin]))
+               {
+                       $ret['addrlist'][$ip_bin] = array();
+                       $ret['addrlist'][$ip_bin]['ip'] = $row['ip'];
+                       $ret['addrlist'][$ip_bin]['name'] = '';
+                       $ret['addrlist'][$ip_bin]['reserved'] = 'no';
+                       $ret['addrlist'][$ip_bin]['references'] = array();
+                       $ret['addrlist'][$ip_bin]['lbrefs'] = array();
+                       $ret['addrlist'][$ip_bin]['rsrefs'] = array();
+               }
+               $tmp = array();
+               foreach (array ('object_id', 'type', 'name') as $cname)
+                       $tmp[$cname] = $row[$cname];
+               $quasiobject['name'] = $row['object_name'];
+               $quasiobject['objtype_id'] = $row['objtype_id'];
+               $quasiobject['objtype_name'] = $row['objtype_name'];
+               $tmp['object_name'] = displayedName ($quasiobject);
+               $ret['addrlist'][$ip_bin]['references'][] = $tmp;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query = "select vs_id, inet_ntoa(vip) as ip, vport, proto, " .
+               "object_id, objtype_id, ro.name, dict_value as objtype_name from " .
+               "IPVirtualService as vs inner join IPLoadBalancer as lb on vs.id = lb.vs_id " .
+               "inner join RackObject as ro on lb.object_id = ro.id " .
+               "left join Dictionary on objtype_id=dict_key " .
+               "natural join Chapter " .
+               "where vip between ${db_first} and ${db_last} " .
+               "and chapter_name = 'RackObjectType'" .
+               "order by vport, proto, ro.name, object_id";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $ip_bin = ip2long ($row['ip']);
+               if (!isset ($ret['addrlist'][$ip_bin]))
+               {
+                       $ret['addrlist'][$ip_bin] = array();
+                       $ret['addrlist'][$ip_bin]['ip'] = $row['ip'];
+                       $ret['addrlist'][$ip_bin]['name'] = '';
+                       $ret['addrlist'][$ip_bin]['reserved'] = 'no';
+                       $ret['addrlist'][$ip_bin]['references'] = array();
+                       $ret['addrlist'][$ip_bin]['lbrefs'] = array();
+                       $ret['addrlist'][$ip_bin]['rsrefs'] = array();
+               }
+               $tmp = $qbject = array();
+               foreach (array ('object_id', 'vport', 'proto', 'vs_id') as $cname)
+                       $tmp[$cname] = $row[$cname];
+               foreach (array ('name', 'objtype_id', 'objtype_name') as $cname)
+                       $qobject[$cname] = $row[$cname];
+               $tmp['object_name'] = displayedName ($qobject);
+               $ret['addrlist'][$ip_bin]['lbrefs'][] = $tmp;
+       }
+       $result->closeCursor();
+       unset ($result);
+
+       $query = "select inet_ntoa(rsip) as ip, rsport, rspool_id, rsp.name as rspool_name from " .
+               "IPRealServer as rs inner join IPRSPool as rsp on rs.rspool_id = rsp.id " .
+               "where rsip between ${db_first} and ${db_last} " .
+               "order by ip, rsport, rspool_id";
+       $result = useSelectBlade ($query, __FUNCTION__);
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $ip_bin = ip2long ($row['ip']);
+               if (!isset ($ret['addrlist'][$ip_bin]))
+               {
+                       $ret['addrlist'][$ip_bin] = array();
+                       $ret['addrlist'][$ip_bin]['ip'] = $row['ip'];
+                       $ret['addrlist'][$ip_bin]['name'] = '';
+                       $ret['addrlist'][$ip_bin]['reserved'] = 'no';
+                       $ret['addrlist'][$ip_bin]['references'] = array();
+                       $ret['addrlist'][$ip_bin]['lbrefs'] = array();
+                       $ret['addrlist'][$ip_bin]['rsrefs'] = array();
+               }
+               $tmp = array();
+               foreach (array ('rspool_id', 'rsport', 'rspool_name') as $cname)
+                       $tmp[$cname] = $row[$cname];
+               $ret['addrlist'][$ip_bin]['rsrefs'][] = $tmp;
+       }
+
+       return $ret;
+}
+
 function getRangeByIp ($ip = '', $id = 0)
 {
        if ($id == 0)
index 776ed0a2f7334f65aaf4c2bc776800c2c9738558..5d2412e2469393bd72227edf2035eecd0e526156 100644 (file)
@@ -299,288 +299,6 @@ function binInvMaskFromDec ($maskL)
        return $binmask;
 }
 
-function getIPRange ($id = 0)
-{
-       global $dbxlink;
-       $query =
-               "select ".
-               "id as IPRanges_id, ".
-               "INET_NTOA(ip) as IPRanges_ip, ".
-               "mask as IPRanges_mask, ".
-               "name as IPRanges_name ".
-               "from IPRanges ".
-               "where id = '$id'";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       $ret = array();
-       $row = $result->fetch (PDO::FETCH_ASSOC);
-       if ($row == NULL)
-               return $ret;
-       $ret['id'] = $row['IPRanges_id'];
-       $ret['ip'] = $row['IPRanges_ip'];
-       $ret['ip_bin'] = ip2long ($row['IPRanges_ip']);
-       $ret['mask_bin'] = binMaskFromDec($row['IPRanges_mask']);
-       $ret['mask_bin_inv'] = binInvMaskFromDec($row['IPRanges_mask']);
-       $ret['name'] = $row['IPRanges_name'];
-       $ret['mask'] = $row['IPRanges_mask'];
-       $ret['addrlist'] = array();
-       $result->closeCursor();
-       unset ($result);
-       // We risk losing some significant bits in an unsigned 32bit integer,
-       // unless it is converted to a string.
-       $db_first = "'" . sprintf ('%u', 0x00000000 + $ret['ip_bin'] & $ret['mask_bin']) . "'";
-       $db_last  = "'" . sprintf ('%u', 0x00000000 + $ret['ip_bin'] | ($ret['mask_bin_inv'])) . "'";
-
-       // Don't try to build up the whole structure in a single pass. Request
-       // the list of user comments and reservations and merge allocations in
-       // at a latter point.
-       $query =
-               "select INET_NTOA(ip) as ip, name, reserved from IPAddress " .
-               "where ip between ${db_first} and ${db_last} " .
-               "and (reserved = 'yes' or name != '')";
-       $result = $dbxlink->query ($query);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $ip_bin = ip2long ($row['ip']);
-               $ret['addrlist'][$ip_bin] = $row;
-               $tmp = array();
-               foreach (array ('ip', 'name', 'reserved') as $cname)
-                       $tmp[$cname] = $row[$cname];
-               $tmp['references'] = array();
-               $tmp['lbrefs'] = array();
-               $tmp['rsrefs'] = array();
-               $ret['addrlist'][$ip_bin] = $tmp;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query =
-               "select INET_NTOA(ipb.ip) as ip, ro.id as object_id, " .
-               "ro.name as object_name, ipb.name, ipb.type, objtype_id, " .
-               "dict_value as objtype_name from " .
-               "IPBonds as ipb inner join RackObject as ro on ipb.object_id = ro.id " .
-               "left join Dictionary on objtype_id=dict_key natural join Chapter " .
-               "where ip between ${db_first} and ${db_last} " .
-               "and chapter_name = 'RackObjectType'" .
-               "order by ipb.type, object_name";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $ip_bin = ip2long ($row['ip']);
-               if (!isset ($ret['addrlist'][$ip_bin]))
-               {
-                       $ret['addrlist'][$ip_bin] = array();
-                       $ret['addrlist'][$ip_bin]['ip'] = $row['ip'];
-                       $ret['addrlist'][$ip_bin]['name'] = '';
-                       $ret['addrlist'][$ip_bin]['reserved'] = 'no';
-                       $ret['addrlist'][$ip_bin]['references'] = array();
-                       $ret['addrlist'][$ip_bin]['lbrefs'] = array();
-                       $ret['addrlist'][$ip_bin]['rsrefs'] = array();
-               }
-               $tmp = array();
-               foreach (array ('object_id', 'type', 'name') as $cname)
-                       $tmp[$cname] = $row[$cname];
-               $quasiobject['name'] = $row['object_name'];
-               $quasiobject['objtype_id'] = $row['objtype_id'];
-               $quasiobject['objtype_name'] = $row['objtype_name'];
-               $tmp['object_name'] = displayedName ($quasiobject);
-               $ret['addrlist'][$ip_bin]['references'][] = $tmp;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query = "select vs_id, inet_ntoa(vip) as ip, vport, proto, " .
-               "object_id, objtype_id, ro.name, dict_value as objtype_name from " .
-               "IPVirtualService as vs inner join IPLoadBalancer as lb on vs.id = lb.vs_id " .
-               "inner join RackObject as ro on lb.object_id = ro.id " .
-               "left join Dictionary on objtype_id=dict_key " .
-               "natural join Chapter " .
-               "where vip between ${db_first} and ${db_last} " .
-               "and chapter_name = 'RackObjectType'" .
-               "order by vport, proto, ro.name, object_id";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $ip_bin = ip2long ($row['ip']);
-               if (!isset ($ret['addrlist'][$ip_bin]))
-               {
-                       $ret['addrlist'][$ip_bin] = array();
-                       $ret['addrlist'][$ip_bin]['ip'] = $row['ip'];
-                       $ret['addrlist'][$ip_bin]['name'] = '';
-                       $ret['addrlist'][$ip_bin]['reserved'] = 'no';
-                       $ret['addrlist'][$ip_bin]['references'] = array();
-                       $ret['addrlist'][$ip_bin]['lbrefs'] = array();
-                       $ret['addrlist'][$ip_bin]['rsrefs'] = array();
-               }
-               $tmp = $qbject = array();
-               foreach (array ('object_id', 'vport', 'proto', 'vs_id') as $cname)
-                       $tmp[$cname] = $row[$cname];
-               foreach (array ('name', 'objtype_id', 'objtype_name') as $cname)
-                       $qobject[$cname] = $row[$cname];
-               $tmp['object_name'] = displayedName ($qobject);
-               $ret['addrlist'][$ip_bin]['lbrefs'][] = $tmp;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query = "select inet_ntoa(rsip) as ip, rsport, rspool_id, rsp.name as rspool_name from " .
-               "IPRealServer as rs inner join IPRSPool as rsp on rs.rspool_id = rsp.id " .
-               "where rsip between ${db_first} and ${db_last} " .
-               "order by ip, rsport, rspool_id";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $ip_bin = ip2long ($row['ip']);
-               if (!isset ($ret['addrlist'][$ip_bin]))
-               {
-                       $ret['addrlist'][$ip_bin] = array();
-                       $ret['addrlist'][$ip_bin]['ip'] = $row['ip'];
-                       $ret['addrlist'][$ip_bin]['name'] = '';
-                       $ret['addrlist'][$ip_bin]['reserved'] = 'no';
-                       $ret['addrlist'][$ip_bin]['references'] = array();
-                       $ret['addrlist'][$ip_bin]['lbrefs'] = array();
-                       $ret['addrlist'][$ip_bin]['rsrefs'] = array();
-               }
-               $tmp = array();
-               foreach (array ('rspool_id', 'rsport', 'rspool_name') as $cname)
-                       $tmp[$cname] = $row[$cname];
-               $ret['addrlist'][$ip_bin]['rsrefs'][] = $tmp;
-       }
-
-       return $ret;
-}
-
-// Don't require any records in IPAddress, but if there is one,
-// merge the data between getting allocation list. Collect enough data
-// to call displayedName() ourselves.
-function getIPAddress ($ip = 0)
-{
-       $ret = array
-       (
-               'bonds' => array(),
-               'outpf' => array(),
-               'inpf' => array(),
-               'vslist' => array(),
-               'rslist' => array(),
-               'exists' => 0,
-               'name' => '',
-               'reserved' => 'no'
-       );
-       $query =
-               "select ".
-               "name, reserved ".
-               "from IPAddress ".
-               "where ip = INET_ATON('$ip') and (reserved = 'yes' or name != '')";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       if ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $ret['exists'] = 1;
-               $ret['name'] = $row['name'];
-               $ret['reserved'] = $row['reserved'];
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query =
-               "select ".
-               "IPBonds.object_id as object_id, ".
-               "IPBonds.name as name, ".
-               "IPBonds.type as type, ".
-               "objtype_id, dict_value as objtype_name, " .
-               "RackObject.name as object_name ".
-               "from IPBonds join RackObject on IPBonds.object_id=RackObject.id ".
-               "left join Dictionary on objtype_id=dict_key natural join Chapter " .
-               "where IPBonds.ip=INET_ATON('$ip') ".
-               "and chapter_name = 'RackObjectType' " .
-               "order by RackObject.id, IPBonds.name";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       $count = 0;
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $ret['bonds'][$count]['object_id'] = $row['object_id'];
-               $ret['bonds'][$count]['name'] = $row['name'];
-               $ret['bonds'][$count]['type'] = $row['type'];
-               $qo = array();
-               $qo['name'] = $row['object_name'];
-               $qo['objtype_id'] = $row['objtype_id'];
-               $qo['objtype_name'] = $row['objtype_name'];
-               $ret['bonds'][$count]['object_name'] = displayedName ($qo);
-               $count++;
-               $ret['exists'] = 1;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query = "select id, vport, proto, name from IPVirtualService where vip = inet_aton('${ip}')";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $new = $row;
-               $new['vip'] = $ip;
-               $ret['vslist'][] = $new;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query = "select inservice, rsport, IPRSPool.id as pool_id, IPRSPool.name as poolname from " .
-               "IPRealServer inner join IPRSPool on rspool_id = IPRSPool.id " .
-               "where rsip = inet_aton('${ip}')";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               $new = $row;
-               $new['rsip'] = $ip;
-               $ret['rslist'][] = $new;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       $query =
-               "select " .
-               "proto, " .
-               "INET_NTOA(localip) as localip, " .
-               "localport, " .
-               "INET_NTOA(remoteip) as remoteip, " .
-               "remoteport, " .
-               "description " .
-               "from PortForwarding " .
-               "where remoteip = inet_aton('${ip}') or localip = inet_aton('${ip}') " .
-               "order by localip, localport, remoteip, remoteport, proto";
-       $result = useSelectBlade ($query, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               if ($row['remoteip'] == $ip)
-                       $ret['inpf'][] = $row;
-               if ($row['localip'] == $ip)
-                       $ret['outpf'][] = $row;
-       }
-       $result->closeCursor();
-       unset ($result);
-
-       return $ret;
-}
-
-function bindIpToObject ($ip = '', $object_id = 0, $name = '', $type = '')
-{
-       global $dbxlink;
-
-       $range = getRangeByIp ($ip);
-       if (!$range)
-               return 'Non-existant ip address. Try adding IP range first';
-
-       $result = useInsertBlade
-       (
-               'IPBonds',
-               array
-               (
-                       'ip' => "INET_ATON('$ip')",
-                       'object_id' => "'${object_id}'",
-                       'name' => "'${name}'",
-                       'type' => "'${type}'"
-               )
-       );
-       return $result ? '' : (__FUNCTION__ . '(): useInsertBlade() failed');
-}
-
 // This function looks up 'has_problems' flag for 'T' atoms
 // and modifies 'hl' key. May be, this should be better done
 // in getRackData(). We don't honour 'skipped' key, because
index eb9f334b168b381dc6d822170387f0c5f33a81ad..9c28e4a9f3c5b1dfbd82714b73680525da86e408 100644 (file)
@@ -1397,6 +1397,7 @@ function printLog ($log)
                                167 => array ('code' => 'error', 'format' => 'Could not find port %s'),
                                168 => array ('code' => 'error', 'format' => 'Port %s is a trunk'),
                                169 => array ('code' => 'error', 'format' => 'Failed to configure %s, connector returned code %u'),
+                               170 => array ('code' => 'error', 'format' => 'There is no network for IP address "%s"'),
 
                                200 => array ('code' => 'warning', 'format' => 'generic warning: %s'),
                                201 => array ('code' => 'warning', 'format' => 'nothing happened...'),
@@ -1408,6 +1409,11 @@ function printLog ($log)
                        // Handle the arguments. Is there any better way to do it?
                        foreach ($log['m'] as $record)
                        {
+                               if (!isset ($record['c']) or !isset ($msginfo[$record['c']]))
+                               {
+                                       echo '<div class=msg_neutral>(this message was lost)</div>';
+                                       continue;
+                               }
                                if (isset ($record['a']))
                                        switch (count ($record['a']))
                                        {
@@ -5246,7 +5252,7 @@ function renderObjectSLB ($object_id)
 
 function renderEditRSPool ($pool_id)
 {
-       global $pageno, $tabno;
+       global $root, $pageno, $tabno;
        showMessageOrError();
        $poolinfo = getRSPoolInfo ($pool_id);
        echo "<form method=post action='${root}process.php?page=${pageno}&tab=${tabno}&op=updIPv4RSP'>\n";
@@ -5263,7 +5269,7 @@ function renderEditRSPool ($pool_id)
 
 function renderEditVService ($vsid)
 {
-       global $pageno, $tabno;
+       global $root, $pageno, $tabno;
        showMessageOrError();
        $protocols = array ('TCP' => 'TCP', 'UDP' => 'UDP');
        $vsinfo = getVServiceInfo ($vsid);
index 6ec5c65c7dbb4ad9356eb126ecbd9d358db24ad8..59cdcc7fff01ff6731c1e60f1af6c855e39a5e83 100644 (file)
@@ -67,7 +67,6 @@ $tabhandler['rack']['problems'] = 'renderRackProblems';
 $tabhandler['rack']['tags'] = 'renderRackTags';
 $trigger['rack']['tags'] = 'trigger_tags';
 $ophandler['rack']['tags']['saveTags'] = 'saveRackTags';
-$msgcode['rack']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['objgroup']['title_handler'] = 'dynamic_title_objgroup';
 $page['objgroup']['handler'] = 'renderObjectGroup';
@@ -164,7 +163,8 @@ $msgcode['object']['ports']['useup']['ERR'] = 124;
 $msgcode['object']['ipv4']['updIPv4Allocation']['OK'] = 12;
 $msgcode['object']['ipv4']['updIPv4Allocation']['ERR'] = 100;
 $msgcode['object']['ipv4']['addIPv4Allocation']['OK'] = 13;
-$msgcode['object']['ipv4']['addIPv4Allocation']['ERR'] = 100;
+$msgcode['object']['ipv4']['addIPv4Allocation']['ERR1'] = 170;
+$msgcode['object']['ipv4']['addIPv4Allocation']['ERR2'] = 100;
 $msgcode['object']['ipv4']['delIPv4Allocation']['OK'] = 14;
 $msgcode['object']['ipv4']['delIPv4Allocation']['ERR'] = 100;
 $msgcode['object']['edit']['clearSticker']['OK'] = 15;
@@ -184,6 +184,14 @@ $msgcode['object']['autoports']['generate']['ERR'] = 142;
 $msgcode['object']['tags']['saveTags']['OK'] = 22;
 $msgcode['object']['tags']['saveTags']['ERR'] = 143;
 $msgcode['object']['livevlans']['setPortVLAN']['ERR1'] = 156;
+$msgcode['rack']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
+$msgcode['iprange']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
+$msgcode['ipv4vs']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
+$msgcode['ipv4rsp']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
+$msgcode['user']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
+$msgcode['ipv4vs']['editlblist'] = $msgcode['object']['editrspvs'];
+$msgcode['ipv4rsp']['editlblist'] = $msgcode['object']['editrspvs'];
+$msgcode['ipaddress']['assignment'] = $msgcode['object']['ipv4'];
 
 $page['ipv4space']['title'] = 'IPv4 space';
 $page['ipv4space']['parent'] = 'index';
@@ -220,7 +228,6 @@ $msgcode['iprange']['properties']['editRange']['OK'] = 25;
 $msgcode['iprange']['properties']['editRange']['ERR'] = 100;
 $msgcode['iprange']['liveptr']['importPTRData']['OK'] = 26;
 $msgcode['iprange']['liveptr']['importPTRData']['ERR'] = 141;
-$msgcode['iprange']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['ipaddress']['title_handler'] = 'dynamic_title_ipaddress';
 $page['ipaddress']['parent'] = 'iprange';
@@ -262,6 +269,7 @@ $msgcode['ipv4vslist']['edit']['del']['OK'] = 29;
 $msgcode['ipv4vslist']['edit']['del']['ERR'] = 130;
 $msgcode['ipv4vslist']['edit']['upd']['OK'] = 30;
 $msgcode['ipv4vslist']['edit']['upd']['ERR'] = 135;
+$msgcode['ipv4vs']['edit']['updIPv4VS'] = $msgcode['ipv4vslist']['edit']['upd'];
 
 $page['ipv4vs']['title_handler'] = 'dynamic_title_vservice';
 $page['ipv4vs']['parent'] = 'ipv4vslist';
@@ -283,8 +291,6 @@ $ophandler['ipv4vs']['editlblist']['addLB'] = 'addLoadBalancer';
 $ophandler['ipv4vs']['editlblist']['delLB'] = 'deleteLoadBalancer';
 $ophandler['ipv4vs']['editlblist']['updLB'] = 'updateLoadBalancer';
 $trigger['ipv4vs']['tags'] = 'trigger_tags';
-$msgcode['ipv4vs']['editlblist'] = $msgcode['object']['editrspvs'];
-$msgcode['ipv4vs']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['ipv4rsplist']['title'] = 'RS pools';
 $page['ipv4rsplist']['parent'] = 'ipv4slb';
@@ -301,6 +307,7 @@ $msgcode['ipv4rsplist']['edit']['del']['OK'] = 32;
 $msgcode['ipv4rsplist']['edit']['del']['ERR'] = 138;
 $msgcode['ipv4rsplist']['edit']['upd']['OK'] = 33;
 $msgcode['ipv4rsplist']['edit']['upd']['ERR'] = 139;
+$msgcode['ipv4rsp']['edit']['updIPv4RSP'] = $msgcode['ipv4rsplist']['edit']['upd'];
 
 $page['ipv4rsp']['title_handler'] = 'dynamic_title_rspool';
 $page['ipv4rsp']['parent'] = 'ipv4rsplist';
@@ -341,11 +348,8 @@ $msgcode['ipv4rsp']['editrslist']['updRS']['ERR'] = 133;
 $msgcode['ipv4rsp']['editrslist']['addMany']['OK'] = 37;
 $msgcode['ipv4rsp']['editrslist']['addMany']['ERR1'] = 131;
 $msgcode['ipv4rsp']['editrslist']['addMany']['ERR2'] = 127;
-$msgcode['ipv4rsp']['editlblist'] = $msgcode['object']['editrspvs'];
-$msgcode['ipv4rsp']['edit']['updIPv4RSP'] = $msgcode['ipv4rsplist']['edit']['upd'];
 $msgcode['ipv4rsp']['rsinservice']['upd']['OK'] = 38;
 $msgcode['ipv4rsp']['rsinservice']['upd']['ERR'] = 140;
-$msgcode['ipv4rsp']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['rservers']['title'] = 'Real servers';
 $page['rservers']['parent'] = 'ipv4slb';
@@ -396,7 +400,6 @@ $tab['user']['tags'] = 'Tags';
 $tabhandler['user']['default'] = 'renderUser';
 $tabhandler['user']['tags'] = 'renderUserTags';
 $ophandler['user']['tags']['saveTags'] = 'saveUserTags';
-$msgcode['user']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['perms']['title'] = 'Permissions';
 $page['perms']['parent'] = 'config';
index 836f73807ce2463e4643c6aacd180274c23d5e33..28cf5289bbbd7e3acdade90ee9d0ec27d8a7cf0a 100644 (file)
@@ -378,7 +378,12 @@ function addIPv4Allocation ()
 
        // Strip masklen.
        $ip = ereg_replace ('/[[:digit:]]+$', '', $_REQUEST['ip']);
+       if  (NULL == getRangeByIp ($ip))
+               return buildRedirectURL ('ERR1', array ($ip));
+       
        $error = bindIpToObject ($ip, $_REQUEST['object_id'], $_REQUEST['bond_name'], $_REQUEST['bond_type']);
+       if ($error != '')
+               return buildRedirectURL ('ERR2', array ($error));
        $address = getIPAddress ($ip);
        if ($address['exists'] and ($address['reserved'] == 'yes' or strlen ($address['name']) > 0))
        {
@@ -389,10 +394,7 @@ function addIPv4Allocation ()
                        $address['name'] = '';
                updateAddress ($ip, $address['name'], $address['reserved']);
        }
-       if ($error != '')
-               return buildRedirectURL ('ERR', array ($error));
-       else
-               return buildRedirectURL ('OK');
+       return buildRedirectURL ('OK');
 }
 
 function addIPv4Prefix ()
diff --git a/pi.css b/pi.css
index f7eaf1be1bbfdee63ea81fc09a5325ed443b5b50..0ad4b32d2cd24d6424478646a57d5137273afadc 100644 (file)
--- a/pi.css
+++ b/pi.css
@@ -78,28 +78,27 @@ td.pcright {
        text-align: center;
 }
 
-.msg_error, .msg_success, .msg_warning, .msg_200, .msg_300, .msg_500 {
+.msg_error, .msg_success, .msg_warning, .msg_neutral, .msg_200, .msg_300, .msg_500 {
        text-align: left;
        border: 1px solid;
        padding: 2px;
        margin: 5px;
+       text-align: center;
 }
 
 .msg_error, .msg_500 {
        background-color: #ffa0a0;
        border-color: red;
        font-weight: bold;
-       text-align: center;
 }
 
 .msg_success, .msg_200 {
        background-color: #a0ffa0;
        border-color: green;
        font-weight: bold;
-       text-align: center;
 }
 
-.msg_300 {
+.msg_300, .msg_neutral {
        background-color: #c0c0c0;
        border-color: black;
 }
@@ -108,7 +107,6 @@ td.pcright {
        background-color: #ff9966;
        border-color: #ff3300;
        font-weight: bold;
-       text-align: center;
 }
 
 .opt_attr_th {