Add method OC_Helper::serverHost()
This method returns the server host, even if the website uses one or more reverse proxies.
This commit is contained in:
parent
0466437fa7
commit
7b5395675d
|
@ -59,6 +59,28 @@ class OC_Helper {
|
||||||
return $urlLinkTo;
|
return $urlLinkTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the server host
|
||||||
|
* @returns the server host
|
||||||
|
*
|
||||||
|
* Returns the server host, even if the website uses one or more
|
||||||
|
* reverse proxies
|
||||||
|
*/
|
||||||
|
public static function serverHost() {
|
||||||
|
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||||
|
if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) {
|
||||||
|
$host = trim(array_pop(explode(",", $_SERVER['HTTP_X_FORWARDED_HOST'])));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$host=$_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
|
}
|
||||||
|
return $host;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates an absolute url
|
* @brief Creates an absolute url
|
||||||
* @param $app app
|
* @param $app app
|
||||||
|
|
Loading…
Reference in New Issue