r1940 + align allocations table according to the current style
[racktables] / inc / interface.php
index 8f308be..21b2ed0 100644 (file)
@@ -72,7 +72,7 @@ function renderRackspace ()
        $order = 'odd';
        foreach ($rackrowList as $rackrow)
        {
-               echo "<tr class=row_${order}><th>";
+               echo "<tr class=row_${order}><th class=tdleft>";
                echo "<a href='${root}?page=row&row_id=${rackrow['row_id']}${tagfilter_str}'>";
                echo "${rackrow['row_name']}</a></th>";
                $rackList = getRacksForRow ($rackrow['row_id'], $tagfilter);
@@ -255,76 +255,52 @@ function renderRack ($rack_id = 0, $hl_obj_id = 0)
        echo "</table></center>\n";
 }
 
-function renderNewObjectForm ()
-{
-       global $pageno, $tabno;
-
-       // Look for current submit.
-       if (isset ($_REQUEST['got_data']))
-       {
-               $log = array();
-               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'];
-               $asset_no = $_REQUEST['object_asset_no'];
-               $barcode = $_REQUEST['object_barcode'];
-
-               if (commitAddObject ($name, $label, $barcode, $type_id, $asset_no) === TRUE)
-                       $log[] = array ('code' => 'success', 'message' => "Added new object '${name}'");
-               else
-                       $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitAddObject() failed');
-               printLog ($log);
-       }
-
-       // Render a form for the next.
-       startPortlet ('Object attributes');
-       echo '<form>';
-       echo "<input type=hidden name=page value=${pageno}>";
-       echo "<input type=hidden name=tab value=${tabno}>";
-       echo '<table border=0 align=center>';
-       echo "<tr><th class=tdright>Type:</th><td class=tdleft>";
-       $typelist = getObjectTypeList();
-       $typelist[0] = 'select type...';
-       printSelect ($typelist, 'object_type_id', getConfigVar ('DEFAULT_OBJECT_TYPE'));
-       echo "</td></tr>\n";
-       echo "<tr><th class=tdright>Common name:</th><td class=tdleft><input type=text name=object_name></td></tr>\n";
-       echo "<tr><th class=tdright>Visible label:</th><td class=tdleft><input type=text name=object_label></td></tr>\n";
-       echo "<tr><th class=tdright>Asset tag:</th><td class=tdleft><input type=text name=object_asset_no></td></tr>\n";
-       echo "<tr><th class=tdright>Barcode:</th><td class=tdleft><input type=text name=object_barcode></td></tr>\n";
-       echo "<tr><td class=submit colspan=2><input type=submit name=got_data value='Create'></td></tr>\n";
-       echo '</form></table>';
-       finishPortlet();
-}
-
 function renderNewRackForm ($row_id)
 {
        global $pageno, $tabno;
+       $log = array();
+       $taglist = isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
 
        // Look for current submit.
        if (isset ($_REQUEST['got_data']))
        {
-               $log = array();
                assertStringArg ('rack_name', __FUNCTION__);
-               assertUIntArg ('rack_height', __FUNCTION__);
+               assertUIntArg ('rack_height1', __FUNCTION__);
                assertStringArg ('rack_comment', __FUNCTION__, TRUE);
                $name = $_REQUEST['rack_name'];
-               $height = $_REQUEST['rack_height'];
-               $comment = $_REQUEST['rack_comment'];
 
-               if (commitAddRack ($name, $height, $row_id, $comment) === TRUE)
+               if (commitAddRack ($name, $_REQUEST['rack_height1'], $row_id, $_REQUEST['rack_comment'], $taglist) === TRUE)
                        $log[] = array ('code' => 'success', 'message' => "Added new rack '${name}'");
                else
-                       $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . 'commitAddRack() failed');
-               printLog ($log);
+                       $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitAddRack() failed');
        }
+       elseif (isset ($_REQUEST['got_mdata']))
+       {
+               assertUIntArg ('rack_height2', __FUNCTION__);
+               assertStringArg ('rack_names', __FUNCTION__, TRUE);
+               // copy-and-paste from renderAddMultipleObjectsForm()
+               $names1 = explode ('\n', $_REQUEST['rack_names']);
+               $names2 = array();
+               foreach ($names1 as $line)
+               {
+                       $parts = explode ('\r', $line);
+                       reset ($parts);
+                       if (empty ($parts[0]))
+                               continue;
+                       else
+                               $names2[] = rtrim ($parts[0]);
+               }
+               foreach ($names2 as $cname)
+                       if (commitAddRack ($cname, $_REQUEST['rack_height2'], $row_id, '', $taglist) === TRUE)
+                               $log[] = array ('code' => 'success', 'message' => "Added new rack '${cname}'");
+                       else
+                               $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitAddRack() failed');
+       }
+       printLog ($log);
 
+       echo "<table border=0 width='100%'><tr><td valign=top>";
        // Render a form for the next.
-       startPortlet ('Rack attributes');
+       startPortlet ('Add one');
        echo '<form>';
        echo "<input type=hidden name=page value=${pageno}>";
        echo "<input type=hidden name=tab value=${tabno}>";
@@ -333,12 +309,33 @@ function renderNewRackForm ($row_id)
        $defh = getConfigVar ('DEFAULT_RACK_HEIGHT');
        if ($defh == 0)
                $defh = '';
-       echo "<tr><th class=tdright>Name (required):</th><td class=tdleft><input type=text name=rack_name tabindex=1></td></tr>\n";
-       echo "<tr><th class=tdright>Height in units (required):</th><td class=tdleft><input type=text name=rack_height tabindex=2 value='${defh}'></td></tr>\n";
+       echo "<tr><th class=tdright>Rack name (*):</th><td class=tdleft><input type=text name=rack_name tabindex=1></td></tr>\n";
+       echo "<tr><th class=tdright>Height in units (*):</th><td class=tdleft><input type=text name=rack_height1 tabindex=2 value='${defh}'></td></tr>\n";
        echo "<tr><th class=tdright>Comment:</th><td class=tdleft><input type=text name=rack_comment tabindex=3></td></tr>\n";
-       echo "<tr><td class=submit colspan=2><input type=submit name=got_data value='Create'></td></tr>\n";
+       echo "<tr><td class=submit colspan=2><input type=submit name=got_data value='Add'></td></tr>\n";
+       echo '</table>';
+       finishPortlet();
+       echo '</td>';
+
+       echo '<td rowspan=2 valign=top>';
+       startPortlet ('Pre-assigned tags');
+       renderTagSelect();
+       finishPortlet();
+       echo '</td></tr>';
+
+       echo '<tr><td valign=top>';
+       startPortlet ('Add many');
+       echo '<table border=0 align=center>';
+       $defh = getConfigVar ('DEFAULT_RACK_HEIGHT');
+       if ($defh == 0)
+               $defh = '';
+       echo "<tr><th class=tdright>Height in units (*):</th><td class=tdleft><input type=text name=rack_height2 value='${defh}'></td></tr>\n";
+       echo "<tr><th class=tdright>Rack names (*):</th><td class=tdleft><textarea name=rack_names cols=40 rows=25></textarea></td></tr>\n";
+       echo "<tr><td class=submit colspan=2><input type=submit name=got_mdata value='Add'></td></tr>\n";
        echo '</form></table>';
        finishPortlet();
+       echo '</td></tr>';
+       echo '</table>';
 }
 
 function renderEditObjectForm ($object_id)
@@ -541,14 +538,14 @@ function printSelect ($rowList, $select_name, $selected_id = 1)
        $other = array();
        foreach ($rowList as $dict_key => $dict_value)
        {
-               if (strpos ($dict_value, '^') !== FALSE)
+               if (strpos ($dict_value, '%GSKIP%') !== FALSE)
                {
-                       $tmp = explode ('^', $dict_value, 2);
+                       $tmp = explode ('%GSKIP%', $dict_value, 2);
                        $optgroup[$tmp[0]][$dict_key] = $tmp[1];
                }
-               elseif (strpos ($dict_value, '&') !== FALSE)
+               elseif (strpos ($dict_value, '%GPASS%') !== FALSE)
                {
-                       $tmp = explode ('&', $dict_value, 2);
+                       $tmp = explode ('%GPASS%', $dict_value, 2);
                        $optgroup[$tmp[0]][$dict_key] = $tmp[1];
                }
                else
@@ -598,6 +595,7 @@ function printSelect ($rowList, $select_name, $selected_id = 1)
 // used by renderGridForm() and renderRackPage()
 function renderRackInfoPortlet ($rackData)
 {
+       global $root;
        startPortlet ('summary');
        echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n";
        echo "<tr><th width='50%' class=tdright>Rack row:</th><td class=tdleft>${rackData['row_name']}</td></tr>\n";
@@ -1112,11 +1110,8 @@ function renderPortsForObject ($object_id = 0)
        echo "<input type=hidden name=object_id value='${object_id}'>\n";
        echo "<input type=hidden name=op value=addMultiPorts>";
        echo 'Format: <select name=format>';
-       echo '<option value=c2900 disabled>Cisco 2900 series: sh int eth</option>';
-       echo '<option value=c3600eth disabled>Cisco 3600 ethernet: sh arp | inc -</option>';
        echo '<option value=c3600asy>Cisco 3600 async: sh line | inc TTY</option>';
        echo '<option value=fiwg selected>Foundry ServerIron/FastIron WorkGroup/Edge: sh int br</option>';
-       echo '<option value=fiedge disabled>Foundry FastIron Edge: sh int br</option>';
        echo '<option value=fisxii>Foundry FastIron SuperX/II4000: sh int br</option>';
        echo '<option value=ssv1>SSV:&lt;interface name&gt; &lt;MAC address&gt;</option>';
        echo "</select>";
@@ -1174,10 +1169,10 @@ function renderNetworkForObject ($object_id=0)
                echo "<form action='process.php'>";
                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=editAddressFromObject>";
+               echo "<input type=hidden name=op value=updIPv4Allocation>";
                echo "<input type=hidden name=object_id value='$object_id'>";
                echo "<input type=hidden name=ip value='${addr['ip']}'>";
-               echo "<tr class='$class'><td><a href='process.php?op=delAddrFObj&page=${pageno}&tab=${tabno}&ip=${addr['ip']}&object_id=$object_id'>";
+               echo "<tr class='$class'><td><a href='process.php?op=delIPv4Allocation&page=${pageno}&tab=${tabno}&ip=${addr['ip']}&object_id=$object_id'>";
                printImageHREF ('delete', 'Delete this IPv4 address');
                echo "</a></td>";
                echo "<td class=tdleft><input type='text' name='bond_name' value='${addr['name']}' size=10></td>";
@@ -1248,13 +1243,13 @@ function renderNetworkForObject ($object_id=0)
        echo "<form action='${root}process.php'><tr><td>";
        printImageHREF ('add', 'Allocate new address', TRUE, 99);
        echo "</td><td class=tdleft>";
-       echo "<input type='text' size='10' name='name' tabindex=100></td>\n";
+       echo "<input type='text' size='10' name='bond_name' tabindex=100></td>\n";
        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=addAddrFObj>\n";
+       echo "<input type=hidden name=op value=addIPv4Allocation>\n";
        echo "<input type=hidden name=object_id value='$object_id'>\n";
        echo "<td class=tdleft><input type=text name='ip' tabindex=101>\n";
-       echo "</td><td>&nbsp;</td><td><select name='type' tabindex=102>";
+       echo "</td><td>&nbsp;</td><td><select name='bond_type' tabindex=102>";
        echo "<option value='regular'>Regular</option>";
        echo "<option value='virtual'>Virtual</option>";
        echo "<option value='shared'>Shared</option>";
@@ -2284,7 +2279,7 @@ function renderIPAddressAssignment ()
 
 
        echo "<table class='widetable' cesspadding=5 cellspacing=0 border=0 align='center'>\n";
-       echo "<tr><th>&nbsp;</th><th>Object name</th><th>Interface name</th><th>Interface type</th><th>&nbsp;</th></tr>\n";
+       echo "<tr><th>&nbsp;</th><th>object name</th><th>object interface</th><th>allocation type</th><th>&nbsp;</th></tr>\n";
 
        $numshared = countRefsOfType($address['bonds'], 'shared', 'eq');
        $numreg = countRefsOfType($address['bonds'], 'regular', 'eq');
@@ -2305,12 +2300,12 @@ function renderIPAddressAssignment ()
        foreach ($address['bonds'] as $bond)
        {
                echo "<tr class='$class'><form action='process.php'>";
-               echo "<input type=hidden name=op value='editBondForAddress'>";
+               echo "<input type=hidden name=op value='updIPv4Allocation'>";
                echo "<input type=hidden name=page value='${pageno}'>";
                echo "<input type=hidden name=tab value='${tabno}'>";
                echo "<input type=hidden name=ip value='$ip'>";
                echo "<input type=hidden name=object_id value='${bond['object_id']}'>";
-               echo "<td><a href='process.php?op=delIpAssignment&page=${pageno}&tab=${tabno}&ip=$ip&object_id=${bond['object_id']}'>";
+               echo "<td><a href='process.php?op=delIPv4Allocation&page=${pageno}&tab=${tabno}&ip=$ip&object_id=${bond['object_id']}'>";
                printImageHREF ('delete', 'Unallocate address');
                echo "</a></td>";
                echo "<td><a href='${root}?page=object&object_id=${bond['object_id']}'>${bond['object_name']}</td>";
@@ -2334,13 +2329,17 @@ function renderIPAddressAssignment ()
                                echo "<option value='shared'>Shared</option>";
                                break;
                }
-               echo "</select></td><td><input type='submit' value='OK'></td></form></tr>\n";
+               echo "</select></td><td>";
+               printImageHREF ('save', 'Save changes', TRUE);
+               echo "</td></form></tr>\n";
        }
-       echo "<form action='process.php'><input type='hidden' name='op' value='bindObjectToIp'>";
+       echo "<form action='process.php'><input type='hidden' name='op' value='addIPv4Allocation'>";
        echo "<input type=hidden name=page value='${pageno}'>\n";
        echo "<input type=hidden name=tab value='${tabno}'>\n";
        echo "<input type='hidden' name='ip' value='$ip'>";
-       echo "<td colspan=2><select name='object_id'>";
+       echo "<td>";
+       printImageHREF ('add', 'new allocation', TRUE);
+       echo "</td><td><select name='object_id'>";
 
        foreach (explode (',', getConfigVar ('IPV4_PERFORMERS')) as $type) 
                foreach (getObjectList ($type) as $object)
@@ -2348,7 +2347,7 @@ function renderIPAddressAssignment ()
 
        echo "</select></td><td><input type='text' name='bond_name' value='' size=10></td>";
        echo "<td><select name='bond_type'><option value='regular'>Regular</option><option value='virtual'>Virtual</option><option value='shared'>Shared</option></select></td>";
-       echo "<td><input type='submit' value='Assign address'></td></form></tr>";
+       echo "<td>&nbsp;</td></form></tr>";
        echo "</table><br><br>";
 
 }
@@ -2448,7 +2447,6 @@ function renderNATv4ForObject ($object_id = 0)
        echo "</table><br><br>";
 }
 
-
 function renderAddMultipleObjectsForm ()
 {
        global $root, $pageno, $tabno, $nextorder;
@@ -2462,6 +2460,7 @@ function renderAddMultipleObjectsForm ()
        // Look for current submit.
        if (isset ($_REQUEST['got_fast_data']))
        {
+               $taglist = isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
                $keepvalues = TRUE;
                $max = getConfigVar ('MASSCOUNT');
                for ($i = 0; $i < $max; $i++)
@@ -2483,10 +2482,10 @@ function renderAddMultipleObjectsForm ()
                        $asset_no[$i] = $_REQUEST["${i}_object_asset_no"];
                        $barcode[$i] = $_REQUEST["${i}_object_barcode"];
 
-                       // It's better to skip silently than printing a notice.
+                       // It's better to skip silently, than to print a notice.
                        if ($type_id[$i] == 0)
                                continue;
-                       if (commitAddObject ($name[$i], $label[$i], $barcode[$i], $type_id[$i], $asset_no[$i]) === TRUE)
+                       if (commitAddObject ($name[$i], $label[$i], $barcode[$i], $type_id[$i], $asset_no[$i], $taglist) === TRUE)
                                $log[] = array ('code' => 'success', 'message' => "Added new object '${name[$i]}'");
                        else
                                $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitAddObject() failed');
@@ -2494,6 +2493,7 @@ function renderAddMultipleObjectsForm ()
        }
        elseif (isset ($_REQUEST['got_very_fast_data']))
        {
+               $taglist = isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
                $keepvalues = TRUE;
                assertUIntArg ('global_type_id', __FUNCTION__, TRUE);
                assertStringArg ('namelist', __FUNCTION__, TRUE);
@@ -2520,7 +2520,7 @@ function renderAddMultipleObjectsForm ()
                                        $names2[] = rtrim ($parts[0]);
                        }
                        foreach ($names2 as $cname)
-                               if (commitAddObject ($cname, '', '', $global_type_id, '') === TRUE)
+                               if (commitAddObject ($cname, '', '', $global_type_id, '', $taglist) === TRUE)
                                        $log[] = array ('code' => 'success', 'message' => "Added new object '${cname}'");
                                else
                                        $log[] = array ('code' => 'error', 'message' => "Could not add '${cname}'");
@@ -2532,13 +2532,14 @@ function renderAddMultipleObjectsForm ()
        $typelist = getObjectTypeList();
        $typelist[0] = 'select type...';
 
-       startPortlet ('Fast way');
+       startPortlet ('Distinct types, same tags');
+       $max = getConfigVar ('MASSCOUNT');
        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";
+       echo "<tr><th>Object type</th><th>Common name</th><th>Visible label</th>";
+       echo "<th>Asset tag</th><th>Barcode</th><th>Tags</th></tr>\n";
        // If a user forgot to select object type on input, we keep his
        // previous input in the form.
-       $max = getConfigVar ('MASSCOUNT');
        for ($i = 0; $i < $max; $i++)
        {
                echo '<tr><td>';
@@ -2546,36 +2547,48 @@ function renderAddMultipleObjectsForm ()
                printSelect ($typelist, "${i}_object_type_id", 0);
                echo '</td>';
                echo "<td><input type=text size=30 name=${i}_object_name";
-               if ($keepvalues and $type_id[$i] == 0)
+               if ($keepvalues and isset ($name[$i]) and (!isset ($type_id[$i]) or $type_id[$i] == 0))
                        echo " value='${name[$i]}'";
                echo "></td>";
                echo "<td><input type=text size=30 name=${i}_object_label";
-               if ($keepvalues and $type_id[$i] == 0)
+               if ($keepvalues and isset ($label[$i]) and (!isset ($type_id[$i]) or $type_id[$i] == 0))
                        echo " value='${label[$i]}'";
                echo "></td>";
                echo "<td><input type=text size=20 name=${i}_object_asset_no";
-               if ($keepvalues and $type_id[$i] == 0)
+               if ($keepvalues and isset ($asset_no[$i]) and (!isset ($type_id[$i]) or $type_id[$i] == 0))
                        echo " value='${asset_no[$i]}'";
                echo "></td>";
                echo "<td><input type=text size=10 name=${i}_object_barcode";
-               if ($keepvalues and $type_id[$i] == 0)
+               if ($keepvalues and isset ($barcode[$i]) and (!isset ($type_id[$i]) or $type_id[$i] == 0))
                        echo " value='${barcode[$i]}'";
                echo "></td>";
+               if ($i == 0)
+               {
+                       echo "<td valign=top rowspan=${max}>";
+                       renderTagSelect();
+                       echo "</td>\n";
+               }
                echo "</tr>\n";
        }
-       echo "<tr><td class=submit colspan=5><input type=submit name=got_fast_data value='Create'></td></tr>\n";
+       echo "<tr><td class=submit colspan=5><input type=submit name=got_fast_data value='Go!'></td></tr>\n";
        echo "</form></table>\n";
        finishPortlet();
 
-       startPortlet ('Very fast way');
+       startPortlet ('Same type, same tags');
        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";
-       echo "<textarea name=namelist cols=40 rows=25>\n";
+       echo "<table border=0 align=center><tr><th>names</th><th>type</th></tr>";
+       echo "<tr><td rowspan=3><textarea name=namelist cols=40 rows=25>\n";
        if ($keepvalues and $global_type_id == 0)
                echo $_REQUEST['namelist'];
-       echo "</textarea></form>\n";
+       echo "</textarea></td><td valign=top>";
+       printSelect ($typelist, "global_type_id", getConfigVar ('DEFAULT_OBJECT_TYPE'));
+       echo "</td></tr>";
+       echo "<tr><th>Tags</th></tr>";
+       echo "<tr><td valign=top>";
+       renderTagSelect();
+       echo "</td></tr>";
+       echo "<tr><td colspan=2><input type=submit name=got_very_fast_data value='Go!'></td></tr></table>\n";
+       echo "</form>\n";
        finishPortlet();
 }
 
@@ -2612,6 +2625,8 @@ function renderSearchResults ()
        )
        // Search for L2 address.
        {
+               $terms = str_replace ('.', '', $terms);
+               $terms = str_replace (':', '', $terms);
                $terms = substr ($terms, -12);
                $result = searchByl2address ($terms);
                if ($result !== NULL)
@@ -2690,7 +2705,7 @@ function renderSearchResults ()
                                break;
                        case 'ipv4address2':
                                echo "<script language='Javascript'>document.location='${root}?page=ipaddress";
-                               echo "&ip=${record}";
+                               echo "&ip=${record['ip']}";
                                echo "';//</script>";
                                break;
                        case 'ipv4network':
@@ -2867,7 +2882,7 @@ function renderAccountsEditForm ()
        startPortlet ('User accounts');
        showMessageOrError();
        echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n";
-       echo "<tr><th>op</th><th>Username</th><th>Real name</th><th>Password</th><th>&nbsp;</th></tr>\n";
+       echo "<tr><th>status (click to change)</th><th>Username</th><th>Real name</th><th>Password</th><th>&nbsp;</th></tr>\n";
        foreach ($accounts as $account)
        {
                echo "<form action='${root}process.php'>";
@@ -3380,14 +3395,9 @@ function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
        $image['reports']['path'] = 'pix/report.png';
        $image['reports']['width'] = 218;
        $image['reports']['height'] = 200;
-       $image['reserve']['path'] = 'pix/stop.png';
-       $image['reserve']['width'] = 16;
-       $image['reserve']['height'] = 16;
-       $image['useup']['path'] = 'pix/go.png';
+       $image['useup']['path'] = 'pix/tango-edit-clear.png';
        $image['useup']['width'] = 16;
        $image['useup']['height'] = 16;
-       $image['blockuser'] = $image['reserve'];
-       $image['unblockuser'] = $image['useup'];
        $image['link']['path'] = 'pix/tango-network-wired.png';
        $image['link']['width'] = 16;
        $image['link']['height'] = 16;
@@ -3411,6 +3421,8 @@ function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
        $image['notinservice']['path'] = 'pix/tango-dialog-error.png';
        $image['notinservice']['width'] = 16;
        $image['notinservice']['height'] = 16;
+       $image['blockuser'] = $image['inservice'];
+       $image['unblockuser'] = $image['notinservice'];
        $image['find']['path'] = 'pix/tango-system-search.png';
        $image['find']['width'] = 16;
        $image['find']['height'] = 16;
@@ -3766,7 +3778,7 @@ function renderVLANMembership ($object_id = 0)
 // on the current device or displays the result of the scan.
 function renderSNMPPortFinder ($object_id = 0)
 {
-       global $root, $pageno, $tabno, $remote_username;
+       global $pageno, $tabno;
        if ($object_id <= 0)
        {
                showError ('Invalid object_id', __FUNCTION__);
@@ -3775,331 +3787,8 @@ function renderSNMPPortFinder ($object_id = 0)
 // FIXME: check if SNMP PHP extension is available!
        if (isset ($_REQUEST['do_scan']))
        {
-               $log = array();
-// IDs: http://cisco.com/en/US/products/sw/cscowork/ps2064/products_device_support_table09186a0080803bb4.html
-// 2960: http://www.cisco.com/en/US/products/ps6406/prod_models_comparison.html
-// 2970: http://cisco.com/en/US/products/hw/switches/ps5206/products_qanda_item09186a00801b1750.shtml
-// 3500XL: http://cisco.com/en/US/products/hw/switches/ps637/products_eol_models.html
-// 3560: http://cisco.com/en/US/products/hw/switches/ps5528/products_data_sheet09186a00801f3d7f.html
-// 3750: http://cisco.com/en/US/products/hw/switches/ps5023/products_data_sheet09186a008016136f.html
-               $ciscomodel[283] = 'WS-C6509-E (9-slot system)';
-// FIXME: hwtype hardcoded value will become invalid after the Dictionary table transformation
-// in 0.14.7 version. Either the values will have to be adjusted as well or we have to switch
-// to value lookup (not reliable).
-               $hwtype[283] = 148;
-#              $ciscomodel[694] = 'WS-C2960-24TC-L (24 Ethernet 10/100 ports and 2 dual-purpose uplinks)';
-#              $ciscomodel[695] = 'WS-C2960-48TC-L (48 Ethernet 10/100 ports and 2 dual-purpose uplinks)';
-               $ciscomodel[696] = 'WS-C2960G-24TC-L (20 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)';
-               $hwtype[696] = 167;
-               $ciscomodel[697] = 'WS-C2960G-48TC-L (44 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)';
-               $hwtype[697] = 166;
-#              $ciscomodel[716] = 'WS-C2960-24TT-L (24 Ethernet 10/100 ports and 2 10/100/1000 uplinks)';
-#              $ciscomodel[717] = 'WS-C2960-48TT-L (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)';
-               $ciscomodel[527] = 'WS-C2970G-24T (24 Ethernet 10/100/1000 ports)';
-               $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[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[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)';
-               $hwtype[614] = 175;
-               $ciscomodel[615] = 'WS-C3560G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)';
-               $hwtype[615] = 173;
-               $ciscomodel[616] = 'WS-C3560G-48PS (48 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)';
-               $hwtype[616] = 176;
-               $ciscomodel[617] = 'WS-C3560G-48TS (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)';
-               $hwtype[617] = 174;
-               $ciscomodel[58] = 'WS-C4503 (3-slot system)';
-               $hwtype[58] = 145;
-               $ciscomodel[503] = '4503 (3-slot system)';
-               $hwtype[503] = 145;
-               $ciscomodel[59] = 'WS-C4506 (6-slot system)';
-               $hwtype[59] = 156;
-               $ciscomodel[502] = '4506 (6-slot system)';
-               $hwtype[502] = 156;
-               $ciscomodel[626] = 'WS-C4948 (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)';
-               $hwtype[626] = 147;
-               $ciscomodel[659] = 'WS-C4948-10GE (48 Ethernet 10/100/1000 ports and 2 10Gb X2 uplinks)';
-               $hwtype[659] = 377;
                assertStringArg ('community', __FUNCTION__);
-               $community = $_REQUEST['community'];
-               $objectInfo = getObjectInfo ($object_id);
-               $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-               $sysName = substr (snmpget ($endpoints[0], $community, 'sysName.0'), strlen ('STRING: '));
-               $sysDescr = snmpget ($endpoints[0], $community, 'sysDescr.0');
-               // Strip the object type, it's always string here.
-               $sysDescr = substr ($sysDescr, strlen ('STRING: '));
-               if (strpos ($sysDescr, 'Cisco IOS Software') === 0 or strpos ($sysDescr, 'Cisco Internetwork Operating System Software') === 0)
-                       $log[] = array ('code' => 'success', 'message' => 'Seems to be a Cisco box');
-               else
-               {
-                       $log[] = array ('code' => 'error', 'message' => 'No idea how to handle ' . $sysDescr);
-                       printLog ($log);
-                       return;
-               }
-
-               // It's a Cisco. Go on.
-               $attrs = getAttrValues ($object_id);
-               // Only fill in attribute values, if they are not set.
-               // FIXME: this is hardcoded
-
-               if (empty ($attrs[3]['value']) && !empty ($sysName)) // FQDN
-               {
-                       $error = commitUpdateAttrValue ($object_id, 3, $sysName);
-                       if ($error == TRUE)
-                               $log[] = array ('code' => 'success', 'message' => 'FQDN set to ' . $sysName);
-                       else
-                               $log[] = array ('code' => 'error', 'message' => 'Failed settig FQDN: ' . $error);
-               }
-
-               if (empty ($attrs[5]['value'])) // SW version
-               {
-                       $IOSversion = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
-                       $error = commitUpdateAttrValue ($object_id, 5, $IOSversion);
-                       if ($error == TRUE)
-                               $log[] = array ('code' => 'success', 'message' => 'SW version set to ' . $IOSversion);
-                       else
-                               $log[] = array ('code' => 'error', 'message' => 'Failed settig SW version: ' . $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
-               $sysObjectID = substr ($sysObjectID, strlen ('OID: SNMPv2-SMI::enterprises.9.1.'));
-               if (!isset ($ciscomodel[$sysObjectID]))
-               {
-                       $log[] = array ('code' => 'error', 'message' => 'Could not guess exact HW model!');
-                       printLog ($log);
-                       return;
-               }
-               $log[] = array ('code' => 'success', 'message' => 'HW is ' . $ciscomodel[$sysObjectID]);
-               if (empty ($attrs[2]['value']) and isset ($hwtype[$sysObjectID])) // switch HW type
-               {
-                       $error = commitUpdateAttrValue ($object_id, 2, $hwtype[$sysObjectID]);
-                       if ($error == TRUE)
-                               $log[] = array ('code' => 'success', 'message' => 'HW type updated Ok');
-                       else
-                               $log[] = array ('code' => 'error', 'message' => 'Failed settig HW type: ' . $error);
-               }
-               // Now fetch ifType, ifDescr and ifPhysAddr and let model-specific code sort the data out.
-               $ifType = snmpwalkoid ($endpoints[0], $community, 'ifType');
-               $ifDescr = snmpwalkoid ($endpoints[0], $community, 'ifdescr');
-               $ifPhysAddress = snmpwalkoid ($endpoints[0], $community, 'ifPhysAddress');
-               // Combine 3 tables into 1...
-               $ifList1 = array();
-               foreach ($ifType as $key => $val)
-               {
-                       list ($dummy, $ifIndex) = explode ('.', $key);
-                       list ($dummy, $type) = explode (' ', $val);
-                       $ifList1[$ifIndex]['type'] = $type;
-               }
-               foreach ($ifDescr as $key => $val)
-               {
-                       list ($dummy, $ifIndex) = explode ('.', $key);
-                       list ($dummy, $descr) = explode (' ', $val);
-                       $ifList1[$ifIndex]['descr'] = trim ($descr, '"');
-               }
-               foreach ($ifPhysAddress as $key => $val)
-               {
-                       list ($dummy, $ifIndex) = explode ('.', $key);
-                       list ($dummy, $addr) = explode (':', $val);
-                       $addr = str_replace (' ', '', $addr);
-                       $ifList1[$ifIndex]['phyad'] = $addr;
-               }
-               // ...and then reverse it inside out to make description the key.
-               $ifList2 = array();
-               foreach ($ifList1 as $ifIndex => $data)
-               {
-                       $ifList2[$data['descr']]['type'] = $data['type'];
-                       $ifList2[$data['descr']]['phyad'] = $data['phyad'];
-                       $ifList2[$data['descr']]['idx'] = $ifIndex;
-               }
-               $newports = 0;
-               // Now we can directly pick necessary ports from the table accordingly
-               // to our known hardware model.
-               switch ($sysObjectID)
-               {
-               // FIXME: chassis edge switches often share a common naming scheme, so
-               // the sequences below have to be generalized. Let's have some duplicated
-               // code for the time being, as this is the first implementation ever.
-                       case '697': // WS-C2960G-48TC-L
-                               // 44 copper ports: 1X, 2X, 3X...
-                               // 4 combo ports: 45, 46, 47, 48. Don't list SFP connectors atm, as it's not
-                               // clear how to fit them into current Ports table structure.
-                               for ($i = 1; $i <= 48; $i++)
-                               {
-                                       $label = ($i >= 45) ? "${i}" : "${i}X";
-                                       $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 '696': // WS-C2960G-24TC-L
-                               // Quite similar to the above.
-                               for ($i = 1; $i <= 24; $i++)
-                               {
-                                       $label = ($i >= 21) ? "${i}" : "${i}X";
-                                       $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 '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++)
-                               {
-                                       $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 <= 4; $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 '614': // WS-C3560G-24PS
-                       case '615': // WS-C3560G-24TS
-                       case '527': // WS-C2970G-24T
-                       case '561': // WS-C2970G-24TS
-                               for ($i = 1; $i <= 24; $i++)
-                               {
-                                       $label = "${i}X";
-                                       $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 '616': // WS-C3560G-48PS
-                       case '617': // WS-C3560G-48TS
-                               for ($i = 1; $i <= 48; $i++)
-                               {
-                                       $label = "${i}X";
-                                       $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 '626': // WS-C4948
-                       case '659': // WS-C4948-10GE
-                               for ($i = 1; $i <= 48; $i++)
-                               {
-                                       $label = "${i}X";
-                                       $error = commitAddPort ($object_id, 'gi1/' . $i, 24, $label, $ifList2["GigabitEthernet1/${i}"]['phyad']);
-                                       if ($error == '')
-                                               $newports++;
-                                       else
-                                               $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
-                               }
-                               break;
-               // For modular devices we don't iterate over all possible port names,
-               // but use the first list to pick everything that looks legitimate
-               // for this hardware. It would be correct to fetch the list of modules
-               // installed to generate lists of ports, but who is going to implement
-               // this?
-                       case '503': // 4503
-                       case '58': // WS-C4503
-                       case '502': // 4506
-                       case '59': // WS-C4506
-                       case '283': // WS-C6509-E
-                               foreach ($ifList1 as $port)
-                               {
-                                       if ($port['type'] != 'ethernet-csmacd(6)')
-                                               continue;
-                                       // Copper Fa/Gi harvesting is relatively simple, while 10Gig ports can
-                                       // have random samples of transciever units.
-                                       if (strpos ($port['descr'], 'FastEthernet') === 0) // Fa
-                                       {
-                                               $prefix = 'fa';
-                                               $ptype = 19; // RJ-45/100Base-TX
-                                               list ($slotno, $portno) = explode ('/', substr ($port['descr'], strlen ('FastEthernet')));
-                                       }
-                                       elseif (strpos ($port['descr'], 'GigabitEthernet') === 0) // Gi
-                                       {
-                                               $prefix = 'gi';
-                                               $ptype = 24; // RJ-45/1000Base-T
-                                               list ($slotno, $portno) = explode ('/', substr ($port['descr'], strlen ('GigabitEthernet')));
-                                       }
-                                       else continue;
-                                       $label = "slot ${slotno} port ${portno}";
-                                       $pname = "${prefix}${slotno}/${portno}";
-                                       $error = commitAddPort ($object_id, $pname, $ptype, $label, $port['phyad']);
-                                       if ($error == '')
-                                               $newports++;
-                                       else
-                                               $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $pname . ': ' . $error);
-                               }
-                               break;
-                       default:
-                               showError ("Unexpected sysObjectID '${sysObjectID}'", __FUNCTION__);
-               }
-               $error = commitAddPort ($object_id, 'con0', 29, 'console', '');
-               if ($error == '')
-                       $newports++;
-               else
-                       $log[] = array ('code' => 'error', 'message' => 'Failed to add console port : ' . $error);
-               if ($newports > 0)
-                       $log[] = array ('code' => 'success', 'message' => "Added ${newports} new ports");
-               printLog ($log);
+               printLog (doSNMPmining ($object_id, $_REQUEST['community']));
                return;
        }
        echo "<form method=post>\n";
@@ -4893,7 +4582,7 @@ function renderLivePTR ($id = 0)
                        $cnt_mismatch++;
                }
                echo "><td class='tdleft";
-               if ($addr['reserved'] == 'yes' or count ($range['addrlist'][$ip]['references']))
+               if ($addr['reserved'] == 'yes' or (isset ($range['addrlist'][$ip]) and count ($range['addrlist'][$ip]['references'])))
                        echo ' trbusy';
                echo "'><a href='${root}?page=ipaddress&ip=${straddr}'>${straddr}</a></td>";
                echo "<td class=tdleft>${addr['name']}</td><td class=tdleft>${ptrname}</td><td>";