Esempio n. 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;
}
Esempio n. 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;
}
Esempio n. 3
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]);
Esempio n. 4
0
						$stppri	= str_replace('"','', Get($ip, $dev[14] & 3, $dev[15], "1.3.6.1.2.1.17.2.2.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("-");
					}
Esempio n. 5
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 (substr($field['Type'], 0, 8) == "varchar(" || $field['Type'] == "text") {
                $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);
}
Esempio n. 6
0
    if (isset($_POST["Areaid"]) && !empty($_POST["Areaid"])) {
        //Checks if action value exists
        $Idarea = $_POST["Areaid"];
        if (isset($_POST["startdt"]) && !empty($_POST["startdt"])) {
            //Checks if action value exists
            $startdty = $_POST["startdt"];
            if (isset($_POST["endt"]) && !empty($_POST["endt"])) {
                //Checks if action value exists
                $endty = $_POST["endt"];
                if (isset($_POST["action"]) && !empty($_POST["action"])) {
                    //Checks if action value exists
                    $action = $_POST["action"];
                    switch ($action) {
                        //Switch case for value of action
                        case "go":
                            DbQuery();
                            break;
                    }
                }
            }
        }
    }
}
//Function to check if the request is an AJAX request
function is_ajax()
{
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
function DbQuery()
{
    include 'databaseconn.php';
Esempio n. 7
0
        // 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
for ($i = 0; $i < $nres; $i++) {
    if ($row == "1") {
        $row = "0";
        $bg = $bga;
        $bi = $bia;
                    if ($devs[$dnet][$n[0]]) {
                        $devs[$dnet][$n[0]] = "<span style=\"color : green\">multiple</span> on {$n['1']}";
                    } else {
                        $devs[$dnet][$n[0]] = "<span style=\"color : green\">ok</span> on {$n['1']}";
                    }
                }
            } else {
                $nets[$dnet] = $n[3];
                $pop[$dnet] = 0;
                $age[$dnet] = 0;
                if ($n[3] == -1) {
                    $devs[$dnet][$n[0]] = "<span style=\"color : yellow\">Loopback</span> on {$n['1']}";
                } else {
                    $devs[$dnet][$n[0]] = "<span style=\"color : blue\">mask base</span> on {$n['1']}";
                    $nquery = GenQuery('nodes', 'a', "ip & {$n['3']}", '', 'lastseen - firstseen', array("ip & {$n['3']}"), array('='), array($dnet));
                    $nodres = @DbQuery($nquery, $link);
                    $nnod = @DbNumRows($nodres);
                    $no = @DbFetchRow($nodres);
                    $pop[$dnet] = $no[1];
                    $age[$dnet] = intval($no[2] / 86400);
                    @DbFreeResult($nodres);
                }
            }
        }
        @DbFreeResult($res);
        if ($nets) {
            ?>
<table bgcolor=#666666 <?php 
            echo $tabtag;
            ?>
 >
Esempio n. 9
0
$co = isset($_GET['co']) ? $_GET['co'] : array();
$elm = isset($_GET['elm']) ? preg_replace('/\\D+/', '', $_GET['elm']) : 20;
$off = (isset($_GET['off']) and !isset($_GET['sho'])) ? preg_replace('/\\D+/', '', $_GET['off']) : 0;
$nof = $off;
if (isset($_GET['p'])) {
    $nof = abs($off - $elm);
} elseif (isset($_GET['n'])) {
    $nof = $off + $elm;
}
$dlim = $elm ? "{$elm} OFFSET {$nof}" : '';
$link = DbConnect($dbhost, $dbuser, $dbpass, $dbname);
if (isset($_GET['del'])) {
    # TODO fix for Postgres
    if ($isadmin) {
        $query = GenQuery('events', 'd', '*', 'id desc', $elm, $in, $op, $st, $co);
        if (DbQuery($query, $link)) {
            echo "<h5> {$msglbl} {$dellbl} OK </h5>";
        } else {
            echo "<h4>" . DbError($link) . "</h4>";
        }
    } else {
        echo $nokmsg;
    }
}
$cols = array("info" => "Info", "id" => "ID", "level" => "{$levlbl}", "time" => $timlbl, "source" => $srclbl, "class" => $clalbl, "location" => $loclbl, "contact" => $conlbl);
?>
<h1>Monitoring <?php 
echo $msglbl;
?>
</h1>
Esempio n. 10
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);
    }
}
Esempio n. 11
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 );
}
Esempio n. 12
0
             $trk[$src] = preg_replace('/.+DP:(.+),.+/', '$1', $trk[$src]);
             $setd = "value='{$trk[$src]}',";
         } else {
             $setd = "value='{$trk[$src]}',";
         }
         if (!DbQuery("UPDATE nodetrack SET {$setd}source='{$src}',usrname='{$_SESSION['user']}',time={$time} WHERE device = '{$dev}' AND ifname = '{$ifn}';", $link)) {
             $cfgst = "<img src=\"img/16/bcnl.png\" title=\"" . DbError($link) . "\">";
         } else {
             $cfgst = "<img src=\"img/16/bchk.png\" title=\"{$srclbl} = {$src} OK\">";
             $trk['source'] = $src;
             if ($src != '-') {
                 $trk['value'] = $trk[$src];
             }
         }
     } elseif ($val) {
         if (!DbQuery("UPDATE nodetrack SET value='{$val}',usrname='{$_SESSION['user']}',time={$time} WHERE device = {$dev}' AND ifname = '{$ifn}';", $link)) {
             $cfgst = "<img src=\"img/16/bcnl.png\" title=\"" . DbError($link) . "\">";
         } else {
             $cfgst = "<img src=\"img/16/bchk.png\" title=\"{$vallbl} = {$val} OK\">";
             $trk['value'] = $val;
         }
     }
     $trk['time'] = $time;
     $trk['user'] = $_SESSION['user'];
 }
 $bst = 'good';
 if ($trk['source'] == '-' or $trk['source'] == '') {
     $bst = $bi;
 } elseif ($trk['source'] == 'comment') {
     if ($trk['value'] != preg_replace('/.+DP:(.+),.+/', '$1', $trk['comment'])) {
         $bst = 'warn';
 $row = 0;
 while ($d = @DbFetchRow($res)) {
     if ($row % 2) {
         $bg = $bga;
         $bi = $bia;
     } else {
         $bg = $bgb;
         $bi = $bib;
     }
     $dev++;
     $row++;
     $ud = rawurlencode($d[0]);
     echo "<tr bgcolor=#{$bg}><th bgcolor=#{$bia}><a href=Devices-Status.php?dev={$ud}><b>{$d['0']}</b></a></th>\n";
     echo "<td align=right>-</td><td><b>{$d['1']}</b></td><td>{$d['2']}</td><td>-</td><td>{$d['3']}</td><td>{$d['4']}</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 = $bga;
                 $bi = $bia;
             } else {
                 $bg = $bgb;
                 $bi = $bib;
             }
             $row++;
             echo "<tr bgcolor=#{$bg}><td bgcolor=#{$bib}></td>\n";
             echo "<td align=right>{$m['1']}</td><td><b>{$m['2']}</b> {$m['3']}</td><td>{$m['4']}</td><td>{$m['5']}</td><td>{$m['6']}</td><td>{$m['7']}</td></tr>\n";
         }
         @DbFreeResult($mres);
     } else {
Esempio n. 14
0
> Enable notifications for selected host(s)<br>
		</td>
	</tr>
</table>
</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'];
            ?>
Esempio n. 15
0
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);
    }
}
Esempio n. 16
0
     $bi = "imga";
 } else {
     $bg = "txtb";
     $bi = "imgb";
 }
 $row++;
 $ud = urlencode($if[0]);
 $ui = urlencode($if[1]);
 list($fc, $lc) = Agecol($if[33], $if[34], $row % 2);
 list($cc, $cc) = Agecol($if[26], $if[26], $row % 2);
 if ($isadmin and $_GET['trk']) {
     $trkst = AddRecord('nodetrack', "device='{$if['0']}' AND ifname='{$if['1']}'", "device,ifname,value,source,usrname,time", "'{$if['0']}','{$if['1']}','-','-','{$_SESSION['user']}','" . time() . "'");
 }
 if ($isadmin and $_GET['upm']) {
     $query = GenQuery('interfaces', 'u', "CONCAT(device,ifname)", '=', "{$if['0']}{$if['1']}", array('trafalert', 'brcalert', 'macflood'), array(), array($tal, $bal, $maf));
     $monst = DbQuery($query, $link) ? "<img src=\"img/16/bchk.png\" title=\" {$monlbl} {$updlbl} OK\" vspace=\"4\">" : "<img src=\"img/16/bcnl.png\" title=\"" . DbError($link) . "\" vspace=\"4\">";
 }
 TblRow($bg);
 if (in_array("imBL", $col)) {
     list($ifbg, $ifst) = Ifdbstat($if[8]);
     list($ifimg, $iftyp) = Iftype($if[4]);
     TblCell("", "", "width=\"50\" class=\"" . ($ifbg ? $ifbg : $bi) . "\"", "<img src=\"img/{$ifimg}\" title=\"{$iftyp} - {$ifst}\">", "th-img");
 }
 if (in_array("ifname", $col)) {
     TblCell("{$if['1']} {$trkst} {$monst}", "?in[]=ifname&op[]==&st[]={$ui}", "align=\"left\"", "", "th");
 }
 if (in_array("ifidx", $col)) {
     TblCell($if[2], "?in[]=ifidx&op[]==&st[]={$if['2']}", "align=\"right\"");
 }
 if (in_array("device", $col)) {
     TblCell($if[0], "?in[]=device&op[]==&st[]={$ud}&ord=ifname", "nowrap", "<a href=\"Devices-Status.php?dev={$ud}\"><img src=\"img/16/sys.png\"></a>");
Esempio n. 17
0
$row = 0;
$link = DbConnect($dbhost, $dbuser, $dbpass, $dbname);
$res  = DbQuery(GenQuery("$dbn[0]%","b","LIKE"), $link);
while($ss = DbFetchRow($res)){
	if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";}
	$row++;
	if($dbname == $ss[0]){
		$inactive = 0;
	}else{
		$inactive = 1;
	}
	$slnk = DbConnect($dbhost, $dbuser, $dbpass, $ss[0]);
	$devs = DbFetchRow(DbQuery(GenQuery('devices','s','count(*)'), $slnk));
	$cfgs = DbFetchRow(DbQuery(GenQuery('configs','s','count(*)'), $slnk));
	$nods = DbFetchRow(DbQuery(GenQuery('nodes','s','count(*)'), $slnk));
	$fdis = DbFetchRow(DbQuery(GenQuery('system','s','value','','',array('name'),array('='),array('first') ), $slnk));
	DbClose($slnk);

	TblRow($bg);
	echo "<th class=\"$bi\"> ";
	if($inactive){											# Only allow activate inactive DBs
?>
<a href="?sel=<?= urlencode($ss[0]) ?>">
<img src="img/16/bcls.png" title="DB <?= $sellbl ?>">
</a>
<?php 
	}else{
		echo "<img src=\"img/16/walk.png\" title=\"DB $stco[100]\">";
	}
?>
</th>
Esempio n. 18
0
function VlanEmpty($ina, $opa, $sta, $lim, $ord)
{
    global $link, $modgroup, $self, $verb1, $srtlbl, $lstlbl, $loclbl, $locsep, $conlbl, $emplbl;
    ?>
<h2><?php 
    echo $verb1 ? "{$emplbl} Vlans" : "Vlans {$emplbl}";
    ?>
</h2>

<table class="content"><tr class="<?php 
    echo $modgroup[$self];
    ?>
2">
<th colspan="2" width="20%"><img src="img/16/dev.png"><br>Device</th>
<th><img src="img/16/vlan.png"><br>Vlan <?php 
    echo $lstlbl;
    ?>
</th></tr>
<?php 
    if ($ord) {
        $ocol = 'vlans.vlanid';
        $srt = "{$srtlbl}: Vlan";
    } else {
        $ocol = 'vlans.device';
        $srt = "{$srtlbl}: Device";
    }
    if ($ina == "device") {
        $ina = "vlans.device";
    }
    if ($ina == "vlanid") {
        $ina = "vlans.vlanid";
    }
    $query = GenQuery('vlans', 's', 'vlans.device,vlans.vlanid,vlans.vlanname,contact,location,icon', $ocol, $lim, array('mac', $ina), array('COL IS', $opa), array('NULL', $sta), array('AND'), 'LEFT JOIN nodes on (vlans.device = nodes.device and vlans.vlanid = nodes.vlanid) LEFT JOIN devices on (vlans.device = devices.device)');
    $res = DbQuery($query, $link);
    if ($res) {
        $row = 0;
        $nif = 0;
        while ($r = DbFetchRow($res)) {
            $curi = "<img src=\"img/chip.png\" title=\"{$r['2']}\">{$r['1']} ";
            if ($r[0] == $prev) {
                echo $curi;
                $nif++;
            } else {
                $prev = $r[0];
                if ($row % 2) {
                    $bg = "txta";
                    $bi = "imga";
                } else {
                    $bg = "txtb";
                    $bi = "imgb";
                }
                $row++;
                $l = explode($locsep, $r[3]);
                $ico = $r[5] ? "dev/{$r['5']}" : "32/bbox";
                TblRow($bg);
                echo "<th class=\"{$bi}\"><a href=\"Devices-Status.php?dev=" . urlencode($r[0]) . "\"><img src=\"img/{$ico}.png\" title=\"{$conlbl}: {$r['2']}, {$loclbl}: {$l['0']} {$l['1']} {$l['2']}\"></a></th>\n";
                echo "<td><b>" . substr($r[0], 0, $_SESSION['lsiz']) . "</b></td>\n";
                echo "<td>{$curi} ";
                $nif++;
            }
        }
        echo "</td></tr></table>\n";
    }
    ?>
<table class="content" >
<tr class="<?php 
    echo $modgroup[$self];
    ?>
2"><td><?php 
    echo $nif;
    ?>
 Vlans, <?php 
    echo $row;
    ?>
 Devices, <?php 
    echo $srt;
    ?>
</td></tr>
</table>
<p>
<?php 
}
Esempio n. 19
0
		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
				#	2 for change from dev2 to dev1
				#	0 for unknown collision reason (i.e. devices appearance times overlap)
				if ($colldev['firstdis'] > $device['lastdis']):
					$reason = 1;
				elseif ($colldev['lastdis'] < $device['firstdis']):
					$reason = 2;
				else:
					$reason = 0;
				endif;
				$collisions[] = array('serial' => $device['serial'], 'dev1_name' => $device['device'], 'dev1_ip' => $device['devip'], 'dev2_name' => $colldev['device'], 'dev2_ip' => $colldev['devip'], 'reason' => $reason);
				$coll_serials[] = $device['serial'];
Esempio n. 20
0
    DbFreeResult($res);
} else {
    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';
Esempio n. 21
0
            $_SESSION['theme'] = $usr[9];
            $_SESSION['vol'] = ($usr[10] & 3) * 33;
            $_SESSION['lsiz'] = ($usr[10] & 124) >> 2;
            $_SESSION['col'] = $usr[11];
            $_SESSION['lim'] = $usr[12];
            $_SESSION['gsiz'] = $usr[13] & 7;
            $_SESSION['gbit'] = $usr[13] & 8;
            $_SESSION['far'] = $usr[13] & 16;
            $_SESSION['opt'] = $usr[13] & 32;
            $_SESSION['map'] = $usr[13] & 64;
            $_SESSION['gneg'] = $usr[13] & 128;
            $_SESSION['nip'] = $usr[13] & 256;
            $_SESSION['date'] = $usr[14] ? substr($usr[14], 0, -3) : 'j.M y G:i';
            $_SESSION['tz'] = $tzone[substr($usr[14], -3)];
            $query = GenQuery('users', 'u', 'usrname', '=', $user, array('lastlogin'), array(), array(time()));
            DbQuery($query, $link);
        }
    } else {
        print DbError($link);
    }
    if (isset($_SESSION['group'])) {
        echo "<body style=\"background-color: #666666;\"><script>document.location.href='{$goto}';</script></body>\n";
    } elseif ($raderr) {
        $disc = "<h4>{$raderr}</h4>";
    } else {
        $disc = "<h4>Incorrect login!</h4>";
    }
}
?>
<html>
<head>
Esempio n. 22
0
?>
<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;
	}
}

?>
Esempio n. 23
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";
}
Esempio n. 24
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";
					}
Esempio n. 25
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)) {
Esempio n. 26
0
	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)?"$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;

?>
             echo "<a href=Monitoring-Messages.php?ina=time&opa=%3E=&sta={$fs}&cop=AND&inb=time&opb=%3C&stb={$fe}&lvl={$m['0']}>";
             echo "<img src=img/16/" . $mico[$m[0]] . ".png title=\"" . $mlvl[$m[0]] . "\" border=0></a>{$mbar} \n";
             $nmsg += $m[1];
         }
         if (!$nmsg) {
             echo "<img src=img/16/fogy.png title=\"All Messages\"> ";
         }
         $tmsg += $nmsg;
         echo "{$nmsg}</td></tr>\n";
         @DbFreeResult($res);
     } else {
         print @DbError($link);
     }
 } else {
     $query = GenQuery('messages', 's', 'id', '', '', array('time', 'time'), array('>=', '<'), array($istart, $iend), array('AND'));
     $res = @DbQuery($query, $link);
     if ($res) {
         $m = @DbNumRows($res);
         $mbar = "";
         if ($m) {
             $mbar = Bar($m, 0);
         }
         echo "<img src=img/16/fogy.png title=\"All Messages\">{$mbar} {$m}</td></tr>\n";
         $tmsg += $m;
         @DbFreeResult($res);
     } else {
         print @DbError($link);
     }
 }
 $istart = $iend;
 flush();
Esempio n. 28
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);
    }
}
Esempio n. 29
0
<?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;
    }
}
		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>";
		}