+
+ public static function getPocheUrl()
+ {
+ $baseUrl = "";
+ $https = (!empty($_SERVER['HTTPS'])
+ && (strtolower($_SERVER['HTTPS']) == 'on'))
+ || (isset($_SERVER["SERVER_PORT"])
+ && $_SERVER["SERVER_PORT"] == '443') // HTTPS detection.
+ || (isset($_SERVER["SERVER_PORT"]) //Custom HTTPS port detection
+ && $_SERVER["SERVER_PORT"] == SSL_PORT)
+ || (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
+ && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
+ $serverport = (!isset($_SERVER["SERVER_PORT"])
+ || $_SERVER["SERVER_PORT"] == '80'
+ || $_SERVER["SERVER_PORT"] == HTTP_PORT
+ || ($https && $_SERVER["SERVER_PORT"] == '443')
+ || ($https && $_SERVER["SERVER_PORT"]==SSL_PORT) //Custom HTTPS port detection
+ ? '' : ':' . $_SERVER["SERVER_PORT"]);
+
+ if (isset($_SERVER["HTTP_X_FORWARDED_PORT"])) {
+ $serverport = ':' . $_SERVER["HTTP_X_FORWARDED_PORT"];
+ }
+ // $scriptname = str_replace('/index.php', '/', $_SERVER["SCRIPT_NAME"]);
+ // if (!isset($_SERVER["HTTP_HOST"])) {
+ // return $scriptname;
+ // }
+ $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']));
+ if (strpos($host, ':') !== false) {
+ $serverport = '';
+ }
+ // check if BASE_URL is configured
+ if(BASE_URL) {
+ $baseUrl = BASE_URL;
+ } else {
+ $baseUrl = 'http' . ($https ? 's' : '') . '://' . $host . $serverport;
+ }
+ return $baseUrl;
+
+ }