/** * ldap by Stephane Garret & vtur * Check all the directories. When the user is found, then import it * @param $login : user login * @param $password : user password * @param $import : import user or check **/ function user_from_ldap_servers($login, $password = '', $import = true) { global $ldapsrv, $user_dn, $fields; global $dbhost, $dbuser, $dbpass, $dbname; // search if user exist in local user DB $link = DbConnect($dbhost, $dbuser, $dbpass, $dbname); $query = GenQuery('users', 's', '*', '', '', array('user'), array('='), array($login)); $res = DbQuery($query, $link); if ($import) { if (DbNumRows($res) == 0) { $result = ldapFindDn($login); if ($result != false) { return $result; } } return false; } else { $result = ldapFindDn($login); if ($result != false) { $ds1 = connect_ldap($ldapsrv[0], $ldapsrv[1], $user_dn, $password, 0, 0); if ($ds1) { //Authetication OK for user return true; } else { //Authetication Failed for user return false; } } } return false; }
if( !@DbQuery($query,$link) ){echo "<h4>Links ".DbError($link)."</h4>";}else{echo "<h5>Links $dld $dellbl OK</h5>";} $query = GenQuery('configs','d','','','',array('device'),array('='),array($dld) ); if( !@DbQuery($query,$link) ){echo "<h4>Config ".DbError($link)."</h4>";}else{echo "<h5>Config $dld $dellbl OK</h5>";} $query = GenQuery('monitoring','d','','','',array('name'),array('='),array($dld) ); if( !@DbQuery($query,$link) ){echo "<h4>Monitoring ".DbError($link)."</h4>";}else{echo "<h5>Monitoring $dld $dellbl OK</h5>";} $query = GenQuery('incidents','d','','','',array('name'),array('='),array($dld) ); if( !@DbQuery($query,$link) ){echo "<h4>Incidents ".DbError($link)."</h4>";}else{echo "<h5>Incidents $dld $dellbl OK</h5>";} $query = GenQuery('vlans','d','','','',array('device'),array('='),array($dld) ); if( !@DbQuery($query,$link) ){echo "<h4>Vlans ".DbError($link)."</h4>";}else{echo "<h5>Vlans $dld $dellbl OK</h5>";} $query = GenQuery('networks','d','','','',array('device'),array('='),array($dld) ); if( !@DbQuery($query,$link) ){echo "<h4>Networks ".DbError($link)."</h4>";}else{echo "<h5>Networks $dld $dellbl OK</h5>";} $query = GenQuery('events','d','','','',array('source'),array('='),array($dld) ); if( !@DbQuery($query,$link) ){echo "<h4>Events ".DbError($link)."</h4>";}else{echo "<h5>Events $dld $dellbl OK</h5>";} $query = GenQuery('devdel','i','','','',array('device','user','time'),'',array($dld,$_SESSION['user'],time()) ); if( !@DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h5>$dellbl $dld $updlbl OK</h5>";} $query = GenQuery('events','i','','','',array('level','time','source','info','class'),'',array('100',time(),$dld,"User $_SESSION[user] deleted this device",'usrd') ); if( !@DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h5>$msglbl $updlbl OK</h5>";} #old: DbQuery("DELETE FROM devices WHERE device = '".$rmdev."' LIMIT 1", $link); SteffenScholz-2011-07-05 } } } $collisions = array(); $coll_serials = array(); $devices = DbQuery("SELECT device, devip, serial, firstdis, lastdis FROM devices WHERE serial NOT REGEXP '^$|^-$|noSuch|err|n/a'", $link); #old $devices = DbQuery("SELECT name, ip, serial, firstseen, lastseen FROM devices WHERE serial REGEXP BINARY '^[-() A-Z0-9]{2,}$'", $link); SteffenScholz-2011-07-05 while ($device = DbFetchArray($devices)): if (@!in_array($device['serial'], $coll_serials)): $lookup = DbQuery("SELECT device, devip, firstdis, lastdis FROM devices WHERE serial = '".$device['serial']."' AND NOT device = '".$device['device']."'", $link); while ($colldev = DbFetchArray($lookup)): # determine reason for serial number collision # use
$mbar = Bar($m[1], 0, 1); echo "<a href=Monitoring-Messages.php?ina=time&opa=%3E=&sta={$fs}&cop=AND&inb=time&opb=%3C&stb={$fe}&lvl={$m['0']}>"; echo "<img src=img/16/" . $mico[$m[0]] . ".png title=\"" . $mlvl[$m[0]] . "\" border=0></a>{$mbar} \n"; $nmsg += $m[1]; } if (!$nmsg) { echo "<img src=img/16/fogy.png title=\"All Messages\"> "; } $tmsg += $nmsg; echo "{$nmsg}</td></tr>\n"; @DbFreeResult($res); } else { print @DbError($link); } } else { $query = GenQuery('messages', 's', 'id', '', '', array('time', 'time'), array('>=', '<'), array($istart, $iend), array('AND')); $res = @DbQuery($query, $link); if ($res) { $m = @DbNumRows($res); $mbar = ""; if ($m) { $mbar = Bar($m, 0); } echo "<img src=img/16/fogy.png title=\"All Messages\">{$mbar} {$m}</td></tr>\n"; $tmsg += $m; @DbFreeResult($res); } else { print @DbError($link); } } $istart = $iend;
$st = isset($_GET['st']) ? $_GET['st'] : array(); $co = isset($_GET['co']) ? $_GET['co'] : array(); $elm = isset($_GET['elm']) ? preg_replace('/\\D+/', '', $_GET['elm']) : 20; $off = (isset($_GET['off']) and !isset($_GET['sho'])) ? preg_replace('/\\D+/', '', $_GET['off']) : 0; $nof = $off; if (isset($_GET['p'])) { $nof = abs($off - $elm); } elseif (isset($_GET['n'])) { $nof = $off + $elm; } $dlim = $elm ? "{$elm} OFFSET {$nof}" : ''; $link = DbConnect($dbhost, $dbuser, $dbpass, $dbname); if (isset($_GET['del'])) { # TODO fix for Postgres if ($isadmin) { $query = GenQuery('events', 'd', '*', 'id desc', $elm, $in, $op, $st, $co); if (DbQuery($query, $link)) { echo "<h5> {$msglbl} {$dellbl} OK </h5>"; } else { echo "<h4>" . DbError($link) . "</h4>"; } } else { echo $nokmsg; } } $cols = array("info" => "Info", "id" => "ID", "level" => "{$levlbl}", "time" => $timlbl, "source" => $srclbl, "class" => $clalbl, "location" => $loclbl, "contact" => $conlbl); ?> <h1>Monitoring <?php echo $msglbl; ?> </h1>
function TopoFloors($r, $c, $b, $siz = 0) { global $link, $dev, $img, $modgroup, $self, $v, $place, $netlbl, $acslbl, $porlbl, $frelbl, $refresh; $query = GenQuery('locations', 's', 'id,x,y,ns,ew,locdesc', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($r, $c, $b), array('AND', 'AND')); $res = DbQuery($query, $link); if (DbNumRows($res)) { list($id, $x, $y, $ns, $ew, $des) = DbFetchRow($res); echo "<h2>{$b} - {$des}</h2>\n"; } else { echo "<h2>{$b} {$place['b']}</h2>\n"; } echo "<table class=\"content fixed\">\n"; uksort($dev, "floorsort"); foreach (array_keys($dev) as $fl) { echo "<tr>\n\t<td class=\"{$modgroup[$self]}2\" width=\"80\"><h3>\n"; if (!$siz) { echo "<img src=\"img/stair.png\"><br>\n"; } echo "{$fl}</h3>\n"; if (!$siz) { $bas = "topo/" . preg_replace('/\\W/', '', $r) . '/' . preg_replace('/\\W/', '', $c) . '/' . preg_replace('/\\W/', '', $b) . '-' . preg_replace('/\\W/', '', $fl); foreach (glob("{$bas}*") as $f) { list($ico, $ed) = FileImg($f); echo "{$ico} "; } } echo "</td>\n"; $col = 0; $prm = ""; ksort($dev[$fl]); foreach (array_keys($dev[$fl]) as $rm) { if ($prm != $rm) { $bi = $bi == "imga" ? "imgb" : "imga"; } $prm = $rm; foreach (array_keys($dev[$fl][$rm]) as $d) { $ip = $dev[$fl][$rm][$d]['ip']; $po = $dev[$fl][$rm][$d]['po']; $ty = $dev[$fl][$rm][$d]['ty']; $di = $dev[$fl][$rm][$d]['ic']; $co = $dev[$fl][$rm][$d]['co']; $rk = $dev[$fl][$rm][$d]['rk']; $mn = $dev[$fl][$rm][$d]['mn']; $al = $dev[$fl][$rm][$d]['al']; $sz = $dev[$fl][$rm][$d]['sz']; $sk = $dev[$fl][$rm][$d]['sk'] > 1 ? "<img src=\"img/" . $dev[$fl][$rm][$d]['sk'] . ".png\" title=\"Stack\">" : ""; list($statbg, $stat) = StatusBg(1, $mn, $al, $bi); $tit = $stat ? $stat : $ty; $ud = urlencode($d); $ur = urlencode($r); $uc = urlencode($c); $ub = urlencode($b); $uf = urlencode($fl); $um = urlencode($rm); if ($col == $_SESSION['col']) { $col = 0; echo "</tr><tr><td> </td>\n"; } if ($siz) { echo "<td class=\"{$statbg}\" valign=\"top\"><center><img src=\"img/dev/{$di}.png\" title=\"{$ip}\"><br>{$d}</center></td>\n"; } else { $ii = $refresh ? 0 : IfFree($d); $inif = $ii ? "<div style=\"float:right\"><a href=\"Devices-Interfaces.php?in[]=device&op[]==&st[]={$ud}&co[]=AND&in[]=ifstat&op[]=<&st[]=3&co[]=AND&in[]=iftype&op[]=~&st[]=^(6|7|117)\$&col[]=imBL&col[]=ifname&col[]=device&col[]=linktype&col[]=ifdesc&col[]=alias&col[]=lastchg&col[]=inoct&col[]=outoct&ord=lastchg\"><img src=\"img/p45.png\" title=\"{$acslbl} {$porlbl} {$frelbl}\">{$ii}</a></div>" : ''; $rkv = $dev[$fl][$rm][$d]['ru'] ? "<a href=\"Topology-Table.php?reg={$ur}&cty={$uc}&bld={$ub}&fl={$uf}&rm={$um}\">{$rm}</a>" : $rm; echo "<td class=\"{$statbg}\" valign=\"top\"><b>{$rkv}</b> {$rk} {$inif}<p><div style=\"text-align:center;\">\n"; echo "<a href=\"Devices-Status.php?dev={$ud}\">"; echo "<img src=\"" . ($img ? DevPanel($ty, $di, $sz) . "\" width=\"" . (preg_match('/^ph|^wa|^ca/', $di) ? 40 : 100) . "\"" : "img/dev/{$di}.png\"") . " title=\"{$tit}\"></a>{$sk}<br><b>{$d}</b><br>\n"; echo Devcli($ip, $po); echo "<p>{$co}</div></td>\n"; } $col++; } } } echo "</tr></table>\n"; }
<h2>Recent Vital Messages</h2> <table bgcolor=#666666 <?php echo $tabtag; ?> > <tr bgcolor=#<?php echo $bg2; ?> > <th width=40><img src=img/16/info.png><br>Level</th> <th width=100><img src=img/16/clock.png><br>Time</th> <th><img src=img/16/dev.png><br>Source</th> <th><img src=img/16/find.png><br>Info</th> </tr> <?php $query = GenQuery('messages', 's', '*', 'id desc', $lim, array('level'), array('>'), array('100')); $res = @DbQuery($query, $link); if ($res) { $row = 0; while ($m = @DbFetchRow($res)) { if ($row % 2) { $bg = $bgb; $bi = $bib; } else { $bg = $bga; $bi = $bia; } $row++; $hint = ""; $time = date($datfmt, $m[2]); $fd = str_replace(" ", "%20", date("m/d/Y H:i:s", $m[2]));
$_SESSION['lang'] = $usr[8]; $_SESSION['theme'] = $usr[9]; $_SESSION['vol'] = ($usr[10] & 3) * 33; $_SESSION['lsiz'] = ($usr[10] & 124) >> 2; $_SESSION['col'] = $usr[11]; $_SESSION['lim'] = $usr[12]; $_SESSION['gsiz'] = $usr[13] & 7; $_SESSION['gbit'] = $usr[13] & 8; $_SESSION['far'] = $usr[13] & 16; $_SESSION['opt'] = $usr[13] & 32; $_SESSION['map'] = $usr[13] & 64; $_SESSION['gneg'] = $usr[13] & 128; $_SESSION['nip'] = $usr[13] & 256; $_SESSION['date'] = $usr[14] ? substr($usr[14], 0, -3) : 'j.M y G:i'; $_SESSION['tz'] = $tzone[substr($usr[14], -3)]; $query = GenQuery('users', 'u', 'usrname', '=', $user, array('lastlogin'), array(), array(time())); DbQuery($query, $link); } } else { print DbError($link); } if (isset($_SESSION['group'])) { echo "<body style=\"background-color: #666666;\"><script>document.location.href='{$goto}';</script></body>\n"; } elseif ($raderr) { $disc = "<h4>{$raderr}</h4>"; } else { $disc = "<h4>Incorrect login!</h4>"; } } ?> <html>
?> <h2>Message Sources</h2><p> <table bgcolor=#666666 <?php echo $tabtag; ?> ><tr bgcolor=#<?php echo $bg2; ?> > <th width=10%><img src=img/32/say.png><br>Source</th> <th><img src=img/32/umgr.png><br>Contact</th> <th><img src=img/32/say.png><br>Messages</th> </tr> <?php $rord = $ord ? " desc" : ""; $query = GenQuery('messages', 'g', 'source,level', "source{$rord}"); $res = @DbQuery($query, $link); if ($res) { while ($s = @DbFetchRow($res)) { $source[$s[0]][$s[1]] = $s[2]; } @DbFreeResult($res); } else { print @DbError($link); die; } $row = 0; foreach (array_keys($source) as $s) { if ($row % 2) { $bg = $bga; $bi = $bia;
</th></table> <?php } else { $editam = "<a href=\"?eam=1\"><img src=\"img/16/note.png\" title=\"{$chglbl}\"></a>"; } } echo "<h2>{$editam} Admin {$mlvl['100']}</h2>\n"; if (file_exists($msgfile)) { echo "<div class=\"textpad warn\">\n"; include_once $msgfile; echo "</div><br>"; } ?> <p> <?php $query = GenQuery('chat', 's', '*', 'time desc', $_SESSION['lim']); $res = DbQuery($query, $link); $nchat = DbNumRows($res); if ($nchat) { ?> <p> <h2> <a href="User-Chat.php"><img src="img/16/say.png" title="Chat"></a> <?php echo $verb1 ? "{$laslbl} Chat" : "Chat {$laslbl}"; ?> </h2> <table class="content"><tr class="<?php echo $modgroup[$self]; ?> 2">
echo $bg2; ?> > <?php ColHead('name'); ColHead('email'); ColHead('phone'); ColHead('comment'); ColHead('language'); ColHead('time'); ColHead('lastseen'); echo "<th>Groups</th><th>Action</th></tr>\n"; if ($grp) { $query = GenQuery('user', 's', '*', $ord, '', array($grp), array('='), array('1')); } else { $query = GenQuery('user', 's', '*', $ord); } $res = @DbQuery($query, $link); if ($res) { $row = 0; while ($u = @DbFetchRow($res)) { if ($row % 2) { $bg = $bgb; $bi = $bib; } else { $bg = $bga; $bi = $bia; } $row++; list($cc, $lc) = Agecol($u[10], $u[11], $row % 2); echo "<tr bgcolor=#{$bg}>\n";
while ($d = @DbFetchRow($res)) { echo "<option value=\"{$d['0']}\" "; if ($dv == $d[0]) { echo "selected"; } echo " >{$d['0']}\n"; } @DbFreeResult($res); } else { print @DbError($link); } ?> </select> <?php if ($dv) { $query = GenQuery('interfaces', 's', '*', 'ifname', '', array('device'), array('='), array($dv)); $res = @DbQuery($query, $link); if ($res) { ?> <select multiple size=6 name="if[]"> <?php while ($i = @DbFetchRow($res)) { echo "<OPTION VALUE=\"{$i['1']}\" "; if (in_array($i[1], $if)) { echo "selected"; } echo " >{$i['1']}\n"; } @DbFreeResult($res); echo "</select>"; }
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>"; } ?> <script language="JavaScript"><!-- setTimeout("history.go(-2)",2000); //--></script> <?php } else { echo $nokmsg; } } include_once "inc/footer.php";
?> </tr> <tr bgcolor=#<?php echo $bg2; ?> ><th>Total Devices</th><td align=center><?php echo $ndev; ?> </td></tr> </table> </td><td valign=top align=center> <h3>Messages</h3><p> <?php $query = GenQuery('messages', 'g', 'level', 'level desc'); $res = @DbQuery($query, $link); if ($res) { $nlev = @DbNumRows($res); if ($nlev) { ?> <table bgcolor=#666666 <?php echo $tabtag; ?> ><tr bgcolor=#<?php echo $bg2; ?> > <th width=80><img src=img/32/impt.png><br>Level</th> <th><img src=img/32/eyes.png><br>Events</th> <?php
echo $tabtag; ?> > <tr bgcolor=#<?php echo $bg2; ?> > <th colspan=2><img src=img/32/nglb.png><br>Destination</th> <th><img src=img/32/neti.png ><br>Next Hop</th> <th><img src=img/32/dumy.png><br>Interface</th> <th><img src=img/32/tap.png ><br>Bandwidth</th> <th><img src=img/32/casp.png><br>Metric 1</th> <th><img src=img/32/edit.png><br>Protocol</th> <th><img src=img/32/clock.png><br>Age [s]</th> <?php $query = GenQuery('interfaces', 's', '*', '', '', array('device'), array('='), array($rtr)); $res = @DbQuery($query, $link); while ($i = @DbFetchRow($res)) { $ina[$i[2]] = $i[1]; $ity[$i[2]] = $i[4]; $ial[$i[2]] = $i[7]; $icm[$i[2]] = $i[20]; $isp[$i[2]] = $i[9]; } @DbFreeResult($res); $r = DevRoutes($devip[$rtr], $devcom[$rtr]); $row = 0; foreach (array_keys($r) as $rd) { if ($row % 2) { $bg = $bga; $bi = $bia;
?> </span> <img src="img/16/exit.png" title="Stop" onClick="stop_countdown(interval);"> </th> <th width="80"> <input type="submit" name="create" value="<?php echo $wrtlbl; ?> "></th> </table></form> <p> <?php } $query = GenQuery('chat', 's', '*', 'time desc', 100); $res = DbQuery($query, $link); if ($res) { ?> <h2><?php echo $msglbl; ?> </h2> <table class="content"><tr class="<?php echo $modgroup[$self]; ?> 2"> <th width="40"><img src="img/16/user.png"><br>User</th> <th width="100"><img src="img/16/clock.png"><br><?php echo $timlbl; ?>
<?php } if (in_array("vln", $rep)) { ?> <h2>Unpopulated Vlans</h2><p> <table bgcolor=#666666 <?php echo $tabtag; ?> ><tr bgcolor=#<?php echo $bg2; ?> > <th width=80><img src=img/32/stat.png><br>Vlan Id</th> <th><img src=img/32/dev.png><br>Devices</th> <?php $query = GenQuery('vlans'); $res = @DbQuery($query, $link); if ($res) { $nvl = 0; $nunvl = 0; $uvlandev = array(); while ($vl = @DbFetchRow($res)) { if (!$uvlid[$vl[0]][$vl[1]] and !preg_match("/{$ignoredvlans}/", $vl[1])) { $ud = rawurlencode($vl[0]); $uvlandev[$vl[1]] .= "<a href=Devices-Status.php?dev={$ud}>{$vl['0']}</a> ({$vl['2']}) "; $nunvl++; } $nvl++; } @DbFreeResult($res); } else {
?> > <th><img src=img/32/dev.png><br>Device</th> <th><img src=img/32/dumy.png><br>Interface</th> <th><img src=img/32/fiap.png title="C=CDP,M=Mac,O=Oui,V=VoIP,L=LLDP,S=static"><br>Type</th> <th><img src=img/32/tap.png><br>Bandwidth</th> <th><img src=img/32/powr.png title="PoE consumption in mW"><br>Power</th> <th><img src=img/32/dev.png><br>Neighbour</th> <th><img src=img/32/dumy.png><br>Interface</th> <th><img src=img/32/idea.png><br>Action</th></tr> </tr> <?php if ($typ) { $query = GenQuery('links', 's', '*', 'ifname', '', array('type'), array('='), array($typ)); } else { $query = GenQuery('links', 's', '*', 'ifname', '', array('device'), array('='), array($dv)); } $res = @DbQuery($query, $link); if ($res) { $nli = 0; $row = 0; while ($l = @DbFetchRow($res)) { $ud = urlencode($l[1]); $un = urlencode($l[3]); if ($row % 2) { $bg = $bga; $bi = $bia; } else { $bg = $bgb; $bi = $bib; }
</SELECT> </th> <th> <INPUT type="checkbox" name="ord" <?php echo $ord; ?> > alternative order </th> </SELECT></th> <th width=80><input type="submit" name="do" value="Show"></th> </tr></table></form><p> <?php if ($rep) { $link = @DbConnect($dbhost, $dbuser, $dbpass, $dbname); $query = GenQuery('devices'); $res = @DbQuery($query, $link); if ($res) { $ndev = 0; while ($d = @DbFetchRow($res)) { $dtyp[$d[3]]++; $dico[$d[3]] = $d[18]; $fseen[$d[4]]++; $lseen[$d[5]]++; $dops[$d[8]]++; $dbim[$d[9]]++; $dvtp[$d[12]]++; $ndev++; } @DbFreeResult($res); } else {
} else { echo "<h3>Location {$reg} {$cty} {$bld} {$delokmsg}</h3>"; } } if ($bld) { $query = GenQuery('locations', 's', 'id,x,y,comment', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($reg, $cty, $bld), array('AND', 'AND')); $mapbg = TopoMap($reg, $cty); $nam = $bld; $com = "Building with " . $lopt[$reg][$cty][$bld] . " devices on {$now}"; } elseif ($cty) { $query = GenQuery('locations', 's', 'id,x,y,comment', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($reg, $cty, ''), array('AND', 'AND')); $mapbg = TopoMap($reg); $nam = $cty; $com = "City with " . count(array_keys($lopt[$reg][$cty])) . " buildings on {$now}"; } elseif ($reg) { $query = GenQuery('locations', 's', 'id,x,y,comment', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($reg, '', ''), array('AND', 'AND')); $nam = $reg; $com = "Region with " . count(array_keys($lopt[$reg])) . " cities on {$now}"; } else { $query = ""; } if ($query) { $res = @DbQuery($query, $link); $nloc = @DbNumRows($res); if ($nloc == 1) { list($id, $x, $y, $com) = @DbFetchRow($res); $loco = 1; } } ?> <h1>Location Editor</h1>
function Layout() { global $link,$locsep,$resmsg; global $xm,$ym,$xo,$yo,$len,$geo,$ina,$flt,$lev,$ipi; global $mapbg,$rloc,$cloc,$bloc; $net = array(); # Gather Device Info if($ina == "vlan"){ $query = GenQuery('vlans','g','device','device','',array('vlanid'),array('regexp'),array($flt)); $res = @DbQuery($query,$link); if($res){ while( ($vl = @DbFetchRow($res)) ){ $devs[] = preg_replace('/([\^\$+])/','\\\\\\\\$1',$vl[0]); # \Q...\E Doesn't seem to work in MySQL? } @DbFreeResult($res); }else{ echo @DbError($link); } if (! is_array ($devs) ){echo $resmsg;die;} $query = GenQuery('devices','s','name,ip,location,icon','','',array('name'),array('regexp'),array(implode("|",$devs))); }elseif($ina == "network"){ $query = GenQuery('networks','g','device','device','',array('ip'),array('='),array($flt)); $res = @DbQuery($query,$link); if($res){ while( ($net = @DbFetchRow($res)) ){ $devs[] = preg_replace('/([\^\$\*\+])/','\\\\\\\\$1',$net[0]); } @DbFreeResult($res); }else{ echo @DbError($link); } if (! is_array ($devs) ){echo $resmsg;die;} $query = GenQuery('devices','s','name,ip,location,icon','','',array('name'),array('regexp'),array(implode("|",$devs))); }elseif($ina == "type"){ $query = GenQuery('devices','s','name,ip,location,icon','','',array('type'),array('regexp'),array($flt)); }else{ $query = GenQuery('devices','s','name,ip,location,icon','','',array('location'),array('regexp'),array($flt)); } $res = @DbQuery($query,$link); if($res){ while( ($d = @DbFetchRow($res)) ){ $l = explode($locsep, $d[2]); if($lev == "c" or $lev == "C"){ $locs[$l[0]][$l[1]]++; }elseif($lev == "b" or $lev == "B"){ $locs[$l[0]][$l[1]][$l[2]]++; }else{ $locs[$l[0]][$l[1]][$l[2]][$l[3]][] = $d[0]; } $dev['ip'] [$d[0]] = long2ip($d[1]); $dev['ic'] [$d[0]] = $d[3]; $dev['reg'][$d[0]] = $l[0]; $dev['cty'][$d[0]] = $l[1]; $dev['bld'][$d[0]] = $l[2]; $dev['rom'][$d[0]] = $l[4]; } @DbFreeResult($res); }else{ echo @DbError($link); } if($ipi){ $query = GenQuery('networks'); $res = @DbQuery($query,$link); if($res){ while( ($n = @DbFetchRow($res)) ){ $net[$n[0]][$n[1]] .= " ". long2ip($n[2]); } }else{ echo @DbError($link); } @DbFreeResult($res); } # Gather Link Info $query = GenQuery('links'); $res = @DbQuery($query,$link); if($res){ while( ($l = @DbFetchRow($res)) ){ if($dev[$l[1]]['ic'] and $dev[$l[3]]['ic']){ # both ends are ok, if an icon exists if($lev == "f"){ if( isset($devlink[$l[3]][$l[1]]) ){ # opposite link doesn't exist? $devlink[$l[3]][$l[1]]['nbw'][$l[3]][$l[4]][$l[1]][$l[2]] = $l[5]; }else{ $devlink[$l[1]][$l[3]]['bw'][$l[1]][$l[2]][$l[3]][$l[4]] = $l[5]; } } if($dev[$l[1]]['bld'] != $dev[$l[3]]['bld']) { # is it same bld? $nbldlink[$dev[$l[1]]['bld']] ++; $abldlink[$dev[$l[1]]['bld']][$dev[$l[3]]['bld']]++; # needed for Arranging. if(isset($bldlink[$dev[$l[3]]['bld']][$dev[$l[1]]['bld']]) ){ # link defined already? $bldlink[$dev[$l[3]]['bld']][$dev[$l[1]]['bld']]['nbw'][$l[3]][$l[4]][$l[1]][$l[2]] = $l[5]; }else{ $bldlink[$dev[$l[1]]['bld']][$dev[$l[3]]['bld']]['bw'][$l[1]][$l[2]][$l[3]][$l[4]] = $l[5]; } } if($dev[$l[1]]['cty'] != $dev[$l[3]]['cty']){ # is it same cty? $nctylink[$dev[$l[1]]['cty']]++; $actylink[$dev[$l[1]]['cty']][$dev[$l[3]]['cty']]++; # needed for Arranging. if(isset($ctylink[$dev[$l[3]]['cty']][$dev[$l[1]]['cty']]) ){ # link defined already? $ctylink[$dev[$l[3]]['cty']][$dev[$l[1]]['cty']]['nbw'][$l[3]][$l[4]][$l[1]][$l[2]] = $l[5]; }else{ $ctylink[$dev[$l[1]]['cty']][$dev[$l[3]]['cty']]['bw'][$l[1]][$l[2]][$l[3]][$l[4]] = $l[5]; } } } } @DbFreeResult($res); }else{ echo @DbError($link); } # Prepare geographic stuff $mapinfo = ""; $mapframes = ""; $maplinks = ""; $mapitems = ""; if ($geo) { if(count($cdev) == 1){ $rk = array_keys($cdev); if(count($cdev[$rk[0]]) == 1){ $ck = array_keys($cdev[$rk[0]]); $mapbg = TopoMap($rk[0],$ck[0]); }else{ $mapbg = TopoMap($rk[0]); } }else{ $mapbg = TopoMap(); } $bg = Imagecreatefrompng("log/$mapbg"); $xm = Imagesx($bg); $ym = Imagesy($bg); Imagedestroy($bg); $query = GenQuery('locations'); $res = @DbQuery($query,$link); if($res){ while( ($l = @DbFetchRow($res)) ){ if($l[3]){ if( $mapbg == TopoMap($l[1],$l[2]) ){ $bloc[$l[3]] = $l[4]; $bloc[$l[3]] = $l[5]; } }elseif($l[2]){ if($mapbg == TopoMap($l[1]) ){ $cloc[$l[2]] = $l[4]; $cloc[$l[2]] = $l[5]; } }else{ $rloc[$l[1]] = $l[4]; $rloc[$l[1]] = $l[5]; } } @DbFreeResult($res); }else{ echo @DbError($link); } } # Build Layout Drawlevel($locs,(intval($xm/2) + $xo), (intval($ym/2) + $yo),$len ); }
echo "<option value=\"{$d['0']}\" "; if ($dv == $d[0]) { echo "selected"; } echo " >{$d['0']}\n"; } @DbFreeResult($res); } else { print @DbError($link); } ?> </select> <select multiple size=6 name="if[]"> <?php if ($dv) { $query = GenQuery('interfaces', 's', 'ifname,alias,comment', 'ifname', '', array('device'), array('='), array($dv)); $res = @DbQuery($query, $link); if ($res) { while ($i = @DbFetchRow($res)) { echo "<OPTION VALUE=\"{$i['0']}\" "; if (in_array($i[0], $if)) { echo "selected"; } echo " >{$i['0']} " . substr("{$i['1']} {$i['2']}\n", 0, 30); } @DbFreeResult($res); } } ?> </select> </th>
if ($usr[5]) { $_SESSION['group'] .= "mon,"; } if ($usr[6]) { $_SESSION['group'] .= "mgr,"; } if ($usr[7]) { $_SESSION['group'] .= "oth,"; } if ($usr[13]) { $_SESSION['lang'] = $usr[13]; } else { $_SESSION[lang] = "eng"; } $now = time(); $query = GenQuery('user', 'u', 'name', $_POST['user'], '', array('lastseen'), '', array($now)); @DbQuery($query, $link); } else { print @DbError($link); } if (isset($_SESSION['group'])) { echo "<script>document.location.href='User-Profile.php';</script>\n"; exit; } else { echo "<body bgcolor=#ff0000>"; echo "<script>alert('{$logmsg}');"; echo "history.go(-1);"; echo "</script></body>"; } } ?>
} else { if ($devs[$dnet][$n[0]]) { $devs[$dnet][$n[0]] = "<span style=\"color : green\">multiple</span> on {$n['1']}"; } else { $devs[$dnet][$n[0]] = "<span style=\"color : green\">ok</span> on {$n['1']}"; } } } else { $nets[$dnet] = $n[3]; $pop[$dnet] = 0; $age[$dnet] = 0; if ($n[3] == -1) { $devs[$dnet][$n[0]] = "<span style=\"color : yellow\">Loopback</span> on {$n['1']}"; } else { $devs[$dnet][$n[0]] = "<span style=\"color : blue\">mask base</span> on {$n['1']}"; $nquery = GenQuery('nodes', 'a', "ip & {$n['3']}", '', 'lastseen - firstseen', array("ip & {$n['3']}"), array('='), array($dnet)); $nodres = @DbQuery($nquery, $link); $nnod = @DbNumRows($nodres); $no = @DbFetchRow($nodres); $pop[$dnet] = $no[1]; $age[$dnet] = intval($no[2] / 86400); @DbFreeResult($nodres); } } } @DbFreeResult($res); if ($nets) { ?> <table bgcolor=#666666 <?php echo $tabtag; ?>
echo $tabtag; ?> > <tr bgcolor=#<?php echo $bg2; ?> > <th colspan=2><img src=img/32/key.png><br>Serial #</th> <th><img src=img/32/fiap.png><br>Type</th> <th><img src=img/32/smil.png><br>Added by</th> <th><img src=img/32/clock.png><br>Added on</th> <th><img src=img/32/glob.png><br>Location</th> <th><img src=img/32/idea.png><br>Action</th></tr> <?php $query = GenQuery('stock', 's', '*', 'type'); $res = @DbQuery($query, $link); if ($res) { $row = 0; while ($dev = @DbFetchRow($res)) { if ($row % 2) { $bg = $bgb; $bi = $bib; } else { $bg = $bga; $bi = $bia; } $row++; $img = "genh.png"; $ud = rawurlencode($dev[0]); $da = date("j.M (G:i)", $dev[3]);
$cred = addcslashes($cred, ';$!'); $out = system("perl {$nedipath}/inc/devwrite.pl {$nedipath} {$ip} {$devpo[$dv]} {$cred} {$devos[$dv]} log/cmd_{$_SESSION['user']}", $err); echo "<iframe style=\"display:block;\" class=\"textpad txta code\" " . ($ndev == 1 ? 'height="800"' : '') . " src=\"log/cmd_{$_SESSION['user']}-{$ip}.log\"></iframe>"; $cstr = preg_replace('/\\n|"|\'/', ' ', $cmds); if (strlen($cstr) > 40) { $cstr = substr($cstr, 0, 40) . "..."; } $msg = "User {$_SESSION['user']} wrote {$cstr}"; if ($err) { $lvl = 150; $msg = "User {$_SESSION['user']} wrote {$cstr} causing errors"; } else { $lvl = 100; $msg = "User {$_SESSION['user']} wrote {$cstr} successfully"; } $query = GenQuery('events', 'i', '', '', '', array('level', 'time', 'source', 'info', 'class', 'device'), array(), array($lvl, time(), $dv, $msg, 'usrd', $dv)); if (!DbQuery($query, $link)) { echo "<h4>" . DbError($link) . "</h4>"; } } } } include_once "inc/footer.php"; function Buildcmd($arg = "", $configureos = "", $hdr = 0) { global $cmd, $stb, $sint, $eint, $smod, $emod, $ssub, $esub, $int, $icfg; $config = $hdr ? "<?php exit; ?>\n" : ''; if ($configureos == "IOS" or $configureos == "ProCurve") { $config .= "conf t\n"; } elseif ($configureos == "Comware") { $config .= "sys\n";
<th> <img src="img/16/grph.png" title="IF <?= $gralbl ?>"> <input type="checkbox" name="shg" <?= $shg ?>> </th> <th width="80"> <input type="submit" value="<?= $sholbl ?>"> </th> </tr></table></form> <p> <?php if ($dev) { $query = GenQuery('interfaces','s','ifidx,ifname,iftype,speed,alias,comment,ifdesc,ifstat','','',array('device'),array('='),array($dev) ); $res = DbQuery($query,$link); while( ($i = DbFetchRow($res)) ){ $ifn[$i[0]] = $i[1]; $ift[$i[0]] = $i[2]; $ifs[$i[0]] = $i[3]; $ifa[$i[0]] = $i[7]; if( strstr($i[5],"DP:") ){ $uneb = urlencode( preg_replace('/.+DP:(.+),.+/','$1',$i[5]) ); $neb = ($uneb)?"<a href=\"Topology-Spanningtree.php?dev=$uneb\"><img src=\"img/16/traf.png\"></a>":""; $ifi[$i[0]] = "$i[6] - <i>$i[4]</i> - $i[5] $neb"; }else{ $ifi[$i[0]] = "$i[6] - <i>$i[4]</i>"; } } DbFreeResult($res);
echo "<td>{$n['8']}</td>"; } if (in_array("ifmetric", $col)) { echo "<td align=right>{$n['9']}</td>"; } if (in_array("ifupdate", $col)) { $iu = date("j.M G:i:s", $n[10]); list($i1c, $i2c) = Agecol($n[10], $n[10], $row % 2); echo "<td bgcolor=#{$i1c}>{$iu}</td>"; } if (in_array("ifchanges", $col)) { echo "<td align=right>{$n['11']}</td>"; } if (in_array("ifdet", $col)) { $link = @DbConnect($dbhost, $dbuser, $dbpass, $dbname); $iquery = GenQuery('interfaces', 's', '*', '', '', array('device', 'ifname'), array('=', '='), array($n[6], $n[7]), array('AND')); $ires = @DbQuery($iquery, $link); $nif = @DbNumRows($ires); if ($nif == 1) { $if = @DbFetchRow($ires); if ($if[8] == "2") { $ifimg = "<img src=img/bulbr.png title=\"Disabled!\">"; } else { $ifimg = "<img src=img/bulbg.png title=\"Enabled\">"; } echo "<td> {$ifimg} " . Zfix($if[9]) . "-{$if['10']} <i>{$if['7']} {$if['20']}</i></td>"; } else { echo "<td>-</td>"; } @DbFreeResult($ires); }
?> > <tr bgcolor=#<?php echo $bg2; ?> > <th width=80><img src=img/32/eyes.png><br>Id</th> <th><img src=img/32/info.png title="Unspecified<50, 100=Notice, 150=Warning, 200=Alert, 250=Emergency"><br>Level</th> <th width=100><img src=img/32/clock.png><br>Time</th> <th><img src=img/32/dev.png title="Device (if in devices) or IP (will only produce level <50)"><br>Source</th> <th><img src=img/32/idea.png title="Action based on message info"><br>Action</th> <th><img src=img/32/find.png><br>Info</th> </tr> <?php $query = GenQuery('messages', 's', '*', 'id desc', $dlim, $in, $op, $st, $co); $res = @DbQuery($query, $link); if ($res) { $row = 0; while ($m = @DbFetchRow($res)) { if ($row % 2) { $bg = $bgb; $bi = $bib; } else { $bg = $bga; $bi = $bia; } $row++; $hint = ""; $time = date($datfmt, $m[2]); $fd = str_replace(" ", "%20", date("m/d/Y H:i:s", $m[2]));
<?php } elseif ($del) { if (preg_match("/adm/", $_SESSION['group'])) { $link = @DbConnect($dbhost, $dbuser, $dbpass, $dbname); $query = GenQuery('nodes', 'd', '', '', '', array('mac'), array('='), array($del)); if (!@DbQuery($query, $link)) { echo "<h4>" . DbError($link) . "</h4>"; } else { echo "<h3>Node {$del} {$delokmsg}</h3>"; } $query = GenQuery('nodiplog', 'd', '', '', '', array('mac'), array('='), array($del)); if (!@DbQuery($query, $link)) { echo "<h4>" . DbError($link) . "</h4>"; } else { echo "<h3>Node IP log {$del} {$delokmsg}</h3>"; } $query = GenQuery('nodiflog', 'd', '', '', '', array('mac'), array('='), array($del)); if (!@DbQuery($query, $link)) { echo "<h4>" . DbError($link) . "</h4>"; } else { echo "<h3>Node IF log {$del} {$delokmsg}</h3>"; } ?> <script language="JavaScript"><!-- setTimeout("history.go(-2)",2000); //--></script> <?php } else { echo $nokmsg; } }
?> > <th width=80 colspan=2><img src=img/32/eyes.png><br>Incident</th> <th colspan=2><img src=img/32/dev.png><br>Device</th> <th colspan=2><img src=img/32/clock.png><br>Timeframe</th> <th colspan=2><img src=img/32/smil.png><br>Agent</th> <th colspan=2><img src=img/32/find.png><br>Info</th> </tr> <?php if ($cat) { $query = GenQuery('incidents', 's', '*', 'id desc', $dlim, array('category'), array('='), array($cat)); } elseif ($id) { $query = GenQuery('incidents', 's', '*', '', '', array('id'), array('='), array($id)); } else { $query = GenQuery('incidents', 's', '*', 'id desc', $dlim); } $res = @DbQuery($query, $link); if ($res) { $nin = 0; $row = 0; while ($i = @DbFetchRow($res)) { if ($row % 2) { $bg = $bga; $bi = $bia; } else { $bg = $bgb; $bi = $bib; } $row++; $fs = date("d.M H:i", $i[4]);