mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
more db*
git-svn-id: http://www.observium.org/svn/observer/trunk@2329 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -6,8 +6,7 @@
|
||||
<select name='device_id' id='device_id'>
|
||||
<option value=''>All Devices</option>
|
||||
<?php
|
||||
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
|
||||
while ($data = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`") as $dat)
|
||||
{
|
||||
echo("<option value='".$data['device_id']."'");
|
||||
if ($data['device_id'] == $_POST['device_id']) { echo("selected"); }
|
||||
@@ -36,8 +35,7 @@ while ($data = mysql_fetch_assoc($query))
|
||||
<select name='ifSpeed' id='ifSpeed'>
|
||||
<option value=''>All Speeds</option>
|
||||
<?php
|
||||
$query = mysql_query("SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed`");
|
||||
while ($data = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed`") as $data)
|
||||
{
|
||||
if ($data['ifSpeed'])
|
||||
{
|
||||
@@ -53,8 +51,7 @@ while ($data = mysql_fetch_assoc($query))
|
||||
<select name='ifType' id='ifType'>
|
||||
<option value=''>All Media</option>
|
||||
<?php
|
||||
$query = mysql_query("SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`");
|
||||
while ($data = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`") as $data)
|
||||
{
|
||||
if ($data['ifType'])
|
||||
{
|
||||
@@ -88,6 +85,8 @@ while ($data = mysql_fetch_assoc($query))
|
||||
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
|
||||
#}
|
||||
|
||||
$param = array();
|
||||
|
||||
# FIXME block below is not totally used, at least the iftype stuff is bogus?
|
||||
if ($_GET['opta'] == "down" || $_GET['type'] == "down" || $_POST['state'] == "down")
|
||||
{
|
||||
@@ -114,20 +113,37 @@ if ($_GET['opta'] == "down" || $_GET['type'] == "down" || $_POST['state'] == "do
|
||||
$where .= " AND I.ifType = 'ppp'";
|
||||
}
|
||||
|
||||
if (is_numeric($_POST['device_id'])) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
|
||||
if ($_POST['ifType']) { $where .= " AND I.ifType = '".mres($_POST['ifType'])."'"; }
|
||||
if (is_numeric($_POST['ifSpeed'])) { $where .= " AND I.ifSpeed = '".$_POST['ifSpeed']."'"; }
|
||||
if ($_POST['ifAlias']) { $where .= " AND I.ifAlias LIKE '%".mres($_POST['ifAlias'])."%'"; }
|
||||
if (is_numeric($_POST['device_id']))
|
||||
{
|
||||
$where .= " AND I.device_id = ?";
|
||||
$param[] = $_POST['device_id'];
|
||||
}
|
||||
if ($_POST['ifType'])
|
||||
{
|
||||
$where .= " AND I.ifType = ?";
|
||||
$param[] = $_POST['ifType'];
|
||||
}
|
||||
|
||||
if (is_numeric($_POST['ifSpeed']))
|
||||
{
|
||||
$where .= " AND I.ifSpeed = ?";
|
||||
$param[] = $_POST['ifSpeed'];
|
||||
}
|
||||
|
||||
if ($_POST['ifAlias']) {
|
||||
$where .= " AND I.ifAlias LIKE ?";
|
||||
$param[] = "%".$_POST['ifAlias']."%";
|
||||
}
|
||||
|
||||
if ($_POST['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; }
|
||||
|
||||
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifIndex";
|
||||
$query = mysql_query($sql);
|
||||
$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ORDER BY D.hostname, I.ifIndex";
|
||||
|
||||
echo("<tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Media</th><th>Description</th></tr>");
|
||||
|
||||
$row = 1;
|
||||
|
||||
while ($interface = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows($query, $param) as $interface)
|
||||
{
|
||||
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
|
@@ -2,9 +2,7 @@
|
||||
|
||||
if ($_GET['optb'] == "purge" && $_GET['optc'] == "all")
|
||||
{
|
||||
$sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id";
|
||||
$query = mysql_query($sql);
|
||||
while ($interface = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface)
|
||||
{
|
||||
if (port_permitted($interface['interface_id'], $interface['device_id']))
|
||||
{
|
||||
@@ -13,7 +11,7 @@ if ($_GET['optb'] == "purge" && $_GET['optc'] == "all")
|
||||
}
|
||||
}
|
||||
} elseif ($_GET['optb'] == "purge" && $_GET['optc']) {
|
||||
$interface = mysql_fetch_assoc(mysql_query("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = '".mres($_GET['optc'])."' AND D.device_id = P.device_id"));
|
||||
$interface = dbFetchRow("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = ? AND D.device_id = P.device_id", array($_GET['optc']));
|
||||
if (port_permitted($interface['interface_id'], $interface['device_id']))
|
||||
delete_port($interface['interface_id']);
|
||||
echo("<div class=infobox>Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."</div>");
|
||||
@@ -24,9 +22,7 @@ $i_deleted = 1;
|
||||
echo("<table cellpadding=5 cellspacing=0 border=0 width=100%>");
|
||||
echo("<tr><td></td><td></td><td></td><td><a href='".$config['base_url'] . "/ports/deleted/purge/all/'><img src='images/16/cross.png' align=absmiddle></img> Purge All</a></td></tr>");
|
||||
|
||||
$sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id";
|
||||
$query = mysql_query($sql);
|
||||
while ($interface = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface)
|
||||
{
|
||||
$interface = ifLabel($interface, $interface);
|
||||
if (port_permitted($interface['interface_id'], $interface['device_id']))
|
||||
@@ -45,4 +41,4 @@ while ($interface = mysql_fetch_assoc($query))
|
||||
|
||||
echo("</table>");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user