Small cleanups (#4405)

* Small cleanups

* Small cleanups
This commit is contained in:
Tony Murray
2016-09-11 22:11:16 -05:00
committed by GitHub
parent d1ae83a378
commit 195a8ee349

View File

@@ -39,16 +39,14 @@ if (is_admin() === false && is_read() === false) {
$sql .= ' LEFT JOIN `devices` AS `D` ON `ports`.`device_id` = `D`.`device_id`';
if (!empty($_POST['hostname']) || !empty($_POST['location']) || $sort_column == 'device') {
if (!empty($_POST['hostname'])) {
$where .= ' AND `D`.`hostname` LIKE ?';
$param[] = '%' . $_POST['hostname'] . '%';
}
if (!empty($_POST['hostname'])) {
$where .= ' AND `D`.`hostname` LIKE ?';
$param[] = '%' . $_POST['hostname'] . '%';
}
if (!empty($_POST['location'])) {
$where .= " AND `D`.`location` = ?";
$param[] = $_POST['location'];
}
if (!empty($_POST['location'])) {
$where .= " AND `D`.`location` = ?";
$param[] = $_POST['location'];
}
$sql .= " WHERE $where ";
@@ -163,18 +161,11 @@ foreach (dbFetchRows($sql, $param) as $port) {
);
}
// debug
//$vals = $param;
//$query = preg_replace_callback('/\?/', function ($match) use (&$vals) {
// return array_shift($vals); // wrap in quotes and sanitize
//}, $sql);
$output = array(
'current' => $current,
'rowCount' => $rowCount,
'rows' => $response,
'total' => $total,
// 'sql' => $query,
);
echo _json_encode($output);