diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php new file mode 100644 index 0000000000..22a493a316 --- /dev/null +++ b/html/pages/search/arp.inc.php @@ -0,0 +1,96 @@ + + + + + + + + + + + +
+ + Search by + + + + + +
+ +'); + +$query = "SELECT * FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D WHERE M.interface_id = P.interface_id AND P.device_id = D.device_id "; +if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") +{ + $query .= " AND `ipv4_address` LIKE ?"; + $param = array("%".trim($_POST['address'])."%"); +} else { + $query .= " AND `mac_address` LIKE ?"; + $param = array("%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"); +} + +if (is_numeric($_POST['device_id'])) +{ + $query .= " AND P.device_id = ?"; + $param[] = $_POST['device_id']; +} +$query .= " ORDER BY M.mac_address"; + +echo('MAC AddressIP AddressDeviceInterfaceRemote deviceRemote interface'); +foreach (dbFetchRows($query, $param) as $entry) +{ + if (!$ignore) + { + //why are they here for? + //$speed = humanspeed($entry['ifSpeed']); + //$type = humanmedia($entry['ifType']); + + if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) + { + $error_img = generate_port_link($entry,"Interface Errors",errors); + } else { $error_img = ""; } + + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); + if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } + if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } + if ($arp_host['device_id'] == $entry['device_id']) { $arp_name = "Localhost"; } + if ($arp_host['interface_id'] == $entry['interface_id']) { $arp_if = "Local port"; } + + + echo(' + ' . formatMac($entry['mac_address']) . ' + ' . $entry['ipv4_address'] . ' + ' . generate_device_link($entry) . ' + ' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . ' + '.$arp_name.' + '.$arp_if.' + '); + } + + unset($ignore); +} + +echo(""); + +?>