r1852 + fix missing line break
[racktables] / inc / interface.php
index 74447ddcca182e59d17cb4a7192ee97ff261770b..bbdc119f7dc1d49830b1a599e77014cf13d65cb1 100644 (file)
@@ -244,11 +244,11 @@ function renderNewObjectForm ()
        if (isset ($_REQUEST['got_data']))
        {
                $log = array();
-               assertUIntArg ('object_type_id');
-               assertStringArg ('object_name', TRUE);
-               assertStringArg ('object_label', TRUE);
-               assertStringArg ('object_barcode', TRUE);
-               assertStringArg ('object_asset_no', TRUE);
+               assertUIntArg ('object_type_id', __FUNCTION__);
+               assertStringArg ('object_name', __FUNCTION__, TRUE);
+               assertStringArg ('object_label', __FUNCTION__, TRUE);
+               assertStringArg ('object_barcode', __FUNCTION__, TRUE);
+               assertStringArg ('object_asset_no', __FUNCTION__, TRUE);
                $type_id = $_REQUEST['object_type_id'];
                $name = $_REQUEST['object_name'];
                $label = $_REQUEST['object_label'];
@@ -290,9 +290,9 @@ function renderNewRackForm ($row_id)
        if (isset ($_REQUEST['got_data']))
        {
                $log = array();
-               assertStringArg ('rack_name');
-               assertUIntArg ('rack_height');
-               assertStringArg ('rack_comment', TRUE);
+               assertStringArg ('rack_name', __FUNCTION__);
+               assertUIntArg ('rack_height', __FUNCTION__);
+               assertStringArg ('rack_comment', __FUNCTION__, TRUE);
                $name = $_REQUEST['rack_name'];
                $height = $_REQUEST['rack_height'];
                $comment = $_REQUEST['rack_comment'];
@@ -330,11 +330,11 @@ function renderEditObjectForm ($object_id)
        {
                $log = array();
                // object_id is already verified by page handler
-               assertUIntArg ('object_type_id');
-               assertStringArg ('object_name', TRUE);
-               assertStringArg ('object_label', TRUE);
-               assertStringArg ('object_barcode', TRUE);
-               assertStringArg ('object_asset_no', TRUE);
+               assertUIntArg ('object_type_id', __FUNCTION__);
+               assertStringArg ('object_name', __FUNCTION__, TRUE);
+               assertStringArg ('object_label', __FUNCTION__, TRUE);
+               assertStringArg ('object_barcode', __FUNCTION__, TRUE);
+               assertStringArg ('object_asset_no', __FUNCTION__, TRUE);
                $type_id = $_REQUEST['object_type_id'];
                if (isset ($_REQUEST['object_has_problems']) and $_REQUEST['object_has_problems'] == 'on')
                        $has_problems = 'yes';
@@ -461,10 +461,10 @@ function renderEditRackForm ($rack_id)
        if (isset ($_REQUEST['got_data']))
        {
                $log = array();
-               assertUIntArg ('rack_row_id');
-               assertUIntArg ('rack_height');
-               assertStringArg ('rack_name');
-               assertStringArg ('rack_comment', TRUE);
+               assertUIntArg ('rack_row_id', __FUNCTION__);
+               assertUIntArg ('rack_height', __FUNCTION__);
+               assertStringArg ('rack_name', __FUNCTION__);
+               assertStringArg ('rack_comment', __FUNCTION__, TRUE);
                $row_id = $_REQUEST['rack_row_id'];
                $height = $_REQUEST['rack_height'];
                $name = $_REQUEST['rack_name'];
@@ -511,13 +511,62 @@ function renderEditRackForm ($rack_id)
 // This is a helper for creators and editors.
 function printSelect ($rowList, $select_name, $selected_id = 1)
 {
-       echo "<select name=${select_name}>";
+       // First collect all data for OPTGROUPs, then ouput it and dump
+       // the rest of records as is.
+       $optgroup = array();
+       $other = array();
        foreach ($rowList as $dict_key => $dict_value)
        {
-               echo "<option value=${dict_key}";
-               if ($dict_key == $selected_id)
-                       echo ' selected';
-               echo ">${dict_value}</option>";
+               if (strpos ($dict_value, '^') !== FALSE)
+               {
+                       $tmp = explode ('^', $dict_value, 2);
+                       $optgroup[$tmp[0]][$dict_key] = $tmp[1];
+               }
+               elseif (strpos ($dict_value, '&') !== FALSE)
+               {
+                       $tmp = explode ('&', $dict_value, 2);
+                       $optgroup[$tmp[0]][$dict_key] = $tmp[1];
+               }
+               else
+                       $other[$dict_key] = $dict_value;
+       }
+       echo "<select name=${select_name}>";
+       if (!count ($optgroup))
+       {
+               foreach ($other as $dict_key => $dict_value)
+               {
+                       echo "<option value=${dict_key}";
+                       if ($dict_key == $selected_id)
+                               echo ' selected';
+                       echo ">${dict_value}</option>";
+               }
+       }
+       else
+       {
+               foreach ($optgroup as $groupname => $groupdata)
+               {
+                       echo "<optgroup label='${groupname}'>";
+                       foreach ($groupdata as $dict_key => $dict_value)
+                       {
+                               echo "<option value=${dict_key}";
+                               if ($dict_key == $selected_id)
+                                       echo ' selected';
+                               echo ">${dict_value}</option>";
+                       }
+                       echo "</optgroup>\n";
+               }
+               if (count ($other))
+               {
+                       echo "<optgroup label='other'>\n";
+                       foreach ($other as $dict_key => $dict_value)
+                       {
+                               echo "<option value=${dict_key}";
+                               if ($dict_key == $selected_id)
+                                       echo ' selected';
+                               echo ">${dict_value}</option>";
+                       }
+                       echo "</optgroup>\n";
+               }
        }
        echo "</select>";
 }
@@ -658,9 +707,10 @@ function renderRackObject ($object_id = 0)
                echo "<tr><th width='50%' class=tdright>Barcode:</th><td class=tdleft>${info['barcode']}</td></tr>\n";
        if ($info['has_problems'] == 'yes')
                echo "<tr><td colspan=2 class=msg_error>Has problems</td></tr>\n";
-       foreach (getAttrValues ($object_id) as $record)
+       foreach (getAttrValues ($object_id, TRUE) as $record)
                if (!empty ($record['value']))
                        echo "<tr><th width='50%' class=opt_attr_th>${record['name']}:</th><td class=tdleft>${record['a_value']}</td></tr>\n";
+       printTagTRs();
        echo "</table><br>\n";
        finishPortlet();
 
@@ -681,7 +731,7 @@ function renderRackObject ($object_id = 0)
                        $hl_port_id = 0;
                        if (isset ($_REQUEST['hl_port_id']))
                        {
-                               assertUIntArg ('hl_port_id');
+                               assertUIntArg ('hl_port_id', __FUNCTION__);
                                $hl_port_id = $_REQUEST['hl_port_id'];
                        }
                        echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
@@ -879,7 +929,7 @@ function renderRackObject ($object_id = 0)
                        echo '</a>';
                        if (!empty ($info['name']))
                                echo " (${info['name']})";
-                       echo "</td><td class=tdleft><a href='${root}?page=rspool&id=${info['pool_id']}'>";
+                       echo "</td><td class=tdleft><a href='${root}?page=rspool&pool_id=${info['pool_id']}'>";
                        echo (empty ($info['pool_name']) ? 'ANONYMOUS' : $info['pool_name']);
                        echo '</a></td><td class=tdleft>' . $info['rscount'] . '</td>';
                        echo "<td class=tdleft><pre>${info['vsconfig']}</pre></td>";
@@ -1445,6 +1495,8 @@ function renderProblematicObjectsPortlet ()
 function renderObjectGroupSummary ()
 {
        global $root;
+       $tagfilter = isset ($_REQUEST['tagfilter']) ? $_REQUEST['tagfilter'] : array();
+       $tagfilter = complementByKids ($tagfilter);
        $summary = getObjectGroupInfo();
        if ($summary === NULL)
        {
@@ -1456,22 +1508,138 @@ function renderObjectGroupSummary ()
 
        startPortlet ('Summary');
        foreach ($summary as $gi)
-       {
                echo "<a href='${root}?page=objgroup&group_id=${gi['id']}'><b>${gi['name']}</b></a> <i>(${gi['count']})</i><br>";
-       }
        finishPortlet();
 
        echo '</td><td class=pcright>';
        renderUnmountedObjectsPortlet();
        echo '</td><td class=pcright>';
        renderProblematicObjectsPortlet();
+       echo '</td><td class=pcright>';
+       startPortlet ('Tag filter');
+       renderTagFilterSelect ($tagfilter, 'object');
+       finishPortlet();
+       echo "</td></tr></table>\n";
+}
+
+function renderObjectSpace ()
+{
+       global $root, $taglist, $tagtree;
+       echo "<table border=0 class=objectview>\n";
+       echo "<tr><td class=pcleft width='50%'>";
+       startPortlet ('View all by type');
+       $groupInfo = getObjectGroupInfo();
+       if ($groupInfo === NULL)
+       {
+               showError ('getObjectGroupInfo() failed', __FUNCTION__);
+               return;
+       }
+       if (count ($groupInfo) == 0)
+               echo "No objects exist in DB";
+       else
+       {
+               echo '<div align=left><ul>';
+               foreach ($groupInfo as $gi)
+                       echo "<li><a href='${root}?page=objgroup&group_id=${gi['id']}'>${gi['name']}</a> (${gi['count']})</li>";
+               echo '</ul></div>';
+       }
+       finishPortlet();
+
+       echo '</td><td class=pcright>';
+
+       startPortlet ('View all by tag');
+       if (count ($taglist) == 0)
+               echo "No tags exist in DB";
+       else
+               renderTagCloud ('object');
+       finishPortlet();
        echo "</td></tr></table>\n";
 }
 
 function renderObjectGroup ()
+{
+       global $root, $pageno, $tabno, $nextorder, $taglist, $tagtree;
+       assertUIntArg ('group_id', __FUNCTION__, TRUE);
+       $group_id = $_REQUEST['group_id'];
+       $tagfilter = isset ($_REQUEST['tagfilter']) ? $_REQUEST['tagfilter'] : array();
+       $tagfilter_str = getStringFromTrail (getExplicitTagsOnly (buildTrailFromIds ($tagfilter)));
+       $tagfilter = complementByKids ($tagfilter);
+       echo "<form>\n";
+       echo "<input type=hidden name=page value=${pageno}>\n";
+       echo "<input type=hidden name=group_id value=${group_id}>\n";
+       echo "<table border=0 class=objectview>\n";
+       echo "<tr><td class=pcleft width='25%'>";
+       startPortlet ('change type');
+       $groupInfo = getObjectGroupInfo();
+       if ($groupInfo === NULL)
+       {
+               showError ('getObjectGroupInfo() failed', __FUNCTION__);
+               return;
+       }
+       if (count ($groupInfo) == 0)
+               echo "No objects exist in DB";
+       else
+       {
+               echo '<div align=left><ul>';
+               foreach ($groupInfo as $gi)
+               {
+                       echo "<li><a href='${root}?page=${pageno}&group_id=${gi['id']}&tagfilter[]=${tagfilter_str}'>";
+                       if ($gi['id'] == $group_id)
+                               echo '<strong>';
+                       echo "${gi['name']}</a>";
+                       if ($gi['id'] == $group_id)
+                               echo '</strong>';
+                       echo " (${gi['count']})";
+                       if ($gi['id'] == $group_id)
+                               echo ' &larr;';
+                       echo "</li>";
+               }
+               echo '</ul></div>';
+       }
+       finishPortlet();
+
+       echo '</td><td class=pcleft>';
+
+       startPortlet ('Objects');
+       $objects = getObjectList ($group_id, $tagfilter);
+       if ($objects === NULL)
+       {
+               showError ('getObjectList() failed', __FUNCTION__);
+               return;
+       }
+       echo '<br><br><table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
+       echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Barcode</th><th>Rack</th></tr>';
+       $order = 'odd';
+       foreach ($objects as $obj)
+       {
+               echo "<tr class=row_${order}><td><a href='${root}?page=object&object_id=${obj['id']}'>${obj['dname']}</a></td>";
+               echo "<td>${obj['label']}</td>";
+               echo "<td>${obj['asset_no']}</td>";
+               echo "<td>${obj['barcode']}</td>";
+               if ($obj['rack_id'])
+                       echo "<td><a href='${root}?page=rack&rack_id=${obj['rack_id']}'>${obj['Rack_name']}</a></td>";
+               else
+                       echo '<td>Unmounted</td>';
+               echo '</tr>';
+               $order = $nextorder[$order];
+       }
+       echo '</table>';
+       finishPortlet();
+
+       echo "</td><td class=pcright width='25%'>";
+
+       startPortlet ('change filter');
+       renderTagFilterSelect ($tagfilter, 'object');
+       echo "<input type=submit value='Apply'>\n";
+       finishPortlet();
+       echo "</td></tr></table>\n";
+       echo '</form>';
+}
+
+function renderObjectGroup_old ()
 {
        global $root;
-       assertUIntArg ('group_id');
+       assertUIntArg ('group_id', __FUNCTION__);
        $group_id = $_REQUEST['group_id'];
        $summary = getObjectGroupInfo();
        if ($summary == NULL)
@@ -1672,9 +1840,14 @@ function renderAddressspace ()
 {
        global $root, $page;
 
+       echo "<table border=0 class=objectview>\n";
+       echo "<tr><td class=pcleft>";
+
        startPortlet ('Subnets');
        echo "<table class='widetable' border=0 cellpadding=10 cellspacing=0 align='center'>\n";
-       $addrspaceList = getAddressspaceList();
+       $tagfilter = isset ($_REQUEST['tagfilter']) ? $_REQUEST['tagfilter'] : array();
+       $tagfilter = complementByKids ($tagfilter);
+       $addrspaceList = getAddressspaceList ($tagfilter);
        echo "<tr><th>Subnet</th><th>Name</th><th>Utilization</th></tr>";
        foreach ($addrspaceList as $iprange)
        {
@@ -1688,6 +1861,9 @@ function renderAddressspace ()
        }
        echo "</table>\n";
        finishPortlet();
+       echo '</td><td class=pcright>';
+       renderTagFilterPortlet ($tagfilter, 'ipv4net');
+       echo "</td></tr></table>\n";
 }
 
 function renderIPv4SLB ()
@@ -1741,7 +1917,7 @@ function renderIPv4SLB ()
                                else
                                {
                                        echo $vsdata['lblist'][$lb_object_id]['size'];
-                                       echo " (<a href='${root}?page=rspool&id=";
+                                       echo " (<a href='${root}?page=rspool&pool_id=";
                                        echo $vsdata['lblist'][$lb_object_id]['id'] . "'>";
                                        echo $vsdata['lblist'][$lb_object_id]['name'] . '</a>)';
                                }
@@ -1760,20 +1936,25 @@ function renderAddNewRange ()
        global $root, $pageno, $tabno;
        showMessageOrError();
 
-       echo "<center><h2>Add New</h2></center>\n";
+       startPortlet ("Add New");
        echo "<table class='widetable' border=0 cellpadding=10 align='center'>\n";
-       echo "<tr><th>Address range</th><th>Name</th><th>C&gt;*</th><th>&nbsp;</th></tr>\n";
+       echo "<tr><th>Address range</th><th>Name</th><th>connected network</th><th>assign tags</th><th>&nbsp;</th></tr>\n";
        echo "<form name='add_new_range' action='process.php'>\n";
        echo "<input type=hidden name=op value=addRange>\n";
        echo "<input type=hidden name=page value='${pageno}'>\n";
        echo "<input type=hidden name=tab value='${tabno}'>\n";
-       echo "<tr><td class='tdcenter'><input type=text name='range' size=18 class='live-validate' tabindex=1></td>\n";
+       echo "<tr valign=top><td class='tdcenter'><input type=text name='range' size=18 class='live-validate' tabindex=1></td>\n";
        echo "<td class='tdcenter'><input type=text name='name' size='20' tabindex=2></td>\n";
        echo "<td class='tdcenter'><input type=checkbox name='is_bcast' tabindex=3 checked></td>\n";
-       echo "<td class='tdcenter'><input type=submit value='Add a new range' tabindex=4></td></tr>\n";
+       echo "<td>\n";
+       renderTagSelect();
+       echo "</td>\n";
+       echo "<td class='tdcenter'><input type=submit value='Add a new range' tabindex=4></td>\n";
+       echo "</td></tr>\n";
        echo "</form></table><br><br>\n";
+       finishPortlet();
 
-       echo "<center><h2>Manage Existing</h2></center>\n";
+       startPortlet ("Manage Existing");
        echo "<table class='widetable' border=0 cellpadding=10 align='center'>\n";
        $addrspaceList = getAddressspaceList();
        echo "<tr><th>&nbsp;</th><th>Address range</th><th>Name</th><th>Utilization</th></tr>";
@@ -1791,17 +1972,90 @@ function renderAddNewRange ()
                }
                else
                        printImageHREF ('nodelete', 'There are IP addresses allocated or reserved');
-               echo "</td>\n<td><a href='${root}?page=iprange&id=${iprange['id']}'>${iprange['ip']}/${iprange['mask']}</a></td><td>${iprange['name']}</td><td class=tdleft>";
+               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 "</td><td class=tdleft>";
                renderProgressBar ($usedips / $totalips);
                echo " ${usedips}/${totalips}";
                echo "</td></tr>";
        }
        echo "</table>";
+       finishPortlet();
 }
 
 function renderIPRange ($id)
 {
        global $root, $pageno, $tabno;
+       $netmaskbylen = array
+       (
+               32 => '255.255.255.255',
+               31 => '255.255.255.254',
+               30 => '255.255.255.252',
+               29 => '255.255.255.248',
+               28 => '255.255.255.240',
+               27 => '255.255.255.224',
+               26 => '255.255.255.192',
+               25 => '255.255.255.128',
+               24 => '255.255.255.0',
+               23 => '255.255.254.0',
+               22 => '255.255.252.0',
+               21 => '255.255.248.0',
+               20 => '255.255.240.0',
+               19 => '255.255.224.0',
+               18 => '255.255.192.0',
+               17 => '255.255.128.0',
+               16 => '255.255.0.0',
+               15 => '255.254.0.0',
+               14 => '255.252.0.0',
+               13 => '255.248.0.0',
+               12 => '255.240.0.0',
+               11 => '255.224.0.0',
+               10 => '255.192.0.0',
+               9 => '255.128.0.0',
+               8 => '255.0.0.0',
+               7 => '254.0.0.0',
+               6 => '252.0.0.0',
+               5 => '248.0.0.0',
+               4 => '240.0.0.0',
+               3 => '224.0.0.0',
+               2 => '192.0.0.0',
+               1 => '128.0.0.0'
+       );
+       $wildcardbylen = array
+       (
+               32 => '0.0.0.0',
+               31 => '0.0.0.1',
+               30 => '0.0.0.3',
+               29 => '0.0.0.7',
+               28 => '0.0.0.15',
+               27 => '0.0.0.31',
+               26 => '0.0.0.63',
+               25 => '0.0.0.127',
+               24 => '0.0.0.255',
+               23 => '0.0.1.255',
+               22 => '0.0.3.255',
+               21 => '0.0.7.255',
+               20 => '0.0.15.255',
+               19 => '0.0.31.255',
+               18 => '0.0.63.255',
+               17 => '0.0.127.255',
+               16 => '0.0.255.25',
+               15 => '0.1.255.255',
+               14 => '0.3.255.255',
+               13 => '0.7.255.255',
+               12 => '0.15.255.255',
+               11 => '0.31.255.255',
+               10 => '0.63.255.255',
+               9 => '0.127.255.255',
+               8 => '0.255.255.255',
+               7 => '1.255.255.255',
+               6 => '3.255.255.255',
+               5 => '7.255.255.255',
+               4 => '15.255.255.255',
+               3 => '31.255.255.255',
+               2 => '63.255.255.255',
+               1 => '127.255.255.255'
+       );
        $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE');
        if (isset($_REQUEST['pg']))
                $page = $_REQUEST['pg'];
@@ -1809,8 +2063,30 @@ function renderIPRange ($id)
                $page=0;
 
        $range = getIPRange($id);
-       echo "<center><h1>${range['ip']}/${range['mask']}</h1><h2>${range['name']}</h2></center>\n";
+       echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
+       echo "<tr><td colspan=2 align=center><h1>${range['ip']}/${range['mask']}</h1><h2>${range['name']}</h2></td></tr>\n";
 
+       echo "<tr><td class=pcleft width='50%'>";
+       startPortlet ('summary');
+       $total = ($range['ip_bin'] | $range['mask_bin_inv']) - ($range['ip_bin'] & $range['mask_bin']) + 1;
+       $used = count ($range['addrlist']);
+       echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n";
+       echo "<tr><th width='50%' class=tdright>Utilization:</th><td class=tdleft>";
+       renderProgressBar ($used/$total);
+       echo "&nbsp;${used}/${total}</td></tr>\n";
+       echo "<tr><th width='50%' class=tdright>Netmask:</th><td class=tdleft>";
+       echo $netmaskbylen[$range['mask']];
+       echo "</td></tr>\n";
+       echo "<tr><th width='50%' class=tdright>Wildcard bits:</th><td class=tdleft>";
+       echo $wildcardbylen[$range['mask']];
+       echo "</td></tr>\n";
+       printTagTRs();
+       echo "</table><br>\n";
+       finishPortlet();
+       echo "</td>\n";
+
+       echo "<td class=pcright>";
+       startPortlet ('details');
        $startip = $range['ip_bin'] & $range['mask_bin'];
        $endip = $range['ip_bin'] | $range['mask_bin_inv'];
        $realstartip = $startip;
@@ -1845,21 +2121,24 @@ function renderIPRange ($id)
                        $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 > 0)
+                       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 > 0 || $numreg > 0)
+                       elseif ( $numshared > 0 || $numreg > 0 || $numlb > 0 || $numrs > 0)
                                echo "<tr class='trbusy'>";
                        else
                                echo "<tr>";
 
                        echo "<td><a href='${root}?page=ipaddress&ip=${addr['ip']}'>${addr['ip']}</a></td><td>${addr['name']}</td><td>";
                        $delim = '';
+                       $prologue = '';
                        if ( $addr['reserved'] == 'yes')
                        {
                                echo "<b>Reserved</b> ";
@@ -1872,6 +2151,33 @@ function renderIPRange ($id)
                                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=vservice&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=rspool&pool_id=${ref['rspool_id']}'>";
+                               echo "${ref['rspool_name']}</a>";
+                               $delim = '; ';
+                       }
                        echo "</td></tr>\n";
                }
                else
@@ -1881,7 +2187,8 @@ function renderIPRange ($id)
        }
 
        echo "</table>";
-       
+       finishPortlet();
+       echo "</td></tr></table>\n";
 }
 
 function renderIPRangeProperties ($id)
@@ -1979,7 +2286,7 @@ function renderIPAddress ()
                                printImageHREF ('inservice', 'in service');
                        else
                                printImageHREF ('notinservice', 'NOT in service');
-                       echo "</td><td class=tdleft>${rsinfo['rsport']}</td><td class=tdleft><a href='${root}?page=rspool&id=${rsinfo['pool_id']}'>";
+                       echo "</td><td class=tdleft>${rsinfo['rsport']}</td><td class=tdleft><a href='${root}?page=rspool&pool_id=${rsinfo['pool_id']}'>";
                        echo $rsinfo['poolname'] . "</a></td></tr>\n";
                }
                echo "</table><br><br>";
@@ -2195,7 +2502,7 @@ function renderIPAddressPortForwarding ($object_id=0)
 
 function renderAddMultipleObjectsForm ()
 {
-       global $pageno, $tabno, $nextorder;
+       global $root, $pageno, $tabno, $nextorder;
 
        $type_id = array();
        $global_type_id = 0;
@@ -2215,11 +2522,11 @@ function renderAddMultipleObjectsForm ()
                                $log[] = array ('code' => 'error', 'message' => "Submitted form is invalid at line " . $i + 1);
                                break;
                        }
-                       assertUIntArg ("${i}_object_type_id", TRUE);
-                       assertStringArg ("${i}_object_name", TRUE);
-                       assertStringArg ("${i}_object_label", TRUE);
-                       assertStringArg ("${i}_object_asset_no", TRUE);
-                       assertStringArg ("${i}_object_barcode", TRUE);
+                       assertUIntArg ("${i}_object_type_id", __FUNCTION__, TRUE);
+                       assertStringArg ("${i}_object_name", __FUNCTION__, TRUE);
+                       assertStringArg ("${i}_object_label", __FUNCTION__, TRUE);
+                       assertStringArg ("${i}_object_asset_no", __FUNCTION__, TRUE);
+                       assertStringArg ("${i}_object_barcode", __FUNCTION__, TRUE);
                        $type_id[$i] = $_REQUEST["${i}_object_type_id"];
                        // Save user input for possible rendering.
                        $name[$i] = $_REQUEST["${i}_object_name"];
@@ -2239,8 +2546,8 @@ function renderAddMultipleObjectsForm ()
        elseif (isset ($_REQUEST['got_very_fast_data']))
        {
                $keepvalues = TRUE;
-               assertUIntArg ('global_type_id', TRUE);
-               assertStringArg ('namelist', TRUE);
+               assertUIntArg ('global_type_id', __FUNCTION__, TRUE);
+               assertStringArg ('namelist', __FUNCTION__, TRUE);
                $global_type_id = $_REQUEST['global_type_id'];
                if ($global_type_id == 0)
                {
@@ -2277,9 +2584,7 @@ function renderAddMultipleObjectsForm ()
        $typelist[0] = 'select type...';
 
        startPortlet ('Fast way');
-       echo '<form>';
-       echo "<input type=hidden name=page value=${pageno}>";
-       echo "<input type=hidden name=tab value=${tabno}>";
+       echo "<form name=fastform method=post action='${root}?page=${pageno}&tab=${tabno}'>";
        echo '<table border=0 align=center>';
        echo "<tr><th>Object type</th><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Barcode</th></tr>\n";
        // If a user forgot to select object type on input, we keep his
@@ -2314,9 +2619,7 @@ function renderAddMultipleObjectsForm ()
        finishPortlet();
 
        startPortlet ('Very fast way');
-       echo '<form>';
-       echo "<input type=hidden name=page value=${pageno}>";
-       echo "<input type=hidden name=tab value=${tabno}>";
+       echo "<form name=veryfastform method=post action='${root}?page=${pageno}&tab=${tabno}'>";
        echo 'For each line shown below create an object of type ';
        printSelect ($typelist, "global_type_id", getConfigVar ('DEFAULT_OBJECT_TYPE'));
        echo " <input type=submit name=got_very_fast_data value='Go!'><br>\n";
@@ -2348,38 +2651,26 @@ function renderSearchResults ()
                showError ('You are not authorized for viewing information about objects.', __FUNCTION__);
                return;
        }
+       $nhits = 0;
        // If we search for L2 address, we can either find one or find none.
        if
        (
                preg_match ('/^[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?$/i', $terms) or
                preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms) or
-               preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms)
+               preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms) or
+               // STP bridge ID: bridge priotity + port MAC address. Cut off first 4 chars and look for MAC address.
+               preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms)
        )
        // Search for L2 address.
        {
+               $terms = substr ($terms, -12);
                $result = searchByl2address ($terms);
                if ($result !== NULL)
                {
-                       echo "<script language='Javascript'>document.location='${root}?page=object";
-                       echo "&hl_port_id=${result['port_id']}";
-                       echo "&object_id=${result['object_id']}';//</script>";
+                       $nhits++;
+                       $lasthit = 'port';
+                       $summary['port'][] = $result;
                }
-               else
-                       echo "L2 address '${terms}' not found!";
-       }
-       elseif (preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms))
-       // STP bridge ID: bridge priotity + port MAC address. Cut off first 4 chars and look for MAC address.
-       {
-               $terms = substr ($terms, 4);
-               $result = searchByl2address ($terms);
-               if ($result !== NULL)
-               {
-                       echo "<script language='Javascript'>document.location='${root}?page=object";
-                       echo "&hl_port_id=${result['port_id']}";
-                       echo "&object_id=${result['object_id']}';//</script>";
-               }
-               else
-                       echo "L2 address '${terms}' not found!";
        }
        elseif (preg_match ('/^[0-9][0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?$/i', $terms))
        // Search for IP address.
@@ -2387,41 +2678,121 @@ function renderSearchResults ()
                $result = getRangeByIp ($terms);
                if ($result !== NULL)
                {
-                       echo "<script language='Javascript'>document.location='${root}?page=ipaddress";
-                       echo "&ip=${terms}";
-                       echo "';//</script>";
+                       $nhits++;
+                       $lasthit = 'ipv4address1';
+                       $summary['ipv4address1'][] = $terms;
                }
-               else
-                       echo "IP address '${terms}' not found!";
-               return;
        }
        else
-       // Search for objects.
+       // Search for objects, addresses, networks, virtual services and RS pools by their description.
        {
-               $objects = getSearchResults ($terms);
-               if (count ($objects) == 1)
+               $tmp = getObjectSearchResults ($terms);
+               if (count ($tmp))
+               {
+                       $nhits += count ($tmp);
+                       $lasthit = 'object';
+                       $summary['object'] = $tmp;
+               }
+               $tmp = getIPv4AddressSearchResult ($terms);
+               if (count ($tmp))
                {
-                       $obj = current ($objects);
-                       echo "<script language='Javascript'>document.location='${root}?page=object&object_id=${obj['id']}';//</script>";
+                       $nhits += count ($tmp);
+                       $lasthit = 'ipv4address2';
+                       $summary['ipv4address2'] = $tmp;
                }
-               elseif (count ($objects) > 1)
+               $tmp = getIPv4PrefixSearchResult ($terms);
+               if (count ($tmp))
                {
-                       echo '<br><br><table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
-                       echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>barcode</th></tr>';
-                       $order = 'odd';
-                       global $nextorder;
-                       foreach ($objects as $obj)
+                       $nhits += count ($tmp);
+                       $lasthit = 'ipv4network';
+                       $summary['ipv4network'] = $tmp;
+               }
+       }
+       if ($nhits == 0)
+               echo "<center><h2>Nothing found for '${terms}'</h2></center>";
+       elseif ($nhits == 1)
+       {
+               $record = current ($summary[$lasthit]);
+               switch ($lasthit)
+               {
+                       case 'port':
+                               echo "<script language='Javascript'>document.location='${root}?page=object";
+                               echo "&hl_port_id=" . $record['port_id'];
+                               echo "&object_id=" . $record['object_id'] . "';//</script>";
+                               break;
+                       case 'ipv4address1':
+                               echo "<script language='Javascript'>document.location='${root}?page=ipaddress";
+                               echo "&ip=${record}";
+                               echo "';//</script>";
+                               break;
+                       case 'ipv4address2':
+                               echo "<script language='Javascript'>document.location='${root}?page=ipaddress";
+                               echo "&ip=${record}";
+                               echo "';//</script>";
+                               break;
+                       case 'ipv4network':
+                               echo "<script language='Javascript'>document.location='${root}?page=iprange";
+                               echo "&id=${record['id']}";
+                               echo "';//</script>";
+                               break;
+                       case 'object':
+                               echo "<script language='Javascript'>document.location='${root}?page=object&object_id=${record['id']}';//</script>";
+                               break;
+               }
+               return;
+       }
+       else
+       {
+               global $nextorder;
+               $order = 'odd';
+               echo "<center><h2>${nhits} result(s) found for '${terms}'</h2></center>";
+               foreach ($summary as $where => $what)
+                       switch ($where)
                        {
-                               echo "<tr class=row_${order}><td><a href=\"${root}?page=object&object_id=${obj['id']}\">${obj['dname']}</a></td>";
-                               echo "<td>${obj['label']}</td>";
-                               echo "<td>${obj['asset_no']}</td>";
-                               echo "<td>${obj['barcode']}</td></tr>";
-                               $order = $nextorder[$order];
+                               case 'object':
+                                       startPortlet ('Objects');
+                                       echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
+                                       echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>barcode</th></tr>';
+                                       foreach ($what as $obj)
+                                       {
+                                               echo "<tr class=row_${order}><td><a href=\"${root}?page=object&object_id=${obj['id']}\">${obj['dname']}</a></td>";
+                                               echo "<td>${obj['label']}</td>";
+                                               echo "<td>${obj['asset_no']}</td>";
+                                               echo "<td>${obj['barcode']}</td></tr>";
+                                               $order = $nextorder[$order];
+                                       }
+                                       echo '</table>';
+                                       finishPortlet();
+                                       break;
+                               case 'ipv4network':
+                                       startPortlet ('IPv4 networks');
+                                       echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
+                                       echo '<tr><th>Network</th><th>Descritpion</th></tr>';
+                                       foreach ($what as $net)
+                                       {
+                                               echo "<tr class=row_${order}><td class=tdleft><a href='${root}?page=iprange&id=${net['id']}'>${net['ip']}";
+                                               echo '/' . $net['mask'] . '</a></td>';
+                                               echo "<td class=tdleft>${net['name']}</td></tr>";
+                                               $order = $nextorder[$order];
+                                       }
+                                       echo '</table>';
+                                       finishPortlet();
+                                       break;
+                               case 'ipv4address2':
+                                       startPortlet ('IPv4 addresses');
+                                       echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
+                                       echo '<tr><th>Address</th><th>Descritpion</th></tr>';
+                                       foreach ($what as $addr)
+                                       {
+                                               echo "<tr class=row_${order}><td class=tdleft><a href='${root}?page=ipaddress&ip=${addr['ip']}'>";
+                                               echo "${addr['ip']}</a></td>";
+                                               echo "<td class=tdleft>${addr['name']}</td></tr>";
+                                               $order = $nextorder[$order];
+                                       }
+                                       echo '</table>';
+                                       finishPortlet();
+                                       break;
                        }
-                       echo '</table>';
-               }
-               else
-                       echo "Object '${terms}' not found!";
        }
 }
 
@@ -2485,7 +2856,9 @@ function renderAccounts ()
        $order = 'odd';
        foreach ($accounts as $user)
        {
-               echo "<tr class=row_${order}><td class=tdleft>${user['user_name']}</td><td class=tdleft>${user['user_realname']}</td></li>";
+               echo "<tr class=row_${order}><td class=tdleft><div title='\$userid_${user['user_id']}'>";
+               echo "${user['user_name']}</div></td>";
+               echo "<td class=tdleft>${user['user_realname']}</td></li>";
                $order = $nextorder[$order];
        }
        echo '</table>';
@@ -2618,6 +2991,16 @@ function renderPermissionsEditForm ()
        finishPortlet();
 }
 
+function renderPortMapViewer ()
+{
+       renderPortMap (FALSE);
+}
+
+function renderPortMapEditor ()
+{
+       renderPortMap (TRUE);
+}
+
 function renderPortMap ($editable = FALSE)
 {
        global $nextorder, $root, $pageno, $tabno;
@@ -2701,6 +3084,7 @@ function renderRackPage ($rack_id)
        echo "<tr><th width='50%' class=tdright>Objects:</th><td class=tdleft>";
        echo getObjectCount ($rackData);
        echo "</td></tr>\n";
+       printTagTRs();
        if (!empty ($rackData['comment']))
                echo "<tr><th width='50%' class=tdright>Comment:</th><td class=tdleft>${rackData['comment']}</td></tr>\n";
        echo '</table>';
@@ -2720,7 +3104,7 @@ function renderRackPage ($rack_id)
 function renderDictionary ()
 {
        global $nextorder;
-       $dict = getDict();
+       $dict = getDict (TRUE);
        echo "<br><table class=cooltable border=0 cellpadding=5 cellspacing=0 align=center>\n";
        foreach ($dict as $chapter_no => $chapter)
        {
@@ -2746,7 +3130,7 @@ function renderDictionary ()
                        }
                }
        }
-       echo "</table>\n";
+       echo "</table>\n<br>";
 }
 
 function renderDictionaryEditor ()
@@ -3014,9 +3398,6 @@ function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
        $image['reports']['path'] = 'pix/report.png';
        $image['reports']['width'] = 218;
        $image['reports']['height'] = 200;
-       $image['help']['path'] = 'pix/help.png';
-       $image['help']['width'] = 218;
-       $image['help']['height'] = 200;
        $image['reserve']['path'] = 'pix/stop.png';
        $image['reserve']['width'] = 16;
        $image['reserve']['height'] = 16;
@@ -3042,9 +3423,6 @@ function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
        $image['nodelete']['height'] = 16;
        $image['grant'] = $image['add'];
        $image['revoke'] = $image['delete'];
-       $image['helphint']['path'] = 'pix/helphint.png';
-       $image['helphint']['width'] = 24;
-       $image['helphint']['height'] = 24;
        $image['inservice']['path'] = 'pix/go.png';
        $image['inservice']['width'] = 16;
        $image['inservice']['height'] = 16;
@@ -3054,6 +3432,9 @@ function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
        $image['find']['path'] = 'pix/find.png';
        $image['find']['width'] = 16;
        $image['find']['height'] = 16;
+       $image['spacer']['path'] = 'pix/pixel.png';
+       $image['spacer']['width'] = 16;
+       $image['spacer']['height'] = 16;
        if (!isset ($image[$tag]))
                $tag = 'error';
        $img = $image[$tag];
@@ -3213,7 +3594,7 @@ function renderVLANMembership ($object_id = 0)
                // included. The gateway is expected to filter unnecessary changes silently
                // and to provide a list of responses with either error or success message
                // for each of the rest.
-               assertUIntArg ('portcount');
+               assertUIntArg ('portcount', __FUNCTION__);
                $nports = $_REQUEST['portcount'];
                $prefix = 'set ';
                $log = array();
@@ -3411,12 +3792,12 @@ function renderSNMPPortFinder ($object_id = 0)
                $hwtype[527] = 210;
                $ciscomodel[561] = 'WS-C2970G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)';
                $hwtype[561] = 115;
-#              $ciscomodel[633] = 'WS-C3560-24TS (24 Ethernet 10/100 ports and 2 10/100/1000 SFP uplinks)';
-#              $hwtype[633] = 169;
+               $ciscomodel[633] = 'WS-C3560-24TS (24 Ethernet 10/100 ports and 2 10/100/1000 SFP uplinks)';
+               $hwtype[633] = 169;
                $ciscomodel[634] = 'WS-C3560-48TS (48 Ethernet 10/100 ports and 4 10/100/1000 SFP uplinks)';
                $hwtype[634] = 170;
-#              $ciscomodel[563] = 'WS-C3560-24PS (24 Ethernet 10/100 POE ports and 2 10/100/1000 SFP uplinks)';
-#              $hwtype[563] = 171;
+               $ciscomodel[563] = 'WS-C3560-24PS (24 Ethernet 10/100 POE ports and 2 10/100/1000 SFP uplinks)';
+               $hwtype[563] = 171;
                $ciscomodel[564] = 'WS-C3560-48PS (48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)';
                $hwtype[564] = 172;
                $ciscomodel[614] = 'WS-C3560G-24PS (24 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)';
@@ -3439,7 +3820,7 @@ function renderSNMPPortFinder ($object_id = 0)
                $hwtype[626] = 147;
                $ciscomodel[659] = 'WS-C4948-10GE (48 Ethernet 10/100/1000 ports and 2 10Gb X2 uplinks)';
                $hwtype[659] = 377;
-               assertStringArg ('community');
+               assertStringArg ('community', __FUNCTION__);
                $community = $_REQUEST['community'];
                $objectInfo = getObjectInfo ($object_id);
                $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
@@ -3480,14 +3861,23 @@ function renderSNMPPortFinder ($object_id = 0)
                                $log[] = array ('code' => 'error', 'message' => 'Failed settig SW version: ' . $error);
                }
 
-               if (empty ($attrs[4]['value']) and substr ($IOSversion, 0, 4) == '12.2') // switch OS type
-               {
-                       $error = commitUpdateAttrValue ($object_id, 4, 252);
-                       if ($error == TRUE)
-                               $log[] = array ('code' => 'success', 'message' => 'Switch OS type set to Cisco IOS 12.2');
-                       else
-                               $log[] = array ('code' => 'error', 'message' => 'Failed settig Switch OS type: ' . $error);
-               }
+               if (empty ($attrs[4]['value'])) // switch OS type
+                       switch (substr ($IOSversion, 0, 4))
+                       {
+                               case '12.2':
+                                       $error = commitUpdateAttrValue ($object_id, 4, 252);
+                                       break;
+                               case '12.1':
+                                       $error = commitUpdateAttrValue ($object_id, 4, 251);
+                                       break;
+                               case '12.0':
+                                       $error = commitUpdateAttrValue ($object_id, 4, 244);
+                                       break;
+                       }
+               if ($error == TRUE)
+                       $log[] = array ('code' => 'success', 'message' => 'Switch OS type set to Cisco IOS ' . substr ($IOSversion, 0, 4));
+               else
+                       $log[] = array ('code' => 'error', 'message' => 'Failed settig Switch OS type');
 
                $sysObjectID = snmpget ($endpoints[0], $community, 'sysObjectID.0');
                // Transform OID
@@ -3574,6 +3964,27 @@ function renderSNMPPortFinder ($object_id = 0)
                                                $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
                                }
                                break;
+                       case '563': // WS-C3560-24PS
+                       case '633': // WS-C3560-24TS
+                               for ($i = 1; $i <= 24; $i++)
+                               {
+                                       $label = "${i}X";
+                                       $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
+                                       if ($error == '')
+                                               $newports++;
+                                       else
+                                               $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
+                               }
+                               for ($i = 1; $i <= 2; $i++)
+                               {
+                                       $label = "${i}";
+                                       $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
+                                       if ($error == '')
+                                               $newports++;
+                                       else
+                                               $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
+                               }
+                               break;
                        case '564': // WS-C3560-48PS
                        case '634': // WS-C3560-48TS
                                for ($i = 1; $i <= 48; $i++)
@@ -3785,7 +4196,7 @@ function renderLVSConfig ($object_id = 0)
        }
        if (isset ($_REQUEST['do_activate']))
        {
-               printLog (activateSLBConfig ($object_id, html_entity_decode ($newconfig, ENT_QUOTES)));
+               printLog (activateSLBConfig ($object_id, html_entity_decode ($newconfig, ENT_QUOTES, 'UTF-8')));
        }
        echo "<form method=post action=${root}>";
        echo "<input type=hidden name=page value=${pageno}>";
@@ -3800,7 +4211,7 @@ function renderLVSConfig ($object_id = 0)
 
 function renderVirtualService ()
 {
-       assertUIntArg ('id');
+       assertUIntArg ('id', __FUNCTION__);
        $vsid = $_REQUEST['id'];
        global $root, $nextorder;
        if ($vsid <= 0)
@@ -3822,6 +4233,7 @@ function renderVirtualService ()
        echo "<tr><th width='50%' class=tdright>Protocol:</th><td class=tdleft>${vsinfo['proto']}</td></tr>\n";
        echo "<tr><th width='50%' class=tdright>Virtual IP address:</th><td class=tdleft><a href='${root}?page=ipaddress&tab=default&ip=${vsinfo['vip']}'>${vsinfo['vip']}</a></td></tr>\n";
        echo "<tr><th width='50%' class=tdright>Virtual port:</th><td class=tdleft>${vsinfo['vport']}</td></tr>\n";
+       printTagTRs();
        if (!empty ($vsinfo['vsconfig']))
        {
                echo "<tr><th width='50%' class=tdright>VS configuration:</th><td class=tdleft>&nbsp;</td></tr>\n";
@@ -3846,7 +4258,7 @@ function renderVirtualService ()
                echo "<tr class=row_${order}><td class=tdleft>";
                // Pool info
                echo '<table width=100%>';
-               echo "<tr><td colspan=2><a href='${root}?page=rspool&id=${pool_id}'>";
+               echo "<tr><td colspan=2><a href='${root}?page=rspool&pool_id=${pool_id}'>";
                if (!empty ($poolInfo['name']))
                        echo $poolInfo['name'];
                else
@@ -3918,7 +4330,7 @@ function renderRSPoolServerForm ($pool_id = 0)
                        echo "<input type=hidden name=tab value='${tabno}'>\n";
                        echo "<input type=hidden name=op value=updRS>";
                        echo "<input type=hidden name=rs_id value='${rsid}'>";
-                       echo "<input type=hidden name=id value='${pool_id}'>";
+                       echo "<input type=hidden name=pool_id value='${pool_id}'>";
                        echo "<tr valign=top class=row_${order}><td><a href='${root}process.php?page=${pageno}&tab=${tabno}";
                        echo "&op=delRS&pool_id=${pool_id}&id=${rsid}'>";
                        printImageHREF ('delete', 'Delete this real server');
@@ -3940,13 +4352,16 @@ function renderRSPoolServerForm ($pool_id = 0)
        echo "<input type=hidden name=page value='${pageno}'>\n";
        echo "<input type=hidden name=tab value='${tabno}'>\n";
        echo "<input type=hidden name=op value=addRS>";
-       echo "<input type=hidden name=id value='${pool_id}'>";
+       echo "<input type=hidden name=pool_id value='${pool_id}'>";
        echo "<tr><td>";
        if (getConfigVar ('DEFAULT_IPV4_RS_INSERVICE') == 'yes')
                printImageHREF ('inservice', 'in service');
        else
                printImageHREF ('notinservice', 'NOT in service');
-       echo "</td><td><input type=text name=rsip tabindex=1></td>";
+       echo "</td><td><input type=text name=remoteip id=remoteip tabindex=1>";
+       echo "<a href='javascript:;' onclick='window.open(\"${root}find_object_ip_helper.php\", \"findobjectip\", \"height=700, width=400, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, titlebar=no, toolbar=no\");'>";
+       printImageHREF ('find', 'pick address');
+       echo "</a></td>";
        $default_port = getConfigVar ('DEFAULT_SLB_RS_PORT');
        if ($default_port == 0)
                $default_port = '';
@@ -3962,14 +4377,19 @@ function renderRSPoolServerForm ($pool_id = 0)
        echo "<input type=hidden name=page value='${pageno}'>\n";
        echo "<input type=hidden name=tab value='${tabno}'>\n";
        echo "<input type=hidden name=op value=addMany>";
-       echo "<input type=hidden name=id value='${pool_id}'>";
+       echo "<input type=hidden name=pool_id value='${pool_id}'>";
        echo "<table border=0 align=center>\n<tr><td>";
        if (getConfigVar ('DEFAULT_IPV4_RS_INSERVICE') == 'yes')
                printImageHREF ('inservice', 'in service');
        else
                printImageHREF ('notinservice', 'NOT in service');
        echo "</td><td>Format: ";
-       $formats = array ('ipvs_2' => 'ipvsadm -l -n (address and port)', 'ipvs_3' => 'ipvsadm -l -n (address, port and weight)');
+       $formats = array
+       (
+               'ipvs_2' => 'ipvsadm -l -n (address and port)',
+               'ipvs_3' => 'ipvsadm -l -n (address, port and weight)',
+               'ssv_2' => 'SSV: &lt;IP address&gt; &lt;port&gt;'
+       );
        printSelect ($formats, 'format');
        echo "</td><td><input type=submit value=Parse></td></tr>\n";
        echo "<tr><td colspan=3><textarea name=rawtext cols=100 rows=50></textarea></td></tr>\n";
@@ -4071,6 +4491,7 @@ function renderRSPool ($pool_id = 0)
                echo "<tr><th width='50%' class=tdright>Pool name:</th><td class=tdleft>${poolInfo['name']}</td></tr>\n";
        echo "<tr><th width='50%' class=tdright>Real servers:</th><td class=tdleft>" . count ($poolInfo['rslist']) . "</td></tr>\n";
        echo "<tr><th width='50%' class=tdright>Load balancers:</th><td class=tdleft>" . count ($poolInfo['lblist']) . "</td></tr>\n";
+       printTagTRs();
        echo "</table>";
        finishPortlet();
 
@@ -4214,7 +4635,7 @@ function renderRSPoolList ()
        foreach ($pool_list as $pool_id => $pool_info)
        {
                echo "<tr valign=top class=row_${order}><td>" . ($pool_info['refcnt'] ? $pool_info['refcnt'] : '&nbsp;') . '</td>';
-               echo "<td><a href='${root}?page=rspool&id=${pool_id}'>";
+               echo "<td><a href='${root}?page=rspool&pool_id=${pool_id}'>";
                echo (empty ($pool_info['name']) ? 'ANONYMOUS' : $pool_info['name']) . '</a></td>';
                echo "<td><pre>${pool_info['vsconfig']}</pre></td>";
                echo "<td><pre>${pool_info['rsconfig']}</pre></td>";
@@ -4292,7 +4713,7 @@ function renderRealServerList ()
                        $order = $nextorder[$order];
                        $last_pool_id = $rsinfo['rspool_id'];
                }
-               echo "<tr valign=top class=row_${order}><td><a href='${root}?page=rspool&id=${rsinfo['rspool_id']}'>";
+               echo "<tr valign=top class=row_${order}><td><a href='${root}?page=rspool&pool_id=${rsinfo['rspool_id']}'>";
                echo empty ($pool_list[$rsinfo['rspool_id']]['name']) ? 'ANONYMOUS' : $pool_list[$rsinfo['rspool_id']]['name'];
                echo '</a></td><td align=center>';
                if ($rsinfo['inservice'] == 'yes')
@@ -4341,7 +4762,7 @@ function renderRSPoolRSInServiceForm ($pool_id = 0)
        echo "<input type=hidden name=page value=${pageno}>\n";
        echo "<input type=hidden name=tab value=${tabno}>\n";
        echo "<input type=hidden name=op value=upd>\n";
-       echo "<input type=hidden name=id value=${pool_id}>\n";
+       echo "<input type=hidden name=pool_id value=${pool_id}>\n";
        echo "<input type=hidden name=rscount value=${rscount}>\n";
        echo "<table class=widetable border=0 cellpadding=10 cellspacing=0 align=center>\n";
        echo "<tr><th>RS address</th><th>RS port</th><th>RS configuration</th><th>in service</th></tr>\n";
@@ -4473,4 +4894,293 @@ function renderLivePTR ($id = 0)
        echo "</td></tr></table>\n";
 }
 
+function renderAutoPortsForm ($object_id = 0)
+{
+       global $root, $pageno, $tabno;
+       if ($object_id <= 0)
+       {
+               showError ('Invalid object_id', __FUNCTION__);
+               return;
+       }
+       $info = getObjectInfo ($object_id);
+       $ptlist = readChapter ('PortType');
+       echo "<table class='widetable' border=0 cellspacing=0 cellpadding=5 align='center'>\n";
+       echo "<caption>The following ports can be quickly added:</caption>";
+       echo "<tr><th>type</th><th>name</th></tr>";
+       foreach (getAutoPorts ($info['objtype_id']) as $autoport)
+               echo "<tr><td>" . $ptlist[$autoport['type']] . "</td><td>${autoport['name']}</td></tr>";
+       echo "<form method=post action='${root}process.php'>\n";
+       echo "<input type=hidden name=page value=${pageno}>\n";
+       echo "<input type=hidden name=tab value=${tabno}>\n";
+       echo "<input type=hidden name=object_id value=${object_id}>\n";
+       echo "<input type=hidden name=op value=generate>\n";
+       echo "<tr><td colspan=2 align=center>";
+       echo "<input type=submit value='Generate'>";
+       echo "</td></tr>";
+       echo "</table>";
+}
+
+function renderTagRowForViewer ($taginfo, $realm, $level = 0)
+{
+       echo '<tr><td align=left>';
+       for ($i = 0; $i < $level; $i++)
+               printImageHREF ('spacer');
+       echo $taginfo['tag'];
+       if ($realm != '' && isset ($taginfo['refcnt'][$realm]))
+               echo ' (' . $taginfo['refcnt'][$realm] . ')';
+       echo "</td></tr>\n";
+       foreach ($taginfo['kids'] as $kid)
+               renderTagRowForViewer ($kid, $realm, $level + 1);
+}
+
+function renderTagRowForCloud ($taginfo, $realm, $level = 0)
+{
+       global $root;
+       echo '<tr><td align=left>';
+       for ($i = 0; $i < $level; $i++)
+               printImageHREF ('spacer');
+       echo "<a href='${root}?page=objgroup&group_id=0&tagfilter[]=${taginfo['id']}'>";
+       echo $taginfo['tag'] . '</a>';
+       if (isset ($taginfo['refcnt'][$realm]))
+               echo ' (' . $taginfo['refcnt'][$realm] . ')';
+       echo "</td></tr>\n";
+       foreach ($taginfo['kids'] as $kid)
+               renderTagRowForCloud ($kid, $realm, $level + 1);
+}
+
+function renderTagRowForEditor ($taginfo, $level = 0)
+{
+       global $root, $pageno, $tabno;
+       echo '<tr><td>';
+       // FIXME: check [supplied] refcnt for each tag
+       echo "<a href='${root}process.php?page=${pageno}&tab=${tabno}&op=destroyTag&id=${taginfo['id']}'>";
+       printImageHREF ('delete', 'Destroy tag');
+       echo "</a></td>\n<td>";
+       for ($i = 0; $i < $level; $i++)
+               printImageHREF ('spacer');
+       echo $taginfo['tag'] . "</td><td>&nbsp;</td></tr>\n";
+       foreach ($taginfo['kids'] as $kid)
+               renderTagRowForEditor ($kid, $level + 1);
+}
+
+function renderTagTree ()
+{
+       global $tagtree;
+       echo '<table>';
+       foreach ($tagtree as $taginfo)
+       {
+               echo '<tr>';
+               renderTagRowForViewer ($taginfo, $realm);
+               echo "</tr>\n";
+       }
+       echo '</table>';
+}
+
+function renderTagCloud ($realm = '')
+{
+       global $taglist, $tagtree;
+       echo '<table>';
+       foreach (getObjectiveTagTree ($tagtree, $realm) as $taginfo)
+       {
+               echo '<tr>';
+               renderTagRowForCloud ($taginfo, $realm);
+               echo "</tr>\n";
+       }
+       echo '</table>';
+}
+
+function renderTagTreeEditor ()
+{
+       global $root, $pageno, $tabno, $taglist, $tagtree;
+       showMessageOrError();
+       echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n";
+       echo "<tr><th>&nbsp;</th><th>tag</th><th>&nbsp;</th></tr>\n";
+       foreach ($tagtree as $taginfo)
+       {
+               renderTagRowForEditor ($taginfo, TRUE);
+       }
+       echo "<form action='${root}process.php' method=post>";
+       echo "<input type=hidden name=page value='${pageno}'>";
+       echo "<input type=hidden name=tab value='${tabno}'>";
+       echo "<input type=hidden name=op value='createTag'>";
+       echo "<tr><td>";
+       printImageHREF ('grant', 'Create tag', TRUE);
+       echo '</td><td><input type=text name=tagname> under <select name=parent_id>';
+       echo "<option value=0>-- NONE --</option>\n";
+       foreach ($taglist as $taginfo)
+               echo "<option value=${taginfo['id']}>${taginfo['tag']}</option>";
+       echo "</select></td><td>&nbsp;</td></tr>";
+       echo "</form>\n";
+       echo '</table>';
+}
+
+// Output a sequence of OPTION elements, selecting those, which are present on the
+// explicit tags list.
+function renderTagOption ($taginfo, $level = 0)
+{
+       global $expl_tags;
+       $selected = '';
+       foreach ($expl_tags as $etaginfo)
+               if ($taginfo['id'] == $etaginfo['id'])
+               {
+                       $selected = ' selected';
+                       break;
+               }
+       echo '<option value=' . $taginfo['id'] . "${selected}>";
+       for ($i = 0; $i < $level; $i++)
+               echo '-- ';
+       echo $taginfo['tag'] . "</option>\n";
+       foreach ($taginfo['kids'] as $kid)
+               renderTagOption ($kid, $level + 1);
+}
+
+// Idem, but select those, which are shown on the $_REQUEST['tagfiler'] array.
+// Ignore tag ids, which can't be found on the tree.
+function renderTagOptionForFilter ($taginfo, $tagfilter, $realm, $level = 0)
+{
+       echo $level;
+       $selected = '';
+       foreach ($tagfilter as $filter_id)
+               if ($taginfo['id'] == $filter_id)
+               {
+                       $selected = ' selected';
+                       break;
+               }
+       echo '<option value=' . $taginfo['id'] . "${selected}>";
+       for ($i = 0; $i < $level; $i++)
+               echo '-- ';
+       echo $taginfo['tag'] . (isset ($taginfo['refcnt'][$realm]) ? ' (' . $taginfo['refcnt'][$realm] . ')' : '') . "</option>\n";
+       foreach ($taginfo['kids'] as $kid)
+               renderTagOptionForFilter ($kid, $tagfilter, $realm, $level + 1);
+}
+
+function renderObjectTags ($id)
+{
+       renderEntityTags ('object', 'object_id', $id);
+}
+
+function renderIPv4PrefixTags ($id)
+{
+       renderEntityTags ('ipv4net', 'id', $id);
+}
+
+function renderRackTags ($id)
+{
+       renderEntityTags ('rack', 'rack_id', $id);
+}
+
+function renderIPv4VSTags ($id)
+{
+       renderEntityTags ('ip4vs', 'id', $id);
+}
+
+function renderIPv4RSPoolTags ($id)
+{
+       renderEntityTags ('ip4rspool', 'id', $id);
+}
+
+function renderEntityTags ($entity_realm = '', $bypass_name, $entity_id = 0)
+{
+       global $tagtree;
+       if ($entity_realm == '' or $entity_id <= 0)
+       {
+               showError ('Invalid or missing arguments', __FUNCTION__);
+               return;
+       }
+       global $root, $pageno, $tabno;
+       showMessageOrError();
+       startPortlet ('Tag list');
+       echo "<form method=post action='${root}process.php'>\n";
+       echo "<input type=hidden name=page value=${pageno}>\n";
+       echo "<input type=hidden name=tab value=${tabno}>\n";
+       echo "<input type=hidden name=${bypass_name} value=${entity_id}>\n";
+       echo "<input type=hidden name=op value=save>\n";
+       echo '<select name=taglist[] multiple size=' . getConfigVar ('MAXSELSIZE') . '>';
+       foreach ($tagtree as $taginfo)
+               renderTagOption ($taginfo);
+       echo '</select><br>';
+       echo "<input type=submit value='Save'></form>\n";
+       finishPortlet();
+}
+
+function printTagTRs()
+{
+       global $expl_tags, $impl_tags, $auto_tags;
+       if (getConfigVar ('SHOW_EXPLICIT_TAGS') == 'yes' and count ($expl_tags))
+       {
+               echo "<tr><th width='50%' class=tag_list_th>Explicit tags:</th><td class=tdleft>";
+               echo serializeTags ($expl_tags) . "</td></tr>\n";
+       }
+       if (getConfigVar ('SHOW_IMPLICIT_TAGS') == 'yes' and count ($impl_tags))
+       {
+               echo "<tr><th width='50%' class=tag_list_th>Implicit tags:</th><td class=tdleft>";
+               echo serializeTags ($impl_tags) . "</td></tr>\n";
+       }
+       if (getConfigVar ('SHOW_AUTOMATIC_TAGS') == 'yes' and count ($auto_tags))
+       {
+               echo "<tr><th width='50%' class=tag_list_th>Automatic tags:</th><td class=tdleft>";
+               echo serializeTags ($auto_tags) . "</td></tr>\n";
+       }
+}
+
+function renderTagFilterPortlet ($tagfilter, $realm)
+{
+       global $pageno, $tabno, $taglist, $tagtree;
+       startPortlet ('Tag filter');
+       if (!count ($taglist))
+       {
+               echo "No tags defined<br>";
+               return;
+       }
+       echo "<form method=get>\n";
+       echo "<input type=hidden name=page value=${pageno}>\n";
+       echo "<input type=hidden name=tab value=${tabno}>\n";
+       echo '<select name=tagfilter[] multiple>';
+       foreach (getObjectiveTagTree ($tagtree, $realm) as $taginfo)
+               renderTagOptionForFilter ($taginfo, $tagfilter, $realm);
+       echo '</select><br>';
+       echo "<input type=submit value='Apply'></form>\n";
+       finishPortlet();
+}
+
+function renderTagFilterSelect ($tagfilter, $realm)
+{
+       global $taglist, $tagtree;
+       if (!count ($taglist))
+       {
+               echo "No tags defined";
+               return;
+       }
+       echo '<select name=tagfilter[] multiple>';
+       foreach (getObjectiveTagTree ($tagtree, $realm) as $taginfo)
+               renderTagOptionForFilter ($taginfo, $tagfilter, $realm);
+       echo '</select><br>';
+}
+
+function renderTagSelect ()
+{
+       global $taglist, $tagtree;
+       if (!count ($taglist))
+       {
+               echo "No tags defined";
+               return;
+       }
+       echo '<select name=taglist[] multiple>';
+       foreach ($tagtree as $taginfo)
+               renderTagOption ($taginfo);
+       echo '</select><br>';
+}
+
+function renderTagRollerForRow ()
+{
+       renderTagSelect();
+}
+
+function dump ($var)
+{
+       echo '<pre>';
+       print_r ($var);
+       echo '</pre>';
+}
+
 ?>