r1268 + bindIpToObject(): make use of the standard useInsertBlade()
authorDenis Ovsienko <infrastation@yandex.ru>
Wed, 14 Nov 2007 09:39:25 +0000 (09:39 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Wed, 14 Nov 2007 09:39:25 +0000 (09:39 +0000)
+ bindIpToObject(): don't create ghost records in IPAddress table

inc/functions.php

index 5eecd7a67c0610daf6ce63b5d894b4df76f3e669..b1a48109814ebb8ad103a8bb68528a1557b62150 100644 (file)
@@ -561,23 +561,21 @@ 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';
 
-       $address = getIPAddress($ip);
-
-       if ($address['exists'] == 0)
-       {
-               $query =
-                       "insert into IPAddress set ip=INET_ATON('$ip')";
-               $dbxlink->exec ($query);
-       }
-
-       $query =
-               "insert into IPBonds set ip=INET_ATON('$ip'), object_id='$object_id', name='$name', type='$type'";
-       $result = $dbxlink->exec ($query);
-       return '';
+       $result = useInsertBlade
+       (
+               'IPBonds',
+               array
+               (
+                       'ip' => INET_ATON('$ip'),
+                       'object_id' => "'${object_id}'",
+                       'name' => "'${name}'",
+                       'type' => "'${type}'"
+               )
+       );
+       return $result ? '' : 'useInsertBlade() failed in bindIpToObject()';
 }
 
 // This function looks up 'has_problems' flag for 'T' atoms