diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index b595029c0..0e1484c76 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -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 "; -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'])) { $sql .= ' AND P.device_id = ?'; $param[] = $_POST['device_id']; @@ -31,6 +22,25 @@ if (is_numeric($_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"; $total = dbFetchCell($count_sql, $param); diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 9f2ed062f..f6c6492d6 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -71,9 +71,9 @@ if ($_POST['searchby'] == 'ip') { ""+ ""+ "
"+ - " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ @@ -88,7 +88,7 @@ echo '"'.$_POST['address'].'"+'; id: "arp-search", device_id: '', searchby: '', - address: '' + searchPhrase: '' }; }, url: "ajax_table.php"