function Map() { global $debug, $link, $locsep, $vallbl, $sholbl, $sumlbl, $imas, $fmt, $lit, $fsz, $pos; global $xm, $ym, $xo, $yo, $rot, $cro, $bro, $len, $lsf, $mde, $in, $op, $st, $co, $lev, $loo, $loa, $loi, $ipi, $ifa; global $mapbg, $mapitems, $maplinks, $mapinfo, $imgmap, $reg, $cty, $bld, $flr, $dev, $nod, $nlnk, $jnod, $cud; $rlnk = array(); $clnk = array(); $blnk = array(); $dlnk = array(); $acol = ''; $join = ''; if ($pos == 'a') { $acol = ',status'; $join .= 'LEFT JOIN monitoring USING (device) '; } if (in_array('vlanid', $in) or in_array('vlanname', $in)) { $join .= 'LEFT JOIN vlans USING (device) '; } if (in_array('mac', $in) or in_array('nodip', $in) or in_array('name', $in) or in_array('oui', $in)) { $join .= 'LEFT JOIN nodes USING (device) '; } if (in_array('ifip', $in) or in_array('vrfname', $in)) { $join .= 'LEFT JOIN networks USING (device) '; } if (in_array('neighbor', $in)) { $join .= 'LEFT JOIN links USING (device) '; } $query .= GenQuery('devices', 's', "distinct device,devip,type,location,contact,devmode,icon,cpu,temp,devopts,size,stack{$acol},snmpversion", '', '', $in, $op, $st, $co, $join); # Postgres requires ordercolumn (snmpversion)! if ($lev < 5) { if (strpos($query, 'WHERE')) { $query .= ' AND snmpversion != 0'; } else { $query .= ' WHERE snmpversion != 0'; } } $query .= ' order by snmpversion desc'; $res = DbQuery($query, $link); if ($res) { while ($d = DbFetchRow($res)) { $l = explode($locsep, $d[3]); $reg[$l[0]]['ndv']++; $cty[$l[0]][$l[1]]['ndv']++; $dev[$d[0]]['reg'] = $l[0]; if ($d[6] and $ipi) { # Get IP info for interfaces on snmpdevs $nquery = GenQuery('networks', 's', 'ifname,ifip,ifip6,vrfname', '', '', array('device'), array('='), array($d[0])); $nres = DbQuery($nquery, $link); if ($nres) { while ($n = DbFetchRow($nres)) { if ($n[1]) { $dev[$d[0]]['ifip'][$n[0]] .= " " . long2ip($n[1]) . ($n[3] ? " ({$n['3']})" : ""); } else { $dev[$d[0]]['ifip'][$n[0]] .= " " . DbIPv6($n[2]) . ($n[3] ? " ({$n['3']})" : ""); } } } else { echo DbError($nlink); } DbFreeResult($nres); } if ($d[6] and ($ifa or $lit == 'l')) { # Get IF alias TODO use iftype to determine links? $nquery = GenQuery('interfaces', 's', 'ifname,ifidx,iftype,alias,dinoct,doutoct', '', '', array('device'), array('='), array($d[0])); $nres = DbQuery($nquery, $link); if ($nres) { while ($n = DbFetchRow($nres)) { $dev[$d[0]]['ifty'][$n[0]] = $n[1]; $dev[$d[0]]['ifix'][$n[0]] = $n[2]; $dev[$d[0]]['ifal'][$n[0]] = $n[3]; $dev[$d[0]]['ifin'][$n[0]] = $n[4]; $dev[$d[0]]['ifout'][$n[0]] = $n[5]; } } else { echo DbError($nlink); } DbFreeResult($nres); } if ($lev > 1) { $dev[$d[0]]['cty'] = $l[1]; } if ($lev > 2) { $bld[$l[0]][$l[1]][$l[2]]['ndv']++; $dev[$d[0]]['bld'] = $l[2]; } if ($lev > 3) { if ($mde == "r") { $flr[$l[0]][$l[1]][$l[2]][$d[0]]['ndv']++; } else { $flr[$l[0]][$l[1]][$l[2]][$l[3]][] = $d[0]; } $dev[$d[0]]['ip'] = long2ip($d[1]); $dev[$d[0]]['rom'] = $l[4]; $dev[$d[0]]['rak'] = $l[5] ? $l[5] : ""; $dev[$d[0]]['typ'] = $d[2]; $dev[$d[0]]['con'] = $d[4]; $dev[$d[0]]['mod'] = Devmode($d[5]); $dev[$d[0]]['ico'] = $d[6]; if (substr($d[9], 1, 1) == "C") { $dev[$d[0]]['cpu'] = $d[7]; } else { $dev[$d[0]]['cpu'] = "-"; } $dev[$d[0]]['tmp'] = $d[8]; if ($d[8] != 0) { $dev[$d[0]]['tlb'] = $_SESSION['far'] ? intval($dev[$d[0]]['tmp'] * 1.8 + 32) . "F" : $dev[$d[0]]['tmp'] . "C"; } else { $dev[$d[0]]['tlb'] = "-"; } $dev[$d[0]]['stk'] = $d[11] > 1 ? $d[11] : 1; $dev[$d[0]]['siz'] = $d[10] * $dev[$d[0]]['stk']; if ($pos == 'a') { $dev[$d[0]]['sta'] = $d[12]; } } } DbFreeResult($res); } else { echo DbError($link); } # Precalculate Links foreach (array_keys($dev) as $d) { # Devs sorted by snmpversion creates links with stats first! $lquery = GenQuery('links', 's', '*', '', '', array('device'), array('='), array($d)); $lres = DbQuery($lquery, $link); while ($k = DbFetchRow($lres)) { if (isset($dev[$k[3]]['reg'])) { # Only use, if we have complete devs $rlquery = GenQuery('links', 's', '*', '', '', array('device', 'neighbor'), array('=', '='), array($k[3], $k[1]), array('AND')); $rlres = DbQuery($rlquery, $link); $rlnum = DbNumRows($rlres); if ($debug) { echo "<div class=\"textpad good\">LINK:{$k['1']} to {$k['3']} with BW of {$k['5']}</div>\n"; } if (array_key_exists("{$k['3']};;{$k['1']}", $dlnk)) { $dlnk["{$k['3']};;{$k['1']}"]['rbw'] += $k[5]; $dlnk["{$k['3']};;{$k['1']}"]['rtr'] += $dev[$k[3]]['ifin'][$k[4]]; $dlnk["{$k['3']};;{$k['1']}"]['rif'][] = "{$k['1']};;{$k['2']}"; $dlnk["{$k['3']};;{$k['1']}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } elseif (isset($dev[$k[3]]['ico'])) { if (!$rlnum) { if ($debug) { echo "<div class=\"textpad alrm\">LNK: Fixing missing link from {$k['3']} to {$k['1']}</div>\n"; } $dlnk["{$k['1']};;{$k['3']}"]['rbw'] += $k[5]; $dlnk["{$k['1']};;{$k['3']}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $dlnk["{$k['1']};;{$k['3']}"]['rif'][] = "{$k['3']};;{$k['4']}"; $dlnk["{$k['1']};;{$k['3']}"]['fty']["{$k['6']}:" . date('j.M', $k[10])]++; } $dlnk["{$k['1']};;{$k['3']}"]['fbw'] += $k[5]; $dlnk["{$k['1']};;{$k['3']}"]['ftr'] += $dev[$k[1]]['ifout'][$k[2]]; $dlnk["{$k['1']};;{$k['3']}"]['fif'][] = "{$k['1']};;{$k['2']}"; $dlnk["{$k['1']};;{$k['3']}"]['fty']["{$k['6']}:" . date('j.M', $k[10])]++; } $ra = $dev[$k[1]]['reg']; $rb = $dev[$k[3]]['reg']; $ca = $dev[$k[1]]['cty']; $cb = $dev[$k[3]]['cty']; $ba = $dev[$k[1]]['bld']; $bb = $dev[$k[3]]['bld']; if ($mde != "f" and $ra != $rb) { $reg[$ra]['nlk']++; $reg[$ra]['alk'][$rb]++; # Needed for arranging if (array_key_exists("{$rb};;{$ra}", $rlnk)) { # Reverse link exists? $rlnk["{$rb};;{$ra}"]['rbw'] += $k[5]; $rlnk["{$rb};;{$ra}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $rlnk["{$rb};;{$ra}"]['rif'][] = "{$k['1']};;{$k['2']}"; $rlnk["{$rb};;{$ra}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } else { if (!$rlnum) { $reg[$rb]['nlk']++; $reg[$rb]['alk'][$rb]++; $rlnk["{$ra};;{$rb}"]['rbw'] += $k[5]; $rlnk["{$ra};;{$rb}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $rlnk["{$ra};;{$rb}"]['rif'][] = "{$k['3']};;{$k['4']}"; $rlnk["{$ra};;{$rb}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } $rlnk["{$ra};;{$rb}"]['fbw'] += $k[5]; $rlnk["{$ra};;{$rb}"]['ftr'] += $dev[$k[1]]['ifout'][$k[2]]; $rlnk["{$ra};;{$rb}"]['fif'][] = "{$k['1']};;{$k['2']}"; $rlnk["{$ra};;{$rb}"]['fty']["{$k['6']}:" . date('j.M', $k[10])]++; } } if ($mde != "f" and $lev > 1) { if ("{$ra};;{$ca}" != "{$rb};;{$cb}") { $cty[$ra][$ca]['nlk']++; if ($ra == $rb) { $cty[$ra][$ca]['alk'][$cb]++; } #TODO test whether this improves arranging! if (array_key_exists("{$rb};;{$cb};;{$ra};;{$ca}", $clnk)) { $clnk["{$rb};;{$cb};;{$ra};;{$ca}"]['rbw'] += $k[5]; $clnk["{$rb};;{$cb};;{$ra};;{$ca}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $clnk["{$rb};;{$cb};;{$ra};;{$ca}"]['rif'][] = "{$k['1']};;{$k['2']}"; $clnk["{$rb};;{$cb};;{$ra};;{$ca}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } else { if (!$rlnum) { $cty[$rb][$cb]['nlk']++; if ($ra == $rb) { $cty[$rb][$cb]['alk'][$ca]++; } $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['rbw'] += $k[5]; $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['rif'][] = "{$k['3']};;{$k['4']}"; $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['fbw'] += $k[5]; $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['ftr'] += $dev[$k[1]]['ifout'][$k[2]]; $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['fif'][] = "{$k['1']};;{$k['2']}"; $clnk["{$ra};;{$ca};;{$rb};;{$cb}"]['fty']["{$k['6']}:" . date('j.M', $k[10])]++; } } } if ($mde != "f" and $lev > 2) { if ("{$ra};;{$ca};;{$ba}" != "{$rb};;{$cb};;{$bb}") { $bld[$ra][$ca][$ba]['nlk']++; if ("{$ra};;{$ca}" == "{$rb};;{$cb}") { $bld[$ra][$ca][$ba]['alk'][$bb]++; } if (array_key_exists("{$rb};;{$cb};;{$bb};;{$ra};;{$ca};;{$ba}", $blnk)) { $blnk["{$rb};;{$cb};;{$bb};;{$ra};;{$ca};;{$ba}"]['rbw'] += $k[5]; $blnk["{$rb};;{$cb};;{$bb};;{$ra};;{$ca};;{$ba}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $blnk["{$rb};;{$cb};;{$bb};;{$ra};;{$ca};;{$ba}"]['rif'][] = "{$k['1']};;{$k['2']}"; $blnk["{$rb};;{$cb};;{$bb};;{$ra};;{$ca};;{$ba}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } else { if (!$rlnum) { $bld[$rb][$cb][$bb]['nlk']++; if ("{$ra};;{$ca}" == "{$rb};;{$cb}") { $bld[$rb][$cb][$bb]['alk'][$ba]++; } $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['rbw'] += $k[5]; $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['rtr'] += $dev[$k[1]]['ifin'][$k[2]]; $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['rif'][] = "{$k['3']};;{$k['4']}"; $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['rty']["{$k['6']}:" . date('j.M', $k[10])]++; } $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['fbw'] += $k[5]; $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['ftr'] += $dev[$k[1]]['ifout'][$k[2]]; $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['fif'][] = "{$k['1']};;{$k['2']}"; $blnk["{$ra};;{$ca};;{$ba};;{$rb};;{$cb};;{$bb}"]['fty']["{$k['6']}:" . date('j.M', $k[10])]++; } } } if ($lev > 3) { $dev[$k[1]]['nlk']++; # Count devlinks for flatmode $dev[$k[1]]['alk'][$k[3]]++; # Needed for arranging #if ($mde == "r") {# TODO find arrange method for building rings (only links within bld matter!) # $flr[$l[0]][$l[1]][$l[2]][$k[1]]['alk'][$k[3]]++; #} if (!$rlnum) { $dev[$k[3]]['nlk']++; $dev[$k[3]]['alk'][$k[1]]++; } } } } DbFreeResult($lres); } $rk = array_keys($reg); $nr = count($rk); # Draw Layout $cud = 0; if ($mde == "f") { $fstnod = 1; $nd = count(array_keys($dev)); foreach (Arrange($dev) as $dv) { $jdev[$dv] = $cud; list($dev[$dv]['x'], $dev[$dv]['y']) = CircleCoords(intval($xm / 2 + $xo), intval($ym / 2 - $yo), $cud, $nd, $dev[$dv]['nlk'], $len, $rot); $mapitems .= DrawItem($dev[$dv]['x'], $dev[$dv]['y'], '0', $dv, 'd'); if ($lev == 6) { DrawNodes($dv); } $imgmap .= "<area href=\"Devices-Status.php?dev=" . urlencode($dv) . "\" coords=\"" . ($dev[$dv]['x'] - $imas) . "," . ($dev[$dv]['y'] - $imas) . "," . ($dev[$dv]['x'] + $imas) . "," . ($dev[$dv]['y'] + $imas) . "\" shape=\"rect\" title=\"{$dv} " . $dev[$dv]['ip'] . " CPU:" . $dev[$dv]['cpu'] . "% Temp:" . $dev[$dv]['tlb'] . "\">\n"; if ($loi) { $mapinfo .= DrawLabel($dev[$dv]['x'], $dev[$dv]['y'] - 40, Safelabel($dev[$dv]['cty'] . " " . $dev[$dv]['bld']), 1, "cornflowerblue"); } elseif ($debug) { $mapinfo .= DrawLabel($dev[$dv]['x'], $dev[$dv]['y'] - 40, "Pos{$cud}", 1, "cornflowerblue"); } $cud++; } } else { if ($mde == "g") { # Prepare geographic stuff if (count($rk) == 1) { $ck = array_keys($cty[$rk[0]]); if (count($ck) == 1) { $mapbg = TopoMap($rk[0], $ck[0]); } else { $mapbg = TopoMap($rk[0]); } } else { $mapbg = TopoMap(); } $bg = Imagecreatefromjpeg("../topo/{$mapbg}"); $xm = Imagesx($bg); $ym = Imagesy($bg); Imagedestroy($bg); } $cur = 0; $toc = 0; $tob = 0; foreach (Arrange($reg) as $r) { if ($mde == "g") { list($reg[$r]['x'], $reg[$r]['y'], $reg[$r]['cmt']) = DbCoords($r); } if (!$reg[$r]['x']) { list($reg[$r]['x'], $reg[$r]['y']) = CircleCoords(intval($xm / 2 + $xo), intval($ym / 2 - $yo), $cur, $nr, $reg[$r]['nlk'], $len, $rot); } if ($lev == 1) { $jreg[$r] = $cur; $mapitems .= DrawItem($reg[$r]['x'], $reg[$r]['y'], $reg[$r]['ndv'], $r, 1); $imgmap .= "<area href=\"?lev=2&mde={$mde}&fmt=png&loo={$loo}&loa={$loa}&st[]=" . urlencode(TopoLoc($r)) . "\" coords=\"" . ($reg[$r]['x'] - $imas) . "," . ($reg[$r]['y'] - $imas) . "," . ($reg[$r]['x'] + $imas) . "," . ($reg[$r]['y'] + $imas) . "\" shape=\"rect\" title=\"{$sholbl}\">\n"; } else { if ($loi) { if (count($cty[$r]) > 1) { $mapinfo .= DrawItem($reg[$r]['x'], $reg[$r]['y'], '0', $r . " " . $reg[$r]['cmt'], 'ri'); } else { $mapinfo .= DrawLabel($reg[$r]['x'], $reg[$r]['y'] - 42, Safelabel($r), 1, "cornflowerblue"); } } $cuc = 0; $nc = count(array_keys($cty[$r])); foreach (Arrange($cty[$r]) as $c) { if ($mde == "g") { list($cty[$r][$c]['x'], $cty[$r][$c]['y'], $cty[$r][$c]['cmt']) = DbCoords($r, $c); } if (!$cty[$r][$c]['x']) { list($cty[$r][$c]['x'], $cty[$r][$c]['y']) = CircleCoords($reg[$r]['x'], $reg[$r]['y'], $cuc, $nc, $cty[$r][$c]['nlk'], $len * 10 / $lsf, $cro); } if ($lev == 2) { $jcty["{$r};;{$c}"] = $toc; $mapitems .= DrawItem($cty[$r][$c]['x'], $cty[$r][$c]['y'], $cty[$r][$c]['ndv'], $c, 2); $imgmap .= "<area href=\"?lev=3&mde={$mde}&fmt=png&loo={$loo}&loa={$loa}&st[]=" . urlencode(TopoLoc($r, $c)) . "\" coords=\"" . ($cty[$r][$c]['x'] - $imas) . "," . ($cty[$r][$c]['y'] - $imas) . "," . ($cty[$r][$c]['x'] + $imas) . "," . ($cty[$r][$c]['y'] + $imas) . "\" shape=\"rect\" title=\"{$sholbl}\">\n"; } else { if ($loi) { if (count($bld[$r][$c]) > 1) { $mapinfo .= DrawItem($cty[$r][$c]['x'], $cty[$r][$c]['y'], '0', $c . " " . $cty[$r][$c]['cmt'], 'ci'); } else { $mapinfo .= DrawLabel($cty[$r][$c]['x'], $cty[$r][$c]['y'] - 30, Safelabel($c), 1, "cornflowerblue"); } } $cub = 0; $nb = count(array_keys($bld[$r][$c])); foreach (Arrange($bld[$r][$c]) as $b) { if ($mde == "g") { list($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y'], $bld[$r][$c][$b]['cmt']) = DbCoords($r, $c, $b); } if (!$bld[$r][$c][$b]['x']) { list($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y']) = CircleCoords($cty[$r][$c]['x'], $cty[$r][$c]['y'], $cub, $nb, $bld[$r][$c][$b]['nlk'] * ($mde == "b" ? $cb % 2 + 0.3 : 1), $len / pow($lsf / 10, 2), $bro); } if ($lev == 3) { $jbld["{$r};;{$c};;{$b}"] = $tob; $mapitems .= DrawItem($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y'], $bld[$r][$c][$b]['ndv'], $b, 3); $imgmap .= "<area href=\"?lev=4&mde={$mde}&fmt=png&loo={$loo}&loa={$loa}&st[]=" . urlencode(TopoLoc($r, $c, $b)) . "\" coords=\"" . ($bld[$r][$c][$b]['x'] - $imas) . "," . ($bld[$r][$c][$b]['y'] - $imas) . "," . ($bld[$r][$c][$b]['x'] + $imas) . "," . ($bld[$r][$c][$b]['y'] + $imas) . "\" shape=\"rect\" title=\"{$sholbl}\">\n"; } elseif ($mde == "b" or $mde == "g") { DrawBuilding($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y'], $r, $c, $b); } else { if ($loi) { if (count($flr[$r][$c][$b]) > 1) { $mapinfo .= DrawItem($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y'], '0', $b . " " . $bld[$r][$c][$b]['cmt'], 'bi'); } else { $mapinfo .= DrawLabel($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y'] - 38, Safelabel($b), 1, "cornflowerblue"); } } $cd = 0; $nd = count(array_keys($flr[$r][$c][$b])); foreach (Arrange($flr[$r][$c][$b]) as $d) { $jdev[$d] = $cud; list($dev[$d]['x'], $dev[$d]['y']) = CircleCoords($bld[$r][$c][$b]['x'], $bld[$r][$c][$b]['y'], $cd, $nd, $dev[$d]['nlk'], $fsz, 0, 0); $mapitems .= DrawItem($dev[$d]['x'], $dev[$d]['y'], '0', $d, 'd'); $imgmap .= "<area href=\"Devices-Status.php?dev=" . urlencode($d) . "\" coords=\"" . ($dev[$d]['x'] - $imas) . "," . ($dev[$d]['y'] - $imas) . "," . ($dev[$d]['x'] + $imas) . "," . ($dev[$d]['y'] + $imas) . "\" shape=\"rect\" title=\"{$dv} " . $dev[$d]['ip'] . " CPU:" . $dev[$d]['cpu'] . "% T:" . $dev[$d]['tmp'] . "C\">\n"; if ($lev == 6) { DrawNodes($d); } $cd++; $cud++; } } $cub++; $tob++; } } $cuc++; $toc++; } } $cur++; } } # Draw Links if ($lev == 1) { $rlkeys = array_keys($rlnk); foreach ($rlkeys as $li) { $l = explode(';;', $li); if ($fmt == "json") { $ls = intval(sqrt($rlnk[$li]['fbw'] / 100000000 / $lsf) + 1); $maplinks .= " {\"source\":" . $jreg[$l[0]] . ",\"target\":" . $jreg[$l[1]] . ",\"value\":{$ls}},\n"; } else { DrawLink($reg[$l[0]]['x'], $reg[$l[0]]['y'], $reg[$l[1]]['x'], $reg[$l[1]]['y'], $rlnk[$li]); } } } elseif ($lev == 2) { foreach (array_keys($clnk) as $li) { $l = explode(';;', $li); if ($fmt == "json") { $ls = intval(sqrt($clnk[$li]['fbw'] / 100000000 / $lsf) + 1); $maplinks .= " {\"source\":" . $jcty["{$l['0']};;{$l['1']}"] . ",\"target\":" . $jcty["{$l['2']};;{$l['3']}"] . ",\"value\":{$ls}},\n"; } else { DrawLink($cty[$l[0]][$l[1]]['x'], $cty[$l[0]][$l[1]]['y'], $cty[$l[2]][$l[3]]['x'], $cty[$l[2]][$l[3]]['y'], $clnk[$li]); } } } elseif ($lev == 3) { foreach (array_keys($blnk) as $li) { $l = explode(';;', $li); if ($fmt == "json") { $ls = intval(sqrt($blnk[$li]['fbw'] / 100000000 / $lsf) + 1); $maplinks .= " {\"source\":" . $jbld["{$l['0']};;{$l['1']};;{$l['2']}"] . ",\"target\":" . $jbld["{$l['3']};;{$l['4']};;{$l['5']}"] . ",\"value\":{$ls}},\n"; } else { DrawLink($bld[$l[0]][$l[1]][$l[2]]['x'], $bld[$l[0]][$l[1]][$l[2]]['y'], $bld[$l[3]][$l[4]][$l[5]]['x'], $bld[$l[3]][$l[4]][$l[5]]['y'], $blnk[$li]); } } } elseif ($lev > 3) { foreach (array_keys($dlnk) as $li) { $l = explode(';;', $li); if ($fmt == "json") { $ls = intval(sqrt($dlnk[$li]['fbw'] / 100000000 / $lsf) + 1); $ls = $ls ? $ls : 1; $maplinks .= " {\"source\":" . $jdev[$l[0]] . ",\"target\":" . $jdev[$l[1]] . ",\"value\":{$ls}},\n"; } else { DrawLink($dev[$l[0]]['x'], $dev[$l[0]]['y'], $dev[$l[1]]['x'], $dev[$l[1]]['y'], $dlnk[$li]); } } if ($lev == 6) { foreach (array_keys($nlnk) as $li) { $l = explode(';;', $li); if ($fmt == "json") { $ls = intval(sqrt($nlnk[$li]['fbw'] / 100000000 / $lsf) + 1); $ls = $ls ? $ls : 1; $maplinks .= " {\"source\":" . $jdev[$l[0]] . ",\"target\":" . $jnod["{$l['0']};;{$l['1']}"] . ",\"value\":{$ls}},\n"; } else { DrawLink($dev[$l[0]]['x'], $dev[$l[0]]['y'], $nod[$l[1]]['x'], $nod[$l[1]]['y'], $nlnk[$li]); } } } } }
if ($uok == 1) { $res = DbQuery($_POST['q'], $link); $sys = posix_uname(); $sys['nedi'] = "1.0.9-010"; if ($_POST['m']) { if ($res) { while ($l = DbFetchArray($res)) { $rows[] = $l; } array_unshift($rows, $sys); print json_encode($rows); } else { echo "ERR :DB - " . DbError($link); } } else { echo join(';;', $sys) . "\n"; if ($res) { while ($l = DbFetchRow($res)) { echo join(';;', $l) . "\n"; } } else { echo "ERR :DB - " . DbError($link); } } DbFreeResult($res); } else { echo "ERR :Incorrect password!"; } } else { echo "ERR :Need credentials!"; }
echo "$n1rmsg"; } } echo "<h3>"; $query = GenQuery('user','u','name',$name,'',array('email'),array('='),array($_GET['email']) ); if( !@DbQuery($query,$link) ){echo DbError($link);}else{echo "Email, ";} $query = GenQuery('user','u','name',$name,'',array('phone'),array('='),array($_GET['phone']) ); if( !@DbQuery($query,$link) ){echo DbError($link);}else{echo "Phone, ";} $query = GenQuery('user','u','name',$name,'',array('comment'),array('='),array($_GET['comment']) ); if( !@DbQuery($query,$link) ){echo DbError($link);}else{echo "Comment, ";} $_SESSION['lang'] = $_GET['lang']; $query = GenQuery('user','u','name',$name,'',array('language'),array('='),array($_GET['lang']) ); if( !@DbQuery($query,$link) ){echo DbError($link);}else{echo "Feedback language, ";} $_SESSION['theme'] = $_GET['teme']; $query = GenQuery('user','u','name',$name,'',array('theme'),array('='),array($_GET['teme']) ); if( !@DbQuery($query,$link) ){echo DbError($link);}else{echo "Theme ";} echo " $upokmsg</h3>"; } $query = GenQuery('user','s','*','','',array('name'),array('='),array($name) ); $res = @DbQuery($query,$link); $uok = @DbNumRows($res); if ($uok == 1) { $u = @DbFetchRow($res); }else{ echo "<h4>user $name doesn't exist! ($uok)</h4>"; die; } ?> <h1>User Profile</h1> <form method="get" action="<?php echo $_SERVER['PHP_SELF'];
function TopoTable($reg = "", $cty = "", $bld = "", $flr = "", $rom = "", $nsd = 0) { global $link, $dev, $noloc, $alarr, $dreg, $dcity, $dbuild, $locsep, $now, $retire; if ($nsd) { $query = GenQuery('devices', 's', '*', '', '', array('location'), array('like'), array(TopoLoc($reg, $cty, $bld, $flr, $rom))); } else { $query = GenQuery('devices', 's', '*', '', '', array('snmpversion', 'location'), array('>', 'like'), array('0', TopoLoc($reg, $cty, $bld, $flr, $rom)), array('AND')); } $res = DbQuery($query, $link); if ($res) { while ($d = DbFetchRow($res)) { $mn = array_key_exists($d[0], $alarr) ? 1 : 0; if (preg_match("/.+{$locsep}.+{$locsep}.+/", $d[10])) { $l = explode($locsep, $d[10]); if ($mn) { $dreg[$l[0]]['mn']++; $dreg[$l[0]]['al'] += $alarr[$d[0]]['st']; $dcity[$l[0]][$l[1]]['mn']++; $dcity[$l[0]][$l[1]]['al'] += $alarr[$d[0]]['st']; $dbuild[$l[0]][$l[1]][$l[2]]['mn']++; $dbuild[$l[0]][$l[1]][$l[2]]['al'] += $alarr[$d[0]]['st']; } $dreg[$l[0]]['nd']++; $dcity[$l[0]][$l[1]]['nd']++; $dbuild[$l[0]][$l[1]][$l[2]]['nd']++; if ($d[6] > 3) { $dbuild[$l[0]][$l[1]][$l[2]]['nr']++; } if ($reg and $cty) { $dev[$l[3]][$l[4]][$d[0]]['rk'] = $l[5]; $dev[$l[3]][$l[4]][$d[0]]['ru'] = $l[6]; $dev[$l[3]][$l[4]][$d[0]]['ip'] = long2ip($d[1]); $dev[$l[3]][$l[4]][$d[0]]['ty'] = $d[3]; $dev[$l[3]][$l[4]][$d[0]]['co'] = $d[11]; $dev[$l[3]][$l[4]][$d[0]]['po'] = $d[16]; $dev[$l[3]][$l[4]][$d[0]]['ic'] = $d[18]; $dev[$l[3]][$l[4]][$d[0]]['mn'] = $mn; $dev[$l[3]][$l[4]][$d[0]]['al'] = $alarr[$d[0]]['st']; $dev[$l[3]][$l[4]][$d[0]]['sz'] = $d[28]; $dev[$l[3]][$l[4]][$d[0]]['sk'] = $d[29] ? $d[29] : 1; } } else { $noloc[$d[0]]['ip'] = long2ip($d[1]); $noloc[$d[0]]['ty'] = $d[3]; $noloc[$d[0]]['lo'] = $d[10]; $noloc[$d[0]]['co'] = $d[11]; $noloc[$d[0]]['po'] = $d[16]; $noloc[$d[0]]['ic'] = $d[18]; $noloc[$d[0]]['mn'] = $mn; if ($mn) { $noloc[$d[0]]['al'] = $alarr[$d[0]]['st']; } } } DbFreeResult($res); } else { print DbError($link); } }
} $radres = @DbQuery($radquery, $radlink); $nres = 0; if ($radres) { while ($u = @DbFetchArray($radres)) { // allet in variablen schreiben $radusr[$nres]["UserName"] = $u['UserName']; $radusr[$nres]["Name"] = $u['Name']; $radusr[$nres]["Department"] = $u['Department']; $radusr[$nres]["Mail"] = $u['Mail']; $radusr[$nres]["WorkPhone"] = $u['WorkPhone']; $nres++; } @DbFreeResult($radres); } else { print @DbError($radlink); } // get online status on these users for ($i = 0; $i < $nres; $i++) { $radquery = Query('radacct', '*', 'UserName', '=', $radusr[$i]["UserName"], 'AND', 'AcctStopTime', '=', '0', $_GET[ord], ''); $radres = @DbQuery($radquery, $radlink); if ($u = @DbFetchArray($radres)) { $radusr[$i]["Online"] = true; $radusr[$i]["NAS"] = $u['NASIPAddress']; } else { $radusr[$i]["Online"] = false; $radusr[$i]["NAS"] = ''; } @DbFreeResult($radres); } // print
function Read($ina, $filter) { global $link, $locsep, $resmsg; global $lev, $ipi, $net, $dev, $ndev, $bdev, $cdev, $rdev; global $devlink, $ctylink, $bldlink; global $nctylink, $nbldlink, $actylink, $abldlink; $net = array(); if ($ina == "vlan") { $query = GenQuery('vlans', 'g', 'device', 'device', '', array('vlanid'), array('regexp'), array($filter)); $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($filter)); $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($filter)); } else { $query = GenQuery('devices', 's', 'name,ip,location,icon', '', '', array('location'), array('regexp'), array($filter)); } $res = @DbQuery($query, $link); if ($res) { while ($unit = @DbFetchRow($res)) { $l = explode($locsep, $unit[2]); $ndev["{$l['0']}{$locsep}{$l['1']}"][$l[2]][$l[3]][] = $unit[0]; $bdev["{$l['0']}{$locsep}{$l['1']}"][$l[2]]++; $cdev["{$l['0']}{$locsep}{$l['1']}"]++; $rdev[$l[0]][$l[1]]++; $dev[$unit[0]]['ip'] = long2ip($unit[1]); $dev[$unit[0]]['ic'] = $unit[3]; $dev[$unit[0]]['cty'] = "{$l['0']}{$locsep}{$l['1']}"; $dev[$unit[0]]['bld'] = $l[2]; $dev[$unit[0]]['rom'] = $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); } $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); } }
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 ); }
$lopt[$l[0]][$l[1]][$l[2]]++; } @DbFreeResult($res); }else{ echo @DbError($link); } if ($do == 'Create' and $reg){ $query = GenQuery('locations','i','','','',array('region','city','building','x','y','comment'),'',array($reg,$cty,$bld,$x,$y,$com) ); if( !@DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h3>Location $reg $cty $bld - $upokmsg</h3>";} }elseif ($do == 'Update' and $id){ $query = GenQuery('locations','u','id',$id,'',array('region','city','building','x','y','comment'),'',array($reg,$cty,$bld,$x,$y,$com) ); if( !@DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h3>Location $reg $cty $bld - $upokmsg</h3>";} }elseif($do == 'Delete' and $id){ $query = GenQuery('locations','d','','','',array('id'),array('='),array($id) ); if( !@DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}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;
}elseif($stop and $isadmin){ if( $pid = GetPID($mysrv[$stop]['cmd']) ){ if( posix_kill ($pid, 9) ){ $procs = shell_exec($pscmd); # Refresh PIDs after kill echo "<h5>$stop stopped</h5>"; }else{ echo "<h4>$stop not stopped!</h4>"; } }else{ echo "<h4>$stop not running!</h4>"; } }elseif($clear and $isadmin){ $query = GenQuery('system','u','name','=','threads',array('value'),array(),array('0') ); if( !DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h5>$dellbl threads OK</h5>";} $query = GenQuery('system','u','name','=','nodlock',array('value'),array(),array('0') ); if( !DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h5>$reslbl nodlock OK</h5>";} if( $pid = GetPID('nedi.pl') ){ posix_kill ($pid, 9); $err = posix_get_last_error(); if( $err ){ echo "<h4>$dellbl NeDi: ".posix_strerror($err)."</h4>"; }else{ echo "<h5>NeDi $dellbl OK</h5>"; } $procs = shell_exec($pscmd); # Refresh PIDs after kill }else{ echo "<h4>NeDi not running</h4>"; } }
if($res){ while( ($l = @DbFetchRow($res)) ){ $neb[$l[3]] = $l[4]; } @DbFreeResult($res); }else{ print @DbError($link); } if($gen == 'Monitor' and !$mdev[$na] and $dsnm[$na]){ $adep = 'none'; if(count(array_keys($neb) ) == 1 and $ars){ $adep = key($neb); } $mdep[$na] = $adep; $query = GenQuery('monitoring','i','','','',array('device','status','depend','sms','mail','lastchk','uptime','lost','ok'),'',array($na,'0',$adep,'0','0','0','0','0','0') ); if( !@DbQuery($query,$link) ){echo "<h4 align=center>".DbError($link)."</h4>";}else{echo "<h3>$na $upokmsg</h3>";$mdev[$na]=1;} } list($statbg,$stat) = StatusBg(1,$mdev[$na],$msta[$na],$bi); echo "<tr class=\"$bg\"><th class=\"$statbg\">\n"; echo "<a href=Devices-Status.php?dev=$ud><img src=\"img/dev/$ico.png\" title=\"$stat\"></a><p>\n"; echo "<b>$na</b></th><td>$dloc[$na]</td><td>$minfo[$na]</td>"; echo "<th>"; if($mdev[$na]){ echo "<a href=?loc=$uloc&crm=$ud&gen=up><img src=\"img/16/bchk.png\" title=\"-Check\"></a>"; }elseif($dsnm["$na"]){ echo "<a href=?loc=$uloc&cad=$ud&gen=up><img src=\"img/16/bcls.png\" title=\"+Check\"></a>"; }else{ echo "<img src=\"img/16/bstp.png\" title=\"no SNMP available!\"></a>"; }
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 }
<? $libw = array(); $query = GenQuery('links'); $res = @DbQuery($query,$link); $nli = @DbNumRows($res); if($res){ $row = 0; while( ($l = @DbFetchRow($res)) ){ $libw[$l[1]][$l[2]][$l[3]][$l[4]] = $l[5]; # Bandwidth is the only value, which is constructed from local IF in SNMP::CDP/LLDP $lity[$l[1]][$l[2]][$l[3]][$l[4]] = $l[6]; $lidu[$l[1]][$l[2]][$l[3]][$l[4]] = $l[8]; # Duplex and Vlan are read via CDP from remote side $livl[$l[1]][$l[2]][$l[3]][$l[4]] = $l[9]; } @DbFreeResult($res); }else{ echo @DbError($link); die; } $row = 0; foreach(array_keys($libw) as $dv){ foreach(array_keys($libw[$dv]) as $if){ foreach(array_keys($libw[$dv][$if]) as $nb){ foreach(array_keys($libw[$dv][$if][$nb]) as $ni){ $ud = rawurlencode($dv); $un = rawurlencode($nb); if($alt or $libw[$dv][$if][$nb][$ni] and $libw[$nb][$ni][$dv][$if]){ if($libw[$dv][$if][$nb][$ni] != $libw[$nb][$ni][$dv][$if]){ if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";} $row++; echo "<tr class=\"$bg\"><th class=\"$bi\">\n"; echo "<img src=\"img/spd.png\" title=\"bandwidth\"></th>\n";
function TopoTable($reg = "", $cty = "", $bld = "") { global $link, $dev, $deval, $dcity, $dbuild, $locsep, $maxcol, $bg1, $bg2, $tabtag; $query = GenQuery('devices', 's', '*', '', '', array('location'), array('regexp'), array(TopoLoc($reg, $cty, $bld))); $res = @DbQuery($query, $link); if ($res) { while ($d = @DbFetchRow($res)) { $l = explode($locsep, $d[10]); if (isset($deval[$d[0]])) { # Device is monitored if set... $dcity[$l[0]][$l[1]]['mn']++; $dcity[$l[0]][$l[1]]['al'] += $deval[$d[0]]; $dbuild[$l[0]][$l[1]][$l[2]]['mn']++; $dbuild[$l[0]][$l[1]][$l[2]]['al'] += $deval[$d[0]]; $mn = 1; } else { $mn = 0; } if (!$cty) { $dcity[$l[0]][$l[1]]['nd']++; } elseif (!$bld) { $dbuild[$l[0]][$l[1]][$l[2]]['nd']++; if ($d[6] > 3) { $dbuild[$l[0]][$l[1]][$l[2]]['nr']++; } } else { $dev[$l[3]][$l[4]][$d[0]]['rk'] = "{$l['5']} <i>{$l['6']}</i>"; $dev[$l[3]][$l[4]][$d[0]]['ip'] = $d[1]; $dev[$l[3]][$l[4]][$d[0]]['ty'] = $d[3]; $dev[$l[3]][$l[4]][$d[0]]['co'] = $d[11]; $dev[$l[3]][$l[4]][$d[0]]['ic'] = $d[18]; $dev[$l[3]][$l[4]][$d[0]]['mn'] = $mn; $dev[$l[3]][$l[4]][$d[0]]['al'] = $deval[$d[0]]; } } @DbFreeResult($res); } else { print @DbError($link); } }
function DevDelete($dld, $dtxt) { global $link, $delbl, $errlbl, $updlbl, $nedipath; $query = GenQuery('devices', 'd', '', '', '', array('device'), array('='), array($dld)); if (!DbQuery($query, $link)) { echo "<h4>Device " . DbError($link) . "</h4>"; } else { echo "<h5>Device {$dld} {$dellbl} OK</h5>"; } $query = GenQuery('interfaces', 'd', '', '', '', array('device'), array('='), array($dld)); if (!DbQuery($query, $link)) { echo "<h4>IF " . DbError($link) . "</h4>"; } else { echo "<h5>IF {$dld} {$dellbl} OK</h5>"; } $query = GenQuery('modules', 'd', '', '', '', array('device'), array('='), array($dld)); if (!DbQuery($query, $link)) { echo "<h4>Modules " . DbError($link) . "</h4>"; } else { echo "<h5>Modules {$dld} {$dellbl} OK</h5>"; } $query = GenQuery('links', 'd', '', '', '', array('device'), array('='), array($dld)); if (!DbQuery($query, $link)) { echo "<h4>Links " . DbError($link) . "</h4>"; } else { echo "<h5>Links {$dld} {$dellbl} OK</h5>"; } $query = GenQuery('links', 'd', '', '', '', array('neighbor'), array('='), array($dld)); 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>"; } $devdir = rawurlencode($dld); if (file_exists("{$nedipath}/rrd/{$devdir}/*.rrd")) { foreach (glob("{$nedipath}/rrd/{$devdir}/*.rrd") as $rrd) { echo unlink($rrd) ? "<h5>{$rrd} {$dellbl} OK</h5>" : "<h4>{$rrd} {$dellbl} {$errlbl}</h4>"; } echo rmdir("{$nedipath}/rrd/{$devdir}") ? "<h5>{$nedipath}/rrd/{$devdir} {$dellbl} OK</h5>" : "<h4>{$nedipath}/rrd/{$devdir} {$dellbl} {$errlbl}</h4>"; } if (file_exists("{$nedipath}/rrd/{$devdir}/*.rrd")) { foreach (glob("{$nedipath}/conf/{$devdir}/*.cfg") as $cfg) { echo unlink($cfg) ? "<h5>{$cfg} {$dellbl} OK</h5>" : "<h4>{$cfg} {$dellbl} {$errlbl}</h4>"; } echo rmdir("{$nedipath}/conf/{$devdir}") ? "<h5>{$nedipath}/conf/{$devdir} {$dellbl} OK</h5>" : "<h4>{$nedipath}/conf/{$devdir} {$dellbl} {$errlbl}</h4>"; } $query = GenQuery('events', 'i', '', '', '', array('level', 'time', 'source', 'info', 'class', 'device'), array(), array('100', time(), $dld, "device{$dtxt} deleted by {$_SESSION['user']}", 'usrd', $dld)); if (!DbQuery($query, $link)) { echo "<h4>" . DbError($link) . "</h4>"; } else { echo "<h5>{$msglbl} {$updlbl} OK</h5>"; } }
$mail_importe = fgets($liste, 4096); if (strlen($mail_importe) == 2) { // dummy and pretty function ;-) yeah ! } else { $mail_importe = str_replace("'", "", $mail_importe); $mail_importe = str_replace('"', "", $mail_importe); $mail_importe = strtolower(trim($mail_importe)); if (!empty($mail_importe) && validEmailAddress($mail_importe)) { $added = add_subscriber($cnx, $row_config_globale['table_email'], $list_id, $mail_importe); if ($added == -1) { $subscriber_op_msg .= "<h4 class='alert_error'>" . translate("ERROR_ALREADY_SUBSCRIBER", "<b>{$mail_importe}</b>") . ".</h4>"; } elseif ($added == 2) { $subscriber_op_msg .= "<h4 class='alert_success'>" . translate("SUBSCRIBER_ADDED", "<b>{$mail_importe}</b>") . ".</h4>"; $tx_import++; } elseif ($added == 0) { $subscriber_op_msg .= "<h4 class='alert_error'>" . translate("ERROR_SQL", DbError()) . "</h4>"; } } else { $subscriber_op_msg .= "<h4 class='alert_error'>Adresse mail invalide : " . $mail_importe . "</h4>"; } } } $subscriber_op_msg .= "<h4 class='alert_success'><b>{$tx_import} mails importés</b></h4>"; } else { $subscriber_op_msg = "<h4 class='alert_error'>" . translate("ERROR_IMPORT_TMPDIR_NOT_WRITABLE") . " !</h4>"; } } else { $subscriber_op_msg = "<h4 class='alert_error'>" . translate("ERROR_IMPORT_FILE_MISSING") . " !</h4>"; } break; default:
function Read($ina, $filter) { global $link, $locsep, $fpos, $bpos, $cpos, $rpos, $resmsg; global $lev, $ipi, $net, $dev, $ndev, $bdev, $fdev; global $devlink, $ctylink, $bldlink; global $nctylink, $nbldlink, $actylink, $abldlink; $net = array(); if ($ina == "vlan") { $query = GenQuery('vlans', 's', '*', '', '', array('vlanid'), array('regexp'), array($filter)); $res = @DbQuery($query, $link); if ($res) { while ($vl = @DbFetchRow($res)) { $devs[] = preg_replace('/([\\^\\$+])/', '\\\\\\\\$1', $vl[0]); } @DbFreeResult($res); } else { print @DbError($link); } if (!is_array($devs)) { echo $resmsg; die; } $query = GenQuery('devices', 's', '*', '', '', array('name'), array('regexp'), array(implode("|", $devs))); } elseif ($ina == "network") { $query = GenQuery('networks', 's', '*', '', '', array('ip'), array('='), array($filter)); $res = @DbQuery($query, $link); if ($res) { while ($vl = @DbFetchRow($res)) { $devs[] = preg_replace('/([\\^\\$\\*\\+])/', '\\\\\\\\$1', $vl[0]); } @DbFreeResult($res); } else { print @DbError($link); } if (!is_array($devs)) { echo $resmsg; die; } $query = GenQuery('devices', 's', '*', '', '', array('name'), array('regexp'), array(implode("|", $devs))); } else { $query = GenQuery('devices', 's', '*', '', '', array('location'), array('regexp'), array($filter)); } $res = @DbQuery($query, $link); if ($res) { while ($unit = @DbFetchRow($res)) { $locitems = explode($locsep, $unit[10]); if ($cpos === false) { $cty = "-"; } else { $cty = $locitems[$cpos]; } if ($bpos === false) { $bld = "-"; } else { $bld = $locitems[$bpos]; } if ($fpos === false) { $flr = "-"; } else { $flr = $locitems[$fpos]; } if ($rpos === false) { $rom = "-"; } else { $rom = $locitems[$rpos]; } $dev[$unit[0]]['ip'] = long2ip($unit[1]); $dev[$unit[0]]['ic'] = $unit[18]; $dev[$unit[0]]['cty'] = $cty; $dev[$unit[0]]['bld'] = $bld; $dev[$unit[0]]['flr'] = $flr; $dev[$unit[0]]['rom'] = $rom; $ndev[$cty][$bld][$flr][] = $unit[0]; $bdev[$cty][$bld]++; $fdev[$cty][$bld][$flr]++; } @DbFreeResult($res); } else { print @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 { print @DbError($link); } @DbFreeResult($res); } $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 { print @DbError($link); } }
function AddRecord($table, $key, $col, $val) { global $link, $alrlbl, $addlbl; $mres = DbQuery("SELECT * FROM {$table} WHERE {$key}", $link); if ($mres) { if (DbNumRows($mres)) { $status = "<img src=\"img/16/bdis.png\" title=\"{$alrlbl} OK\" vspace=\"4\">"; } else { if (!DbQuery("INSERT INTO {$table} ({$col}) VALUES ({$val})", $link)) { $status = "<img src=\"img/16/bcnl.png\" title=\"" . DbError($link) . "\" vspace=\"4\">"; } else { $status = "<img src=\"img/16/bchk.png\" title=\"{$addlbl} OK\" vspace=\"4\">"; } } } else { print DbError($link); } return $status; }
} else { echo "<h3>{$name}'s email {$upokmsg}</h3>"; } } if (isset($_GET['phone'])) { $query = GenQuery('user', 'u', 'name', $name, '', array('phone'), array('='), array($_GET['phone'])); if (!@DbQuery($query, $link)) { echo "<h4 align=center>" . DbError($link) . "</h3>"; } else { echo "<h3>{$name}'s phone {$upokmsg}</h3>"; } } if (isset($_GET['comment'])) { $query = GenQuery('user', 'u', 'name', $name, '', array('comment'), array('='), array($_GET['comment'])); if (!@DbQuery($query, $link)) { echo "<h4 align=center>" . DbError($link) . "</h3>"; } else { echo "<h3>{$name}'s comment {$upokmsg}</h3>"; } } } elseif (isset($_GET['lang'])) { echo "<h3>Feedback language set to {$_GET['lang']}</h3>"; $query = GenQuery('user', 'u', 'name', $name, '', array('language'), array('='), array($_GET['lang'])); @DbQuery($query, $link); } $query = GenQuery('user', 's', '*', '', '', array('name'), array('='), array($name)); $res = @DbQuery($query, $link); $uok = @DbNumRows($res); if ($uok == 1) { $u = @DbFetchRow($res); } else {
$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 # 1 for change from dev1 to dev2
$qry = GenQuery('devices', 's', 'count(*)', '', '', array('snmpversion'), array('='), array('0')); $res = DbQuery($qry, $lnk); if ($res) { $ndv = DbFetchRow($res); DbFreeResult($res); } else { print DbError($lnk); die; } $qry = GenQuery('nodes', 's', 'count(*)'); $res = DbQuery($qry, $lnk); if ($res) { $nod = DbFetchRow($res); DbFreeResult($res); } else { print DbError($lnk); die; } if ($cu == "u") { $cuf = 0.95; $cul = 'USD'; $ibn = 'CH72 0070 0130 0072 8546 9'; } elseif ($cu == "e") { $cuf = 1.2; $cul = 'EUR'; $ibn = 'CH77 0070 0130 0079 5031 4'; } elseif ($cu == "c") { $cuf = 1; $cul = 'CHF'; $ibn = 'CH31 0070 0110 0041 9947 4'; }
$_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> <head> <title>NeDi 1.0.9-010</title> <meta name="generator" content="NeDi 1.0.9-010"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
?> <h5>Magic Packet sent to <?php echo $ip; ?> </h5> <script language="JavaScript"><!-- setTimeout("history.go(-1)",10000); //--></script> <? }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> <? }else{ echo $nokmsg; } } ?>
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; flush(); } echo "</table><table bgcolor=#666666 {$tabtag} >\n"; echo "<tr bgcolor=#{$bg2}><td>Total of {$tmsg} messages shown</td></tr></table>\n"; include_once "inc/footer.php";
}elseif(isset($_GET['del']) and $id){ $query = GenQuery('locations','d','','','',array('id'),array('='),array($id) ); if( !DbQuery($query,$link) ){echo "<h4>".DbError($link)."</h4>";}else{echo "<h5>$dellbl $reg $cty $bld OK</h5>";} $id = $reg = $cty = $bld = $x = $y = $com = $ns = $ew = ''; } $query = GenQuery('devices','s','distinct location'); $res = DbQuery($query,$link); if($res){ while( ($d = DbFetchRow($res)) ){ $l = explode($locsep, $d[0]); $lopt[$l[0]][$l[1]][$l[2]]++; } DbFreeResult($res); }else{ echo DbError($link); } $x = $y = $ns = $ew = ''; if($reg){ $z = "6"; $nam = $reg; $ico = 'img/regg.png'; $res = DbQuery( GenQuery('locations','s','id,x,y,ns,ew,locdesc','','',array('region','city','building'),array('=','=','='),array($reg,'',''),array('AND','AND') ),$link); if ( DbNumRows($res) == 1){ $locex = 1; list($id,$x,$y,$ns,$ew,$com) = DbFetchRow($res); $geost = ($dem)?$com:$nam; }else{ $locex = 0; $geost = $nam;
<?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; } }
} else { echo "<h4 class='alert_error'>" . translate("ERROR_DELETING_NEWSLETTER") . ".</h4>"; } } if (empty($action)) { if ($op == "SaveConfig") { if ($save) { echo "<h4 class='alert_success'>" . translate("NEWSLETTER_SETTINGS_SAVED") . "</h4>"; } else { echo "<h4 class='alert_error'>" . translate("ERROR_SAVING_SETTINGS") . "</h4>"; } } if ($op == "createConfig") { if ($new_id) { echo "<h4 class='alert_success'>" . translate("NEWSLETTER_SETTINGS_CREATED") . ".</h4>"; } else { echo "<h4 class='alert_error'>" . translate("ERROR_SAVING_SETTINGS", ":<br />" . DbError()) . "</h4>"; } } echo "<input type='hidden' name='op' value='SaveConfig' /><input type='hidden' name='token' value='{$token}' />"; echo "<input type='hidden' name='list_id' value='{$list_id}' />\n <fieldset><label>" . translate("NEWSLETTER_NAME") . " : </label>\n <input type='text' name='newsletter_name' value='" . htmlspecialchars(@$newsletter['newsletter_name']) . "' /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_FROM_NAME") . " : </label>\n <input type='text' name='from_name' value='" . htmlspecialchars($newsletter['from_name']) . "' /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_FROM_ADDR") . " : </label>\n <input type='text' name='from' value='" . $newsletter['from_addr'] . "' /></fieldset>\n <fieldset><label>Adresse électronique pour preview : </label>\n <input type='text' name='preview_addr' value='" . $newsletter['preview_addr'] . "' /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_SUBJECT") . " : </label>\n <input type='text' name='subject' value=\"" . htmlspecialchars($newsletter['subject']) . "\" /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_HEADER") . " : </label>\n <br><textarea class='editme' name='header' rows='15' id='NEWSLETTER_DEFAULT_HEADER'>" . $newsletter['header'] . "</textarea></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_FOOTER") . " : </label>\n <br><textarea class='editme' name='footer' rows='15' id='NEWSLETTER_DEFAULT_FOOTER'>" . $newsletter['footer'] . "</textarea></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_SUB_MSG_SUBJECT") . " : </label>\n <input type='text' name='subscription_subject' value=\"" . htmlspecialchars($newsletter['subscription_subject']) . "\" /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_SUB_MSG_BODY") . " : </label>\n <br><textarea class='editme' name='subscription_body' rows='15' id='NEWSLETTER_SUB_DEFAULT_BODY'>" . $newsletter['subscription_body'] . "</textarea></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_WELCOME_MSG_SUBJECT") . " : </label>\n <input type='text' name='welcome_subject' value=\"" . htmlspecialchars($newsletter['welcome_subject']) . "\" /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_WELCOME_MSG_BODY") . " : </label>\n <br><textarea class='editme' name='welcome_body' rows='15' id='NEWSLETTER_WELCOME_DEFAULT_BODY'>" . $newsletter['welcome_body'] . "</textarea></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_UNSUB_MSG_SUBJECT") . " : </label>\n <input type='text' name=' quit_subject' value=\"" . htmlspecialchars($newsletter['quit_subject']) . "\" /></fieldset>\n <fieldset><label>" . translate("NEWSLETTER_UNSUB_MSG_BODY") . " : </label>\n <br><textarea class='editme' name='quit_body' rows='15' id='NEWSLETTER_UNSUB_DEFAULT_BODY'>" . $newsletter['quit_body'] . "</textarea></fieldset>"; echo "</div>"; echo "<script src='/" . $row_config_globale['path'] . "js/tinymce/tinymce.min.js'></script>"; echo "<script>tinymce.init({\n selector: 'textarea.editme', theme: 'modern',\n plugins: [\n 'advlist autolink lists link image charmap print preview anchor searchreplace visualblocks code fullscreen textcolor emoticons insertdatetime media table contextmenu paste filemanager colorpicker'\n ],\n toolbar1: 'insertfile undo redo | bold italic | colorpicker forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent',\n toolbar2: 'styleselect | fontselect fontsizeselect | emoticons | link image | filemanager',\n style_formats: [\n {title: 'Open Sans', inline: 'span', styles: { 'font-family':'Open Sans'}},\n {title: 'Arial', inline: 'span', styles: { 'font-family':'arial'}},\n {title: 'Book Antiqua', inline: 'span', styles: { 'font-family':'book antiqua'}},\n {title: 'Comic Sans MS', inline: 'span', styles: { 'font-family':'comic sans ms,sans-serif'}},\n {title: 'Courier New', inline: 'span', styles: { 'font-family':'courier new,courier'}},\n {title: 'Georgia', inline: 'span', styles: { 'font-family':'georgia,palatino'}},\n {title: 'Helvetica', inline: 'span', styles: { 'font-family':'helvetica'}},\n {title: 'Impact', inline: 'span', styles: { 'font-family':'impact,chicago'}},\n {title: 'Symbol', inline: 'span', styles: { 'font-family':'symbol'}},\n {title: 'Tahoma', inline: 'span', styles: { 'font-family':'tahoma'}},\n {title: 'Terminal', inline: 'span', styles: { 'font-family':'terminal,monaco'}},\n {title: 'Times New Roman', inline: 'span', styles: { 'font-family':'times new roman,times'}},\n {title: 'Verdana', inline: 'span', styles: { 'font-family':'Verdana'}}\n ],\n relative_urls: false,\n remove_script_host: false,\n language : 'fr_FR',\n image_advtab: true ,\n external_filemanager_path:'/" . $row_config_globale['path'] . "js/tinymce/plugins/filemanager/',\n filemanager_title:'Responsive Filemanager' ,\n external_plugins: { 'filemanager' : '/" . $row_config_globale['path'] . "js/tinymce/plugins/filemanager/plugin.min.js'}});\n </script>"; } } echo '</article>'; echo '<article class="module width_quarter"><div class="sticky-scroll-box">'; echo '<header><h3>Actions :</h3></header><div align="center">'; echo "<br>\n\t<input type='submit' value='" . translate("NEWSLETTER_SAVE_SETTINGS") . "' />\n\t<input type='hidden' name='list_id' value='{$list_id}' />\n\t<input type='hidden' name='page' value='newsletterconf' />\n\t<input type='hidden' name='token' value='{$token}' />\n\t<div class='spacer'></div>"; echo '</div></article></div>';