summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/helper.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index efff00c2fe6..6d7d1702aa8 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -60,6 +60,28 @@ class OC_Helper {
}
/**
+ * @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
* @param $app app
* @param $file file