function renderFlatIP()
{
    if (isset($_REQUEST['attr_id']) && isset($_REQUEST['attr_value'])) {
        $params = array('attr_id' => $_REQUEST['attr_id'], 'attr_value' => $_REQUEST['attr_value']);
        $av = $_REQUEST['attr_value'];
        if ($av === 'NULL') {
            $av = NULL;
        }
        $nets = fetchNetworksByAttr($_REQUEST['attr_id'], $av, TRUE);
    } else {
        $params = array();
        $nets = array_merge(listCells('ipv4net'), listCells('ipv6net'));
    }
    $cf = getCellFilter();
    $nets = filterCellList($nets, $cf['expression']);
    echo "<table border=0 class=objectview>\n";
    echo "<tr><td class=pcleft>";
    startPortlet(sprintf("Networks (%d)", count($nets)));
    echo '<ol>';
    foreach ($nets as $network) {
        echo '<li>';
        renderCell($network);
        echo '</li>';
    }
    echo '</ol>';
    finishPortlet();
    echo '</td><td class=pcright>';
    renderCellFilterPortlet($cf, 'ipv4net', $nets, $params);
    echo '</td></tr></table>';
}
function FullRowView()
{
    if (isset($_REQUEST['row_id'])) {
        $row_id = $_REQUEST['row_id'];
    } else {
        $rack_id = 1;
    }
    global $frvVersion;
    $rowData = getRowInfo($row_id);
    $cellfilter = getCellFilter();
    $rackList = filterCellList(listCells('rack', $row_id), $cellfilter['expression']);
    // echo "<form method=post name=ImportObject action='?module=redirect&page=row&row_id=$row_id&tab=full_row_view&op=preparePrint'>";
    echo "<font size=1em color=gray>version {$frvVersion}&nbsp;</font>";
    // echo "<input type=submit name=got_very_fast_data value='Print view'>";
    // echo "</form>";
    echo '<table><tr><td nowrap="nowrap" valign="top">';
    $count = 1;
    foreach ($rackList as $rack) {
        // echo "<br>Schrank: ${rack['name']} ${rack['id']}";
        // $rackData = spotEntity ('rack', ${rack['id']});
        echo '<div class="phgrack" style="float: top; width: 240px">';
        renderReducedRack("{$rack['id']}");
        echo '</div>';
        echo '</td><td nowrap="nowrap" valign="top">';
    }
    echo '</td></tr></table>';
}
Example #3
0
function renderCellList($realm = NULL, $title = 'items', $do_amplify = FALSE, $celllist = NULL)
{
    if ($realm === NULL) {
        global $pageno;
        $realm = $pageno;
    }
    global $nextorder;
    $order = 'odd';
    $cellfilter = getCellFilter();
    if (!isset($celllist)) {
        $celllist = applyCellFilter($realm, $cellfilter);
    } else {
        $celllist = filterCellList($celllist, $cellfilter['expression']);
    }
    echo "<table border=0 class=objectview>\n";
    echo "<tr><td class=pcleft>";
    if ($realm != 'file' || !renderEmptyResults($cellfilter, 'files', count($celllist))) {
        if ($do_amplify) {
            array_walk($celllist, 'amplifyCell');
        }
        startPortlet($title . ' (' . count($celllist) . ')');
        echo "<table class=cooltable border=0 cellpadding=5 cellspacing=0 align=center>\n";
        foreach ($celllist as $cell) {
            echo "<tr class=row_{$order}><td>";
            renderCell($cell);
            echo "</td></tr>\n";
            $order = $nextorder[$order];
        }
        echo '</table>';
        finishPortlet();
    }
    echo '</td><td class=pcright>';
    renderCellFilterPortlet($cellfilter, $realm, $celllist);
    echo "</td></tr></table>\n";
}
Example #4
0
File: api.php Project: xtha/salt
     commitDeleteObject($_REQUEST['object_id']);
     foreach ($racklist as $rack_id) {
         usePreparedDeleteBlade('RackThumbnail', array('rack_id' => $rack_id));
     }
     // redirect to the depot method
     redirectUser($_SERVER['SCRIPT_NAME'] . "?method=get_depot");
     break;
     // get all objects
     //    UI equivalent: /index.php?page=depot&tab=default
     //    UI handler: renderDepot()
 // get all objects
 //    UI equivalent: /index.php?page=depot&tab=default
 //    UI handler: renderDepot()
 case 'get_depot':
     require_once 'inc/init.php';
     $cellfilter = getCellFilter();
     $objects = filterCellList(listCells('object'), $cellfilter['expression']);
     // get details if requested
     if (isset($_REQUEST['include_attrs'])) {
         foreach ($objects as $object_id => $object) {
             amplifyCell($object);
             // return the attributes in an array keyed on 'name', unless otherwise requested
             $key_attrs_on = 'name';
             if (isset($_REQUEST['key_attrs_on'])) {
                 $key_attrs_on = $_REQUEST['key_attrs_on'];
             }
             $attrs = array();
             foreach (getAttrValues($object_id) as $record) {
                 // check that the key exists for this record
                 if (!isset($record[$key_attrs_on])) {
                     throw new InvalidRequestArgException('key_attrs_on', $_REQUEST['key_attrs_on'], 'requested keying value not set for all attributes');
function renderSearchNewIP4Range()
{
    global $pTable;
    // prepare $cellfilter
    $cellfilter = getCellFilter();
    if ($cellfilter['is_empty'] || !isset($_REQUEST['cfp'])) {
        if (defined('SPARE_SEARCH_PREDICATE') && isset($pTable[SPARE_SEARCH_PREDICATE])) {
            $_REQUEST['cfp'] = array(SPARE_SEARCH_PREDICATE);
            $cellfilter = getCellFilter();
        }
    }
    $mask = NULL;
    if (!empty($_REQUEST['pref_len'])) {
        $mask = intval($_REQUEST['pref_len']);
    }
    $nets = array();
    foreach (filterCellList(listCells('ipv4net'), $cellfilter['expression']) as $net) {
        if (!isset($mask)) {
            $nets[] = $net;
        } elseif ($net['mask'] <= $mask) {
            $is_aggregate = FALSE;
            foreach ($net['atags'] as $atag) {
                if ($atag['tag'] == '$aggregate') {
                    $is_aggregate = TRUE;
                } elseif (preg_match('/^\\$spare_(\\d+)$/', $atag['tag'], $m) && $mask >= $m[1]) {
                    $nets[] = $net;
                    continue 2;
                }
            }
            if (!$is_aggregate) {
                $nets[] = $net;
            }
        }
    }
    $filter = getOutputOf('renderCellFilterPortlet', $cellfilter, 'ipv4net', $nets);
    echo '<table width="100%"><tr valign=top>';
    echo '<td>';
    startPortlet("Results (" . count($nets) . ")");
    echo '<ul class="spare-nets">';
    foreach ($nets as $net) {
        echo '<li>';
        renderNetCellForAlloc($net, $mask);
        echo '</li>';
    }
    echo '</ul>';
    finishPortlet();
    echo '</td>';
    echo '<td width="33%">';
    echo preg_replace_callback('/(<form[^<>]*>)/', 'generatePrefixLengthInput', $filter);
    echo '</td>';
    echo '</tr></table>';
    addCSS(<<<END
ul.spare-nets {
\tlist-style: none;
\tpadding: 0px;
}
ul.spare-nets li {
\tmargin: 5px 0px;
}

END
, TRUE);
}
function getWattsPerRow()
{
    // assertions
    // find the needed attributes
    global $nextorder;
    // Was this function called with a specific row_id?
    if (isset($_REQUEST['row_id'])) {
        assertStringArg('row_id');
        $row_toshow = $_REQUEST['row_id'];
    } else {
        $row_toshow = -1;
    }
    //from renderRackspace(), interface.php:151
    $found_racks = array();
    $rows = array();
    $cellfilter = getCellFilter();
    $rackCount = 0;
    $order = 'odd';
    // get rackspace information
    foreach (getAllRows() as $row_id => $rowInfo) {
        $rackList = filterCellList(listCells('rack', $row_id), $cellfilter['expression']);
        $found_racks = array_merge($found_racks, $rackList);
        $rows[] = array('location_id' => $rowInfo['location_id'], 'location_name' => $rowInfo['location_name'], 'row_id' => $row_id, 'row_name' => $rowInfo['name'], 'racks' => $rackList);
        $rackCount += count($rackList);
    }
    // Main layout starts.
    echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
    // Left portlet with list of rows.
    echo "<tr><td class=pcleft width='50%'>";
    startPortlet('Rack Rows (' . count($rows) . ')');
    echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n";
    foreach ($rows as $row) {
        $row_id = $row['row_id'];
        $row_name = $row['row_name'];
        $row_location = $row['location_name'];
        $rackList = $row['racks'];
        echo "<tr class=row_{$order}><td width='20%'></td><td class=tdleft>";
        if (!count($rackList)) {
            echo "{$row_location} - {$row_name} (empty row)";
        } else {
            echo "<a href='" . makeHref(array('page' => 'reports', 'tab' => 'watts_per_row', 'row_id' => $row_id)) . "'>{$row_location} - {$row_name}</a>";
        }
        echo "<td><tr>\n";
        $order = $nextorder[$order];
    }
    echo "</td></tr>\n";
    echo "</table><br>\n";
    finishPortlet();
    echo "</td><td class=pcright>";
    // Right Portlet: Draw the racks in the selected row
    if ($row_toshow > -1) {
        $rowInfo = getRowInfo($row_toshow);
        $cellfilter = getCellFilter();
        $rackList = filterCellList(listCells('rack', $row_toshow), $cellfilter['expression']);
        $rackwidth = getRackImageWidth() * getConfigVar('ROW_SCALE');
        // Maximum number of racks per row is proportionally less, but at least 1.
        $maxPerRow = max(floor(getConfigVar('RACKS_PER_ROW') / getConfigVar('ROW_SCALE')), 1);
        $rackListIdx = 0;
        $rowTotalWattage = 0;
        $order = 'odd';
        startPortlet('Racks within ' . $rowInfo['name'] . ' (' . count($rackList) . ')');
        echo "<table border=0 cellspacing=5 align='center'><tr>";
        foreach ($rackList as $rack) {
            $rackTotalWattage = 0;
            // see renderRack(), interface.php:311
            $rackData = spotEntity('rack', $rack['id']);
            amplifyCell($rackData);
            $objectChildren = getEntityRelatives('children', 'object', $objectData['id']);
            foreach ($rackData['mountedObjects'] as $object) {
                $objectData = spotEntity('object', $object);
                amplifyCell($objectData);
                foreach (getAttrValues($objectData['id']) as $record) {
                    if ($record['name'] == 'Wattage consumption') {
                        $rackTotalWattage += $record['value'];
                    }
                }
            }
            if ($rackListIdx % $maxPerRow == 0) {
                echo $rackListIdx > 0 ? '</tr><tr>' : '<tr>';
            }
            echo "<td align=center class=row_{$order}><a href='" . makeHref(array('page' => 'rack', 'rack_id' => $rack['id'])) . "'>";
            echo "<img border=0 width={$rackwidth} height=" . getRackImageHeight($rack['height']) * getConfigVar('ROW_SCALE');
            echo " title='{$rack['height']} units'";
            echo "src='?module=image&img=minirack&rack_id={$rack['id']}'>";
            echo "<br>{$rack['name']} ({$rackTotalWattage})</a></td>";
            $order = $nextorder[$order];
            $rackListIdx++;
            $rowTotalWattage += $rackTotalWattage;
        }
        echo "</tr><tr><td align=center colspan=";
        print count($rackList);
        echo "><br><b>The row total for attribute Wattage consuption is:  {$rowTotalWattage}</b></td>\n";
        echo "</tr></table>\n";
        finishPortlet();
    }
    echo "</td></tr></table>";
}