Esempio n. 1
0
function renderIPSpace()
{
    global $pageno, $tabno;
    $realm = $pageno == 'ipv4space' ? 'ipv4net' : 'ipv6net';
    $cellfilter = getCellFilter();
    // expand request can take either natural values or "ALL". Zero means no expanding.
    $eid = isset($_REQUEST['eid']) ? $_REQUEST['eid'] : 0;
    echo "<table border=0 class=objectview>\n";
    echo "<tr><td class=pcleft>";
    $netlist = array();
    if (!($cellfilter['is_empty'] && !$eid && renderEmptyResults($cellfilter, 'IP nets', getEntitiesCount($realm)))) {
        $top = NULL;
        foreach (listCells($realm) as $net) {
            if (isset($top) and IPNetContains($top, $net)) {
            } elseif (!count($cellfilter['expression']) or judgeCell($net, $cellfilter['expression'])) {
                $top = $net;
            } else {
                continue;
            }
            $netlist[$net['id']] = $net;
        }
        $netcount = count($netlist);
        $tree = prepareIPTree($netlist, $eid);
        if (!renderEmptyResults($cellfilter, 'IP nets', count($tree))) {
            startPortlet("networks ({$netcount})");
            echo '<h4>';
            $all = "<a href='" . makeHref(array('page' => $pageno, 'tab' => $tabno, 'eid' => 'ALL')) . $cellfilter['urlextra'] . "'>expand&nbsp;all</a>";
            $none = "<a href='" . makeHref(array('page' => $pageno, 'tab' => $tabno, 'eid' => 'NONE')) . $cellfilter['urlextra'] . "'>collapse&nbsp;all</a>";
            $auto = "<a href='" . makeHref(array('page' => $pageno, 'tab' => $tabno)) . $cellfilter['urlextra'] . "'>auto-collapse</a>";
            if ($eid === 0) {
                echo 'auto-collapsing at threshold ' . getConfigVar('TREE_THRESHOLD') . " ({$all} / {$none})";
            } elseif ($eid === 'ALL') {
                echo "expanding all ({$auto} / {$none})";
            } elseif ($eid === 'NONE') {
                echo "collapsing all ({$all} / {$auto})";
            } else {
                try {
                    $netinfo = spotEntity($realm, $eid);
                    echo "expanding {$netinfo['ip']}/{$netinfo['mask']} ({$auto} / {$all} / {$none})";
                } catch (EntityNotFoundException $e) {
                    // ignore invalid eid error
                }
            }
            echo "</h4><table class='widetable' border=0 cellpadding=5 cellspacing=0 align='center'>\n";
            echo "<tr><th>prefix</th><th>name/tags</th><th>capacity</th>";
            if (getConfigVar('IPV4_TREE_RTR_AS_CELL') != 'none') {
                echo "<th>routed by</th>";
            }
            echo "</tr>\n";
            $baseurl = makeHref(array('page' => $pageno, 'tab' => $tabno)) . $cellfilter['urlextra'];
            renderIPSpaceRecords($tree, $baseurl, $eid);
            echo "</table>\n";
            finishPortlet();
        }
    }
    echo '</td><td class=pcright>';
    renderCellFilterPortlet($cellfilter, $realm, $netlist);
    echo "</td></tr></table>\n";
}
Esempio n. 2
0
function considerGivenConstraint($cell, $filtertext)
{
    if ($filtertext == '') {
        return TRUE;
    }
    $parse = spotPayload($filtertext, 'SYNT_EXPR');
    if ($parse['result'] != 'ACK') {
        throw new InvalidRequestArgException('filtertext', $filtertext, 'RackCode parsing error');
    }
    if (isset($cell)) {
        return judgeCell($cell, $parse['load']);
    } else {
        return judgeContext($parse['load']);
    }
}