Fixed sql query for port stats call to include the device_id :/

This commit is contained in:
Neil Lathwood
2015-02-18 16:22:52 +00:00
parent 55621becb9
commit 0596643b55

View File

@ -76,8 +76,10 @@ function get_port_stats_by_port_hostname()
global $config; global $config;
$app = \Slim\Slim::getInstance(); $app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams(); $router = $app->router()->getCurrentRoute()->getParams();
$hostname = $router['hostname'];
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$ifName = urldecode($router['ifname']); $ifName = urldecode($router['ifname']);
$stats = dbFetchRow("SELECT * FROM `ports` WHERE `ifName`=?", array($ifName)); $stats = dbFetchRow("SELECT * FROM `ports` WHERE `device_id`=? AND `ifName`=?", array($device_id,$ifName));
$output = array("status" => "ok", "port" => $stats); $output = array("status" => "ok", "port" => $stats);
$app->response->headers->set('Content-Type', 'application/json'); $app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output); echo _json_encode($output);