]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Introduced detectServerProtocol() to fully support HTTPS and more use of isFullQualif...
[mailer.git] / inc / wrapper-functions.php
index 4520489da1ffc09a355846e58f2018a46c3034ad..b3a63292626d341f5764167b638f1b39db7f8feb 100644 (file)
@@ -293,6 +293,24 @@ function detectServerName () {
        return (getenv('SERVER_NAME'));
 }
 
+// Detects server protocol (http/s)
+function detectServerProtocol () {
+       // Is cache there?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Default is HTTP
+               $GLOBALS[__FUNCTION__] = 'http';
+
+               // Are some specific fields set?
+               if (((isset($_SERVER['HTTPS'])) && (strtolower($_SERVER['HTTPS']) == 'on')) || ((isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) && (strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'))) {
+                       // Switch to HTTPS
+                       $GLOBALS[__FUNCTION__] = 'https';
+               } // END - if
+       } // END - if
+
+       // Return cached value
+       return $GLOBALS[__FUNCTION__];
+}
+
 // Removes any  existing www. from SERVER_NAME. This is very silly but enough
 // for our purpose here.
 function detectDomainName () {