r2069 + fixed renderIPRange() to highlight unassigned IP addresses correctly
authorDenis Ovsienko <infrastation@yandex.ru>
Fri, 18 Jul 2008 12:40:10 +0000 (12:40 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 18 Jul 2008 12:40:10 +0000 (12:40 +0000)
inc/interface.php

index cb1d629ee5759bbc6d42c5bdfbf0b9fe3114e40f..dc1d28d5ecaca5b9002e13c37c25421780a11130 100644 (file)
@@ -2052,79 +2052,81 @@ function renderIPRange ($id)
        echo "<tr><th>Address</th><th>Name</th><th>Allocation</th></tr>\n";
 
 
-       for ($ip = $startip; $ip<=$endip; $ip++)
-               if (!isset ($range['addrlist'][$ip]))
-                       echo "<tr><td class=tdleft><a href='${root}?page=ipaddress&ip=".long2ip($ip)."'>".long2ip($ip)."</a></td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
+       for ($ip = $startip; $ip <= $endip; $ip++) :
+               if (isset ($_REQUEST['hl_ipv4_addr']) and ip2long ($_REQUEST['hl_ipv4_addr']) == $ip)
+                       $secondstyle = 'tdleft port_highlight';
                else
+                       $secondstyle = 'tdleft';
+               if (!isset ($range['addrlist'][$ip]))
                {
-                       $numshared = countRefsOfType($range['addrlist'][$ip]['references'], 'shared', 'eq');
-                       $numreg = countRefsOfType($range['addrlist'][$ip]['references'], 'regular', 'eq');
-                       $numvirt = countRefsOfType($range['addrlist'][$ip]['references'], 'virtual', 'eq');
-                       $numlb = count ($range['addrlist'][$ip]['lbrefs']);
-                       $numrs = count ($range['addrlist'][$ip]['rsrefs']);
-                       
-                       $addr = $range['addrlist'][$ip];
-                       if ( ($numshared > 0 && $numreg > 0) || $numreg > 1 )
-                               echo "<tr class='trerror'>";
-                       elseif ( $addr['reserved'] == 'yes' and $numshared+$numreg+$numvirt+$numlb+$numrs > 0)
-                               echo "<tr class='trerror'>";
-                       elseif ( $addr['reserved'] == 'yes')
-                               echo "<tr class='trbusy'>";
-                       elseif ($numshared + $numreg + $numvirt + $numlb + $numrs > 0)
-                               echo "<tr class='trbusy'>";
-                       else
-                               echo "<tr>";
+                       echo "<tr><td class=tdleft><a href='${root}?page=ipaddress&ip=" . long2ip ($ip) . "'>" . long2ip ($ip);
+                       echo "</a></td><td class='${secondstyle}'>&nbsp;</td><td class='${secondstyle}'>&nbsp;</td></tr>\n";
+                       continue;
+               }
+               $numshared = countRefsOfType ($range['addrlist'][$ip]['references'], 'shared', 'eq');
+               $numreg = countRefsOfType ($range['addrlist'][$ip]['references'], 'regular', 'eq');
+               $numvirt = countRefsOfType ($range['addrlist'][$ip]['references'], 'virtual', 'eq');
+               $numlb = count ($range['addrlist'][$ip]['lbrefs']);
+               $numrs = count ($range['addrlist'][$ip]['rsrefs']);
 
-                       echo "<td class=tdleft><a href='${root}?page=ipaddress&ip=${addr['ip']}'>${addr['ip']}</a></td>";
-                       if (isset ($_REQUEST['hl_ipv4_addr']) and $_REQUEST['hl_ipv4_addr'] == $addr['ip'])
-                               $secondstyle = 'tdleft port_highlight';
-                       else
-                               $secondstyle = 'tdleft';
-                       echo "<td class='${secondstyle}'>${addr['name']}</td><td class='${secondstyle}'>";
+               $addr = $range['addrlist'][$ip];
+               if ( ($numshared > 0 && $numreg > 0) || $numreg > 1 )
+                       echo "<tr class='trerror'>";
+               elseif ( $addr['reserved'] == 'yes' and $numshared+$numreg+$numvirt+$numlb+$numrs > 0)
+                       echo "<tr class='trerror'>";
+               elseif ( $addr['reserved'] == 'yes')
+                       echo "<tr class='trbusy'>";
+               elseif ($numshared + $numreg + $numvirt + $numlb + $numrs > 0)
+                       echo "<tr class='trbusy'>";
+               else
+                       echo "<tr>";
+
+               echo "<td class=tdleft><a href='${root}?page=ipaddress&ip=${addr['ip']}'>${addr['ip']}</a></td>";
+               echo "<td class='${secondstyle}'>${addr['name']}</td><td class='${secondstyle}'>";
+               $delim = '';
+               $prologue = '';
+               if ( $addr['reserved'] == 'yes')
+               {
+                       echo "<b>Reserved</b> ";
+                       $delim = '; ';
+               }
+               foreach ($range['addrlist'][$ip]['references'] as $ref)
+               {
+                       echo "${delim}<a href='${root}?page=object&object_id=${ref['object_id']}";
+                       echo "&hl_ipv4_addr=${addr['ip']}'>";
+                       echo $ref['name'] . (empty ($ref['name']) ? '' : '@');
+                       echo "${ref['object_name']}</a>";
+                       $delim = '; ';
+               }
+               if ($delim != '')
+               {
+                       $delim = '';
+                       $prologue = '<br>';
+               }
+               foreach ($range['addrlist'][$ip]['lbrefs'] as $ref)
+               {
+                       echo $prologue;
+                       $prologue = '';
+                       echo "${delim}<a href='${root}?page=object&object_id=${ref['object_id']}'>";
+                       echo "${ref['object_name']}</a>:<a href='${root}?page=ipv4vs&vs_id=${ref['vs_id']}'>";
+                       echo "${ref['vport']}/${ref['proto']}</a>&rarr;";
+                       $delim = '; ';
+               }
+               if ($delim != '')
+               {
                        $delim = '';
+                       $prologue = '<br>';
+               }
+               foreach ($range['addrlist'][$ip]['rsrefs'] as $ref)
+               {
+                       echo $prologue;
                        $prologue = '';
-                       if ( $addr['reserved'] == 'yes')
-                       {
-                               echo "<b>Reserved</b> ";
-                               $delim = '; ';
-                       }
-                       foreach ($range['addrlist'][$ip]['references'] as $ref)
-                       {
-                               echo "${delim}<a href='${root}?page=object&object_id=${ref['object_id']}";
-                               echo "&hl_ipv4_addr=${addr['ip']}'>";
-                               echo $ref['name'] . (empty ($ref['name']) ? '' : '@');
-                               echo "${ref['object_name']}</a>";
-                               $delim = '; ';
-                       }
-                       if ($delim != '')
-                       {
-                               $delim = '';
-                               $prologue = '<br>';
-                       }
-                       foreach ($range['addrlist'][$ip]['lbrefs'] as $ref)
-                       {
-                               echo $prologue;
-                               $prologue = '';
-                               echo "${delim}<a href='${root}?page=object&object_id=${ref['object_id']}'>";
-                               echo "${ref['object_name']}</a>:<a href='${root}?page=ipv4vs&vs_id=${ref['vs_id']}'>";
-                               echo "${ref['vport']}/${ref['proto']}</a>&rarr;";
-                               $delim = '; ';
-                       }
-                       if ($delim != '')
-                       {
-                               $delim = '';
-                               $prologue = '<br>';
-                       }
-                       foreach ($range['addrlist'][$ip]['rsrefs'] as $ref)
-                       {
-                               echo $prologue;
-                               $prologue = '';
-                               echo "${delim}&rarr;${ref['rsport']}@<a href='${root}?page=ipv4rsp&pool_id=${ref['rspool_id']}'>";
-                               echo "${ref['rspool_name']}</a>";
-                               $delim = '; ';
-                       }
-                       echo "</td></tr>\n";
+                       echo "${delim}&rarr;${ref['rsport']}@<a href='${root}?page=ipv4rsp&pool_id=${ref['rspool_id']}'>";
+                       echo "${ref['rspool_name']}</a>";
+                       $delim = '; ';
                }
+               echo "</td></tr>\n";
+       endfor;
        // end of iteration
 
        echo "</table>";