asort($nonf); } else { arsort($nonf); } $row = 0; foreach ($nonf as $m => $nf) { if ($row % 2) { $bg = $bga; $bi = $bia; } else { $bg = $bgb; $bi = $bib; } $row++; $nbar = Bar($nf, 100); $img = Nimg($noou[$m]); echo "<tr bgcolor=#{$bg}>\n"; echo "<th bgcolor=#{$bi}>{$row}</th><th bgcolor=#{$bi}><a href=Nodes-Status.php?mac={$m}><img src=img/oui/{$img} border=0></a></th><td>{$nona[$m]}</td>\n"; echo "<td> {$nodv[$m]}</td><td>{$noif[$m]}\n"; list($fc, $lc) = Agecol($nofs[$m], $nols[$m], $row % 2); $fs = date("j.M G:i:s", $nofs[$m]); echo "<td bgcolor=#{$fc}>{$fs}</td>"; $ls = date("j.M G:i:s", $nols[$m]); echo "<td bgcolor=#{$lc}>{$ls}</td>"; echo "<td>{$nbar} {$nf}</td></tr>\n"; if ($row == $lim) { break; } } echo "</table><table bgcolor=#666666 {$tabtag} >\n"; echo "<tr bgcolor=#{$bg2}><td>{$row} nomads out of {$tnod} nodes</td></tr></table>\n";
$link = @DbConnect($dbhost, $dbuser, $dbpass, $dbname); $query = GenQuery('nodes', 's', '*', '', '', array('mac'), array('='), array($mac)); $res = @DbQuery($query, $link); $nnod = @DbNumRows($res); if ($nnod != 1) { echo "<h4>{$mac} {$n1rmsg}</h4>"; @DbFreeResult($res); die; } else { $n = @DbFetchRow($res); @DbFreeResult($res); $name = preg_replace("/^(.*?)\\.(.*)/", "\$1", $n[0]); $ip = long2ip($n[1]); $au = date($datfmt, $n[12]); list($a1c, $a2c) = Agecol($n[12], $n[12], 1); $img = Nimg("{$n['2']};{$n['3']}"); $fs = date($datfmt, $n[4]); $ls = date($datfmt, $n[5]); $ud = rawurlencode($n[6]); list($fc, $lc) = Agecol($n[4], $n[5], 0); if ($n[7]) { $query = GenQuery('interfaces', 's', '*', '', '', array('device', 'ifname'), array('=', '='), array($n[6], $n[7]), array('AND')); $res = @DbQuery($query, $link); $nif = @DbNumRows($res); if ($nif != 1) { echo "<h4>{$query} {$n1rmsg}</h4>"; } else { $if = @DbFetchRow($res); if ($if[8] == "2") { $ifimg = "<img src=img/bulbr.png title=\"Disabled!\">"; } else {
if( in_array("tel",$col) ) {echo "<th>Telnet server</th>";} if( in_array("www",$col) ) {echo "<th>Web server</th>";} if( in_array("nbt",$col) ) {echo "<th>Netbios</th>";} echo "</tr>\n"; $link = @DbConnect($dbhost,$dbuser,$dbpass,$dbname); $query = GenQuery('nodes','s','*',$ord,'',array($ina,$inb),array($opa,$opb),array($sta,$stb),array($cop)); $res = @DbQuery($query,$link); if($res){ $row = 0; while( ($n = @DbFetchRow($res)) ){ if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";} $row++; $name = preg_replace("/^(.*?)\.(.*)/","$1", $n[0]); $ip = long2ip($n[1]); $img = Nimg("$n[2];$n[3]"); list($fc,$lc) = Agecol($n[4],$n[5],$row % 2); $ud = rawurlencode($n[6]); $ui = rawurlencode($n[7]); echo "<tr class=\"$bg\"><th class=\"$bi\">\n"; echo "<a href=Nodes-Status.php?mac=$n[2]><img src=\"img/oui/$img.png\" title=\"$n[3] ($n[2])\"></a></th>\n"; if(in_array("name",$col)){ echo "<td><b>$n[0]</b></td>";} if(in_array("ip",$col)){ echo "<td><a href=?ina=ip&opa==&sta=$ip>$ip</a></td>"; } if(in_array("ipupdate",$col)){ $au = date("j.M G:i:s",$n[12]); list($a1c,$a2c) = Agecol($n[12],$n[12],$row % 2); echo "<td bgcolor=#$a1c>$au</td>"; }
function DrawNodes($dv) { global $link, $fsz, $fco, $fmt, $len, $lsf, $in, $op, $st, $imas; global $dev, $nod, $nlnk, $mapframes, $mapitems, $imgmap, $sub, $cud, $jnod; if ($sub) { include_once 'libnod.php'; } else { include_once 'inc/libnod.php'; } if ($in[0] == "vlanid" or $in[0] == "mac" or $in[0] == 'nodip' or $in[0] == 'name' or $in[0] == 'oui') { $nquery = GenQuery('nodes', 's', 'name,nodip,mac,oui,ifname,ifmetric,iftype,speed,duplex,pvid,alias,dinoct,doutoct', 'ifname', '', array('device', $in[0]), array('=', $op[0]), array($dv, $st[0]), array('AND'), 'LEFT JOIN interfaces USING (device,ifname)'); } else { $nquery = GenQuery('nodes', 's', 'name,nodip,mac,oui,ifname,ifmetric,iftype,speed,duplex,pvid,alias,dinoct,doutoct', 'ifname', '', array('device'), array('='), array($dv), array(), 'LEFT JOIN interfaces USING (device,ifname)'); } $nres = DbQuery($nquery, $link); if ($nres) { $cun = 0; $nn = DbNumRows($nres); while ($n = DbFetchRow($nres)) { $nod[$n[2]]['nam'] = $n[0]; $nod[$n[2]]['ip'] = long2ip($n[1]) . ($n[9] ? " Vl{$n['9']}" : ""); $nod[$n[2]]['ico'] = Nimg("{$n['2']};{$n['3']}"); list($nod[$n[2]]['x'], $nod[$n[2]]['y']) = CircleCoords($dev[$dv]['x'], $dev[$dv]['y'], $cun, $nn, 8 * ($cun % 2), $len / pow($lsf / 10, 3), 0, 0); $mapitems .= DrawItem($nod[$n[2]]['x'], $nod[$n[2]]['y'], '0', $n[2], 'n'); $imgmap .= "<area href=\"Nodes-Status.php?mac={$n['2']}\" coords=\"" . ($nod[$n[2]]['x'] - $imas) . "," . ($nod[$n[2]]['y'] - $imas) . "," . ($nod[$n[2]]['x'] + $imas) . "," . ($nod[$n[2]]['y'] + $imas) . "\" shape=\"rect\" title=\"" . $nod[$n[2]]['nam'] . " " . $nod[$n[2]]['ip'] . "\">\n"; $nlnk["{$dv};;{$n['2']}"]['fbw'] = $n[7]; $nlnk["{$dv};;{$n['2']}"]['rbw'] = $n[8]; $nlnk["{$dv};;{$n['2']}"]['ftr'] = $n[11]; $nlnk["{$dv};;{$n['2']}"]['rtr'] = $n[12]; $nlnk["{$dv};;{$n['2']}"]['ifal'][] = $n[10]; $nlnk["{$dv};;{$n['2']}"]['fif'][] = "{$dv};;{$n['4']}"; $nlnk["{$dv};;{$n['2']}"]['rif'][] = $n[5] < 256 ? ";;{$n['5']}db" : ""; # Draws SNR... if ($fmt == "json") { $cud++; } $jnod["{$dv};;{$n['2']}"] = $cud; $cun++; } DbFreeResult($nres); } else { echo DbError($link); } }
<title>NeDi Find Me</title> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <link href="inc/print.css" type="text/css" rel="stylesheet"> <link rel="shortcut icon" href="img/favicon.ico"> </head> <body> <?php $link = DbConnect($dbhost, $dbuser, $dbpass, $dbname); $query = GenQuery('nodes', 's', 'nodes.*,location,speed,duplex,pvid,dinoct,doutoct,dinerr,douterr,dindis,doutdis,dinbrc', 'lastseen', '1', array('nodip'), array('='), array(ip2long($_SERVER[REMOTE_ADDR])), array(), 'LEFT JOIN devices USING (device) LEFT JOIN interfaces USING (device,ifname)'); $res = DbQuery($query, $link); if ($res) { $n = DbFetchRow($res); if ($n[2]) { $img = Nimg($n[3]); $l = explode($locsep, $n[23]); echo "<table class=\"mon2\">"; echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/oui/{$img}.png\" title=\"{$n['3']}\"></th><td><b>{$n['0']}</b></td><td class=\"mrn code\">{$n['2']}</td></tr>\n"; echo "<tr class=\"txtb\"><th class=\"imgb\" width=\"20\"><img src=\"img/16/net.png\" title=\"Network\"></th><td class=\"blu code\">" . long2ip($n[1]) . "</td><td class=\"prp code\">" . ($n[16] ? inet_ntop($n[16]) : '') . "</td></tr>\n"; echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/16/dev.png\" title=\"Device\"></th><td>{$n['6']}</td><td>{$l['2']} {$l['3']}</td></tr>\n"; echo "<tr class=\"txtb\"><th class=\"imgb\" width=\"20\"><img src=\"img/16/port.png\" title=\"Interface\"></th><td>{$n['7']}</td><td>" . DecFix($n[24]) . "-{$n['25']} vl{$n['8']}</td></tr>\n"; echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/16/grph.png\" title=\"In/Out\"></th><td colspan=\"2\">Traffic: <b class=\"blu code\">" . DecFix($n[27]) . "/" . DecFix($n[28]) . "</b> Errors:<b class=\"drd code\"> " . DecFix($n[29]) . "/" . DecFix($n[30]) . "</b> Discards:<b class=\"prp code\">" . DecFix($n[31]) . "/" . DecFix($n[32]) . " </b> Bcast:<b class=\"dgy code\"> " . DecFix($n[33]) . "</b></td></tr>\n"; echo "</table>"; } else { echo "<h4>{$_SERVER['REMOTE_ADDR']} was not found</h4>"; } DbFreeResult($res); } else { print DbError($link); }
$bst = 'warn'; } } else { if ($trk['value'] != $trk[$trk['source']]) { $bst = 'warn'; } } TblRow($bg); foreach ($col as $c) { if ($p = strpos($c, ".")) { $c = substr($c, $p + 1); } if ($c == 'tgtNS') { echo "<th class=\"{$bst}\" width=\"50\">"; if ($trk['mac']) { $img = Nimg("{$trk['mac']};{$trk['oui']}"); ?> <a href="Nodes-Status.php?mac=<?php echo $trk['mac']; ?> &vid=<?php echo $trk['vlanid']; ?> "><img src="img/oui/<?php echo $img; ?> .png" title="<?php echo $trk['mac']; ?> (<?php echo $trk['oui'];
function NodSum($ina, $opa, $sta, $lim, $ord) { global $link, $modgroup, $self, $rrdstep, $stco, $sumlbl, $srtlbl, $venlbl, $qtylbl, $alllbl, $chglbl, $totlbl, $deslbl, $fislbl, $laslbl, $emplbl, $namlbl, $metlbl, $nonlbl, $loslbl, $qutlbl, $faslbl, $vallbl, $mullbl; $lasdis = time() - $rrdstep * 2; $query = GenQuery('nodes', 's', "count(*),sum(case when nodip = 0 then 1 else 0 end),sum(case when name = '' then 1 else 0 end),sum(case when firstseen = lastseen then 1 else 0 end),sum(case when iplost > 0 then 1 else 0 end),sum(case when ifmetric < 256 then 1 else 0 end),sum(case when firstseen > {$lasdis} then 1 else 0 end),sum(case when lastseen > {$lasdis} then 1 else 0 end),sum(case when ipchanges > 0 then 1 else 0 end),sum(case when ifchanges > 0 then 1 else 0 end),sum(case when arpval > 1 then 1 else 0 end)", '', '', array($ina), array($opa), array($sta), array(), 'LEFT JOIN devices USING (device)'); $res = DbQuery($query, $link); if ($res) { $r = DbFetchRow($res); } else { print DbError($link); die; } ?> <table class="full fixed"><tr><td class="helper"> <h2>Node <?php echo $sumlbl; ?> </h2> <table class="content"><tr class="<?php echo $modgroup[$self]; ?> 2"> <th width="33%" colspan="2"><img src="img/16/find.png" title="Nodes <?php echo $stslbl; ?> "> <br><?php echo $deslbl; ?> </th><th><img src="img/16/nods.png"><br>Nodes</th> <tr class="txtb"><th class="imgb"><img src="img/16/add.png" title="<?php echo $fislbl; ?> > <?php echo date($_SESSION['date'], $lasdis); ?> "></th><td><b><?php echo $stco['10']; ?> </b></td><td><?php echo Bar($r[6], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=firstseen&op[]=>&st[]=<?php echo $lasdis; ?> &ord=nodip"><?php echo $r[6]; ?> </a></td></tr> <tr class="txta"><th class="imga"><img src="img/16/exit.png" title="<?php echo $laslbl; ?> > <?php echo date($_SESSION['date'], $lasdis); ?> "></th><td><b><?php echo $stco['100']; ?> </b></td><td><?php echo Bar($r[7], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=lastseen&op[]=>&st[]=<?php echo $lasdis; ?> &ord=nodip"><?php echo $r[7]; ?> </a></td></tr> <tr class="txtb"><th class="imgb"><img src="img/16/wlan.png" title="IF <?php echo $metlbl; ?> < 256"></th><td><b>Wlan</th></b><td><?php echo Bar($r[5], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=ifmetric&op[]=<&st[]=256&ord=ifmetric+desc"> <?php echo $r[5]; ?> </a></td></tr> <tr class="txta"><th class="imga"><img src="img/16/calc.png" title="IP <?php echo $chglbl; ?> > 0"></th><td><b>IP <?php echo $chglbl; ?> </b></td><td><?php echo Bar($r[8], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=ipchanges&op[]=>&st[]=0&ord=ipchanges+desc"><?php echo $r[8]; ?> </a></td></tr> <tr class="txtb"><th class="imgb"><img src="img/16/walk.png" title="IF <?php echo $chglbl; ?> > 0"></th><td><b>IF <?php echo $chglbl; ?> </b></td><td><?php echo Bar($r[9], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=ifchanges&op[]=>&st[]=0&ord=ifchanges+desc"><?php echo $r[9]; ?> </a></td></tr> <tr class="txta"><th class="imga"><img src="img/16/abc.png" title=" <?php echo $namlbl; ?> = ''"></th><td><b><?php echo $namlbl; ?> <?php echo $emplbl; ?> </b></td><td><?php echo Bar($r[2], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=name&op[]=~&st[]=^$&ord=nodip"><?php echo $r[2]; ?> </a></td></tr> <tr class="txtb"><th class="imgb"><img src="img/16/glob.png" title="IP = 0"></th><td><b><?php echo $nonlbl; ?> IP</b></td><td><?php echo Bar($r[1], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=nodip&op[]==&st[]=0"> <?php echo $r[1]; ?> </a></td></tr> <tr class="txta"><th class="imga"><img src="img/16/grph.png" title="IP <?php echo $loslbl; ?> > 0"></th><td><b><?php echo $qutlbl; ?> </b></td><td><?php echo Bar($r[4], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=iplost&op[]=%3E&st[]=0&ord=iplost+desc"><?php echo $r[4]; ?> </a></td></tr> <tr class="txtb"><th class="imgb"><img src="img/16/flas.png" title="<?php echo $fislbl; ?> = <?php echo $laslbl; ?> "></th><td><b><?php echo $faslbl; ?> </b></td><td><?php echo Bar($r[3], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=firstseen&co[]==&in[]=lastseen&ord=firstseen"><?php echo $r[3]; ?> </a></td></tr> <tr class="txta"><th class="imga"><img src="img/16/hat.png" title="ARP <?php echo $vallbl; ?> > 1"></th><td><b><?php echo $mullbl; ?> ARP</b></td><td><?php echo Bar($r[10], 0, 'mi'); ?> <a href="Nodes-List.php?in[]=arpval&op[]=>&st[]=1"><?php echo $r[10]; ?> </a></td></tr> <tr class="txtb"><th class="imgb"><img src="img/16/nods.png" title="<?php echo $alllbl; ?> Nodes"></th><td><b><?php echo $totlbl; ?> </b></td><td><?php echo Bar($r[0], 0, 'mi'); ?> <?php echo $r[0]; ?> </td></tr> </table> </td><td class="helper"> <h2>OUI <?php echo $venlbl; ?> </h2> <table class="content"><tr class="<?php echo $modgroup[$self]; ?> 2"> <th colspan="2" width="50%"><img src="img/16/card.png"><br><?php echo $venlbl; ?> </th> <th><img src="img/16/nods.png"><br>Nodes</th> <?php if ($ord) { $ocol = 'oui'; $srt = "{$srtlbl}: {$venlbl}"; } else { $ocol = 'cnt desc'; $srt = "{$srtlbl}: {$qtylbl}"; } $query = GenQuery('nodes', 'g', 'oui', $ocol, $lim, array($ina), array($opa), array($sta), array(), 'LEFT JOIN devices USING (device)'); $res = DbQuery($query, $link); if ($res) { $row = 0; while ($r = DbFetchRow($res)) { if ($row % 2) { $bg = "txta"; $bi = "imga"; } else { $bg = "txtb"; $bi = "imgb"; } $row++; $uo = urlencode($r[0]); echo "<tr class=\"{$bg}\"><th class=\"{$bi}\"><img src=\"img/oui/" . Nimg($r[0]) . ".png\"></th>\n"; echo "<td><a href=\"http://www.google.com/search?q={$uo}&btnI=1\">{$r['0']}</a></td><td>" . Bar($r[1], 0, 'mi') . " <a href=\"Nodes-List.php?in[]=oui&op[]==&st[]={$uo}\">{$r['1']}</a></td></tr>\n"; } } ?> </table> <table class="content" > <tr class="<?php echo $modgroup[$self]; ?> 2"><td><?php echo $row; ?> <?php echo $venlbl; ?> , <?php echo $srt; ?> </td></tr> </table> </td></tr></table> <p> <?php }