فهرست منبع

Added a new session variable base_uri. Uses this variable when
printing the page header. This is needed to be able to print the
header in plugins.

gustavf 25 سال پیش
والد
کامیت
87b17825d0
2فایلهای تغییر یافته به همراه42 افزوده شده و 14 حذف شده
  1. 22 8
      functions/page_header.php
  2. 20 6
      src/webmail.php

+ 22 - 8
functions/page_header.php

@@ -57,6 +57,15 @@
       echo "</HEAD>\n\n";
    }
 
+   function displayInternalLink ($path, $text, $target="") {
+      global $base_uri;
+
+      if ($target != "")
+         $target = " target=\"$target\"";
+
+      echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
+   }
+
    function displayPageHeader($color, $mailbox) {
       displayHtmlHeader ($color);
 
@@ -69,9 +78,9 @@
       $shortBoxName = stripslashes($shortBoxName);
       echo "<TABLE BGCOLOR=\"$color[4]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>\n";
       echo "   <TR BGCOLOR=\"$color[9]\">\n";
-      echo "      <TD ALIGN=left WIDTH=\"30%\">\n";
-      echo "         <A HREF=\"signout.php\" TARGET=\"_top\"><B>" . _("Sign Out") . "</B></A>\n";
-      echo "      </TD><TD ALIGN=right WIDTH=\"70%\">\n";
+      echo "      <TD ALIGN=left WIDTH=\"30%\"><b>\n";
+      displayInternalLink ("src/signout.php", _("Sign Out"), "_top");
+      echo "      </b></TD><TD ALIGN=right WIDTH=\"70%\">\n";
       echo "         <div align=right>" . _("Current Folder: ") . "<B>$shortBoxName&nbsp;</B></div>\n";
       echo "      </TD>\n";
       echo "   </TR>\n";
@@ -80,11 +89,16 @@
       echo "   <TR>\n";
       echo "      <TD ALIGN=left WIDTH=\"70%\">\n";
       $urlMailbox = $mailbox;
-      echo "         <A HREF=\"compose.php?mailbox=$urlMailbox\">" . _("Compose") . "</A>&nbsp;&nbsp;\n";
-      echo "         <A HREF=\"addressbook.php\">" . _("Addresses") . "</A>&nbsp;&nbsp;\n";
-      echo "         <A HREF=\"folders.php\">" . _("Folders") . "</A>&nbsp;&nbsp;\n";
-      echo "         <A HREF=\"options.php\">" . _("Options") . "</A>&nbsp;&nbsp;\n";
-      echo "         <A HREF=\"webmail.php?right_frame=help.php\" TARGET=\"Help Me!\">" . _("Help") . "</A>&nbsp;&nbsp;";
+      displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), "right");
+      echo "&nbsp;&nbsp;\n";
+      displayInternalLink ("src/addressbook.php", _("Addresses"), "right");
+      echo "&nbsp;&nbsp;\n";
+      displayInternalLink ("src/folders.php", _("Folders"), "right");
+      echo "&nbsp;&nbsp;\n";
+      displayInternalLink ("src/options.php", _("Options"), "right");
+      echo "&nbsp;&nbsp;\n";
+      displayInternalLink ("src/webmail.php?right_frame=help.php", _("Help"), "Help Me!");
+      echo "&nbsp;&nbsp;\n";
 
       do_hook("menuline");
 

+ 20 - 6
src/webmail.php

@@ -1,21 +1,35 @@
 <?php
    /**
-    **  webmail.php
+    **  webmail.php -- Displays the main frameset
     **
-    **  This simply creates the frames.
+    **  Copyright (c) 2000 The SquirrelMail development team
+    **  Licensed under the GNU GPL. For full terms see the file COPYING.
+    **
+    **  This file generates the main frameset. The files that are
+    **  shown can be given as parameters. If the user is not logged in
+    **  this file will verify username and password.
     **
     **/
 
+   // Before starting the session, the base URI must be known.
+   // Assuming that this file is in the src/ subdirectory (or
+   // something).
+   ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
+   $base_uri = $regs[1];
+
+   session_set_cookie_params (0, $base_uri);
    session_start();
 
+   session_register ("base_uri");
+
    if(!isset($username)) {
       echo _("You need a valid user and password to access this page!");
       exit;
    }
 
-   setcookie("username", $username, 0, "/");
-   setcookie("key", $key, 0, "/");
-   setcookie("logged_in", 1, 0, "/");
+   setcookie("username", $username, 0, $base_uri);
+   setcookie("key", $key, 0, $base_uri);
+   setcookie("logged_in", 1, 0, $base_uri);
    
    // Refresh the language cookie.
    if (isset($squirrelmail_language)) {
@@ -30,7 +44,7 @@
    if (!isset($auth_php))
       include ("../functions/auth.php");
 
-   if (session_is_registered("user_is_logged_in")) {
+   if (!session_is_registered("user_is_logged_in")) {
       do_hook ("login_before");
       // verify that username and password are correct
       $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);