Przeglądaj źródła

Some optimization on frequent loaded code.
Unification of logout error messages.
Strings update.
Spanish strings update.

philippe_mingo 23 lat temu
rodzic
commit
f9cbd7d61d

+ 5 - 22
functions/auth.php

@@ -11,41 +11,24 @@
  * $Id$
  */
 
-require_once( '../functions/page_header.php' );
-
 /* 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)) {
     ereg ('(^.*/)[^/]+/[^/]+$', $PHP_SELF, $regs);
-    $base_uri = $regs[1];
-    
+    $base_uri = $regs[1];    
 }
 
-function is_logged_in () {
-    global $squirrelmail_language, $frame_top, $base_uri;
+function is_logged_in() {
 
     if ( session_is_registered('user_is_logged_in') ) {
         return;
     } else {
-
-        if (!isset($frame_top) || $frame_top == '' ) {
-            $frame_top = '_top';
-        }
-        
-        set_up_language($squirrelmail_language, true);
-    
-        displayHtmlHeader( _("You must be logged in to access this page.") );
-    
-        echo "<body bgcolor=\"ffffff\">\n" .
-             '&nbsp;<p><center><b>' .
-             _("You must be logged in to access this page.").'</b><br><br>' .
-             '<a href="' . $base_uri . '" target="' . $frame_top . '">' . 
-             _("Go to the login page") . "</a>\n" .
-             "</center></body></html>\n";
+        include_once( '../functions/display_messages.php' );
+        logout_error( _("You must be logged in to access this page.") );
         exit;
     }
 }
 
-?>
+?>

+ 70 - 3
functions/display_messages.php

@@ -88,8 +88,7 @@ function error_message($message, $mailbox, $sort, $startMessage, $color) {
 }
 
 function plain_error_message($message, $color) {
-    echo '<BR>'.
-         "<TABLE COLS=1 WIDTH=\"70%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
+    echo "<br><TABLE COLS=1 WIDTH=\"70%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
             '<TR>'.
                "<TD BGCOLOR=\"$color[0]\">".
                   "<FONT COLOR=\"$color[2]\"><B><CENTER>" . _("ERROR") . '</CENTER></B></FONT>'.
@@ -100,4 +99,72 @@ function plain_error_message($message, $color) {
          '</TABLE>';
 }
 
-?>
+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' );
+    if ( !isset( $org_logo ) ) {
+        // Don't know yet why, but in some accesses $org_logo is not set.
+        include( '../config/config.php' );
+    }
+    /* Display width and height like good little people */
+    $width_and_height = '';
+    if (isset($org_logo_width) && is_int($org_logo_width) && $org_logo_width>0) {
+        $width_and_height = " WIDTH=\"$org_logo_width\"";
+    }
+    if (isset($org_logo_height) && is_int($org_logo_height) && $org_logo_height>0) {
+        $width_and_height .= " HEIGHT=\"$org_logo_height\"";
+    }
+
+    if (!isset($frame_top) || $frame_top == '' ) {
+        $frame_top = '_top';
+    }
+
+    if ( !isset( $color ) ) {
+        $color = array();
+        $color[0]  = '#DCDCDC';  /* light gray    TitleBar               */
+        $color[1]  = '#800000';  /* red                                  */
+        $color[2]  = '#CC0000';  /* light red     Warning/Error Messages */
+        $color[3]  = '#A0B8C8';  /* green-blue    Left Bar Background    */
+        $color[4]  = '#FFFFFF';  /* white         Normal Background      */
+        $color[5]  = '#FFFFCC';  /* light yellow  Table Headers          */
+        $color[6]  = '#000000';  /* black         Text on left bar       */
+        $color[7]  = '#0000CC';  /* blue          Links                  */
+        $color[8]  = '#000000';  /* black         Normal text            */
+        $color[9]  = '#ABABAB';  /* mid-gray      Darker version of #0   */
+        $color[10] = '#666666';  /* dark gray     Darker version of #9   */
+        $color[11] = '#770000';  /* dark red      Special Folders color  */
+        $color[12] = '#EDEDED';
+        $color[15] = '#002266';  /* (dark blue)      Unselectable folders */
+    }
+
+    if ( $errTitle == '' ) {
+        $errTitle = $errString;
+    }
+    set_up_language($squirrelmail_language, true);
+    displayHtmlHeader( $errTitle );
+    
+    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
+         '<CENTER>'.
+         "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
+            "\"$width_and_height><BR>\n".
+         ( $hide_sm_attributions ? '' :
+           '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
+           '  ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
+         "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>".
+         "<TABLE COLS=1 WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
+            "<TR><TD BGCOLOR=\"$color[0]\">".
+                  "<FONT COLOR=\"$color[2]\"><B><CENTER>" . _("ERROR") .
+                  '</CENTER></B></FONT></TD></TR>'.
+            '<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 . '">' .
+                  _("Go to the login page") . "</a></CENTER></B></FONT>".
+            '</TD></TR>'.
+         '</TABLE></td></tr></table></body></html>';
+}
+
+?>

+ 14 - 8
functions/file_prefs.php

@@ -35,7 +35,8 @@ function cachePrefValues($data_dir, $username) {
 
     /* Make sure that the preference file now DOES exist. */
     if (!file_exists($filename)) {
-        echo sprintf (_("Preference file, %s, does not exist. Log out, and log back in to create a default preference file."), $filename) . "<br>\n";
+        include_once( '../functions/display_messages.php' );
+        logout_error( sprintf( _("Preference file, %s, does not exist. Log out, and log back in to create a default preference file."), $filename)  );
         exit;
     }
 
@@ -158,18 +159,23 @@ function checkForPrefs($data_dir, $username, $filename = '') {
         }
 
         /* Otherwise, report an error. */
+        $errTitle = sprintf( _("Error opening %s"), $default_pref );
         if (!file_exists($default_pref)) {
-            echo _("Error opening ") . $default_pref . "<br>\n";
-            echo _("Default preference file not found!") . "<br>\n";
-            echo _("Please contact your system administrator and report this error.") . "<br>\n";
+            $errString = $errTitle . "<br>\n" .
+                         _("Default preference file not found!") . "<br>\n" .
+                         _("Please contact your system administrator and report this error.") . "<br>\n";
+            include_once( '../functions/display_messages.php' );
+            logout_error( $errString, $errTitle );
             exit;
         } else if (!@copy($default_pref, $filename)) {
-            echo _("Error opening ") . $default_pref . '<br>';
-            echo _("Could not create initial preference file!") . "<br>\n";
             $user_data = posix_getpwuid(posix_getuid());
             $uid = $user_data['name'];
-            echo $data_dir . ' ' . _("should be writable by user") . ' ' . $uid . "<br>\n";
-            echo _("Please contact your system administrator and report this error.") . "<br>\n";
+            $errString = $errTitle . '<br>' .
+                       _("Could not create initial preference file!") . "<br>\n" .
+                       sprintf( _("%s should be writable by user %s"), $data_dir, $uid ) .
+                       "<br>\n" . _("Please contact your system administrator and report this error.") . "<br>\n";
+            include_once( '../functions/display_messages.php' );
+            logout_error( $errString, $errTitle );
             exit;
         }
     }

+ 3 - 6
functions/imap_general.php

@@ -12,7 +12,6 @@
  */
 
 require_once('../functions/page_header.php');
-require_once('../functions/display_messages.php');
 
 global $sqimap_session_id;
 $sqimap_session_id = 1;
@@ -247,12 +246,10 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $
                  * $squirrelmail_language is set by a cookie when
                  * the user selects language and logs out
                  */
-
+                
                 set_up_language($squirrelmail_language, true);
-
-                displayHtmlHeader( _("Unknown user or password incorrect.") );
-                echo "<body bgcolor=\"#ffffff\">\n";
-                error_username_password_incorrect();
+                include_once( '../functions/display_messages.php' );
+                logout_error( _("Unknown user or password incorrect.") );                
                 session_destroy();
                 exit;
             }

BIN
locale/es_ES/LC_MESSAGES/squirrelmail.mo


Plik diff jest za duży
+ 254 - 233
locale/es_ES/LC_MESSAGES/squirrelmail.po


+ 36 - 31
po/squirrelmail.po

@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2002-03-29 07:51+0100\n"
+"POT-Creation-Date: 2002-03-30 10:30+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -169,7 +169,8 @@ msgstr ""
 
 #: squirrelmail/functions/display_messages.php:27
 #: squirrelmail/functions/display_messages.php:79
-#: squirrelmail/functions/display_messages.php:95
+#: squirrelmail/functions/display_messages.php:94
+#: squirrelmail/functions/display_messages.php:159
 #: squirrelmail/src/addressbook.php:191 squirrelmail/src/addressbook.php:239
 msgid "ERROR"
 msgstr ""
@@ -595,16 +596,19 @@ msgstr ""
 msgid "Login"
 msgstr ""
 
+#: squirrelmail/functions/display_messages.php:151
 #: squirrelmail/src/login.php:119
 #, c-format
 msgid "%s Logo"
 msgstr ""
 
+#: squirrelmail/functions/display_messages.php:154
 #: squirrelmail/src/login.php:122
 #, c-format
 msgid "SquirrelMail version %s"
 msgstr ""
 
+#: squirrelmail/functions/display_messages.php:155
 #: squirrelmail/src/login.php:123
 msgid "By the SquirrelMail Development Team"
 msgstr ""
@@ -1359,20 +1363,16 @@ msgid ""
 "this message. Would you like to send a receipt?"
 msgstr ""
 
-#: squirrelmail/functions/auth.php:39 squirrelmail/functions/auth.php:43
-#: squirrelmail/src/redirect.php:60 squirrelmail/src/redirect.php:64
+#: squirrelmail/functions/auth.php:29 squirrelmail/src/redirect.php:61
+#: squirrelmail/src/redirect.php:83
 msgid "You must be logged in to access this page."
 msgstr ""
 
-#: squirrelmail/functions/auth.php:45 squirrelmail/src/redirect.php:65
-msgid "Go to the login page"
-msgstr ""
-
-#: squirrelmail/src/redirect.php:85 squirrelmail/src/redirect.php:89
+#: squirrelmail/src/redirect.php:79
 msgid "There was an error contacting the mail server."
 msgstr ""
 
-#: squirrelmail/src/redirect.php:90
+#: squirrelmail/src/redirect.php:81
 msgid "Contact your administrator for help."
 msgstr ""
 
@@ -1731,7 +1731,7 @@ msgid "Preference database error (%s). Exiting abnormally"
 msgstr ""
 
 #: squirrelmail/functions/display_messages.php:30
-#: squirrelmail/functions/imap_general.php:253
+#: squirrelmail/functions/imap_general.php:252
 msgid "Unknown user or password incorrect."
 msgstr ""
 
@@ -1754,7 +1754,11 @@ msgstr ""
 msgid "Click here to return to %s"
 msgstr ""
 
-#: squirrelmail/functions/file_prefs.php:38
+#: squirrelmail/functions/display_messages.php:165
+msgid "Go to the login page"
+msgstr ""
+
+#: squirrelmail/functions/file_prefs.php:39
 #, c-format
 msgid ""
 "Preference file, %s, does not exist. Log out, and log back in to create a "
@@ -1762,34 +1766,35 @@ msgid ""
 msgstr ""
 
 #: squirrelmail/functions/file_prefs.php:162
-#: squirrelmail/functions/file_prefs.php:167
-msgid "Error opening "
+#, c-format
+msgid "Error opening %s"
 msgstr ""
 
-#: squirrelmail/functions/file_prefs.php:163
+#: squirrelmail/functions/file_prefs.php:165
 msgid "Default preference file not found!"
 msgstr ""
 
-#: squirrelmail/functions/file_prefs.php:164
-#: squirrelmail/functions/file_prefs.php:172
+#: squirrelmail/functions/file_prefs.php:166
+#: squirrelmail/functions/file_prefs.php:176
 #: squirrelmail/functions/prefs.php:93
 msgid "Please contact your system administrator and report this error."
 msgstr ""
 
-#: squirrelmail/functions/file_prefs.php:168
+#: squirrelmail/functions/file_prefs.php:174
 msgid "Could not create initial preference file!"
 msgstr ""
 
-#: squirrelmail/functions/file_prefs.php:171
-msgid "should be writable by user"
+#: squirrelmail/functions/file_prefs.php:175
+#, c-format
+msgid "%s should be writable by user %s"
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:133
+#: squirrelmail/functions/imap_general.php:132
 msgid ""
 "Please contact your system administrator and report the following error:"
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:164
+#: squirrelmail/functions/imap_general.php:163
 #: squirrelmail/functions/imap_messages.php:259
 #: squirrelmail/functions/imap_messages.php:266
 #: squirrelmail/functions/imap_messages.php:284
@@ -1799,42 +1804,42 @@ msgstr ""
 msgid "ERROR : Could not complete request."
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:166
-#: squirrelmail/functions/imap_general.php:177
+#: squirrelmail/functions/imap_general.php:165
+#: squirrelmail/functions/imap_general.php:176
 msgid "Query:"
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:168
+#: squirrelmail/functions/imap_general.php:167
 #: squirrelmail/plugins/filters/filters.php:238
 msgid "Reason Given: "
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:175
+#: squirrelmail/functions/imap_general.php:174
 #: squirrelmail/plugins/filters/filters.php:245
 msgid "ERROR : Bad or malformed request."
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:179
+#: squirrelmail/functions/imap_general.php:178
 #: squirrelmail/plugins/filters/filters.php:247
 msgid "Server responded: "
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:212
+#: squirrelmail/functions/imap_general.php:211
 #, c-format
 msgid "Error connecting to IMAP server: %s."
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:228
+#: squirrelmail/functions/imap_general.php:227
 #, c-format
 msgid "Bad request: %s"
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:230
+#: squirrelmail/functions/imap_general.php:229
 #, c-format
 msgid "Unknown error: %s"
 msgstr ""
 
-#: squirrelmail/functions/imap_general.php:232
+#: squirrelmail/functions/imap_general.php:231
 msgid "Read data:"
 msgstr ""
 

+ 12 - 20
src/redirect.php

@@ -57,14 +57,8 @@ set_up_language($squirrelmail_language, true);
 setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri);
 
 if (!isset($login_username)) {
-    displayHtmlHeader( _("You must be logged in to access this page.") );
-    echo "<BODY BGCOLOR=\"#ffffff\">\n" .
-        "&nbsp;<p>\n" .
-        "<CENTER>\n" .
-        '<B>' . _("You must be logged in to access this page.") . "</B><BR>" .
-        "<A HREF=\"$base_uri/src/login.php\">"  . _("Go to the login page") . "</A>\n" .
-        "</CENTER>\n" .
-        "</BODY></HTML>\n";
+    include_once( '../functions/display_messages.php' );
+    logout_error( _("You must be logged in to access this page.") );    
     exit;
 }
 
@@ -82,14 +76,11 @@ if (!session_is_registered('user_is_logged_in')) {
 
     $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
     if (!$imapConnection) {
-        displayHtmlHeader( _("There was an error contacting the mail server.") );
-        echo "<body bgcolor=\"#ffffff\">\n".
-            "<br> <br>\n".
-            "<center>\n".
-            '<b>' . _("There was an error contacting the mail server.") . "</b><br>\n".
-            _("Contact your administrator for help.") . "\n".
-            "</center>\n".
-            "</body></html>\n";
+        $errTitle = _("There was an error contacting the mail server.");
+        $errString = $errTitle . "<br>\n".
+                     _("Contact your administrator for help.");
+        include_once( '../functions/display_messages.php' );
+        logout_error( _("You must be logged in to access this page.") );            
         exit;
     } else {
         $delimiter = sqimap_get_delimiter ($imapConnection);
@@ -120,12 +111,13 @@ session_register('attachment_common_types_parsed');
 
 $debug = false;
 if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) &&
-    !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']]))
+    !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) {
     attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug);
+}
 if (isset($HTTP_ACCEPT) &&
-    !isset($attachment_common_types_parsed[$HTTP_ACCEPT]))
+    !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) {
     attachment_common_parse($HTTP_ACCEPT, $debug);
-
+}
 
 /* Complete autodetection of Javascript. */
 $javascript_setting = getPref
@@ -177,4 +169,4 @@ function attachment_common_parse($str, $debug) {
 }
 
 
-?>
+?>

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików