Esempio n. 1
0
function renderIPNetwork($id)
{
    global $pageno;
    $realm = $pageno;
    // 'ipv4net', 'ipv6net'
    $range = spotEntity($realm, $id);
    loadIPAddrList($range);
    echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
    echo "<tr><td colspan=2 align=center><h1>{$range['ip']}/{$range['mask']}</h1><h2>";
    echo htmlspecialchars($range['name'], ENT_QUOTES, 'UTF-8') . "</h2></td></tr>\n";
    echo "<tr><td class=pcleft width='50%'>";
    // render summary portlet
    $summary = array();
    $summary['%% used'] = getRenderedIPNetCapacity($range);
    $summary = getRenderedIPNetBacktrace($range) + $summary;
    if ($realm == 'ipv4net') {
        $summary[] = array('Netmask:', ip4_format($range['mask_bin']));
        $summary[] = array('Netmask:', "0x" . strtoupper(implode('', unpack('H*', $range['mask_bin']))));
        $summary['Wildcard bits'] = ip4_format(~$range['mask_bin']);
    }
    $reuse_domain = considerConfiguredConstraint($range, '8021Q_MULTILINK_LISTSRC');
    $domainclass = array();
    foreach (array_count_values(reduceSubarraysToColumn($range['8021q'], 'domain_id')) as $domain_id => $vlan_count) {
        $domainclass[$domain_id] = $vlan_count == 1 ? '' : ($reuse_domain ? '{trwarning}' : '{trerror}');
    }
    foreach ($range['8021q'] as $item) {
        $summary[] = array($domainclass[$item['domain_id']] . 'VLAN:', formatVLANAsHyperlink(getVLANInfo($item['domain_id'] . '-' . $item['vlan_id'])));
    }
    if (getConfigVar('EXT_IPV4_VIEW') == 'yes' and count($routers = findRouters($range['addrlist']))) {
        $summary['Routed by'] = '';
        foreach ($routers as $rtr) {
            $summary['Routed by'] .= getOutputOf('renderRouterCell', $rtr['ip_bin'], $rtr['iface'], spotEntity('object', $rtr['id']));
        }
    }
    $summary['tags'] = '';
    renderEntitySummary($range, 'summary', $summary);
    if (strlen($range['comment'])) {
        startPortlet('Comment');
        echo '<div class=commentblock>' . string_insert_hrefs(htmlspecialchars($range['comment'], ENT_QUOTES, 'UTF-8')) . '</div>';
        finishPortlet();
    }
    renderFilesPortlet($realm, $id);
    echo "</td>\n";
    echo "<td class=pcright>";
    startPortlet('details');
    renderIPNetworkAddresses($range);
    finishPortlet();
    echo "</td></tr></table>\n";
}
Esempio n. 2
0
function renderIPNetwork($id)
{
    global $pageno;
    $realm = $pageno;
    // 'ipv4net', 'ipv6net'
    $range = spotEntity($realm, $id);
    loadIPAddrList($range);
    echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
    echo "<tr><td colspan=2 align=center><h1>{$range['ip']}/{$range['mask']}</h1><h2>";
    echo htmlspecialchars($range['name'], ENT_QUOTES, 'UTF-8') . "</h2></td></tr>\n";
    echo "<tr><td class=pcleft width='50%'>";
    // render summary portlet
    $summary = array();
    $summary['%% used'] = getRenderedIPNetCapacity($range);
    $summary = array_merge($summary, getRenderedIPNetBacktrace($range));
    if ($realm == 'ipv4net') {
        $summary[] = array('Netmask:', ip4_format($range['mask_bin']));
        $summary[] = array('Netmask:', "0x" . strtoupper(implode('', unpack('H*', $range['mask_bin']))));
        $summary['Wildcard bits'] = ip4_format(~$range['mask_bin']);
    }
    foreach ($range['8021q'] as $item) {
        $vlaninfo = getVLANInfo($item['domain_id'] . '-' . $item['vlan_id']);
        $summary[] = array('VLAN:', '<a href="' . makeHref(array('page' => 'vlan', 'vlan_ck' => $vlaninfo['vlan_ck'])) . '">' . formatVLANName($vlaninfo, 'markup long') . '</a>');
    }
    if (getConfigVar('EXT_IPV4_VIEW') == 'yes' and count($routers = findRouters($range['addrlist']))) {
        $summary['Routed by'] = '';
        foreach ($routers as $rtr) {
            $summary['Routed by'] .= getOutputOf('renderRouterCell', $rtr['ip_bin'], $rtr['iface'], spotEntity('object', $rtr['id']));
        }
    }
    $summary['tags'] = '';
    renderEntitySummary($range, 'summary', $summary);
    if (strlen($range['comment'])) {
        startPortlet('Comment');
        echo '<div class=commentblock>' . string_insert_hrefs(htmlspecialchars($range['comment'], ENT_QUOTES, 'UTF-8')) . '</div>';
        finishPortlet();
    }
    renderFilesPortlet($realm, $id);
    echo "</td>\n";
    echo "<td class=pcright>";
    startPortlet('details');
    renderIPNetworkAddresses($range);
    finishPortlet();
    echo "</td></tr></table>\n";
}