Updated most files to use dbFacile

This commit is contained in:
laf
2014-03-12 22:21:33 +00:00
parent a0650f0547
commit 02792176fa
45 changed files with 334 additions and 346 deletions
+19 -18
View File
@@ -23,12 +23,12 @@ $count_boxes = 0;
// Device down boxes
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'";
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'");
$sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'";
}
while ($device = mysql_fetch_assoc($sql)) {
foreach (dbFetchRows($sql) as $device)
{
generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."<br />
<span class=list-device-down>Device Down</span> <br />
<span class=body-date-1>".truncate($device['location'], 20)."</span>");
@@ -37,9 +37,9 @@ while ($device = mysql_fetch_assoc($sql)) {
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
} else {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
$sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
}
// These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
@@ -47,7 +47,7 @@ $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS
// Port down boxes
if ($config['warn']['ifdown'])
{
while ($interface = mysql_fetch_assoc($sql))
foreach (dbFetchRows($sql) as $interface)
{
if (!$interface['deleted'])
{
@@ -64,8 +64,8 @@ if ($config['warn']['ifdown'])
/* FIXME service permissions? seem nonexisting now.. */
// Service down boxes
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while ($service = mysql_fetch_assoc($sql))
$sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'";
foreach (dbFetchRows($sql) as $service)
{
generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."<br />
<span class=service-down>Service Down</span>
@@ -79,11 +79,11 @@ if (isset($config['enable_bgp']) && $config['enable_bgp'])
{
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0";
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0";
}
while ($peer = mysql_fetch_assoc($sql))
foreach (dbFetchRows($sql) as $peer)
{
generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."<br />
<span class=bgp-down>BGP Down</span>
@@ -98,13 +98,13 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
{
if ($_SESSION['userlevel'] == '10')
{
$sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0");
$sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0";
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" .
$config['uptime_warning'] . "' AND D.ignore = 0");
$sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" .
$config['uptime_warning'] . "' AND D.ignore = 0";
}
while ($device = mysql_fetch_assoc($sql))
foreach (dbFetchRows($sql) as $device)
{
generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."<br />
<span class=device-rebooted>Device Rebooted</span><br />
@@ -153,7 +153,7 @@ if ($config['enable_syslog'])
</div>
<table class="table table-hover table-condensed table-striped">');
while ($entry = mysql_fetch_assoc($query))
foreach (dbFetchRows($sql) as $entry)
{
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
@@ -191,7 +191,8 @@ if ($config['enable_syslog'])
</div>
<table class="table table-hover table-condensed table-striped">');
while ($entry = mysql_fetch_assoc($data)) {
foreach (dbFetchRows($query) as $entry)
{
include("includes/print-event.inc.php");
}