Commit 020b2736 authored by Tim Niemeyer's avatar Tim Niemeyer Committed by Jan-Tarek Butt

api: router: fix find router by hostname

Based on:
    api: make it possible to find router by hostname
    by mojoaxel <alex@wunschik.net>
Signed-off-by: default avatarTim Niemeyer <tim.niemeyer@mastersword.de>
parent 55fb6bff
......@@ -9,7 +9,7 @@
# get router by mac (api/rest/router/mac)
RewriteRule ^router/([a-fA-F0-9]{12})/?$ api.php?rquest=router&mac=$1 [QSA,L]
# get router by hostname (api/rest/router/hostname)
RewriteRule ^router/([a-zA-Z0-9.-]+)/?$ api.php?rquest=router&hostname=$1 [QSA,L]
RewriteRule ^router/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*)/?$ api.php?rquest=router&hostname=$1 [QSA,L]
################
# ROUTERLIST #
......
......@@ -77,10 +77,11 @@
return false;
}
if (isset($this->_request['router_id']) || isset($this->_request['hostname']))) {
$this->_request['router_id'] = (isset($this->_request['router_id'])) ? $this->_request['router_id'] : false;
$this->_request['hostname'] = (isset($this->_request['hostname'])) ? $this->_request['hostname'] : false;
$router = new Router((int)$this->_request['router_id'], false, $this->_request['hostname']);
if (isset($this->_request['router_id'])) {
$router = new Router((int)$this->_request['router_id']);
} else if (isset($this->_request['hostname'])) {
$router = new Router();
$router->setHostname($this->_request['hostname']);
} else if (isset($this->_request['mac'])) {
$router = new Router();
$router->setMac($this->_request['mac']);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment