<th><img src=img/32/cubs.png><br>Population</th>
<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";
            }
<input type="submit" value="Calculate" name="calc">
</th>
</tr>
</table></form>
<?php 
if (isset($_GET['calc'])) {
    if (preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $getip)) {
        $ip = $getip;
        $dip = ip2long($getip);
    } else {
        $getip = $getip + 0;
        // force 32 Bit unsigned for PHP!!!
        $ip = long2ip($getip);
        $dip = $getip;
    }
    list($pfix, $mask, $bmsk) = Masker($getmsk);
    $hmsk = "0x" . ip2hex($mask);
    $dmsk = ip2long($mask);
    $hip = "0x" . ip2hex($ip);
    $bip = ip2bin($ip);
    //or $bip	= base_convert($dip,10,2);
    $dwmsk = ~$dmsk;
    $wmsk = long2ip($dwmsk);
    $bwmsk = ip2bin($wmsk);
    $hwmsk = "0x" . ip2hex($wmsk);
    $dnet = $dip & $dmsk;
    $net = long2ip($dnet);
    $bnet = ip2bin($net);
    $hnet = "0x" . ip2hex($net);
    $bc = long2ip($dnet + $dwmsk);
    $dbc = ip2long($bc);
                echo "<img src=inc/drawrrd.php?dv={$ud}&if%5B%5D={$ui}&s=s&t=err border=0></a>\n";
            } else {
                echo "<td>Tell Remo, if you see this!!!</td>";
            }
        } else {
            echo "<td bgcolor=#{$bg3}{$bg3}{$bio} align=right>" . $ino[$i] . "</td>\n";
            echo "<td bgcolor=#{$bg3}{$bg3}{$boo} align=right>" . $oto[$i] . "</td>\n";
            echo "<td bgcolor=#{$bie}{$bg3}{$bg3} align=right>" . $ine[$i] . "</td>\n";
            echo "<td bgcolor=#{$boe}{$bg3}{$bg3} align=right>" . $ote[$i] . "</td>\n";
        }
        echo "<td>";
        if ($ifm[$i]) {
            echo "<a href=Nodes-Status.php?mac={$ifm[$i]}>{$ifm[$i]}</a><br>";
        }
        foreach ($net[$in] as $ip => $dmsk) {
            list($pfix, $msk, $bmsk) = Masker($dmsk);
            $dnet = long2ip($ip);
            echo "<a href=Reports-Networks.php?ipf={$dnet}%2F{$pfix}&shw=1 title=\"{$dnet}/{$pfix} Report-Networks\">{$dnet}</a>/{$pfix} ";
        }
        echo "</td></tr>\n";
    }
    echo "</table><table bgcolor=#666666 {$tabtag} >\n";
    echo "<tr bgcolor=#{$bg2}><td>{$nif} Interfaces</td></tr></table>\n";
} elseif ($dld) {
    if (preg_match("/adm/", $_SESSION['group'])) {
        $now = time();
        $query = GenQuery('devdel', 'i', '', '', '', array('device', 'user', 'time'), '', array($dld, $_SESSION['user'], $now));
        if (!@DbQuery($query, $link)) {
            echo "<h4>" . DbError($link) . "</h4>";
        } else {
            echo "<h3>Device {$_GET['del']} {$upokmsg}</h3>";
    $r = DevRoutes($devip[$rtr], $devcom[$rtr]);
    $row = 0;
    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";
//===================================================================
Example #5
0
function DevRoutes($ip, $rv, $rc, $vrfname)
{
    global $toumsg, $nonlbl;
    if (!empty($vrfname)) {
        $suffix = strlen($vrfname);
        $sufarr = str_split($vrfname);
        foreach ($sufarr as $char) {
            $suffix .= "." . ord($char);
        }
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.8.{$suffix}") as $ix => $val) {
            $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $nho = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$3', $ix);
            $msk = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$2', $ix);
            $route[$r]['nho'] = $nho;
            $route[$r]['msk'] = $msk;
            $route[$r]['ifx'] = $val;
        }
        if (!empty($ix)) {
            #metric
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.14.{$suffix}") as $ix => $val) {
                $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['me1'] = $val;
                $route[$r]['vrfname'] = $vrfname;
            }
            #protocol
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.10.{$suffix}") as $ix => $val) {
                $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['pro'] = $val;
            }
            #age
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.3.118.1.4.1.1.11.{$suffix}") as $ix => $val) {
                $r = preg_replace('/.*\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['age'] = $val;
            }
            return $route;
        } else {
            echo "<h4>(VRFs: {$nonlbl})</h4>";
        }
    }
    #snmp_set_oid_numeric_print(1); Doesn't work eveerywhere, so I use the preg_replace hack below to avoid problems
    # now we should try to get ipCidrRouteIfIndex oid. Full table in 4 queries if exists.
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.5") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $msk = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$2', $ix);
        $nho = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.\\d+\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$3', $ix);
        $route[$r]['nho'] = $nho;
        $route[$r]['msk'] = $msk;
        $route[$r]['ifx'] = $val;
    }
    if (!$ix) {
        # no ipCidrRouteIfIndex OID, lets try ipRouteIfIndex OID (old one, but very common). This one will complete in 6 SNMP queries.
        echo "<h4>(ipCidrRouteIfIndex: {$nonlbl})</h4>";
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.2") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['ifx'] = $val;
        }
        if (!$ix) {
            #no luck with generic OIDs, try even more exotic inetCidrRoute
            #walking for inetCidrRouteIfIndex
            #netmask in really CIDR now
            echo "<h4>(generic OIDs: {$nonlbl})</h4>";
            snmp_set_oid_numeric_print(TRUE);
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.7") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $mskcidr = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$2', $ix);
                $nho = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$3', $ix);
                $mskpfix = Masker($mskcidr);
                $route[$r]['nho'] = $nho;
                $route[$r]['msk'] = $mskpfix[1];
                $route[$r]['ifx'] = $val;
            }
            if (!$ix) {
                #no OIDs for route info, timeout or route do not exist.
                echo "</table><h4>{$toumsg}</h4>";
                if ($_SESSION['vol']) {
                    echo "<embed src=\"inc/enter2.mp3\" volume=\"{$_SESSION['vol']}\" hidden=\"true\">\n";
                }
                die;
            }
            #metric inetCidrRouteMetric1
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.12") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['me1'] = $val;
            }
            #protocol inetCidrRouteProto
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.9") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['pro'] = $val;
            }
            #age inetCidrRouteAge
            foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.7.1.10") as $ix => $val) {
                $r = preg_replace('/.*\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+)\\.\\d+\\.1\\.4\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
                $route[$r]['age'] = $val;
            }
            snmp_set_oid_numeric_print(FALSE);
            return $route;
        }
        #metric ipRouteMetric1
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.3") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['me1'] = $val;
        }
        #nexthop ipRouteNextHop
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.7") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['nho'] = $val;
        }
        #proto ipRouteProto
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.9") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['pro'] = $val;
        }
        #age ipRouteAge
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.10") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['age'] = $val;
        }
        #netmask ipRouteMask
        foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.21.1.11") as $ix => $val) {
            $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
            $route[$r]['msk'] = $val;
        }
        return $route;
    }
    #metric ipCidrRouteMetric1
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.11") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.[0-9]\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $route[$r]['me1'] = $val;
    }
    #protocol ipCidrRouteProto
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.7") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.[0-9]\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $route[$r]['pro'] = $val;
    }
    #age ipCidrRouteAge
    foreach (Walk($ip, $rv, $rc, "1.3.6.1.2.1.4.24.4.1.8") as $ix => $val) {
        $r = preg_replace('/.*\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)\\.[0-9]\\.(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', '$1', $ix);
        $route[$r]['age'] = $val;
    }
    return $route;
}
Example #6
0
    ?>
 (<?php 
    echo $nho;
    ?>
 total)</td><td class="drd code"><?php 
    echo $blho;
    ?>
</td><td class="drd code"><?php 
    echo $hlho;
    ?>
</td></tr>
</table>
<?php 
}
if ($getsub) {
    list($spfix, $smask, $bsmsk) = Masker($getsub);
    $hsmsk = "0x" . str_pad(ip2hex($smask), 8, 0);
    $dsmsk = ip2long($smask);
    $dwsmsk = ~$dsmsk;
    $wsmsk = long2ip($dwsmsk);
    $bwsmsk = ip2bin($wsmsk);
    $hwsmsk = "0x" . ip2hex($wsmsk);
    if ($pfix < $spfix) {
        if (!isset($_GET['xls'])) {
            ?>
<h2>Subnet <?php 
            echo $sumlbl;
            ?>
</h2>
<table class="content">
<tr class="<?php