r2095 + don't depend on obsolete getIPAddress() and getIPRange() any more
authorDenis Ovsienko <infrastation@yandex.ru>
Thu, 31 Jul 2008 15:39:16 +0000 (15:39 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Thu, 31 Jul 2008 15:39:16 +0000 (15:39 +0000)
+ use standard save icon

inc/database.php
inc/functions.php
inc/interface.php
inc/navigation.php
inc/ophandlers.php
inc/pagetitles.php

index 2fa3cfa..df77312 100644 (file)
@@ -959,8 +959,7 @@ 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.
+// FIXME: unused function
 function getIPAddress ($ip = 0)
 {
        $ret = array
@@ -1334,6 +1333,7 @@ function getAddressspaceList ($tagfilter = array(), $tfmode = 'any')
 
 }
 
+// FIXME: unused function
 function getIPRange ($id = 0)
 {
        global $dbxlink;
index f2ebad8..f3f2ec1 100644 (file)
@@ -1140,7 +1140,7 @@ function loadIPv4PrefixAutoTags ()
        return array_merge
        (
                array (array ('tag' => '$ip4netid_' . $_REQUEST['id'])),
-               getIPv4PrefixTags (getIPRange ($_REQUEST['id']))
+               getIPv4PrefixTags (getIPv4NetworkInfo ($_REQUEST['id']))
        );
 }
 
index 90e768c..ba8f5ce 100644 (file)
@@ -889,7 +889,7 @@ function renderRackObject ($object_id = 0)
 
                        foreach ($forwards['out'] as $pf)
                        {
-                               $class='trerrorg';
+                               $class='trerror';
                                $name='';
                                foreach ($addresses as $addr)
                                        if ($addr['ip'] == $pf['localip'])
@@ -898,46 +898,33 @@ function renderRackObject ($object_id = 0)
                                                $name=$addr['name'];
                                                break;
                                        }
-
                                echo "<tr class='$class'>";
-
                                echo "<td>${pf['proto']}</td><td class=tdleft>${name}: <a href='${root}?page=ipaddress&tab=default&ip=${pf['localip']}'>${pf['localip']}</a>:${pf['localport']}</td>";
-
                                echo "<td class=tdleft><a href='${root}?page=ipaddress&tab=default&ip=${pf['remoteip']}'>${pf['remoteip']}</a>:${pf['remoteport']}</td>";
-
-                               $address=getIPAddress($pf['remoteip']);
-
+                               $address = getIPv4Address ($pf['remoteip']);
                                echo "<td class='description'>";
-                               if (count ($address['bonds']))
-                                       foreach($address['bonds'] as $bond)
+                               if (count ($address['allocs']))
+                                       foreach($address['allocs'] as $bond)
                                                echo "<a href='${root}?page=object&tab=default&object_id=${bond['object_id']}'>${bond['object_name']}(${bond['name']})</a> ";
                                elseif (!empty ($pf['remote_addr_name']))
                                        echo '(' . $pf['remote_addr_name'] . ')';
-
-                               echo "</td><td class='description'>${pf['description']}</td>";
-
-                               echo "</tr>";
+                               echo "</td><td class='description'>${pf['description']}</td></tr>";
                        }
                        echo "</table><br><br>";
                }
                if (count($forwards['in']))
                {
                        echo "<h3>arriving NAT connections</h3>";
-
                        echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n";
                        echo "<tr><th>Matched endpoint</th><th>Source object</th><th>Translated to</th><th>Rule comment</th></tr>\n";
-
                        foreach ($forwards['in'] as $pf)
                        {
                                echo "<tr>";
                                echo "<td>${pf['proto']}/<a href='${root}?page=ipaddress&tab=default&ip=${pf['localip']}'>${pf['localip']}</a>:${pf['localport']}</td>";
-
                                echo "<td class='description'><a href='${root}?page=object&tab=default&object_id=${pf['object_id']}'>${pf['object_name']}</a>";
-
                                echo "</td><td><a href='${root}?page=ipaddress&tab=default&ip=${pf['remoteip']}'>${pf['remoteip']}</a>:${pf['remoteport']}</td>";
                                echo "<td class='description'>${pf['description']}</td></tr>";
                        }
-
                        echo "</table><br><br>";
                }
                finishPortlet();
@@ -2012,12 +1999,12 @@ function renderAddressspace ()
        echo "<tr><th>prefix</th><th>name/tags</th><th>utilization</th></tr>\n";
        foreach ($addrspaceList as $iprange)
        {
-               $range = getIPRange ($iprange['id']);
+               $netdata = getIPv4Network ($iprange['id']);
                $prefixtags = loadIPv4PrefixTags ($iprange['id']);
-               $total = ($iprange['ip_bin'] | $iprange['mask_bin_inv']) - ($iprange['ip_bin'] & $iprange['mask_bin']) + 1;
-               $used = count ($range['addrlist']);
-               echo "<tr valign=top><td class=tdleft><a href='${root}?page=iprange&id=${iprange['id']}'>${iprange['ip']}/${iprange['mask']}</a></td>";
-               echo "<td class=tdleft>${iprange['name']}";
+               $total = ($netdata['ip_bin'] | $netdata['mask_bin_inv']) - ($netdata['ip_bin'] & $netdata['mask_bin']) + 1;
+               $used = count ($netdata['addrlist']);
+               echo "<tr valign=top><td class=tdleft><a href='${root}?page=iprange&id=${iprange['id']}'>${iprange['ip']}/${netdata['mask']}</a></td>";
+               echo "<td class=tdleft>${netdata['name']}";
                if (count ($prefixtags))
                {
                        echo "<br>";
@@ -2128,9 +2115,9 @@ function renderAddNewRange ()
        echo "<tr><th>&nbsp;</th><th>prefix</th><th>name</th><th>utilization</th></tr>";
        foreach ($addrspaceList as $iprange)
        {
-               $range = getIPRange($iprange['id']);
-               $usedips = count ($range['addrlist']);
-               $totalips = ($iprange['ip_bin'] | $iprange['mask_bin_inv']) - ($iprange['ip_bin'] & $iprange['mask_bin']) + 1;
+               $netdata = getIPv4Network ($iprange['id']);
+               $usedips = count ($netdata['addrlist']);
+               $totalips = ($netdata['ip_bin'] | $netdata['mask_bin_inv']) - ($netdata['ip_bin'] & $netdata['mask_bin']) + 1;
                echo "<tr valign=top><td>";
                if ($usedips == 0)
                {
@@ -2141,7 +2128,7 @@ function renderAddNewRange ()
                else
                        printImageHREF ('nodelete', 'There are IP addresses allocated or reserved');
                echo "</td>\n<td class=tdleft><a href='${root}?page=iprange&id=${iprange['id']}'>";
-               echo "${iprange['ip']}/${iprange['mask']}</a></td><td class=tdleft>${iprange['name']}";
+               echo "${netdata['ip']}/${netdata['mask']}</a></td><td class=tdleft>${netdata['name']}";
                echo "</td><td class=tdcenter>";
                renderProgressBar ($usedips / $totalips);
                echo "<br><small>${usedips}/${totalips}</small></td></tr>\n";
@@ -2348,19 +2335,21 @@ function renderIPRange ($id)
        echo "</td></tr></table>\n";
 }
 
-function renderIPRangeProperties ($id)
+function renderIPv4NetworkProperties ($id)
 {
        global $root, $pageno, $tabno;
        showMessageOrError();
-       $range = getIPRange($id);
-       echo "<center><h1>${range['ip']}/${range['mask']}</h1></center>\n";
+       $netdata = getIPv4NetworkInfo ($id);
+       echo "<center><h1>${netdata['ip']}/${netdata['mask']}</h1></center>\n";
        echo "<table border=0 cellpadding=10 cellpadding=1 align='center'>\n";
        echo "<form action='${root}process.php'><input type=hidden name=op value=editRange>";
        echo "<input type=hidden name=page value='${pageno}'>\n";
        echo "<input type=hidden name=tab value='${tabno}'>\n";
        echo "<input type=hidden name=id value='${id}'>";
-       echo "<tr><td class='tdright'>Name:</td><td class='tdleft'><input type=text name=name size=20 value='${range['name']}'></tr><tr><td colspan=2 class='tdcenter'><input type=submit value='Update range'></td></form></tr>";
-       echo "</table>\n";
+       echo "<tr><td class='tdright'>Name:</td><td class='tdleft'><input type=text name=name size=20 value='${netdata['name']}'></tr>";
+       echo "<tr><td colspan=2 class=tdcenter>";
+       printImageHREF ('SAVE', 'Save changes', TRUE);
+       echo "</td></form></tr></table>\n";
 
 }
 
@@ -2487,8 +2476,9 @@ function renderIPv4AddressProperties ($dottedquad)
        echo "<tr><td class='tdright'>Name:</td><td class='tdleft'><input type=text name=name size=20 value='${address['name']}'></tr>";
        echo "<td class='tdright'>Reserved:</td><td class='tdleft'><input type=checkbox name=reserved size=20 ";
        echo ($address['reserved']=='yes') ? 'checked' : '';
-       echo "></tr><tr><td colspan=2 class='tdcenter'><input type=submit value='Update address'></td></form></tr>";
-       echo "</table>\n";
+       echo "></tr><tr><td colspan=2 class='tdcenter'>";
+       printImageHREF ('SAVE', 'Save changes', TRUE);
+       echo "</td></form></tr></table>\n";
        finishPortlet();
        if (empty ($address['name']) and $address['reserved'] == 'no')
                return;
@@ -2586,11 +2576,11 @@ function renderNATv4ForObject ($object_id = 0)
                echo "</td>";
                echo "<td><a href='${root}?page=ipaddress&tab=default&ip=${pf['remoteip']}'>${pf['remoteip']}</a>:${pf['remoteport']}</td>";
 
-               $address=getIPAddress($pf['remoteip']);
+               $address = getIPv4Address ($pf['remoteip']);
 
                echo "<td class='description'>";
-               if (count ($address['bonds']))
-                       foreach($address['bonds'] as $bond)
+               if (count ($address['allocs']))
+                       foreach ($address['allocs'] as $bond)
                                echo "<a href='${root}?page=object&tab=default&object_id=${bond['object_id']}'>${bond['object_name']}(${bond['name']})</a> ";
                elseif (!empty ($pf['remote_addr_name']))
                        echo '(' . $pf['remote_addr_name'] . ')';
@@ -4674,7 +4664,7 @@ function renderLivePTR ($id = 0)
                $page=0;
        global $root, $pageno, $tabno;
        $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE');
-       $range = getIPRange ($id);
+       $range = getIPv4Network ($id);
        echo "<center><h1>${range['ip']}/${range['mask']}</h1><h2>${range['name']}</h2></center>\n";
 
        echo "<table class=objview border=0 width='100%'><tr><td class=pcleft>";
@@ -4768,7 +4758,8 @@ function renderLivePTR ($id = 0)
        echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>";
        echo "<tr class=trok><th class=tdright>Exact matches:</th><td class=tdleft>${cnt_match}</td></tr>\n";
        echo "<tr class=trwarning><th class=tdright>Missing from DB/DNS:</th><td class=tdleft>${cnt_missing}</td></tr>\n";
-       echo "<tr class=trerror><th class=tdright>Mismatches:</th><td class=tdleft>${cnt_mismatch}</td></tr>\n";
+       if ($cnt_mismatch)
+               echo "<tr class=trerror><th class=tdright>Mismatches:</th><td class=tdleft>${cnt_mismatch}</td></tr>\n";
        echo "</table>\n";
        finishPortlet();
 
index ab8036d..45db99f 100644 (file)
@@ -217,7 +217,7 @@ $tab['iprange']['properties'] = 'Properties';
 $tab['iprange']['liveptr'] = 'Live PTR';
 $tab['iprange']['tags'] = 'Tags';
 $tabhandler['iprange']['default'] = 'renderIPRange';
-$tabhandler['iprange']['properties'] = 'renderIPRangeProperties';
+$tabhandler['iprange']['properties'] = 'renderIPv4NetworkProperties';
 $tabhandler['iprange']['liveptr'] = 'renderLivePTR';
 $tabhandler['iprange']['tags'] = 'renderIPv4PrefixTags';
 $trigger['iprange']['tags'] = 'trigger_tags';
index 28cf528..cd17677 100644 (file)
@@ -384,8 +384,8 @@ function addIPv4Allocation ()
        $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))
+       $address = getIPv4Address ($ip);
+       if ($address['reserved'] == 'yes' or !empty ($address['name']))
        {
                $release = getConfigVar ('IPV4_AUTO_RELEASE');
                if ($release >= 1)
index 28e7484..f8d40f4 100644 (file)
@@ -16,7 +16,7 @@ function dynamic_title_iprange ()
        switch ($pageno)
        {
                case 'iprange':
-                       $range = getIPRange($_REQUEST['id']);
+                       $range = getIPv4NetworkInfo ($_REQUEST['id']);
                        return array ('name' => $range['ip'].'/'.$range['mask'], 'params' => array('id'=>$_REQUEST['id']));
                        break;
                case 'ipaddress':