mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix ARP search on all ARP pages. Adapt ARP search page to use a common search variable.
This commit is contained in:
@@ -12,15 +12,6 @@ if (is_admin() === false && is_read() === false) {
|
|||||||
|
|
||||||
$sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where ";
|
$sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where ";
|
||||||
|
|
||||||
if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') {
|
|
||||||
$sql .= ' AND `ipv4_address` LIKE ?';
|
|
||||||
$param[] = '%'.trim($_POST['address']).'%';
|
|
||||||
}
|
|
||||||
else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') {
|
|
||||||
$sql .= ' AND `mac_address` LIKE ?';
|
|
||||||
$param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_numeric($_POST['device_id'])) {
|
if (is_numeric($_POST['device_id'])) {
|
||||||
$sql .= ' AND P.device_id = ?';
|
$sql .= ' AND P.device_id = ?';
|
||||||
$param[] = $_POST['device_id'];
|
$param[] = $_POST['device_id'];
|
||||||
@@ -31,6 +22,25 @@ if (is_numeric($_POST['port_id'])) {
|
|||||||
$param[] = $_POST['port_id'];
|
$param[] = $_POST['port_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['searchPhrase']) && !empty($_POST['searchPhrase'])) {
|
||||||
|
$ip_search = '%'.mres(trim($_POST['searchPhrase'])).'%';
|
||||||
|
$mac_search = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['searchPhrase'])).'%';
|
||||||
|
|
||||||
|
if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') {
|
||||||
|
$sql .= ' AND `ipv4_address` LIKE ?';
|
||||||
|
$param[] = $ip_search;
|
||||||
|
}
|
||||||
|
else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') {
|
||||||
|
$sql .= ' AND `mac_address` LIKE ?';
|
||||||
|
$param[] = $mac_search;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql .= ' AND (`ipv4_address` LIKE ? OR `mac_address` LIKE ?)';
|
||||||
|
$param[] = $ip_search;
|
||||||
|
$param[] = $mac_search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$count_sql = "SELECT COUNT(`M`.`port_id`) $sql";
|
$count_sql = "SELECT COUNT(`M`.`port_id`) $sql";
|
||||||
|
|
||||||
$total = dbFetchCell($count_sql, $param);
|
$total = dbFetchCell($count_sql, $param);
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ if ($_POST['searchby'] == 'ip') {
|
|||||||
"</select>"+
|
"</select>"+
|
||||||
"</div>"+
|
"</div>"+
|
||||||
"<div class=\"form-group\">"+
|
"<div class=\"form-group\">"+
|
||||||
"<input type=\"text\" name=\"address\" id=\"address\" value=\""+
|
"<input type=\"text\" name=\"searchPhrase\" id=\"address\" value=\""+
|
||||||
<?php
|
<?php
|
||||||
echo '"'.$_POST['address'].'"+';
|
echo '"'.$_POST['searchPhrase'].'"+';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
"\" class=\"form-control input-sm\" placeholder=\"Address\" />"+
|
"\" class=\"form-control input-sm\" placeholder=\"Address\" />"+
|
||||||
@@ -88,7 +88,7 @@ echo '"'.$_POST['address'].'"+';
|
|||||||
id: "arp-search",
|
id: "arp-search",
|
||||||
device_id: '<?php echo htmlspecialchars($_POST['device_id']); ?>',
|
device_id: '<?php echo htmlspecialchars($_POST['device_id']); ?>',
|
||||||
searchby: '<?php echo mres($_POST['searchby']); ?>',
|
searchby: '<?php echo mres($_POST['searchby']); ?>',
|
||||||
address: '<?php echo mres($_POST['address']); ?>'
|
searchPhrase: '<?php echo mres($_POST['searchPhrase']); ?>'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
url: "ajax_table.php"
|
url: "ajax_table.php"
|
||||||
|
|||||||
Reference in New Issue
Block a user