r1852 + fix missing line break
[racktables] / inc / interface.php
index 1371417454b58a9771ad6f640633e3bcaa09f6b3..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'];
@@ -522,6 +522,11 @@ function printSelect ($rowList, $select_name, $selected_id = 1)
                        $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;
        }
@@ -702,7 +707,6 @@ 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";
-       $attrs = getAttrValues ($object_id, TRUE);
        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";
@@ -727,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";
@@ -1555,7 +1559,7 @@ function renderObjectSpace ()
 function renderObjectGroup ()
 {
        global $root, $pageno, $tabno, $nextorder, $taglist, $tagtree;
-       assertUIntArg ('group_id', TRUE);
+       assertUIntArg ('group_id', __FUNCTION__, TRUE);
        $group_id = $_REQUEST['group_id'];
        $tagfilter = isset ($_REQUEST['tagfilter']) ? $_REQUEST['tagfilter'] : array();
        $tagfilter_str = getStringFromTrail (getExplicitTagsOnly (buildTrailFromIds ($tagfilter)));
@@ -1635,7 +1639,7 @@ function renderObjectGroup ()
 function renderObjectGroup_old ()
 {
        global $root;
-       assertUIntArg ('group_id');
+       assertUIntArg ('group_id', __FUNCTION__);
        $group_id = $_REQUEST['group_id'];
        $summary = getObjectGroupInfo();
        if ($summary == NULL)
@@ -1982,6 +1986,76 @@ function renderAddNewRange ()
 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'];
@@ -2000,6 +2074,12 @@ function renderIPRange ($id)
        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();
@@ -2442,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"];
@@ -2466,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)
                {
@@ -2704,7 +2784,7 @@ function renderSearchResults ()
                                        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&id=${addr['ip']}'>";
+                                               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];
@@ -3514,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();
@@ -3712,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)';
@@ -3740,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']);
@@ -3884,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++)
@@ -4110,7 +4211,7 @@ function renderLVSConfig ($object_id = 0)
 
 function renderVirtualService ()
 {
-       assertUIntArg ('id');
+       assertUIntArg ('id', __FUNCTION__);
        $vsid = $_REQUEST['id'];
        global $root, $nextorder;
        if ($vsid <= 0)
@@ -4276,7 +4377,7 @@ 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');
@@ -4838,7 +4939,7 @@ function renderTagRowForCloud ($taginfo, $realm, $level = 0)
        echo '<tr><td align=left>';
        for ($i = 0; $i < $level; $i++)
                printImageHREF ('spacer');
-       echo "<a href='${root}?page=objgroup&group_id=0&taglist[]=${taginfo['id']}'>";
+       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] . ')';
@@ -5028,7 +5129,7 @@ function renderTagFilterPortlet ($tagfilter, $realm)
        startPortlet ('Tag filter');
        if (!count ($taglist))
        {
-               echo "No tags defined";
+               echo "No tags defined<br>";
                return;
        }
        echo "<form method=get>\n";
@@ -5070,4 +5171,16 @@ function renderTagSelect ()
        echo '</select><br>';
 }
 
+function renderTagRollerForRow ()
+{
+       renderTagSelect();
+}
+
+function dump ($var)
+{
+       echo '<pre>';
+       print_r ($var);
+       echo '</pre>';
+}
+
 ?>