Handy place to show error reporting values - can use this as a tool for support requests
[squirrelmail.git] / functions / strings.php
index 68c607819bd9d230c41590d0e189109b252c9b49..14015cc0c6716af5d22bfb861cbf27bcea9c6a73 100644 (file)
@@ -6,7 +6,7 @@
  * This code provides various string manipulation functions that are
  * used by the rest of the SquirrelMail code.
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -496,11 +496,15 @@ function get_location () {
     /*
      * If you have 'SSLOptions +StdEnvVars' in your apache config
      *     OR if you have HTTPS=on in your HTTP_SERVER_VARS
+     *     OR if you have HTTP_X_FORWARDED_PROTO=https in your HTTP_SERVER_VARS
      *     OR if you are on port 443
      */
     $getEnvVar = getenv('HTTPS');
+    if (!sqgetGlobalVar('HTTP_X_FORWARDED_PROTO', $forwarded_proto, SQ_SERVER))
+        $forwarded_proto = '';
     if ((isset($getEnvVar) && strcasecmp($getEnvVar, 'on') === 0) ||
         (sqgetGlobalVar('HTTPS', $https_on, SQ_SERVER) && strcasecmp($https_on, 'on') === 0) ||
+        (strcasecmp($forwarded_proto, 'https') === 0) ||
         (sqgetGlobalVar('SERVER_PORT', $server_port, SQ_SERVER) &&  $server_port == 443)) {
         $proto = 'https://';
     }
@@ -518,7 +522,8 @@ function get_location () {
     if (! strstr($host, ':')) {
         if (sqgetGlobalVar('SERVER_PORT', $server_port, SQ_SERVER)) {
             if (($server_port != 80 && $proto == 'http://') ||
-                ($server_port != 443 && $proto == 'https://')) {
+                ($server_port != 443 && $proto == 'https://' &&
+                 strcasecmp($forwarded_proto, 'https') !== 0)) {
                 $port = sprintf(':%d', $server_port);
             }
         }