Better base_uri workaround code.
authorgraf25 <graf25@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 6 Apr 2002 21:00:18 +0000 (21:00 +0000)
committergraf25 <graf25@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 6 Apr 2002 21:00:18 +0000 (21:00 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2691 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/auth.php
functions/display_messages.php

index 83affbe6ea4568e484a21f3857ea0851ed3e2f5c..3ac8fc897b0919180dd5686217b666c6df30585f 100644 (file)
  * $Id$
  */
 
-/* If a user opens a new session then comes back to this one,
- * $base_uri isn't set because it the session is invalid.
- */
-
-if (!isset($base_uri)) {
-    $base_uri = dirname(dirname($PHP_SELF)) . "/";
-}
-
 function is_logged_in() {
 
     if ( session_is_registered('user_is_logged_in') ) {
index adb7acff72e85b8f9d928b4c098912d98abce1d9..29e1c16ecb40a8c44a3ba89a3ffe9e1f57cc8419 100644 (file)
  * $Id$
  */
 
+function sqm_baseuri(){
+    global $base_uri, $PHP_SELF;
+    if (isset($base_uri)){
+        return $base_uri;
+    }
+    $dirs = array("|src/.*|", "|plugins/.*|", "|functions/.*|");
+    $repl = array("", "", "");
+    $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
+    return $base_uri;
+}
+
 function error_username_password_incorrect() {
     global $frame_top, $color;
     /* XXX: Should really not start the HTML before this, or close off more
@@ -28,8 +39,8 @@ function error_username_password_incorrect() {
                 '</TR>' .
                 '<TR><TD>'.
                     '<CENTER><BR>' . _("Unknown user or password incorrect.") .
-                    '<BR><A HREF="login.php" TARGET='.$frame_top.'>' .
-                    _("Click here to try again") .
+                    '<BR><A HREF="' . sqm_baseuri() . '"login.php" TARGET='.
+                    $frame_top.'>' . _("Click here to try again") .
                     '</A>.</CENTER>'.
                 '</TD></TR>'.
                 '</TABLE>'.
@@ -80,7 +91,9 @@ function error_message($message, $mailbox, $sort, $startMessage, $color) {
             '</TD></TR><TR><TD>'.
                "<CENTER><BR>$message<BR>\n".
                '<BR>'.
-                  "<A HREF=\"right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">";
+                  "<A HREF=\"" . sqm_baseuri() 
+                  . "right_main.php?sort=$sort&amp;startMessage=$startMessage"
+                  . "&amp;mailbox=$urlMailbox\">";
     printf (_("Click here to return to %s"), $mailbox);
     echo '</A>.'.
             '</TD></TR>'.
@@ -103,11 +116,11 @@ function logout_error( $errString, $errTitle = '' ) {
 
     GLOBAL $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
            $hide_sm_attributions, $version;
-
-    include_once( '../functions/page_header.php' );
+    $base_uri = sqm_baseuri();
+    include_once($base_uri . 'functions/page_header.php' );
     if ( !isset( $org_logo ) ) {
         // Don't know yet why, but in some accesses $org_logo is not set.
-        include( '../config/config.php' );
+        include( $base_uri . '../config/config.php' );
     }
     /* Display width and height like good little people */
     $width_and_height = '';