mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated search pages to fix broken elements
This commit is contained in:
@@ -3,21 +3,35 @@
|
|||||||
$where = 1;
|
$where = 1;
|
||||||
$param = array();
|
$param = array();
|
||||||
|
|
||||||
|
list($address,$prefix) = explode("/", $_POST['address']);
|
||||||
if ($_POST['search_type'] == 'ipv4') {
|
if ($_POST['search_type'] == 'ipv4') {
|
||||||
$sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D, `ipv4_networks` AS N WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id ";
|
$sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D, `ipv4_networks` AS N WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id ";
|
||||||
|
if (!empty($address)) {
|
||||||
|
$sql .= " AND ipv4_address LIKE '%".$address."%'";
|
||||||
|
}
|
||||||
|
if (!empty($prefix)) {
|
||||||
|
$sql .= " AND ipv4_prefixlen='?'";
|
||||||
|
$param[] = array($prefix);
|
||||||
|
}
|
||||||
} elseif ($_POST['search_type'] == 'ipv6') {
|
} elseif ($_POST['search_type'] == 'ipv6') {
|
||||||
$sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `devices` AS D, `ipv6_networks` AS N WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id ";
|
$sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `devices` AS D, `ipv6_networks` AS N WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id ";
|
||||||
|
if (!empty($address)) {
|
||||||
|
$sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')";
|
||||||
|
}
|
||||||
|
if (!empty($prefix)) {
|
||||||
|
$sql .= " AND ipv6_prefixlen = '$prefix'";
|
||||||
|
}
|
||||||
} elseif ($_POST['search_type'] == 'mac') {
|
} elseif ($_POST['search_type'] == 'mac') {
|
||||||
$sql = " FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE ? ";
|
$sql = " FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%?%' ";
|
||||||
$param = array("%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%");
|
$param[] = array("%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%");
|
||||||
}
|
}
|
||||||
if (is_numeric($_POST['device_id'])) {
|
if (is_numeric($_POST['device_id'])) {
|
||||||
$sql .= " AND I.device_id = ?";
|
$sql .= " AND I.device_id = ?";
|
||||||
$param[] = $_POST['device_id'];
|
$param[] = array($_POST['device_id']);
|
||||||
}
|
}
|
||||||
if ($_POST['interface']) {
|
if ($_POST['interface']) {
|
||||||
$sql .= " AND I.ifDescr LIKE '?'";
|
$sql .= " AND I.ifDescr LIKE '?'";
|
||||||
$param[] = $_POST['interface'];
|
$param[] = array($_POST['interface']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['search_type'] == 'ipv4') {
|
if ($_POST['search_type'] == 'ipv4') {
|
||||||
@@ -50,53 +64,31 @@ if ($rowCount != -1) {
|
|||||||
$sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql";
|
$sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql";
|
||||||
|
|
||||||
foreach (dbFetchRows($sql, $param) as $interface) {
|
foreach (dbFetchRows($sql, $param) as $interface) {
|
||||||
if ($_POST['address']) {
|
$speed = humanspeed($interface['ifSpeed']);
|
||||||
list($addy, $mask) = explode("/", $_POST['address']);
|
$type = humanmedia($interface['ifType']);
|
||||||
if ($_POST['search_type']) {
|
|
||||||
$tmp_mask = '128';
|
|
||||||
if (!Net_IPv6::isInNetmask($interface['ipv6_address'], $addy, $mask)) {
|
|
||||||
$ignore = 1;
|
|
||||||
} else {
|
|
||||||
$ignore = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$tmp_mask = '32';
|
|
||||||
if (!match_network($addy . "/" . $mask, $interface['ipv4_address'])) {
|
|
||||||
$ignore = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$mask) {
|
|
||||||
$mask = $tmp_mask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$ignore) {
|
|
||||||
$speed = humanspeed($interface['ifSpeed']);
|
|
||||||
$type = humanmedia($interface['ifType']);
|
|
||||||
|
|
||||||
if ($_POST['search_type'] == 'ipv6') {
|
if ($_POST['search_type'] == 'ipv6') {
|
||||||
list($prefix, $length) = explode("/", $interface['ipv6_network']);
|
list($prefix, $length) = explode("/", $interface['ipv6_network']);
|
||||||
$address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length;
|
$address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length;
|
||||||
} elseif ($_POST['search_type'] == 'mac') {
|
} elseif ($_POST['search_type'] == 'mac') {
|
||||||
$address = formatMac($interface['ifPhysAddress']);
|
$address = formatMac($interface['ifPhysAddress']);
|
||||||
} else {
|
} else {
|
||||||
list($prefix, $length) = explode("/", $interface['ipv4_network']);
|
list($prefix, $length) = explode("/", $interface['ipv4_network']);
|
||||||
$address = $interface['ipv4_address'] . '/' .$length;
|
$address = $interface['ipv4_address'] . '/' .$length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
|
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
|
||||||
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
|
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
|
||||||
} else {
|
} else {
|
||||||
$error_img = "";
|
$error_img = "";
|
||||||
}
|
}
|
||||||
if (port_permitted($interface['port_id'])) {
|
if (port_permitted($interface['port_id'])) {
|
||||||
$interface = ifLabel ($interface, $interface);
|
$interface = ifLabel ($interface, $interface);
|
||||||
$response[] = array('hostname'=>generate_device_link($interface),
|
$response[] = array('hostname'=>generate_device_link($interface),
|
||||||
'interface'=>generate_port_link($interface) . ' ' . $error_img,
|
'interface'=>generate_port_link($interface) . ' ' . $error_img,
|
||||||
'address'=>$address,
|
'address'=>$address,
|
||||||
'description'=>$interface['ifAlias']);
|
'description'=>$interface['ifAlias']);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unset($ignore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
|
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ if ($_POST['interface'] == "Vlan%") {
|
|||||||
"<input type=\"text\" name=\"address\" id=\"address\" value=\""+
|
"<input type=\"text\" name=\"address\" id=\"address\" value=\""+
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo($_POST['address']);
|
echo('"'.$_POST['address'].'"+');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
"\" class=\"form-control input-sm\" placeholder=\"Mac Address\"/>"+
|
"\" class=\"form-control input-sm\" placeholder=\"Mac Address\"/>"+
|
||||||
|
|||||||
Reference in New Issue
Block a user