Cache the base url (protocol://host:port) in the session to make it
authorebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 10 Mar 2003 07:19:20 +0000 (07:19 +0000)
committerebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 10 Mar 2003 07:19:20 +0000 (07:19 +0000)
faster. get_location already parsed php_self to get the url
e.g. /path/to/sqmail/src
So now, to make Locations compliant, you can either, call get_location if
you know the place you're redirecting to has the same url path you do
(src to src, for example), or check for 'sq_base_url' in the session vars,
call get_location to set it if it isn't there, and then use the
'sq_base_url' session var + base_uri from session + desired location to
redirect.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4629 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php

index d4adfaa715b8b11ccdb4394cc4a93c52ef925bc6..f6ba0500b9fac3ceb263237e5775624f6bd04e87 100644 (file)
@@ -190,10 +190,14 @@ function php_self () {
 function get_location () {
     
     global $imap_server_type;
-    
+
     /* Get the path, handle virtual directories */
     $path = substr(php_self(), 0, strrpos(php_self(), '/'));
-    
+
+    if ( sqgetGlobalVar('sq_base_url', $full_url, SQ_SESSION) ) {
+      return $full_url . $path;
+    }
+
     /* Check if this is a HTTPS or regular HTTP request. */
     $proto = 'http://';
     
@@ -234,9 +238,11 @@ function get_location () {
         $port = '';
    }
    
-    /* Fallback is to omit the server name and use a relative */
-    /* URI, although this is not RFC 2616 compliant.          */
-    return ($host ? $proto . $host . $port . $path : $path);
+   /* Fallback is to omit the server name and use a relative */
+   /* URI, although this is not RFC 2616 compliant.          */
+   $full_url = ($host ? $proto . $host . $port : '');
+   sqsession_register($full_url, 'sq_base_url');
+   return $full_url . $path;
 }