Commit 26113c81 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(captiveportal, new) psr style fix

(cherry picked from commit e508d11f)
parent 231f7277
...@@ -72,15 +72,17 @@ class AccessController extends ApiControllerBase ...@@ -72,15 +72,17 @@ class AccessController extends ApiControllerBase
*/ */
private function getClientIp() private function getClientIp()
{ {
// determine orginal sender of this request // determine orginal sender of this request
$trusted_proxy = array("127.0.0.1"); $trusted_proxy = array("127.0.0.1");
if ($this->request->getHeader('X-Forwarded-For') != "" && in_array($this->request->getClientAddress(), $trusted_proxy) ) { if ($this->request->getHeader('X-Forwarded-For') != "" &&
// use X-Forwarded-For header to determine real client in_array($this->request->getClientAddress(), $trusted_proxy)
return $this->request->getHeader('X-Forwarded-For'); ) {
} else { // use X-Forwarded-For header to determine real client
// client accesses the Api directly return $this->request->getHeader('X-Forwarded-For');
return $this->request->getClientAddress(); } else {
} // client accesses the Api directly
return $this->request->getClientAddress();
}
} }
/** /**
...@@ -146,11 +148,13 @@ class AccessController extends ApiControllerBase ...@@ -146,11 +148,13 @@ class AccessController extends ApiControllerBase
$backend = new Backend(); $backend = new Backend();
$CPsession = $backend->configdpRun( $CPsession = $backend->configdpRun(
"captiveportal allow", "captiveportal allow",
array((string)$cpZone->zoneid, array(
(string)$cpZone->zoneid,
$userName, $userName,
$clientIp, $clientIp,
$authServerName, $authServerName,
'json') 'json'
)
); );
$CPsession = json_decode($CPsession, true); $CPsession = json_decode($CPsession, true);
if ($CPsession != null) { if ($CPsession != null) {
...@@ -160,12 +164,12 @@ class AccessController extends ApiControllerBase ...@@ -160,12 +164,12 @@ class AccessController extends ApiControllerBase
} }
} }
} else { } else {
return array("clientState" => 'NOT_AUTHORIZED',"ipAddress" => $clientIp); return array("clientState" => 'NOT_AUTHORIZED', "ipAddress" => $clientIp);
} }
} }
} }
return array("clientState" => 'UNKNOWN',"ipAddress" => $clientIp); return array("clientState" => 'UNKNOWN', "ipAddress" => $clientIp);
} }
...@@ -187,7 +191,7 @@ class AccessController extends ApiControllerBase ...@@ -187,7 +191,7 @@ class AccessController extends ApiControllerBase
$backend = new Backend(); $backend = new Backend();
$statusRAW = $backend->configdpRun( $statusRAW = $backend->configdpRun(
"captiveportal disconnect", "captiveportal disconnect",
array($zoneid, $clientSession['sessionId'], 'json') array($zoneid, $clientSession['sessionId'], 'json')
); );
$status = json_decode($statusRAW, true); $status = json_decode($statusRAW, true);
if ($status != null) { if ($status != null) {
......
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