Example #1
0
/**
 * 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;
}
Example #2
0
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;
}
Example #3
0
						if( preg_match("/^No Such|^$/",$stppri) ){
							TblCell("?");
						}else{
							$numchg	= str_replace('"','', Get($ip, $dev[14] & 3, $dev[15], "1.3.6.1.2.1.17.2.4.0") );
							if( preg_match("/^No Such|^$/",$numchg) ){
								TblCell("TC:?");
							}else{
								$laschg	= str_replace('"','', Get($ip, $dev[14] & 3, $dev[15], "1.3.6.1.2.1.17.2.3.0") );
								sscanf($laschg, "%d:%d:%0d:%0d.%d",$tcd,$tch,$tcm,$tcs,$ticks);
								$tcstr  = sprintf("%dD-%d:%02d:%02d",$tcd,$tch,$tcm,$tcs);
								$rport	= str_replace('"','', Get($ip, $dev[14] & 3, $dev[15], "1.3.6.1.2.1.17.2.7.0") );
								if($rport){
									$rootif	 = str_replace('"','', Get($ip, $dev[14] & 3, $dev[15], "1.3.6.1.2.1.17.1.4.1.2.$rport") );
									$ifquery = GenQuery('interfaces','s','*','','',array('device','ifidx'),array('=','='),array($dev[0],$rootif),array('AND') );
									$ifres	 = DbQuery($ifquery,$link);
									if(DbNumRows($ifres) == 1){
										$if = DbFetchRow($ifres);
										$it = "RP:<span class=\"grn\">$if[1] <i>$if[7]</i></span>";
									}else{
										$it = "Rootport n/a!";
									}
								}else{
									$it = "<span class=\"drd\">Root</span>";
								}
								TblCell("$prilbl:<span class=\"prp\">$stppri</span> $it TC:<span class=\"blu\">$numchg</span> $tcstr","","","<a href=\"Topology-Spanningtree.php?dev=$ud\"><img src=\"img/16/traf.png\" title=\"Topology-Spanningtree\"></a>");
							}
						}
					}else{
						TblCell("-");
					}
				}
                $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;
    flush();
}
echo "</table><table bgcolor=#666666 {$tabtag} >\n";
Example #5
0
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>&nbsp;</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";
}
<?php 
StatusSys('cpu');
StatusSys('mem');
StatusSys('tmp');
?>
</th></tr></table>
<p>
<table width=100%>
<tr><th width=20% valign=top>
<h2>Message Statistics</h2>
<?php 
$query = GenQuery('messages', 'g', 'level', 'level desc');
$res = @DbQuery($query, $link);
if ($res) {
    $nlev = @DbNumRows($res);
    if ($nlev) {
        ?>
<p><table bgcolor=#666666 <?php 
        echo $tabtag;
        ?>
 ><tr bgcolor=#<?php 
        echo $bg2;
        ?>
>
<th width=40><img src=img/16/info.png><br>Level</th>
<th><img src=img/16/say.png><br>Messages</th>
<?php 
        $row = 0;
        while ($msg = @DbFetchRow($res)) {
            if ($row % 2) {
    $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>
<form method="get" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" name="lof">
<table bgcolor=#000000 <?php 
echo $tabtag;
?>
 >
Example #8
0
if (isset($_POST['user'])) {
    $pass = md5($_POST['pass']);
    $link = @DbConnect($dbhost, $dbuser, $dbpass, $dbname);
    if (stristr('p', $guiauth) && $_POST['user'] != "admin") {
        # PAM code by Owen Brotherhood & bruberg
        if (!extension_loaded('pam_auth')) {
            dl("pam_auth.so");
        }
        $uok = pam_auth($_POST['user'], $_POST['pass']);
        $query = GenQuery('user', 's', '*', '', '', array('name'), array('='), array($_POST[user]));
        $res = @DbQuery($query, $link);
    } else {
        $pass = md5($_POST['pass']);
        $query = GenQuery('user', 's', '*', '', '', array('name', 'password'), array('=', '='), array($_POST['user'], $pass), array('AND'));
        $res = @DbQuery($query, $link);
        $uok = @DbNumRows($res);
    }
    if ($uok == 1) {
        $usr = @DbFetchRow($res);
        session_start();
        $_SESSION['user'] = $_POST['user'];
        $_SESSION['group'] = "usr,";
        if ($usr[2]) {
            $_SESSION['group'] .= "adm,";
        }
        if ($usr[3]) {
            $_SESSION['group'] .= "net,";
        }
        if ($usr[4]) {
            $_SESSION['group'] .= "dsk,";
        }
Example #9
0
    } 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">
<th width="40"><img src="img/16/user.png"><br>User</th>
<th width="120"><img src="img/16/clock.png"><br><?php 
Example #10
0
    }
    echo "</select>";
    ?>
</th><th width="80">
<input type="submit" value="<?php 
    echo $sholbl;
    ?>
">
</th>
</tr></table></form>
<?php 
}
if ($dev) {
    $query = GenQuery('devices', 's', '*', '', '', array('device'), array('='), array($dev));
    $res = DbQuery($query, $link);
    $ndev = DbNumRows($res);
    if ($ndev != 1) {
        echo "<h4>{$dev} {$mullbl} {$vallbl}</h4>";
        DbFreeResult($res);
        die;
    } else {
        $dev = DbFetchRow($res);
        $ip = long2ip($dev[1]);
        $sv = Syssrv($dev[6]);
        $ud = rawurlencode($dev[0]);
        DbFreeResult($res);
        $query = GenQuery('interfaces', 's', 'ifidx,ifname,iftype,alias,comment', '', '', array('device'), array('='), array($rtr));
        $res = DbQuery($query, $link);
        while ($i = DbFetchRow($res)) {
            $ifn[$i[0]] = $i[1];
            $ift[$i[0]] = $i[2];
Example #11
0
</th>

<?php 
    $row = 0;
    while ($s = DbFetchRow($res)) {
        if ($row % 2) {
            $bg = "txta";
            $bi = "imga";
        } else {
            $bg = "txtb";
            $bi = "imgb";
        }
        $row++;
        $nquery = GenQuery('nodes', 's', '*', '', '', array('mac'), array('='), array($s[2]));
        $nres = DbQuery($nquery, $link);
        $nnod = DbNumRows($nres);
        if ($nnod == 1) {
            $n = DbFetchRow($nres);
            DbFreeResult($nres);
        } else {
            $n = array($s[0], $s[1], $s[2], '-', 0, 0, 'Not in nodes', '-');
        }
        $dbna = preg_replace("/^(.*?)\\.(.*)/", "\$1", $n[0]);
        $dbip = long2ip($n[1]);
        $img = Nimg("{$n['2']};{$n['3']}");
        $ls = date("r", $n[5]);
        list($fc, $lc) = Agecol($n[4], $n[5], $row % 2);
        $na = preg_replace("/^(.*?)\\.(.*)/", "\$1", $s[0]);
        $ip = long2ip($s[1]);
        $sup = date("r", $s[6]);
        $simg = "";
Example #12
0
			print DbError($link);
		}
	?>
</table>
<table class="content">
<tr class="<?= $modgroup[$self] ?>2"><td><?= $row ?> Devices</td></tr>
</table>
	<?php
	}

}elseif($shc){
	echo "<h2>$shc</h2>\n";

	$query	= GenQuery('configs','s','configs.*,inet_ntoa(devip),cliport','','',array('device'),array('='),array($shc),array(),'LEFT JOIN devices USING (device)');
	$res	= DbQuery($query,$link);
	$cfgok	= DbNumRows($res);
	if ($cfgok == 1) {
		$cfg = DbFetchRow($res);
		DbFreeResult($res);
	}else{
		echo "<h4>$shc: $cfgok $vallbl</h4>";
		die;
	}
	$ucfg	= rawurlencode($cfg[0]);
	$charr	= explode("\n",$cfg[2]);
	$charr	= preg_replace("/^#(.*)$/","<span class='gry'>#$1</span>",$charr);
	$charr	= preg_replace("/(^\s*[0-9]{1,3}\-.*)$/","<span class='drd'>$1</span>",$charr);
	$charr	= preg_replace("/(^\s*[0-9]{1,3}\+.*)$/","<span class='olv'>$1</span>",$charr);
?>
<table class="content"><tr class="<?= $modgroup[$self] ?>2">
<th><img src="img/32/note.png"><br><?= $cfglbl ?> (<?= date($_SESSION['date'],$cfg[3]) ?>)</th>
Example #13
0
</form>
<?php 
if ($ERR) {
    ?>
<div class="textpad warn"><center><b><?php 
    echo $ERR;
    ?>
</b></center></div>
<?php 
}
if ($_POST['~']) {
    $result = DbQuery("SELECT device, devip FROM devices WHERE device REGEXP BINARY '" . $_POST['expression'] . "'", $link);
    ?>
<div class="textpad devConf">
<?php 
    if (DbNumRows($result)) {
        ?>
<b>Hosts matching regular expression '<?php 
        echo $_POST['expression'];
        ?>
':</b><br>
<?php 
        while ($row = DbFetchArray($result)) {
            ?>
<br><?php 
            echo $row['device'];
            ?>
 (<?php 
            echo long2ip($row['devip']);
            ?>
)
Example #14
0
$cico['200'] = "bstp";
$cico['250'] = "bbox";
include_once "inc/header.php";
include_once "inc/libdev.php";
$_GET = sanitize($_GET);
$chg = isset($_GET['chg']) ? $_GET['chg'] : "";
$add = isset($_GET['add']) ? $_GET['add'] : "";
$upd = isset($_GET['upd']) ? $_GET['upd'] : "";
$del = isset($_GET['del']) ? $_GET['del'] : "";
$lst = isset($_GET['lst']) ? $_GET['lst'] : "";
$val = isset($_GET['val']) ? $_GET['val'] : "";
$link = DbConnect($dbhost, $dbuser, $dbpass, $dbname);
if ($chg) {
    $query = GenQuery('stock', 's', '*', '', '', array('serial'), array('='), array($chg));
    $res = DbQuery($query, $link);
    $nitm = DbNumRows($res);
    if ($nitm != 1) {
        echo "<h4>{$chg}: {$nitm} {$vallbl}!</h4>";
        DbFreeResult($res);
    } else {
        $item = DbFetchRow($res);
    }
    DbFreeResult($res);
    $sta = $item[0];
    $sn = $item[1];
    $ty = $item[2];
    $as = $item[3];
    $lo = $item[4];
    $ps = $item[5];
    $pc = $item[6];
    $pn = $item[7];
Example #15
0
</select>
</th>

<th width="80"><input type="submit" value="<?php 
    echo $sholbl;
    ?>
"></th>
</table>
</form>

<?php 
}
if ($dev) {
    $query = GenQuery('configs', 's', 'config,devos', '', '', array('device'), array('='), array($dev), array(), 'LEFT JOIN devices USING (device)');
    $res = DbQuery($query, $link);
    if (DbNumRows($res) != 1) {
        echo "<h4>{$dev}: {$nonlbl}</h4>";
        DbFreeResult($res);
        die;
    }
    $cfg = DbFetchRow($res);
    DbFreeResult($res);
    if ($debug) {
        echo "<div class=\"textpad code warn\">{$cfg['0']}</div>\n";
    }
    ?>
<h2>
<a href="Devices-Config.php?shc=<?php 
    echo urlencode($dev);
    ?>
"><img src="img/16/conf.png" title="<?php 
Example #16
0
function NodDup($ina, $opa, $sta, $lim, $ord)
{
    global $link, $modgroup, $self, $srtlbl, $manlbl, $namlbl, $qtylbl, $duplbl, $typlbl, $totlbl, $nonlbl;
    ?>
<table class="full fixed"><tr><td class="helper">

<h2><?php 
    echo $duplbl;
    ?>
 Node <?php 
    echo $namlbl;
    ?>
</h2>

<?php 
    if ($ord) {
        $ocol = 'devip';
        $srt = "{$srtlbl}: {$namlbl}";
    } else {
        $ocol = 'cnt desc';
        $srt = "{$srtlbl}: {$qtylbl}";
    }
    $query = GenQuery('nodes', 'g', 'name;-;count(*)>1', $ocol, $lim, array('CHAR_LENGTH(name)', $ina), array('>', $opa), array('1', $sta), array('AND'), 'LEFT JOIN devices USING (device)');
    $res = DbQuery($query, $link);
    if (DbNumRows($res)) {
        ?>
<table class="content"><tr class="<?php 
        echo $modgroup[$self];
        ?>
2">
<th width="120"><img src="img/16/abc.png"><br><?php 
        echo $namlbl;
        ?>
</th>
<th><img src="img/16/nods.png"><br>Nodes</th></tr>
<?php 
        $row = 0;
        while ($r = DbFetchRow($res)) {
            if ($row % 2) {
                $bg = "txta";
                $bi = "imga";
            } else {
                $bg = "txtb";
                $bi = "imgb";
            }
            $row++;
            echo "<tr class=\"{$bg}\"><td>{$r['0']}</td><td>";
            echo Bar($r[1], 0) . " <a href=\"Nodes-List.php?in[]=name&op[]==&st[]={$r['0']}\">{$r['1']}</a></td></tr>\n";
        }
        ?>
</table>
<table class="content" >
<tr class="<?php 
        echo $modgroup[$self];
        ?>
2"><td><?php 
        echo $row;
        ?>
 <?php 
        echo $duplbl;
        ?>
 Nodes, <?php 
        echo $srt;
        ?>
</td></tr>
</table>
<?php 
    } else {
        echo "<h5>{$nonlbl}</h5>";
    }
    ?>

</td><td class="helper">

<h2><?php 
    echo $duplbl;
    ?>
 Node MACs</h2>

<?php 
    if ($ord) {
        $ocol = 'mac,vlanid';
        $srt = "{$srtlbl}: MAC, Vlan";
    } else {
        $ocol = 'cnt desc';
        $srt = "{$srtlbl}: Nodes";
    }
    $query = GenQuery('nodes', 'g', 'mac,oui;-;count(*)>1', $ocol, $lim, array($ina), array($opa), array($sta), array(), 'LEFT JOIN devices USING (device)');
    $res = DbQuery($query, $link);
    if (DbNumRows($res)) {
        ?>
<table class="content"><tr class="<?php 
        echo $modgroup[$self];
        ?>
2">
<th colspan="2" width="25%"><img src="img/16/card.png"><br>MAC</th>
<th width="40"><img src="img/16/vlan.png"><br>Vlan</th>
<th><img src="img/16/nods.png"><br>Nodes</th></tr>
<?php 
        $row = 0;
        while ($r = DbFetchRow($res)) {
            if ($row % 2) {
                $bg = "txta";
                $bi = "imga";
            } else {
                $bg = "txtb";
                $bi = "imgb";
            }
            $row++;
            echo "<tr class=\"{$bg}\"><th class=\"{$bi}\"><img src=\"img/oui/" . Nimg($r[1]) . ".png\"></th><td>{$r['0']}</td><td>{$r['1']}</td>\n";
            echo "<td>" . Bar($r[2], 0) . " <a href=Nodes-List.php?in[]=mac&op[]==&st[]={$r['0']}>{$r['2']}</a></td></tr>\n";
        }
        ?>
</table>
<table class="content" >
<tr class="<?php 
        echo $modgroup[$self];
        ?>
2"><td><?php 
        echo $row;
        ?>
 <?php 
        echo $duplbl;
        ?>
 MACs, <?php 
        echo $srt;
        ?>
</td></tr>
</table>
<?php 
    } else {
        echo "<h5>{$nonlbl}</h5>";
    }
    ?>

</td></tr></table>
<p>
<?php 
}
 ><tr bgcolor=#<?php 
    echo $bg2;
    ?>
>
<th valign=bottom><img src=img/32/dumy.png><br>Interface</th>
<th valign=bottom><img src=img/32/dev.png><br>Neighbour</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/fiap.png title="C=CDP,M=Mac,O=Oui,V=VoIP,L=LLDP,S=static"><br>Type</th></tr>
<?php 
    $query = GenQuery('links', 's', '*', 'ifname', '', array('device'), array('='), array($shd));
    $res = @DbQuery($query, $link);
    $row = 0;
    $tpow = 0;
    # China in your hand ;-)
    if (@DbNumRows($res)) {
        while ($l = @DbFetchRow($res)) {
            if ($row % 2) {
                $bg = $bga;
                $bi = $bia;
            } else {
                $bg = $bgb;
                $bi = $bib;
            }
            $row++;
            $tpow += $l[7];
            $ul = rawurlencode($l[3]);
            echo "<tr bgcolor=#{$bg}>";
            echo "<th bgcolor=#{$bi}>{$l['2']}</th><td><a href={$_SERVER['PHP_SELF']}?dev={$ul}>{$l['3']}</a> on {$l['4']} (Vlan{$l['9']} {$l['8']})</td>";
            echo "<td align=right>" . Zfix($l[5]) . "</td><td align=right>{$l['7']}</td>";
            echo "<td align=center>{$l['6']}</td></tr>\n";
foreach (array_keys($devtyp) as $r ){
	echo "<OPTION VALUE=\"$r\" ";
	if($rtr == $r){echo "selected";}
	echo " >$r\n";
}
echo "</select>";
?>
</th><th width=80>
<input type="submit" value="Show">
</th>
</tr></table></form>
<?
if ($rtr) {
	$query	= GenQuery('devices','s','*','','',array('name'),array('='),array($rtr) );
	$res	= @DbQuery($query,$link);
	$ndev	= @DbNumRows($res);
	if ($ndev != 1) {
		echo "<h4>$rtr $n1rmsg</h4>";
		@DbFreeResult($res);
		die;
	}else{
		$dev	= @DbFetchRow($res);
		$ip	= long2ip($dev[1]);
		$sv	= Syssrv($dev[6]);
		$ud = rawurlencode($dev[0]);
		@DbFreeResult($res);
?>
<h2>General Info</h2>
<table class="content">
<tr><th class="imga" width=80>
<a href=Devices-Status.php?dev=<?php 
function Drawlink($x1,$y1,$x2,$y2,$prop) {

	$ida = 0;
	$oda = 0;

	$ltxt = "";
	$itxt = "";

	$slabel  = array();
	$elabel = array();
	
        global $fmt,$link,$lev,$lis,$ifi,$ipi,$lwt,$lix,$liy,$net;
	global $trfw,$trfa,$rrdstep,$rrdpath,$rrdcmd;

        if($x1 == $x2){
                $lix[$x1]+= 2;
                $x1 += $lix[$x1];
                $x2 = $x1;
        }
        if($y1 == $y2){
                $liy[$y1]+= 2;
                $y1 += $liy[$y1];
                $y2 = $y1;
        }

	foreach(array_keys($prop['bw']) as $dv){
		foreach(array_keys($prop['bw'][$dv]) as $if){
			if( preg_match("/[tsm]/",$lis) ){
				$rrd = "$rrdpath/" . rawurlencode($dv) . "/" . rawurlencode($if) . ".rrd";
				if (file_exists($rrd)){
					$rrdif["$dv-$if"] = $rrd;
				}else{
					echo "RRD:$rrd not found!\n";
				}
			}elseif($lis == 'r'){
				$iquery	= GenQuery('interfaces','s','dinoct,doutoct','','',array('device','ifname'),array('=','='),array($dv,$if),array('AND') );
				$ires	= @DbQuery($iquery,$link);
				$nres	= @DbNumRows($ires);
				if ($nres == 1) {
					$trf  = @DbFetchRow($ires);
					$ida += $trf[0];
					$oda += $trf[1];
				}
				@DbFreeResult($ires);
			}
			foreach(array_keys($prop['bw'][$dv][$if]) as $ndv){
				foreach(array_keys($prop['bw'][$dv][$if][$ndv]) as $nif){
					if($lis == 'e'){
						$iquery	= GenQuery('interfaces','s','dinerr,douterr','','',array('device','ifname'),array('=','='),array($dv,$if),array('AND') );
						$ires	= @DbQuery($iquery,$link);
						$nres	= @DbNumRows($ires);
						if ($nres == 1) {
							$err  = @DbFetchRow($ires);
							$ida += $err[0];
							$oda += $err[1];
						}
						$iquery	= GenQuery('interfaces','s','dinerr,douterr','','',array('device','ifname'),array('=','='),array($ndv,$nif),array('AND') );
						$ires	= @DbQuery($iquery,$link);
						$nres	= @DbNumRows($ires);
						if ($nres == 1) {
							$err  = @DbFetchRow($ires);
							$oda += $err[0];
							$ida += $err[1];
						}
						@DbFreeResult($ires);
					}
					if($ipi){
						if($net[$dv][$if])  {$ia = $net[$dv][$if];}
						if($net[$ndv][$nif]){$nia= $net[$ndv][$nif];}
					}
					if($ifi){
						if($lev == "f"){
							$in = $if;
							$nin= $nif;
						}else{
							$in = "$dv $if";
							$nin= "$ndv $nif";
						}
					}
					if ($ifi or $ipi){
						array_push($slabel,"$in $ia");
						array_push($elabel,"$nin $nia");
					}
					$bw  += $prop['bw'][$dv][$if][$ndv][$nif];
					$nbw += $prop['nbw'][$dv][$if][$ndv][$nif];
				}
			}
		}
	}
	$xl   = intval($x1  + $x2) / 2;
	$yl   = intval($y1  + $y2) / 2;
	$xi1  = intval($x1+($x2-$x1)/(1 + $lwt/10));
	$xi2  = intval($x2+($x1-$x2)/(1 + $lwt/10));
	$yi1  = intval($y1+($y2-$y1)/(1 + $lwt/10));
	$yi2  = intval($y2+($y1-$y2)/(1 + $lwt/10));
	$bwtxt= ZFix($bw) . "/" . ZFix($nbw);

	if($lis == 'r'){
		if($bw and $nbw){
			$ri = round($ida*800/$bw/$rrdstep);
			$ro = round($oda*800/$nbw/$rrdstep);
			if ($ri > intval($trfa + (100 - $trfa)/2) ){
				$lico = "red";
			}elseif ($ri > $trfa){
				$lico = "orange";
			}elseif ($ri > intval($trfw + $trfw/2) ){
				$lico = "purple";
			}elseif ($ri > $trfw){
				$lico = "blue";
			}else{
				$lico = "limegreen";
			}
			if ($ro > intval($trfa + (100 - $trfa)/2) ){
				$loco = "red";
			}elseif ($ro > $trfa){
				$loco = "orange";
			}elseif ($ro > intval($trfw + $trfw/2) ){
				$loco = "purple";
			}elseif ($ro > $trfw){
				$loco = "blue";
			}else{
				$loco = "limegreen";
			}
		}else{
			$lico = "gray";
			$loco = "gray";
			$ri   = "-";
			$ro   = "-";
		}
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$xl\" y2=\"$yl\" stroke=\"$lico\" stroke-width=\"4\"/>\n";
			$ltxt .= "	<line x1=\"$xl\" y1=\"$yl\" x2=\"$x2\" y2=\"$y2\" stroke=\"$loco\" stroke-width=\"4\"/>\n";
			$ltxt .= "	<text x=\"$xi2\" y=\"".($yi2-8)."\">${ri}%</text>\n";
			$ltxt .= "	<text x=\"$xi2\" y=\"".($yi1-8)."\">${ro}%</text>\n";
		}else{
			$ltxt .= "Imagesetthickness(\$image,4);\n";
			$ltxt .= "Imageline(\$image,$x1,$y1,$xl,$yl,\$$lico);\n";
			$ltxt .= "Imageline(\$image,$xl,$yl,$x2,$y2,\$$loco);\n";
			$ltxt .= "Imagesetthickness(\$image, 1);\n";
			$itxt .= "ImageString(\$image, 1,$xi2,".($yi2-8).",\"${ri}%\", \$black);\n";
			$itxt .= "ImageString(\$image, 1,$xi1,".($yi1-8).",\"${ro}%\", \$black);\n";
		}
	}elseif($lis == 'e'){
		if ($ida > $rrdstep ){
			$lico = "red";
		}elseif ($ida > intval($rrdstep/60) ){
			$lico = "orange";
		}elseif ($ida > 1){
			$lico = "blue";
		}else{
			$lico = "limegreen";
		}
		if ($oda > $rrdstep ){
			$loco = "red";
		}elseif ($oda > intval($rrdstep/60) ){
			$loco = "orange";
		}elseif ($oda > 1){
			$loco = "blue";
		}else{
			$loco = "limegreen";
		}
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$xl\" y2=\"$yl\" stroke=\"$lico\" stroke-width=\"4\"/>\n";
			$ltxt .= "	<line x1=\"$xl\" y1=\"$yl\" x2=\"$x2\" y2=\"$y2\" stroke=\"$loco\" stroke-width=\"4\"/>\n";
			$ltxt .= "	<text x=\"$xi2\" y=\"".($yi2-8)."\">$ida</text>\n";
			$ltxt .= "	<text x=\"$xi2\" y=\"".($yi1-8)."\">$oda</text>\n";
		}else{
			$ltxt .= "Imagesetthickness(\$image,4);\n";
			$ltxt .= "Imageline(\$image,$x1,$y1,$xl,$yl,\$$lico);\n";
			$ltxt .= "Imageline(\$image,$xl,$yl,$x2,$y2,\$$loco);\n";
			$ltxt .= "Imagesetthickness(\$image, 1);\n";
			$itxt .= "ImageString(\$image, 1,$xi2,".($yi2-8).",\"$ida\", \$black);\n";
			$itxt .= "ImageString(\$image, 1,$xi1,".($yi1-8).",\"$oda\", \$black);\n";
		}
	}elseif($bw == 11000000 or $bw == 54000000){
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" stroke=\"cornflowerblue\" stroke-dasharray=\"3,3\"/>\n";
		}else{
			$ltxt .= "imagesetstyle(\$image,array(\$navy,\$blue,\$cornflowerblue,\$wte,\$wte) );\n";
			$ltxt .= "Imageline(\$image,$x1,$y1,$x2,$y2,IMG_COLOR_STYLED);\n";
		}
	}elseif($bw < 10000000){
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" stroke=\"limegreen\" />\n";
		}else{
			$ltxt .= "Imageline(\$image,$x1,$y1,$x2,$y2,\$limegreen);\n";
		}
	}elseif($bw < 100000000){
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" stroke=\"blue\" />\n";
		}else{
			$ltxt .= "Imageline(\$image,$x1,$y1,$x2,$y2,\$blue);\n";
		}
	}elseif($bw < 1000000000){
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" stroke=\"purple\" />\n";
		}else{
			$ltxt .= "Imageline(\$image,$x1,$y1,$x2,$y2,\$purple);\n";
		}
	}elseif($bw == 1000000000){
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" stroke=\"orange\" />\n";
		}else{
			$ltxt .= "Imageline(\$image,$x1,$y1,$x2,$y2,\$orange);\n";
		}
	}else{
		$lt = ($bw/1000000000 < 10)?($bw/1000000000):10;
		if($fmt == "svg"){
			$ltxt .= "	<line x1=\"$x1\" y1=\"$y1\" x2=\"$x2\" y2=\"$y2\" stroke=\"red\" stroke-width=\"$lt\"/>\n";
		}else{
			$ltxt .= "imagesetthickness(\$image,$lt);\n";
			$ltxt .= "Imageline(\$image,$x1,$y1,$x2,$y2,\$red);\n";
			$ltxt .= "Imagesetthickness(\$image, 1);\n";
		}
	}

	if($lis	and is_array($rrdif) ){
		$opts = GraphOpts($lis,0,'Link Traffic',$bw);
		list($drawin,$drawout,$tit) = GraphTraffic($rrdif,'trf');
		exec("$rrdcmd graph log/$xl$yl.png -a PNG $opts $drawin $drawout");
		if($lis == "t"){
			if($fmt == "svg"){
				$itxt .= "	<text x=\"".($xl-16)."\" y=\"".($yl-18)."\" fill=\"green\">$bwtxt</text>\n";
			}else{
				$itxt .= "ImageString(\$image, 1,".($xl-16).", ".($yl-18).", \"$bwtxt\", \$green);\n";
			}
		}
		if($fmt == "svg"){
				$itxt .= "	<text x=\"".($xl-16)."\" y=\"".($yl-18)."\" fill=\"green\">no RRDs in SVG!</text>\n";
		}else{
			$ltxt .= "\$icon = Imagecreatefrompng(\"$xl$yl.png\");\n";
			$ltxt .= "\$w = Imagesx(\$icon);\n";
			$ltxt .= "\$h = Imagesy(\$icon);\n";
			$ltxt .= "Imagecopy(\$image, \$icon,$xl-\$w/2,$yl-\$h/2,0,0,\$w,\$h);\n";
			$ltxt .= "Imagedestroy(\$icon);\n";
			$ltxt .= "unlink(\"$xl$yl.png\");\n";
		}
	}elseif( preg_match("/[rw]/",$lis) ){
		if($fmt == "svg"){
			$itxt .= "	<text x=\"".($xl-16)."\" y=\"$yl\" fill=\"green\">$bwtxt</text>\n";
		}else{
			$itxt .= "ImageString(\$image, 1, ".($xl-16).",$yl, \"$bwtxt\", \$green);\n";
		}
	}
	$yof = 0;
	foreach ($slabel as $i){
		$i = preg_replace('/[$&]/','.', $i);
		if($fmt == "svg"){
			$itxt .= "	<text x=\"$xi2\" y=\"".($yi2+$yof)."\" fill=\"green\">$i</text>\n";
		}else{
			$itxt .= "ImageString(\$image, 1, $xi2, ".($yi2+$yof).", \"$i\", \$green);\n";
		}
		$yof += 8;
	}
	$yof = 0;
	foreach ($elabel as $i){
		if($fmt == "svg"){
			$itxt .= "	<text x=\"$xi1\" y=\"".($yi1+$yof)."\" fill=\"green\">".Safelabel($i)."</text>\n";
		}else{
			$itxt .= "ImageString(\$image, 1, $xi1, ".($yi1+$yof).", \"".Safelabel($i)."\", \$green);\n";
		}
		$yof += 8;
	}
	return array($ltxt,$itxt);
}
Example #20
0
		$locex = 1;
		list($id,$x,$y,$ns,$ew,$com) = DbFetchRow($res);
		$geost = ($dem)?"$com, $geost":$nam;
	}else{
		$locex = 0;
		$geost = ($dem)?"$cty, $geost":$nam;
		$com = "$place[c], ".count(array_keys($lopt[$reg][$cty]))." buildings ($now)";
	}
}
if($bld){
	$z   = "16";
	$nam = "$bld $cty, $reg";
	if(!$map) $bgm = TopoMap($reg,$cty);
	$ico = preg_match("/$redbuild/",$bld)?'img/bldsr.png':'img/blds.png';
	$res = DbQuery( GenQuery('locations','s','id,x,y,ns,ew,locdesc','','',array('region','city','building'),array('=','=','='),array($reg,$cty,$bld),array('AND','AND') ),$link);
	if ( DbNumRows($res) == 1){
		$locex = 1;
		list($id,$x,$y,$ns,$ew,$com) = DbFetchRow($res);
		$geost = ($dem)?"$com $geost":$nam;
	}else{
		$locex = 0;
		$geost = ($dem)?"$bld $geost":$nam;
		$com = "$place[b], ".$lopt[$reg][$cty][$bld] ." devices ($now)";
	}
}
DbFreeResult($res);
$ns /= 10000000;
$ew /= 10000000;

?>
<h1>Topology <?= $loclbl ?> Editor</h1>
			$loc	= $d[5];
			$con	= $d[6];
			$cli	= $d[7];
			$img	= $d[8];
		}
		echo " >$d[0]\n";
	}
	DbFreeResult($res);
}else{
	print DbError($link);
}
echo "</select>";
if ($dev) {
	$query	= GenQuery('vlans','s','*','vlanid','',array('device'),array('='),array($dev) );
	$res	= DbQuery($query,$link);
	$nvln	= DbNumRows($res);

	if($res and $nvln){
?>
 Vlan
<select size="1" name="vln">
<option value="">---
<?php

		while( ($v = DbFetchRow($res)) ){
			echo "<OPTION VALUE=\"$v[1]\" ";
			if($vln == $v[1]){echo "selected";}
			echo " >$v[1] $v[2]\n";
		}
		DbFreeResult($res);
		echo "</select>";
Example #22
0
<tr class="<?= $modgroup[$self] ?>2"><td><?= $row ?> Links <?= $totlbl ?></td></tr>
</table>
<?php
}else{
?>
<h2>
<?= ($isadmin)?"<a href=\"Topology-Linked.php?dv=$ud\"><img src=\"img/16/ncon.png\" title=\"".(($verb1)?"$edilbl Links":"Links $edilbl")."\"></a>":"" ?> 
Links</h2>
<h5><?= $nonlbl ?></h5>
<?php
}

if ($rver){
	$query = GenQuery('vlans','s','*','vlanid','',array('device'),array('='),array($shd) );
	$res   = DbQuery($query,$link);
	if( DbNumRows($res) ){
?>
<h2>
<a href="Devices-Vlans.php?in[]=device&op[]==&st[]=<?= $ud ?>"><img src="img/16/vlan.png" title="Vlan <?= $lstlbl ?>"></a>
Vlans</h2>

<table class="content" >
<tr class="<?= $modgroup[$self] ?>2">
<th valign="bottom" width="80"><img src="img/16/vlan.png" title="SSIDs on some Wlan Controllers"><br>Vlan</th>
<th valign="bottom"><img src="img/16/say.png"><br><?= $namlbl ?></th></tr>
</table>
<div class="scroller">
<table class="content" >
<?php
		$row  = 0;
		while( $v = DbFetchRow($res) ){
Example #23
0
 if ($ldapmap[1] and in_array($ldapmap[1], $ldapusersgrp)) {
     $_SESSION['group'] .= "net,";
 }
 if ($ldapmap[2] and in_array($ldapmap[2], $ldapusersgrp)) {
     $_SESSION['group'] .= "dsk,";
 }
 if ($ldapmap[3] and in_array($ldapmap[3], $ldapusersgrp)) {
     $_SESSION['group'] .= "mon,";
 }
 if ($ldapmap[4] and in_array($ldapmap[4], $ldapusersgrp)) {
     $_SESSION['group'] .= "mgr,";
 }
 if ($ldapmap[5] and in_array($ldapmap[5], $ldapusersgrp)) {
     $_SESSION['group'] .= "oth,";
 }
 if (DbNumRows($res) > 0) {
     $_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)];
Example #24
0
function DbCoords($r = '', $c = '', $b = '')
{
    global $mapbg, $link;
    $query = GenQuery('locations', 's', 'x,y,locdesc', '', '', array('region', 'city', 'building'), array('=', '=', '='), array($r, $c, $b), array('AND', 'AND'));
    $res = DbQuery($query, $link);
    $nloc = DbNumRows($res);
    if (!$c) {
        $r = "";
    } elseif (!$b) {
        $c = "";
    }
    # Clear those for Topomap()
    if ($nloc == 1 and $mapbg == TopoMap($r, $c)) {
        return DbFetchRow($res);
    }
}
                        $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;
            ?>
 >
<tr bgcolor=#<?php 
                echo "<td><table bgcolor=#666666 {$tabtag}><tr bgcolor=#{$bg2}><th colspan=2>{$tab['0']}</th><th>NULL</th><th>KEY</th></tr>\n";
                $cres = DbQuery(GenQuery($tab[0], "c"), $dblink);
                $row = 0;
                while ($c = DbFetchRow($cres)) {
                    if ($row % 2) {
                        $bg = $bga;
                        $bi = $bia;
                    } else {
                        $bg = $bgb;
                        $bi = $bib;
                    }
                    $row++;
                    echo "<tr bgcolor=#{$bg}><th bgcolor=#{$bi} align=left>{$c['0']}</th><td>{$c['1']}</td><td>{$c['2']}</td><td>{$c['3']}</td></tr>\n";
                }
                $nres = DbQuery(GenQuery($tab[0], "s"), $dblink);
                echo "<tr bgcolor=#{$bg2}><th colspan=4>" . DbNumRows($nres) . " Records</th></tr>";
                echo "</table></td>";
                $col++;
            }
            echo "</td></tr></table>\n";
        }
    }
}
// Now the database connection can be closed
@DbClose($dblink);
// This is the footer on the very bottom of the page
include_once "inc/footer.php";
//================================================================================
// Name: DbDump()
//
// Description: Creates a MySQL dump of a given set of database tables.
Example #27
0
 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);
 }
 if (in_array("graph", $col)) {
     echo "<td nowrap align=center>\n";
            $ip = long2ip($d[1]);
            $sv = Syssrv($d[2]);
            $comm = $d[3];
            $img = $d[4];
        }
        echo " >{$d['0']}\n";
    }
    @DbFreeResult($res);
} else {
    print @DbError($link);
}
echo "</select>";
if ($dev) {
    $query = GenQuery('vlans', 's', '*', '', '', array('device'), array('='), array($dev));
    $res = @DbQuery($query, $link);
    $nvln = @DbNumRows($res);
    if ($res and $nvln) {
        ?>
 Vlan
<SELECT size=1 name="vln">
<OPTION VALUE="">---
<?php 
        while ($v = @DbFetchRow($res)) {
            echo "<OPTION VALUE=\"{$v['1']}\" ";
            if ($vln == $v[1]) {
                echo "selected";
            }
            echo " >{$v['1']} {$v['2']}\n";
        }
        @DbFreeResult($res);
        echo "</select>";
        $uti = rawurlencode($l[3]);
        echo "<tr bgcolor=#{$bg}><th bgcolor=#{$bi}>{$row}</th><td>" . date($datfmt, $l[1]) . "</td>\n";
        echo "<td><a href=Devices-Status.php?dev={$utd}&shp=on>{$l['2']}</a></td><td>";
        echo "<a href=Nodes-List.php?ina=device&opa==&sta={$utd}&cop=AND&inb=ifname&opb==&stb={$uti}>{$l['3']}</td><td>{$l['4']}</td><td>{$l['5']}</td></tr>\n";
    }
    @DbFreeResult($res);
    echo "</table><table bgcolor=#666666 {$tabtag} >\n";
    echo "<tr bgcolor=#{$bg2}><td>{$row} IF changes in total</td></tr></table>\n";
    echo '</td></tr></table>';
    include_once "inc/footer.php";
} elseif ($wol) {
    if (preg_match("/dsk/", $_SESSION['group'])) {
        $link = @DbConnect($dbhost, $dbuser, $dbpass, $dbname);
        $query = GenQuery('nodes', 's', '*', '', '', array('mac'), array('='), array($wol));
        $res = @DbQuery($query, $link);
        $nnod = @DbNumRows($res);
        if ($nnod != 1) {
            echo "<h4>{$wol} {$n1rmsg}</h4>";
            @DbFreeResult($res);
            die;
        } else {
            $n = @DbFetchRow($res);
            @DbFreeResult($res);
            $ip = long2ip($n[1]);
        }
        wake($ip, $wol, 9);
    } else {
        echo $nokmsg;
    }
    ?>
<h5>Magic Packet sent to <?php 
         $row++;
         $ud = rawurlencode($v[0]);
         echo "<tr bgcolor=#{$bg}>";
         if (in_array("device", $col)) {
             echo "<td><a href=Devices-Status.php?dev={$ud}>{$v['0']}</a></td>\n";
         }
         if (in_array("vlanid", $col)) {
             echo "<td>{$v['1']}</td>";
         }
         if (in_array("vlanname", $col)) {
             echo "<td>{$v['2']}</td>";
         }
         if (in_array("pop", $col)) {
             $nquery = GenQuery('nodes', 'g', 'vlanid', '', '', array('device', 'vlanid'), array('=', '='), array($v[0], $v[1]), array('AND'));
             $np = @DbQuery($nquery, $link);
             $nnp = @DbNumRows($np);
             if ($nnp == 1) {
                 $vpop = @DbFetchRow($np);
                 $pbar = Bar($vpop[1], 110);
                 echo "<td>{$pbar} <a href=Nodes-List.php?ina=device&opa==&sta={$v['0']}&inb=vlanid&opb==&stb={$v['1']}&cop=AND>{$vpop['1']}</td>";
             } else {
                 echo "<td></td>";
             }
             @DbFreeResult($np);
         }
         echo "</tr>\n";
     }
     @DbFreeResult($res);
 } else {
     print @DbError($link);
 }