You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
3.8 KiB
145 lines
3.8 KiB
<?php
|
|
/*****************************************************************************
|
|
IP Reg, a PHP/MySQL IPAM tool
|
|
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
|
|
Copyright (C) 2011-2023 Thomas Hooge
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
*****************************************************************************/
|
|
|
|
include("includes.php");
|
|
include("header.php");
|
|
|
|
|
|
// get string that was searched for ($search is already set in header.php)
|
|
if (empty($search)) {
|
|
// parse nosearch box
|
|
$smarty->assign("nosearch", TRUE);
|
|
} else {
|
|
// hide nosearch box
|
|
$smarty->assign("nosearch", FALSE);
|
|
$smarty->assign("search", $search);
|
|
|
|
// set needle
|
|
$needle = '%' . $search . '%';
|
|
|
|
// set counter
|
|
$resultcounter = 0;
|
|
|
|
// asset
|
|
$query = "SELECT
|
|
asset_id AS id,
|
|
asset_name AS name,
|
|
asset_info AS description
|
|
FROM
|
|
asset
|
|
WHERE
|
|
asset_name LIKE '" . $needle . "'
|
|
OR asset_hostname LIKE '" . $needle . "'
|
|
OR asset_info LIKE '" . $needle . "'
|
|
ORDER BY
|
|
asset_name";
|
|
|
|
$assets = $db->db_select($query);
|
|
$resultcounter += count($assets);
|
|
$smarty->assign("assets", $assets);
|
|
|
|
// location
|
|
$query = "SELECT
|
|
location_id AS id,
|
|
location_name AS name
|
|
FROM
|
|
location
|
|
WHERE
|
|
location_name LIKE '" . $needle . "'
|
|
OR location_info LIKE '" . $needle . "'
|
|
ORDER BY
|
|
location_name";
|
|
|
|
$locations = $db->db_select($query);
|
|
$resultcounter += count($locations);
|
|
$smarty->assign("locations", $locations);
|
|
|
|
// node
|
|
$query = "SELECT
|
|
node_id AS id,
|
|
node_ip AS ip
|
|
FROM
|
|
node
|
|
WHERE
|
|
node_ip LIKE '" . $needle . "'
|
|
OR node_mac LIKE '" . $needle . "'
|
|
OR node_dns1 LIKE '" . $needle . "'
|
|
OR node_dns2 LIKE '" . $needle . "'
|
|
OR node_info LIKE '" . $needle . "'
|
|
ORDER BY
|
|
node_ip";
|
|
|
|
$nodes = $db->db_select($query);
|
|
$resultcounter += count($nodes);
|
|
$smarty->assign("nodes", $nodes);
|
|
|
|
// subnet
|
|
$query = "SELECT
|
|
subnet_id AS id,
|
|
subnet_address AS address
|
|
FROM
|
|
subnet
|
|
WHERE
|
|
subnet_address LIKE '" . $needle . "'
|
|
OR subnet_info LIKE '" . $needle . "'
|
|
ORDER BY
|
|
subnet_address";
|
|
|
|
// run query
|
|
$subnets = $db->db_select($query);
|
|
$resultcounter += count($subnets);
|
|
$smarty->assign("subnets", $subnets);
|
|
|
|
// vlan
|
|
$query = "SELECT
|
|
vlan_id AS id,
|
|
vlan_name AS name
|
|
FROM
|
|
vlan
|
|
WHERE
|
|
vlan_name LIKE '" . $needle . "'
|
|
OR vlan_info LIKE '" . $needle . "'
|
|
ORDER BY
|
|
vlan_name";
|
|
|
|
$vlans = $db->db_select($query);
|
|
$resultcounter += count($vlans);
|
|
$smarty->assign("vlans", $vlans);
|
|
|
|
// setup zone
|
|
$query = "SELECT
|
|
zone_id AS id,
|
|
zone_origin AS origin
|
|
FROM
|
|
zone
|
|
WHERE
|
|
zone_origin LIKE '" . $needle . "'
|
|
OR zone_soa LIKE '" . $needle . "'
|
|
OR zone_hostmaster LIKE '" . $needle . "'
|
|
OR zone_ns1 LIKE '" . $needle . "'
|
|
OR zone_ns2 LIKE '" . $needle . "'
|
|
OR zone_ns3 LIKE '" . $needle . "'
|
|
OR zone_mx1 LIKE '" . $needle . "'
|
|
OR zone_mx2 LIKE '" . $needle . "'
|
|
OR zone_info LIKE '" . $needle . "'
|
|
ORDER BY
|
|
zone_origin";
|
|
|
|
$zones = $db->db_select($query);
|
|
$resultcounter += count($zones);
|
|
$smarty->assign("zones", $zones);
|
|
|
|
// grand totals
|
|
$smarty->assign("resultcounter", $resultcounter);
|
|
}
|
|
|
|
$smarty->display("search.tpl");
|
|
|
|
include("footer.php");
|
|
?>
|
|
|