+ // Detects full URL of installation
+ function detectServerUrl () {
+ // Is "cache" there?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Default protocol is HTTP
+ $protocol = 'http';
+
+ // Is SSL given?
+ if (((isset($_SERVER['HTTPS'])) && (strtolower($_SERVER['HTTPS']) == 'on')) || ((isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) && (strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'))) {
+ // Protocol is HTTPS
+ $protocol = 'https';
+ } // END - if
+
+ // Construct full URL
+ $GLOBALS[__FUNCTION__] = str_replace("\\", '', sprintf('%s://%s%s/', $protocol, $_SERVER['SERVER_NAME'], dirname($_SERVER['SCRIPT_NAME'])));
+ } // END - if
+
+ // Return cached value
+ return $GLOBALS[__FUNCTION__];
+ }
+