From e2532f4ab4a1c09998058c7a71e0c79ef968a9b0 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 3 Nov 2015 16:43:42 +0000 Subject: [PATCH 1/2] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 3e2aee703..3e65c34f4 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -65,5 +65,6 @@ Contributors to LibreNMS: - Sebastian Neuner (9er) - Robert Zollner (Lupul) - Richard Hartmann (RichiH) +- Robert Gornall Date: Tue, 3 Nov 2015 16:50:06 +0000 Subject: [PATCH 2/2] Quote column titles when sql building to avoid mysql keywords --- html/includes/api_functions.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 68a574a59..2e10819b9 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -163,23 +163,23 @@ function list_devices() { } if (stristr($order, ' desc') === false && stristr($order, ' asc') === false) { - $order .= ' ASC'; + $order = '`'.$order.'` ASC'; } if ($type == 'all' || empty($type)) { $sql = '1'; } elseif ($type == 'ignored') { - $sql = "ignore='1' AND disabled='0'"; + $sql = "`ignore`='1' AND `disabled`='0'"; } elseif ($type == 'up') { - $sql = "status='1' AND ignore='0' AND disabled='0'"; + $sql = "`status`='1' AND `ignore`='0' AND `disabled`='0'"; } elseif ($type == 'down') { - $sql = "status='0' AND ignore='0' AND disabled='0'"; + $sql = "`status`='0' AND `ignore`='0' AND `disabled`='0'"; } elseif ($type == 'disabled') { - $sql = "disabled='1'"; + $sql = "`disabled`='1'"; } elseif ($type == 'mac') { $join = " LEFT JOIN `ports` ON `devices`.`device_id`=`ports`.`device_id` LEFT JOIN `ipv4_mac` ON `ports`.`port_id`=`ipv4_mac`.`port_id` ";