Пример #1
0
}
?>
<h2><?= $usrlbl ?> <?= $lstlbl ?></h2>

<?php
TblHead("$modgroup[$self]2",2);

if ($grp){
	$query	= GenQuery('users','s','*',$ord,'',array('groups'),array('&'),array($grp) );
}else{
	$query	= GenQuery('users','s','*',$ord );
}
$res	= DbQuery($query,$link);
if($res){
	$row = 0;
	while( ($usr = DbFetchRow($res)) ){
		if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";}
		$row++;
		list($cc,$lc) = Agecol($usr[5],$usr[6],$row % 2);
		TblRow($bg);
?>
<th class="<?= $bi ?>">
<?=Smilie($usr[0]) ?><br><?= $usr[0] ?></th>
<td nowrap><?= $usr[3] ?></td>
<td nowrap><?= $usr[4] ?></td>
<td nowrap><?= $usr[7] ?></td>
<td bgcolor="#<?= $cc ?>"><?= (date($datfmt,$usr[5])) ?></td>
<td bgcolor="#<?= $lc ?>"><?= (date($datfmt,$usr[6])) ?></td>
<td>
<?php  if( !($usr[2] & 1) ) { ?>
<form method="get">
Пример #2
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";
}
     $bi = $bia;
 } else {
     $row = "1";
     $bg = $bgb;
     $bi = $bib;
 }
 $fs = rawurlencode(date("m/d/Y H:i:s", $istart));
 $fe = rawurlencode(date("m/d/Y H:i:s", $iend));
 echo "<tr bgcolor=#{$bg}>\n";
 echo "<th bgcolor=#{$bi}><a href=Monitoring-Messages.php?ina=time&opa=%3E=&sta={$fs}&cop=AND&inb=time&opb=%3C&stb={$fe}>" . date("j.M G:i", $istart) . "</a></th><td>\n";
 if ($det) {
     $query = GenQuery('messages', 'g', 'level', '', '', array('time', 'time'), array('>=', '<'), array($istart, $iend), array('AND'));
     $res = @DbQuery($query, $link);
     if ($res) {
         $nmsg = 0;
         while ($m = @DbFetchRow($res)) {
             $mbar = Bar($m[1], 0, 1);
             echo "<a href=Monitoring-Messages.php?ina=time&opa=%3E=&sta={$fs}&cop=AND&inb=time&opb=%3C&stb={$fe}&lvl={$m['0']}>";
             echo "<img src=img/16/" . $mico[$m[0]] . ".png title=\"" . $mlvl[$m[0]] . "\" border=0></a>{$mbar} \n";
             $nmsg += $m[1];
         }
         if (!$nmsg) {
             echo "<img src=img/16/fogy.png title=\"All Messages\"> ";
         }
         $tmsg += $nmsg;
         echo "{$nmsg}</td></tr>\n";
         @DbFreeResult($res);
     } else {
         print @DbError($link);
     }
 } else {
Пример #4
0
    $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;
?>
 >
<tr bgcolor=#<?php 
echo $bg1;
Пример #5
0
        }
        echo " >{$d['0']}\n";
    }
    @DbFreeResult($res);
} else {
    print @DbError($link);
}
?>
</select>
<select multiple size=6 name="if[]">
<?php 
if ($dv) {
    $query = GenQuery('interfaces', 's', 'ifname,alias,comment', 'ifname', '', array('device'), array('='), array($dv));
    $res = @DbQuery($query, $link);
    if ($res) {
        while ($i = @DbFetchRow($res)) {
            echo "<OPTION VALUE=\"{$i['0']}\" ";
            if (in_array($i[0], $if)) {
                echo "selected";
            }
            echo " >{$i['0']} " . substr("{$i['1']} {$i['2']}\n", 0, 30);
        }
        @DbFreeResult($res);
    }
}
?>
</select>
</th>
<td>
<INPUT type="checkbox" name="cpu" <?php 
echo $cpu ? "checked" : "";
Пример #6
0
echo $bg2;
?>
>
<th colspan=2><img src=img/32/key.png><br>Serial #</th>
<th><img src=img/32/fiap.png><br>Type</th>
<th><img src=img/32/smil.png><br>Added by</th>
<th><img src=img/32/clock.png><br>Added on</th>
<th><img src=img/32/glob.png><br>Location</th>
<th><img src=img/32/idea.png><br>Action</th></tr>

<?php 
$query = GenQuery('stock', 's', '*', 'type');
$res = @DbQuery($query, $link);
if ($res) {
    $row = 0;
    while ($dev = @DbFetchRow($res)) {
        if ($row % 2) {
            $bg = $bgb;
            $bi = $bib;
        } else {
            $bg = $bga;
            $bi = $bia;
        }
        $row++;
        $img = "genh.png";
        $ud = rawurlencode($dev[0]);
        $da = date("j.M (G:i)", $dev[3]);
        list($a1c, $a2c) = Agecol($dev[3], $dev[3], $row % 2);
        echo "<tr bgcolor=#{$bg}><th bgcolor=#{$bi}><img src=img/16/" . $cico[$dev[5]] . ".png title=" . $stco[$dev[5]] . "></th><td>{$dev['0']}</td>\n";
        echo "<td>{$dev['1']}</td><td>{$dev['2']}</td><td bgcolor=#{$a1c}>{$da}</td><td>{$dev['4']}</td>\n";
        echo "<td align=center><a href={$_SERVER['PHP_SELF']}?del={$ud}><img src=img/16/bcnl.png border=0 onclick=\"return confirm('Delete {$dev['0']} from stock?')\" title=\"Delete this device!\"></a></td>\n";
Пример #7
0
<th><img src=img/32/powr.png title="PoE consumption in mW"><br>Power</th>
<th><img src=img/32/dev.png><br>Neighbour</th>
<th><img src=img/32/dumy.png><br>Interface</th>
<th><img src=img/32/idea.png><br>Action</th></tr>
</tr>
<?php 
    if ($typ) {
        $query = GenQuery('links', 's', '*', 'ifname', '', array('type'), array('='), array($typ));
    } else {
        $query = GenQuery('links', 's', '*', 'ifname', '', array('device'), array('='), array($dv));
    }
    $res = @DbQuery($query, $link);
    if ($res) {
        $nli = 0;
        $row = 0;
        while ($l = @DbFetchRow($res)) {
            $ud = urlencode($l[1]);
            $un = urlencode($l[3]);
            if ($row % 2) {
                $bg = $bga;
                $bi = $bia;
            } else {
                $bg = $bgb;
                $bi = $bib;
            }
            $row++;
            echo "<tr bgcolor=#{$bg}><td><a href=Devices-Status.php?dev={$ud}>{$l['1']}</a></td><td>{$l['2']}</td>\n";
            echo "<th>{$l['6']}</th>\n";
            echo "<td align=right>" . Zfix($l[5]) . "</td>\n";
            echo "<td align=right>{$l['7']}</td>";
            echo "<td><a href=Devices-Status.php?dev={$un}>{$l['3']}</a></td><td>{$l['4']} (Vlan{$l['9']} {$l['8']})</td>\n";
Пример #8
0
<head>
<title>NeDi Find Me</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<link href="inc/print.css" type="text/css" rel="stylesheet">
<link rel="shortcut icon" href="img/favicon.ico">
</head>

<body>

<?php 
$link = DbConnect($dbhost, $dbuser, $dbpass, $dbname);
$query = GenQuery('nodes', 's', 'nodes.*,location,speed,duplex,pvid,dinoct,doutoct,dinerr,douterr,dindis,doutdis,dinbrc', 'lastseen', '1', array('nodip'), array('='), array(ip2long($_SERVER[REMOTE_ADDR])), array(), 'LEFT JOIN devices USING (device) LEFT JOIN interfaces USING (device,ifname)');
$res = DbQuery($query, $link);
if ($res) {
    $n = DbFetchRow($res);
    if ($n[2]) {
        $img = Nimg($n[3]);
        $l = explode($locsep, $n[23]);
        echo "<table class=\"mon2\">";
        echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/oui/{$img}.png\" title=\"{$n['3']}\"></th><td><b>{$n['0']}</b></td><td class=\"mrn code\">{$n['2']}</td></tr>\n";
        echo "<tr class=\"txtb\"><th class=\"imgb\" width=\"20\"><img src=\"img/16/net.png\" title=\"Network\"></th><td class=\"blu code\">" . long2ip($n[1]) . "</td><td class=\"prp code\">" . ($n[16] ? inet_ntop($n[16]) : '') . "</td></tr>\n";
        echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/16/dev.png\" title=\"Device\"></th><td>{$n['6']}</td><td>{$l['2']} {$l['3']}</td></tr>\n";
        echo "<tr class=\"txtb\"><th class=\"imgb\" width=\"20\"><img src=\"img/16/port.png\" title=\"Interface\"></th><td>{$n['7']}</td><td>" . DecFix($n[24]) . "-{$n['25']} vl{$n['8']}</td></tr>\n";
        echo "<tr class=\"txta\"><th class=\"imga\" width=\"20\"><img src=\"img/16/grph.png\" title=\"In/Out\"></th><td colspan=\"2\">Traffic: <b class=\"blu code\">" . DecFix($n[27]) . "/" . DecFix($n[28]) . "</b> Errors:<b class=\"drd code\"> " . DecFix($n[29]) . "/" . DecFix($n[30]) . "</b> Discards:<b class=\"prp code\">" . DecFix($n[31]) . "/" . DecFix($n[32]) . " </b> Bcast:<b class=\"dgy code\"> " . DecFix($n[33]) . "</b></td></tr>\n";
        echo "</table>";
    } else {
        echo "<h4>{$_SERVER['REMOTE_ADDR']} was not found</h4>";
    }
    DbFreeResult($res);
} else {
Пример #9
0
	if ($ccc[1] == "") {
		$color = "blue";
		$ccc_message = "Unknown";
	}
			echo "<td align=right>-</td><td><b>$d[1]</b></td><td>$d[2]</td><td><font color=$color>$ccc_message</font></td></tr>\n";

			$mquery	= GenQuery('modules','s','*','slot','',array('device'),array('='),array($d[0]));
			$mres	= DbQuery($mquery,$link);
			if($mres){
				while( ($m = DbFetchRow($mres)) ){
					if ($row % 2){$bg = "txta";}else{$bg = "txtb";}
					$row++;
					echo "<tr class=\"$bg\"><th>\n";
					$query_ccc = "SELECT service_level,contract_number,end_date,DATEDIFF(STR_TO_DATE(end_date, '%d-%b-%Y'),CURDATE()) FROM cisco_contracts WHERE serial_number=\"$m[4]\"";
					$res_ccc = DbQuery($query_ccc,$link_ccc);
					$ccc = DbFetchRow($res_ccc);
					if ($ccc[3] > 30) {
						$color = "green";
						$ccc_message = "$ccc[0]<br>Contract #$ccc[1] valid till $ccc[2]";
					} elseif ($ccc[3] > 1) {
						$color = "darkyellow";
						$ccc_message = "$ccc[0]<br>Contract #$ccc[1] valid till $ccc[2]";
					} else {
						$color = "red";
						$ccc_message = "$ccc[0]<br>Contract #$ccc[1] expired since $ccc[2]";
					}
					if ($ccc[1] == "") {
						$color = "blue";
						$ccc_message = "Unknown";
					}
					echo "<td align=right>$m[1]</td><td><b>$m[2]</b> $m[3]</td><td>$m[4]</td><td><font color=$color>$ccc_message</font></td></tr>\n";
Пример #10
0
<?php 
    $row = 0;
    while ($s = @DbFetchRow($res)) {
        if ($row % 2) {
            $bg = $bga;
            $bi = $bia;
        } else {
            $bg = $bgb;
            $bi = $bib;
        }
        $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 = "";
        list($s1c, $s2c) = Agecol($s[6], $s[6], $row % 2);
        if ($n[5] > $s[6]) {
?>
</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 
echo $ud;
?>
 ><img src="img/dev/<?php 
echo $dev[18];
?>
.png" title="<?php 
Пример #12
0
    print DbError($lnk);
    die;
}
$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;
Пример #13
0
<?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 = "";
        list($s1c, $s2c) = Agecol($s[6], $s[6], $row % 2);
        if ($n[5] > $s[6]) {
Пример #14
0
	?>
</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>
<th><img src="img/32/news.png"><br><?= $chglbl ?></th></tr>
<tr class="txta"><td valign="top">
Пример #15
0
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 );
}
Пример #16
0
		$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>
<form method="get" action="<?= $self ?>.php" name="lof">
<table class="content" ><tr class="<?= $modgroup[$self] ?>1">
Пример #17
0
 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,";
     }
     if ($usr[5]) {
         $_SESSION['group'] .= "mon,";
     }
Пример #18
0
<?php
	if($pop){
?>
<th valign="bottom"><img src="img/16/nods.png"><br><?= (substr($poplbl,0,3)) ?></th>
<?php
		$query	= GenQuery('nodes','g','ifname','','',array('device'),array('='),array($shd) );
		$res	= DbQuery($query,$link);
		if($res){
			while( ($nc = DbFetchRow($res)) ){
				$ncount[$nc[0]] = $nc[1];
			}
		}
		$query	= GenQuery('iftrack','g','mac,ifupdate,ifname','','',array('device'),array('='),array($shd) );
		$res	= DbQuery($query,$link);
		if($res){
			while( ($nl = DbFetchRow($res)) ){
				$niflog[$nl[2]] = "$nl[0] $laslbl ". date($datfmt,$nl[1]);
			}
		}
	}
	if($shg and $_SESSION['gsiz']){
?>
<th valign="bottom"><img src="img/16/grph.png"><br>IF <?= $gralbl ?></th>
<?php
	}else{
		$rrdt = ($rrdstep/60)." $tim[i]";
?>
<th valign="bottom"><img src="img/16/bbup.png" title="Octets/<?= $rrdt ?>"><br><?= (substr($inblbl,0,3)) ?></th>
<th valign="bottom"><img src="img/16/bbdn.png" title="Blue: Abs <?= $trflbl ?>"><br><?= (substr($oublbl,0,3)) ?></th>
<th valign="bottom"><img src="img/16/brup.png" title=" <?= $errlbl ?>/<?= $rrdt ?>"><br><?= (substr($inblbl,0,3)) ?></th>
<th valign="bottom"><img src="img/16/brdn.png" title="Red: <?= $mullbl ?> <?= $errlbl ?>"><br><?= (substr($oublbl,0,3)) ?></th>
Пример #19
0
?>
<option value="tmp"<?= (in_array("tmp",$if))?" selected":"" ?>> <?= $tmplbl ?>
<?php
}
if($ct != "-"){
?>
<option value="cuv"<?= (in_array("cuv",$if))?" selected":"" ?>> <?= $ct ?>
<?php
}
?>
<option value="" style="color: blue">- Interfaces -
<?php
	$query	= GenQuery('interfaces','s','ifname,alias,comment','ifidx','',array('device'),array('='),array($dv) );
	$res	= DbQuery($query,$link);
	if($res){
		while( ($i = DbFetchRow($res)) ){
			echo "<option value=\"$i[0]\" ";
			if(in_array($i[0],$if)){echo "selected";}
			echo " >$i[0] " . substr("$i[1] $i[2]\n",0,30);
		}
		DbFreeResult($res);
	}
?>
</select>

<select multiple size="6" name="it[]">
<option value="t"<?= (in_array("t",$it))?" selected":"" ?>> <?= $trflbl ?>
<option value="e"<?= (in_array("e",$it))?" selected":"" ?>> <?= $errlbl ?>
<option value="d"<?= (in_array("d",$it))?" selected":"" ?>> Discards
<option value="b"<?= (in_array("b",$it))?" selected":"" ?>> Broadcast
<option value="s"<?= (in_array("s",$it))?" selected":"" ?>> <?= $stalbl ?>
Пример #20
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);
    }
}
        echo $tabtag;
        ?>
 ><tr bgcolor=#<?php 
        echo $bg2;
        ?>
>
<th width=10%><img src=img/32/say.png><br>Source</th>
<th><img src=img/32/umgr.png><br>Contact</th>
<th><img src=img/32/say.png><br>Messages</th>
</tr>
<?php 
        $rord = $ord ? " desc" : "";
        $query = GenQuery('messages', 'g', 'source,level', "source{$rord}");
        $res = @DbQuery($query, $link);
        if ($res) {
            while ($s = @DbFetchRow($res)) {
                $source[$s[0]][$s[1]] = $s[2];
            }
            @DbFreeResult($res);
        } else {
            print @DbError($link);
            die;
        }
        $row = 0;
        foreach (array_keys($source) as $s) {
            if ($row % 2) {
                $bg = $bga;
                $bi = $bia;
            } else {
                $bg = $bgb;
                $bi = $bib;
Пример #22
0
function DbCsv($res, $sep, $quotes, $outfile)
{
    // The CSV file is created and opened
    $csvfile = fopen($outfile, "w");
    // The rows of the given result are processed one after the other
    while ($row = DbFetchRow($res)) {
        $csv = "";
        // Each element is added to the string individually
        foreach ($row as $field) {
            // If quotes are wished, they are put around the element
            if ($quotes == "on") {
                $csv .= "\"";
            }
            $csv .= $field;
            if ($quotes == "on") {
                $csv .= "\"";
            }
            $csv .= $sep;
        }
        // The last separator of a line is always cut off
        $csv = trim($csv, $sep);
        // For each row a single line of the file is used
        $csv .= "\r\n";
        // After having prepared the CSV row, it is written to the file
        fwrite($csvfile, $csv);
    }
    // When finished, the CSV file is closed
    fclose($csvfile);
}
Пример #23
0
         $_POST['pass'] = $form_pass;
         $pass = hash("sha256", "NeDi" . $user . $_POST['pass']);
         # Salt & pw
         $query = GenQuery('users', 's', '*', '', '', array('usrname', 'password'), array('=', '='), array($user, $pass), array('AND'));
         $res = DbQuery($query, $link);
         $uok = DbNumRows($res);
     }
 } else {
     $pass = hash("sha256", "NeDi" . $user . $_POST['pass']);
     # Salt & pw
     $query = GenQuery('users', 's', '*', '', '', array('usrname', 'password'), array('=', '='), array($user, $pass), array('AND'));
     $res = DbQuery($query, $link);
     $uok = DbNumRows($res);
 }
 if ($uok == 1) {
     $usr = DbFetchRow($res);
     session_start();
     $_SESSION['user'] = $user;
     $_SESSION['group'] = "usr,";
     $_SESSION['view'] = $usr[15];
     $_SESSION['bread'] = array();
     $_SESSION['ver'] = "1.0.9-010";
     if (strstr($guiauth, 'ldap') and $user != "admin" and is_array($ldapmap)) {
         if ($ldapmap[0] and in_array($ldapmap[0], $ldapusersgrp)) {
             $_SESSION['group'] .= "adm,";
         }
         if ($ldapmap[1] and in_array($ldapmap[1], $ldapusersgrp)) {
             $_SESSION['group'] .= "net,";
         }
         if ($ldapmap[2] and in_array($ldapmap[2], $ldapusersgrp)) {
             $_SESSION['group'] .= "dsk,";
Пример #24
0
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);
    }
}
Пример #25
0
                    } 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 $bg1;
Пример #26
0
ColHead('email');
ColHead('phone');
ColHead('comment');
ColHead('language');
ColHead('time');
ColHead('lastseen');
echo "<th>Groups</th><th>Action</th></tr>\n";
if ($grp) {
    $query = GenQuery('user', 's', '*', $ord, '', array($grp), array('='), array('1'));
} else {
    $query = GenQuery('user', 's', '*', $ord);
}
$res = @DbQuery($query, $link);
if ($res) {
    $row = 0;
    while ($u = @DbFetchRow($res)) {
        if ($row % 2) {
            $bg = $bgb;
            $bi = $bib;
        } else {
            $bg = $bga;
            $bi = $bia;
        }
        $row++;
        list($cc, $lc) = Agecol($u[10], $u[11], $row % 2);
        echo "<tr bgcolor=#{$bg}>\n";
        echo "<th bgcolor=#{$bi}><img src=" . Smilie($u[0]) . " title=\"Hello I'm {$u['0']}\"'><br>{$u['0']}</th>\n";
        echo "<td>{$u['8']}</td><td align=center>{$u['9']}</td><td>{$u['12']}</td><td align=center>{$u['13']}</td>\n";
        echo "<td bgcolor=#{$cc}>" . date("j. M Y", $u[10]) . "</td>\n";
        echo "<td bgcolor=#{$lc}>" . date("j. M (G:i)", $u[11]) . "</td><th>\n";
        if ($u[2]) {
Пример #27
0
 }
 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";
     echo "<a href=Devices-Graph.php?dv={$ud}&if%5B%5D={$ui}><img src=inc/drawrrd.php?dv={$ud}&if%5B%5D={$ui}&s=s&t=trf border=0>\n";
     echo "<img src=inc/drawrrd.php?dv={$ud}&if%5B%5D={$ui}&s=s&t=err border=0></a>\n";
Пример #28
0
echo $ord;
?>
 > alternative order
</th>
</select></th>

<th width=80><input type="submit" name="do" value="Show"></th>
</tr></table></form><p>
<?
if($rep){
$link	= @DbConnect($dbhost,$dbuser,$dbpass,$dbname);
$query	= GenQuery('devices');
$res	= @DbQuery($query,$link);
if($res){
	$ndev = 0;
	while( ($d = @DbFetchRow($res)) ){
		$dtyp[$d[3]]++;
		$dico[$d[3]] = $d[18];
		$fseen[$d[4]]++;
		$lseen[$d[5]]++;
		$dops[$d[8]]++;
		$dbim[$d[9]]++;
		$vtpd[$d[12]]++;
		$vtpm[$d[13]]++;
		$ndev++;
	}
	@DbFreeResult($res);
}else{
	print @DbError($link);
	die;
}
Пример #29
0
    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 
    echo $ip;
    ?>
</h5>
<script language="JavaScript"><!--
setTimeout("history.go(-1)",10000);
//--></script>
Пример #30
0
function DbDump($tables, $link, $outfile)
{
    // The dump file is created and opened
    $sqlfile = fopen($outfile, "w");
    // The comment header for the MySQL dump is created...
    $sql = "--\n";
    $sql .= "-- NeDi MySQL Dump - " . date("d M Y H:i") . "\n";
    $sql .= "-- ------------------------------------------------------\n\n";
    // ...and written to the file
    fwrite($sqlfile, $sql);
    $sql = "";
    // All the tables are dumped one after the other
    foreach ($tables as $tbl) {
        // Some SQL comments
        $sql .= "--\n";
        $sql .= "-- Table structure for table `" . $tbl . "`\n";
        $sql .= "--\n\n";
        // This is to make sure, that there is no table with the same name
        $sql .= "DROP TABLE IF EXISTS `" . $tbl . "`;\n";
        // This query gives us the complete SQL query to create the table structure
        $res = DbQuery("SHOW CREATE TABLE `{$tbl}`;", $link);
        $field = array();
        while ($field = DbFetchArray($res)) {
            // Now the SQL command used to create the table structure is read from the database
            $sql .= $field['Create Table'] . ";\n\n";
        }
        // Another block of SQL comments
        $sql .= "--\n";
        $sql .= "-- Dumping data for table `" . $tbl . "`\n";
        $sql .= "--\n\n";
        // To make sure, that we are the only one working on the table, when importing the dump,
        // this SQL command is used
        $sql .= "LOCK TABLES `" . $tbl . "` WRITE;\n";
        $chfields = array();
        $field = array();
        // We want to check each column of the table, if its datatype is numeric or not.
        // Because if it's not numeric, we want to surround the content in the INSERT command
        // with "". But if it is numeric we must not put "" around the content.
        $res = DbQuery("DESCRIBE `{$tbl}`;", $link);
        while ($field = DbFetchArray($res)) {
            // If a field is either of type "varchar()" or "text" the we add a '1' to the array...
            if (preg_match("/char|text/", $field['Type'])) {
                $chfields[] = 1;
            } else {
                $chfields[] = 0;
            }
        }
        // The data, which we gathered since the last time we wrote something to the file
        // is written down to the SQL dump file.
        fwrite($sqlfile, $sql);
        $sql = "";
        // Now we want to have all the data from the table
        $res = DbQuery(GenQuery($tbl, "s", "*"), $link);
        // 		$res = DbQuery("SELECT * FROM `".$tbl."`;", $link);
        $field = array();
        while ($field = DbFetchRow($res)) {
            // For each record a new INSERT command is created
            $sql .= "INSERT INTO `" . $tbl . "` VALUES (";
            // The fields of the record are inserted one after the other
            for ($i = 0; $i < count($field); $i++) {
                // If the current field is a "varchar()" or "text" field
                // then it is surrounded by "". The array $chfields[]
                // tells us, if the current field is numeric (0) or not (1).
                if ($chfields[$i] == 1 && $field[$i] != "") {
                    $sql .= "\"";
                }
                if ($field[$i] != "") {
                    $field[$i] = str_replace("\"", "\\\"", $field[$i]);
                    $sql .= $field[$i];
                } else {
                    $sql .= "NULL";
                }
                if ($chfields[$i] == 1 && $field[$i] != "") {
                    $sql .= "\"";
                }
                if ($i < count($field) - 1) {
                    $sql .= ", ";
                }
            }
            $sql .= ");\n";
            // The INSERT command for the current record is written to the dump file
            fwrite($sqlfile, $sql);
            $sql = "";
        }
        // After having inserted all the data to the database table
        // the table can be unlocked
        $sql .= "UNLOCK TABLES;\n\n";
        fwrite($sqlfile, $sql);
        $sql = "";
    }
    // Finally the SQL dump file is closed
    fclose($sqlfile);
}