summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorDaniele E. Domenichelli <daniele.domenichelli@gmail.com>2012-04-12 14:35:28 +0200
committerRobin Appelman <icewind@owncloud.com>2012-04-12 17:51:17 +0200
commit7b5395675d960bfb83470e36a743054e36a33008 (patch)
treed84bc5c84f14dcfde99ec4761d257cc3364ffd02 /lib/helper.php
parent0466437fa7878fa1681ee01651d7d41cdef7454a (diff)
downloadnextcloud-server-7b5395675d960bfb83470e36a743054e36a33008.tar.gz
nextcloud-server-7b5395675d960bfb83470e36a743054e36a33008.zip
Add method OC_Helper::serverHost()
This method returns the server host, even if the website uses one or more reverse proxies.
Diffstat (limited to 'lib/helper.php')
-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