<th><img src=img/32/clock.png><br>Average Node Age</th>
</tr>
<?php 
            $row = 0;
            foreach (array_keys($nets) as $dn) {
                if ($row % 2) {
                    $bg = $bga;
                    $bi = $bia;
                } else {
                    $bg = $bgb;
                    $bi = $bib;
                }
                $row++;
                $net = long2ip($dn);
                list($pfix, $mask, $bmsk) = Masker($nets[$dn]);
                list($ntimg, $ntit) = Nettype($net);
                $pbar = Bar($pop[$dn], 110);
                $abar = Bar($age[$dn]);
                $dvs = "";
                foreach (array_keys($devs[$dn]) as $dv) {
                    $du = rawurlencode($dv);
                    $dvs .= "<a href=Devices-Status.php?dev={$du}>{$dv}</a> " . $devs[$dn][$dv] . "<br>\n";
                }
                echo "<tr bgcolor=#{$bg}>";
                echo "<td bgcolor={$bi} width=20 align=center><img src=img/16/{$ntimg} title={$ntit}></td>\n";
                echo "<td><a href=Devices-Map.php?ina=network&flt={$net}%2F{$pfix}&draw=1>{$net}/{$pfix}</a></td>\n";
                echo "<td>{$dvs}</td><td>{$pbar} <a href=Nodes-List.php?ina=ip&opa==&sta={$net}/{$pfix}&ord=ip>{$pop[$dn]}</a></td>\n";
                echo "<td>{$abar} {$age[$dn]} days</td>\n";
                echo "</tr>\n";
            }
            echo "</table><table bgcolor=#666666 {$tabtag} >\n";
    foreach (array_keys($r) as $rd) {
        if ($row % 2) {
            $bg = $bga;
            $bi = $bia;
        } else {
            $bg = $bgb;
            $bi = $bib;
        }
        $row++;
        $if = $ina[$r[$rd]['ifx']] . " " . $ial[$r[$rd]['ifx']] . " " . $icm[$r[$rd]['ifx']];
        $spd = ZFix($isp[$r[$rd]['ifx']]);
        $rpimg = RteProto($r[$rd]['pro']);
        $unh = rawurlencode($netif[$r[$rd]['nho']]);
        list($pfix, $msk, $bmsk) = Masker($r[$rd]['msk']);
        list($ifimg, $iftit) = Iftype($ity[$r[$rd]['ifx']]);
        list($ntimg, $ntit) = Nettype($rd);
        echo "<tr bgcolor=#{$bg}>";
        echo "<td bgcolor={$bi} width=20 align=center><img src=img/16/{$ntimg} title={$ntit}></td>\n";
        echo "<td><a href=Topology-Map.php?ina=network&flt={$rd}%2F{$pfix}&draw=1>{$rd}/{$pfix}</a></td>\n";
        echo "<td>" . $r[$rd]['nho'] . " <a href=?rtr={$unh}>" . $netif[$r[$rd]['nho']] . "</a></td><td><img src=img/{$ifimg} title={$iftit} hspace=4> {$if}</td>\n";
        echo "<td align=right>{$spd}</td><td align=center>" . $r[$rd]['me1'] . "</td>\n";
        echo "<td><img src=img/16/{$rpimg}.png> " . $r[$rd]['pro'] . "</td><td align=right>" . $r[$rd]['age'] . "</td>\n";
        echo "</tr>\n";
    }
    echo "</table><table bgcolor=#666666 {$tabtag} >\n";
    echo "<tr bgcolor=#{$bg2}><td>{$row} entries in route table</td></tr></table>\n";
}
include_once "inc/footer.php";
//===================================================================
// Get routes of a device
function DevRoutes($ip, $c)
            $row = 0;
            foreach ($prun as $mr => $pr) {
                if ($row % 2) {
                    $bg = "txta";
                    $bi = "imga";
                } else {
                    $bg = "txtb";
                    $bi = "imgb";
                }
                $row++;
                $i = explode(".", $mr);
                $ip = "{$i['4']}.{$i['5']}.{$i['6']}.{$i['7']}";
                if ($pr == 1) {
                    $ntimg = "16/bstp.png";
                } else {
                    list($ntimg, $ntit) = Nettype($ip);
                }
                sscanf($last[$mr], "%d:%d:%0d:%0d.%d", $lud, $luh, $lum, $lus, $ticks);
                $bpsbar = Bar(intval($bps[$mr] / 1000), 0);
                echo "<tr class=\"{$bg}\">\n";
                echo "<td><a href=Nodes-List.php?in[]=nodip&op[]==&st[]={$ip}>{$ip}</a></td>\n";
                echo "<td><img src=\"img/{$ntimg}\" title=\"{$ntit}\">{$i['0']}.{$i['1']}.{$i['2']}.{$i['3']}</td>\n";
                echo "<td>{$bpsbar}" . $bps[$mr] . "</td>\n";
                printf("<td>%d D %d:%02d:%02d</td>", $lud, $luh, $lum, $lus);
            }
            ?>
</tr></table>
<table class="content">
<tr class="<?php 
            echo $modgroup[$self];
            ?>
Example #4
0
function NetPop($ina, $opa, $sta, $lim, $ord)
{
    global $link, $modgroup, $self, $verb1, $netlbl, $dislbl, $adrlbl, $poplbl, $agelbl, $tim, $totlbl, $srtlbl;
    if ($ina == "devip") {
        $ina = "ifip";
    }
    if ($ord) {
        $ocol = "device";
        $srt = "{$srtlbl}: Device";
    } else {
        $ocol = "ifip";
        $srt = "{$srtlbl}: IP {$adrlbl}";
    }
    $query = GenQuery('networks', 's', 'networks.*,lastdis', $ocol, '', array('ifip', $ina), array('>', $opa), array('0', $sta), array('AND'), 'LEFT JOIN devices USING (device)');
    $res = DbQuery($query, $link);
    if ($res) {
        $row = 0;
        $netok = array();
        while ($n = DbFetchRow($res)) {
            $n[2] = ip2long(long2ip($n[2]));
            # Hack to fix signing issue for 32bit vars in PHP!
            $dmsk = 4294967295.0 << 32 - $n[4];
            $dnet = long2ip($n[2] & $dmsk);
            if ($n[4] > 16 and $n[4] < 32) {
                # Only > /16 but not /32 networks
                if (!array_key_exists($dnet, $netok)) {
                    # Only if subnet hasn't been processed
                    $netok[$dnet] = 1;
                    $nod[$dnet] = array();
                    $nquery = GenQuery('nodes', 's', 'name,inet_ntoa(nodip)', 'nodip', '', array("nodip & {$dmsk}"), array('='), array(sprintf("%u", $n[2] & $dmsk)));
                    $nres = DbQuery($nquery, $link);
                    if ($nres) {
                        while ($no = DbFetchRow($nres)) {
                            $nod[$dnet][$no[1]] = $no[0];
                        }
                    }
                    DbFreeResult($nres);
                }
                $n[2] = long2ip($n[2]);
                $dev[$dnet][$n[2]] = $n[0];
                $nets[$dnet] = $n[4];
                if (count(array_keys($nets)) == $lim) {
                    break;
                }
            }
        }
        DbFreeResult($res);
        if ($nets) {
            ?>
<h2><?php 
            echo $netlbl;
            ?>
 <?php 
            echo $poplbl;
            ?>
</h2>

<table class="content"><tr class="<?php 
            echo $modgroup[$self];
            ?>
2">
<th colspan="2"><img src="img/16/net.png"><br>IP <?php 
            echo $adrlbl;
            ?>
</th>
<th><img src="img/16/nods.png"><br><?php 
            echo $poplbl;
            ?>
</th>
</tr>
<?php 
            $row = 0;
            foreach (array_keys($nets) as $net) {
                if ($row % 2) {
                    $bg = "txta";
                    $bi = "imga";
                } else {
                    $bg = "txtb";
                    $bi = "imgb";
                }
                $row++;
                list($ntimg, $ntit) = Nettype($net);
                echo "<tr class=\"{$bg}\">\n";
                echo "<th class=\"{$bi}\" width=\"20\"><img src=\"img/{$ntimg}\" title=\"{$ntit}\"></th>\n";
                echo "<td><a href=\"?in[]=devip&op[]==&st[]={$net}%2F{$nets[$net]}&rep%5B%5D=pop\">{$net}/{$nets[$net]}</a><p>";
                echo "<a href=\"Topology-Networks.php?in[]=ifip&op[]==&st[]={$net}%2F{$nets[$net]}\"><img src=\"img/16/glob.png\" title=\"IF IPs\"> " . count(array_keys($dev[$net])) . "</a><p>";
                echo "<a href=\"Nodes-List.php?in[]=nodip&op[]==&st[]={$net}%2F{$nets[$net]}\"><img src=\"img/16/nods.png\" title=\"Node IPs\"> " . count(array_keys($nod[$net])) . "</a";
                echo "</td>";
                echo "<td><table><tr>";
                $col = 0;
                $dn = ip2long($net);
                $max = $dn + pow(2, 32 - $nets[$net]);
                for ($a = $dn; $a < $max; $a++) {
                    if ($col == 64) {
                        $col = 0;
                        echo "</tr>\n<tr>";
                    }
                    $ip = long2ip($a);
                    if (array_key_exists($ip, $dev[$net]) and array_key_exists($ip, $nod[$net])) {
                        echo "<td title=\"{$ip} Dev:" . $dev[$net][$ip] . " Node:" . $nod[$net][$ip] . "\" class=\"warn\"><a href=\"Topology-Networks.php?in[]=ifip&op[]==&st[]={$ip}\">&nbsp;</a></td>";
                    } elseif (array_key_exists($ip, $nod[$net])) {
                        echo "<td title=\"{$ip} Node:" . $nod[$net][$ip] . "\" class=\"good\"><a href=\"Nodes-List.php?in[]=nodip&op[]==&st[]={$ip}\">&nbsp;</a></td>";
                    } elseif (array_key_exists($ip, $dev[$net])) {
                        echo "<td title=\"{$ip} Dev:" . $dev[$net][$ip] . "\" class=\"noti\"><a href=\"Topology-Networks.php?in[]=ifip&op[]==&st[]={$ip}\">&nbsp;</a></td>";
                    } elseif ($a == $dn or $a == $max - 1) {
                        $netxt = $a == $dn ? $netlbl : "Broadcast";
                        echo "<td title=\"{$netxt}:{$ip}\" class=\"{$bg} part\">&nbsp;</td>";
                    } else {
                        echo "<td title=\"{$ip}\" class=\"{$bi}\">&nbsp;</td>";
                    }
                    $col++;
                }
                echo "</tr></table></td></tr>\n";
            }
            ?>
</table>
<table class="content">
<tr class="<?php 
            echo $modgroup[$self];
            ?>
2"><td><?php 
            echo $row;
            ?>
 <?php 
            echo $netlbl;
            ?>
, <?php 
            echo $srt;
            ?>
</td></tr>
</table>
<p>
<?php 
        }
    }
}
    $row = 0;
    foreach (array_keys($r) as $dst) {
        if ($row % 2) {
            $bg = $bga;
            $bi = $bia;
        } else {
            $bg = $bgb;
            $bi = $bib;
        }
        $row++;
        $if = $ina[$r[$dst]['ifx']] . " (" . $ial[$r[$dst]['ifx']] . " " . $icm[$r[$dst]['ifx']] . ")";
        $spd = ZFix($isp[$r[$dst]['ifx']]);
        $rpimg = RteProto($r[$dst]['pro']);
        list($pfix, $msk, $bmsk) = Masker($r[$dst]['msk']);
        list($ifimg, $iftit) = Iftype($ity[$r[$dst]['ifx']]);
        list($ntimg, $ntit) = Nettype($dst);
        echo "<tr bgcolor=#{$bg}>";
        echo "<td bgcolor={$bi} width=20 align=center><img src=img/16/{$ntimg} title={$ntit}></td>\n";
        echo "<td>{$dst}/{$pfix}</td><td>" . $r[$dst]['nho'] . "</td><td><img src=img/{$ifimg} title={$iftit} hspace=4> {$if}</td>\n";
        echo "<td align=right>{$spd}</td><td align=center>" . $r[$dst]['me1'] . "</td>\n";
        echo "<td><img src=img/16/{$rpimg}.png>" . $r[$dst]['pro'] . "</td><td align=right>" . $r[$dst]['age'] . "</td>\n";
        echo "</tr>\n";
    }
    echo "</table><table bgcolor=#666666 {$tabtag} >\n";
    echo "<tr bgcolor=#{$bg2}><td>{$row} results using {$query}</td></tr></table>\n";
}
include_once "inc/footer.php";
//===================================================================
// Get routes of a device
function DevRoutes($ip, $c)
{
Example #6
0
 $query = GenQuery('networks', 's', 'networks.*,type,firstdis,lastdis,location,contact', $ord, $lim, $in, $op, $st, $co, 'LEFT JOIN devices USING (device)');
 $res = DbQuery($query, $link);
 if ($res) {
     $row = 0;
     while ($m = DbFetchRow($res)) {
         if ($row % 2) {
             $bg = "txta";
             $bi = "imga";
         } else {
             $bg = "txtb";
             $bi = "imgb";
         }
         $row++;
         $ip = $m[2] ? long2ip($m[2]) : "";
         $ip6 = DbIPv6($m[3]);
         list($ntimg, $ntit) = Nettype($ip, $ip6);
         $ud = urlencode($m[0]);
         list($fc, $lc) = Agecol($m[8], $m[9], $row % 2);
         TblRow($bg);
         if (in_array("imBL", $col)) {
             TblCell("", "", "class=\"{$bi}\" width=\"50\"", "<img src=\"img/{$ntimg}\" title=\"{$ntit}\">", "th-img");
         }
         if (in_array("ifip", $col)) {
             TblCell($ip, "?in[]=ifip&op[]==&st[]={$ip}/{$m['4']}");
         }
         if (in_array("ifip6", $col)) {
             TblCell($ip6, "", "class=\"prp\"");
         }
         if (in_array("prefix", $col)) {
             TblCell($m[4]);
         }