Sigh... I guess global search and replace in emacs doesn't work QUITE as
[squirrelmail.git] / functions / display_messages.php
index adb7acff72e85b8f9d928b4c098912d98abce1d9..f0291ab26829d0aec3cb9267127ed5dd2149ece5 100644 (file)
  * $Id$
  */
 
+/**
+ * Find out where squirrelmail lives and try to be smart about it.
+ * The only problem would be when squirrelmail lives in directories
+ * called "src", "functions", or "plugins", but people who do that need
+ * to be beaten with a steel pipe anyway.
+ *
+ * @return  the base uri of squirrelmail installation.
+ */
+function sqm_baseuri(){
+    global $base_uri, $PHP_SELF;
+    /**
+     * If it is in the session, just return it.
+     */
+    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,47 +50,14 @@ 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>'.
             '</BODY></HTML>';
 }
 
-function general_info($motd, $org_logo, $version, $org_name, $color) {
-
-    echo '<BR>'.
-         "<TABLE COLS=1 WIDTH=\"80%\" CELLSPACING=0 CELLPADDING=2 BORDER=\"0\" ALIGN=CENTER><TR><TD BGCOLOR=\"$color[9]\">".
-         '<TABLE COLS=1 WIDTH="100%" CELLSPACING=0 CELLPADDING=3 BORDER="0" BGCOLOR="' .  $color[4] . '" ALIGN=CENTER>'.
-            '<TR>' .
-               "<TD BGCOLOR=\"$color[0]\">" .
-                  '<B><CENTER>';
-    printf (_("Welcome to %s's WebMail system"), $org_name);
-    echo          '</CENTER></B>'.
-            '<TR><TD BGCOLOR="' . $color[4] .  '">'.
-               '<TABLE COLS=2 WIDTH="90%" CELLSPACING=0 CELLPADDING=3 BORDER="0" align="center">'.
-                  '<TR>'.
-                     '<TD BGCOLOR="' . $color[4] .  '"><CENTER>';
-    if ( strlen($org_logo) > 3 ) {
-        echo                "<IMG SRC=\"$org_logo\">";
-    } else {
-        echo                "<B>$org_name</B>";
-    }
-    echo          '<BR><CENTER>';
-    printf (_("Running SquirrelMail version %s (c) 1999-2001."), $version);
-    echo             '</CENTER><BR>'.
-                     '</CENTER></TD></TR><TR>' .
-                     '<TD BGCOLOR="' . $color[4] .  '">' .
-                         $motd.
-                     '</TD>'.
-                  '</TR>'.
-               '</TABLE>'.
-            '</TD></TR>'.
-         '</TABLE>'.
-         '</TD></TR></TABLE>';
-}
-
 function error_message($message, $mailbox, $sort, $startMessage, $color) {
     $urlMailbox = urlencode($mailbox);
 
@@ -80,7 +69,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() 
+                  . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
+                  . "&amp;mailbox=$urlMailbox\">";
     printf (_("Click here to return to %s"), $mailbox);
     echo '</A>.'.
             '</TD></TR>'.
@@ -102,12 +93,13 @@ function plain_error_message($message, $color) {
 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' );
+           $hide_sm_attributions, $version, $DOCUMENT_ROOT,
+           $squirrelmail_language;
+    $base_uri = sqm_baseuri();
+    include_once($DOCUMENT_ROOT . $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( $DOCUMENT_ROOT . $base_uri . 'config/config.php' );
     }
     /* Display width and height like good little people */
     $width_and_height = '';
@@ -161,10 +153,11 @@ function logout_error( $errString, $errTitle = '' ) {
             '<TR><TD><CENTER>' . $errString . '</CENTER></TD></TR>'.
             "<TR><TD BGCOLOR=\"$color[0]\">".
                   "<FONT COLOR=\"$color[2]\"><B><CENTER>".
-                  '<a href="' . $base_uri . '" target="' . $frame_top . '">' .
+                  '<a href="' . $base_uri . 'src/login.php" target="' .
+                  $frame_top . '">' .
                   _("Go to the login page") . "</a></CENTER></B></FONT>".
             '</TD></TR>'.
          '</TABLE></td></tr></table></body></html>';
 }
 
-?>
\ No newline at end of file
+?>