Merge pull request #60 from andrewmunro/nginx-fix

Nginx fixes
This commit is contained in:
Exodus 4D
2015-11-10 18:57:43 +01:00

View File

@@ -175,7 +175,7 @@ class Controller {
$data = (object) [];
$data->trusted = false;
$data->values = [];
$headerData = apache_request_headers();
$headerData = self::getRequestHeaders();
foreach($headerData as $key => $value){
$key = strtolower($key);
@@ -199,6 +199,24 @@ class Controller {
return $data;
}
/**
* Helper function to return all headers because
* getallheaders() is not available under nginx
*
* @return array (string $key -> string $value)
*/
static function getRequestHeaders(){
$headers = '';
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
/**
* check if the current request was send from inGame
* @return bool