Added ability to filter top interfaces by type

This commit is contained in:
f0o
2015-09-20 10:13:56 +01:00
parent 527f482e4a
commit 14f1bd36b8
2 changed files with 102 additions and 44 deletions

View File

@@ -294,6 +294,28 @@ if (isset($_REQUEST['search'])) {
}//end foreach
}//end if
$json = json_encode($device);
die($json);
}
else if ($_REQUEST['type'] == 'iftype') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `ports`.ifType FROM `ports` WHERE `ifType` LIKE '%".$search."%' GROUP BY ifType ORDER BY ifType LIMIT 8");
}
else {
$results = dbFetchRows("SELECT `I`.ifType FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifType` LIKE '%".$search."%') GROUP BY ifType ORDER BY ifType LIMIT 8", array($_SESSION['user_id'], $_SESSION['user_id']));
}
if (count($results)) {
$found = 1;
$devices = count($results);
foreach ($results as $result) {
$device[] = array(
'filter' => $result['ifType'],
);
}//end foreach
}//end if
$json = json_encode($device);
die($json);
}//end if