Explorar o código

updating error_box() function calls. second argument was modified.
using squirrelmail template code for closing html tags.
added some comments in footer.tpl in order to detect generated footer

tokul %!s(int64=19) %!d(string=hai) anos
pai
achega
4115a9110e

+ 2 - 2
functions/addressbook.php

@@ -27,7 +27,7 @@ include_once(SM_PATH . 'templates/util_global.php');
  * @return object address book object.
  */
 function addressbook_init($showerr = true, $onlylocal = false) {
-    global $data_dir, $username, $color, $ldap_server, $address_book_global_filename;
+    global $data_dir, $username, $ldap_server, $address_book_global_filename;
     global $addrbook_dsn, $addrbook_table;
     global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing;
     global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
@@ -158,7 +158,7 @@ function addressbook_init($showerr = true, $onlylocal = false) {
      * display address book init errors.
      */
     if ($abook_init_error!='' && $showerr) {
-        error_box($abook_init_error,$color);
+        error_box($abook_init_error);
     }
 
     /* Return the initialized object */

+ 17 - 5
functions/display_messages.php

@@ -109,11 +109,19 @@ function logout_error( $errString, $errTitle = '' ) {
  * Displays error message
  * 
  * Since 1.4.1 function checks if page header is already displayed.
+ * 
  * Since 1.4.3 and 1.5.1 function contains error_box hook.
  * Use plain_error_message() and make sure that page header is created,
  * if you want compatibility with 1.4.0 and older.
+ *
+ * In 1.5.2 second function argument is changed. Older functions used it
+ * for $color array, new function uses it for optional link data. Function 
+ * will ignore color array and use standard colors instead.
  * @param string $string Error message to be displayed
- * @param mixed $link Optional array containing link details to be displayed
+ * @param array $link Optional array containing link details to be displayed.
+ *  Array uses three keys. 'URL' key is required and should contain link URL.
+ *  'TEXT' key is optional and should contain link name. 'FRAME' key is 
+ *  optional and should contain link target attribute.
  * @since 1.3.2
  */
 function error_box($string, $link=NULL) {
@@ -134,10 +142,14 @@ function error_box($string, $link=NULL) {
 
     // Double check the link for everything we need
     if (!is_null($link)) {
-        if (!isset($link['FRAME']))
-            $link['FRAME'] = '';
-        if (!isset($link['TEXT']))
-            $link['TEXT'] = $link['URL'];
+        // safety check for older code
+        if (isset($link['URL'])) {
+            if (!isset($link['FRAME'])) $link['FRAME'] = '';
+            if (!isset($link['TEXT'])) $link['TEXT'] = $link['URL'];
+        } else {
+            // somebody used older error_box() code
+            $link=null;
+        }
     }
     
     /** ERROR is pre-translated to avoid multiple translation calls. **/

+ 3 - 2
functions/folder_manip.php

@@ -25,15 +25,16 @@ function folders_checkname($imapConnection, $folder_name, $delimiter)
     if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") ||
         substr_count($folder_name, $delimiter) || ($folder_name == '')) {
 
-        global $color;
+        global $color, $oTemplate;
         error_box(_("Illegal folder name.") . "<br />\n" .
                 sprintf(_("The name may not contain any of the following: %s"), '<tt>" \\ '.$delimiter.'</tt>')
                 . "<br />\n" .
                 _("Please select a different name.").
                 '<br /><a href="folders.php">'.
-                _("Click here to go back") . '</a>.', $color);
+                _("Click here to go back") . '</a>.');
 
         sqimap_logout($imapConnection);
+        $oTemplate->display('footer.tpl');
         exit;
     }
 }

+ 7 - 7
functions/imap_general.php

@@ -66,7 +66,7 @@ function sqimap_run_command_list ($imap_stream, $query, $handle_errors, &$respon
         $string = "<b><font color=\"$color[2]\">\n" .
                 _("ERROR: No available IMAP stream.") .
                 "</b></font>\n";
-        error_box($string,$color);
+        error_box($string);
         return false;
     }
 }
@@ -116,7 +116,7 @@ function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response,
         $string = "<b><font color=\"$color[2]\">\n" .
                 _("ERROR: No available IMAP stream.") .
                 "</b></font>\n";
-        error_box($string,$color);
+        error_box($string);
         return false;
     }
 }
@@ -314,7 +314,7 @@ function sqimap_fread($imap_stream,$iSize,$filter=false,
  */
 function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
           &$response, &$message, $query = '') {
-    global $color, $squirrelmail_language;
+    global $color, $oTemplate, $squirrelmail_language;
     set_up_language($squirrelmail_language);
     $string = "<b><font color=\"$color[2]\">\n" .
         _("ERROR: Bad function call.") .
@@ -326,8 +326,8 @@ function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
           'sqimap_run_command or sqimap_run_command_list instead<br /><br />'.
           'The following query was issued:<br />'.
            htmlspecialchars($query) . '<br />' . "</font><br />\n";
-    error_box($string,$color);
-    echo '</body></html>';
+    error_box($string);
+    $oTemplate->display('footer.tpl');
     exit;
 }
 
@@ -359,7 +359,7 @@ function sqimap_error_box($title, $query = '', $message_title = '', $message = '
     $string .= "</font><br />\n";
     if ($link != '')
         $string .= $link;
-    error_box($string,$color);
+    error_box($string);
 }
 
 /**
@@ -878,7 +878,7 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $
                         $string .= htmlspecialchars($line) . "<br />\n";
                     }
                 }
-                error_box($string,$color);
+                error_box($string);
                 exit;
             } else {
                 /*

+ 2 - 2
plugins/bug_report/bug_report.php

@@ -28,8 +28,8 @@ displayPageHeader($color, 'None');
 
 /** is bug_report plugin disabled or called by wrong user */
 if (! is_plugin_enabled('bug_report') || ! bug_report_check_user()) {
-    error_box(_("Plugin is disabled."),$color);
-    echo "\n</body></html>\n";
+    error_box(_("Plugin is disabled."));
+    $oTemplate->display('footer.tpl');
     exit();
 }
 

+ 2 - 2
plugins/bug_report/show_system_specs.php

@@ -19,8 +19,8 @@ include_once(SM_PATH.'plugins/bug_report/functions.php');
 
 /** is bug_report plugin disabled or called by wrong user */
 if (! is_plugin_enabled('bug_report') || ! bug_report_check_user()) {
-    error_box(_("Plugin is disabled."),$color);
-    echo "\n</body></html>\n";
+    error_box(_("Plugin is disabled."));
+    $oTemplate->display('footer.tpl');
     exit();
 }
 ?>

+ 1 - 1
plugins/calendar/calendar_data.php

@@ -116,7 +116,7 @@ function writecalendardata() {
 
                 $calstr = "$calfoo[key]|$calbar[key]|$calfoobar[length]|$calfoobar[priority]|$calfoobar[title]|$calfoobar[message]|$calfoobar[reminder]\n";
                 if(sq_fwrite($fp, $calstr, 4096) === FALSE) {
-                    error_box(_("Could not write calendar file %s", "$username.$year.cal.tmp"), $color);
+                    error_box(_("Could not write calendar file %s", "$username.$year.cal.tmp"));
                 }
             }
 

+ 4 - 5
plugins/change_password/backend/ldap.php

@@ -158,27 +158,26 @@ $squirrelmail_plugin_hooks['change_password_init']['ldap'] =
  * Makes sure that required functions and configuration options are set.
  */
 function cpw_ldap_init() {
-    global $color;
-    global $cpw_ldap_basedn;
+    global $oTemplate, $cpw_ldap_basedn;
 
     // set initial value for error tracker
     $cpw_ldap_initerr=false;
 
     // check for ldap support in php
     if (! function_exists('ldap_connect')) {
-        error_box(_("Current configuration requires LDAP support in PHP."),$color);
+        error_box(_("Current configuration requires LDAP support in PHP."));
         $cpw_ldap_initerr=true;
     }
 
     // chech required configuration settings.
     if ($cpw_ldap_basedn=='') {
-        error_box(_("Plugin is not configured correctly."),$color);
+        error_box(_("Plugin is not configured correctly."));
         $cpw_ldap_initerr=true;
     }
 
     // if error var is positive, close html and stop execution
     if ($cpw_ldap_initerr) {
-        echo '</body></html>';
+        $oTemplate->display('footer.tpl');
         exit;
     }
 }

+ 3 - 3
plugins/change_password/backend/merak.php

@@ -41,13 +41,13 @@ $squirrelmail_plugin_hooks['change_password_init']['merak'] =
  * Check if php install has all required extensions.
  */
 function cpw_merak_init() {
-    global $color;
+    global $oTemplate;
 
     if (!function_exists('curl_init')) {
         // user_error('Curl module NOT available!', E_USER_ERROR);
-        error_box(_("PHP Curl extension is NOT available! Unable to change password!"),$color);
+        error_box(_("PHP Curl extension is NOT available! Unable to change password!"));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 }

+ 5 - 5
plugins/change_password/backend/peardb.php

@@ -106,19 +106,19 @@ $squirrelmail_plugin_hooks['change_password_init']['peardb'] =
  * Checks if configuration is correct
  */
 function cpw_peardb_init() {
-    global $color, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
+    global $oTemplate, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
 
     if (! $cpw_peardb_detect) {
-        error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."),$color);
-        echo "</body></html>\n";
+        error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."));
+        $oTemplate->display('footer.tpl');
         exit();
     }
 
     // Test required settings
     if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='')
         || trim($cpw_peardb_table)=='' ) {
-        error_box(_("Required change password backend configuration options are missing."),$color);
-        echo "</body></html>\n";
+        error_box(_("Required change password backend configuration options are missing."));
+        $oTemplate->display('footer.tpl');
         exit();
     }
 }

+ 3 - 3
plugins/change_password/backend/template.php

@@ -39,12 +39,12 @@ $squirrelmail_plugin_hooks['change_password_init']['template'] =
  */
 function cpw_template_init()
 {
-    global $color;
+    global $oTemplate;
 
     // plugin is not configured. Handle error gracefully.
-    error_box(_("No valid backend defined."),$color);
+    error_box(_("No valid backend defined."));
     // close html and stop script execution
-    echo "</body></html>\n";
+    $oTemplate->display('footer.tpl');
     exit();
 }
 

+ 7 - 7
plugins/change_password/backend/vmailmgrd.php

@@ -104,13 +104,13 @@ $squirrelmail_plugin_hooks['change_password_init']['vmailmgrd'] =
  * is displayed to the user.
  */
 function cpw_vmailmgrd_init(){
-    global $vmail_inc_path, $color, $username;
+    global $vmail_inc_path, $username, $oTemplate;
 
     if ($vmail_inc_path=='' || ! file_exists($vmail_inc_path)) {
         // $vmail_inc_path is not set or file does not exist
-        error_box(_("Incorrent path to vmail.inc file."),$color);
+        error_box(_("Incorrent path to vmail.inc file."));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 
@@ -118,17 +118,17 @@ function cpw_vmailmgrd_init(){
 
     if (! function_exists('vchpass')) {
         // included vmail.inc does not have required functions.
-        error_box(_("Invalid or corrupted vmail.inc file."),$color);
+        error_box(_("Invalid or corrupted vmail.inc file."));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 
     if (! preg_match("/(.*)\@(.*)/", $username)) {
         // username does not match vmailmgr syntax
-        error_box(_("Invalid user."),$color);
+        error_box(_("Invalid user."));
         // close html and stop script execution
-        echo "</body></html>\n";
+        $oTemplate->display('footer.tpl');
         exit();
     }
 }

+ 3 - 2
plugins/info/options.php

@@ -35,8 +35,9 @@ $mailbox = 'INBOX';
  * prevent use of plugin if it is not enabled
  */
 if (! is_plugin_enabled('info')) {
-    error_box(_("Plugin is disabled."),$color);
-    echo '</body></html>';
+    error_box(_("Plugin is disabled."));
+    // display footer (closes html) and stop script execution
+    $oTemplate->display('footer.tpl');
     exit;
 }
 

+ 3 - 1
plugins/listcommands/mailout.php

@@ -41,7 +41,9 @@ switch ( $action ) {
         $out_string = _("This will send a message to %s requesting that you will be unsubscribed from this list. It will try to unsubscribe the adress below.");
         break;
     default:
-        error_box(sprintf(_("Unknown action: %s"),htmlspecialchars($action)), $color);
+        error_box(sprintf(_("Unknown action: %s"),htmlspecialchars($action)));
+        // display footer (closes html tags) and stop script execution
+        $oTemplate->display('footer.tpl');
         exit;
 }
 

+ 1 - 1
plugins/sent_subfolders/setup.php

@@ -254,7 +254,7 @@ function sent_subfolders_update_sentfolder() {
                 if (sqimap_mailbox_is_noselect($ic,$sent_subfolder,$boxes) ||
                     ($level==2 && sqimap_mailbox_is_noinferiors($ic,$year_folder,$boxes)) ||
                      sqimap_mailbox_is_noinferiors($ic,$sent_subfolders_base,$boxes)) {
-                    error_box(_("Sent Subfolders plugin is misconfigured."),$color);
+                    error_box(_("Sent Subfolders plugin is misconfigured."));
                 } else {
                     if ($level==2) {
                         /* Auto-create the year folder, if it does not yet exist. */

+ 3 - 2
plugins/spamcop/spamcop.php

@@ -57,8 +57,9 @@ if ($js_web) {
 
 /** is spamcop plugin disabled */
 if (! is_plugin_enabled('spamcop')) {
-    error_box(_("Plugin is disabled."),$color);
-    echo "\n</body></html>\n";
+    error_box(_("Plugin is disabled."));
+    // display footer (closes html tags) and stop script execution
+    $oTemplate->display('footer.tpl');
     exit();
 }
 

+ 9 - 9
plugins/squirrelspell/modules/check_me.mod

@@ -100,21 +100,21 @@ if( check_php_version ( 4, 3 ) ) {
     if ( ! is_resource ( $spell_proc ) ) {
         // TODO: replace error_box() with sqspell_makeWindow()
         error_box ( sprintf(_("Could not run the spellchecker command (%s)."),
-            htmlspecialchars($sqspell_command) ) , $color );
-        // close html tags and abort script.
-        echo "</body></html>";
+            htmlspecialchars($sqspell_command) ) );
+        // display footer (closes html tags) and stop script execution
+        $oTemplate->display('footer.tpl');
         exit();
     }
     if ( ! @fwrite($pipes[0], $sqspell_new_text) ) {
         // TODO: replace error_box() with sqspell_makeWindow()
-        error_box ( _("Error while writing to pipe.") , $color );
+        error_box ( _("Error while writing to pipe.") );
         // close all three $pipes here.
         for($i=0; $i<=2; $i++) {
             // disable all fclose error messages
             @fclose($pipes[$i]);
         }
         // close html tags and abort script.
-        echo "</body></html>";
+        $oTemplate->display('footer.tpl');
         exit();
     }
     fclose($pipes[0]);
@@ -140,19 +140,19 @@ if( check_php_version ( 4, 3 ) ) {
     if ( ! is_resource ($fp) ) {
         // TODO: replace error_box() with sqspell_makeWindow()
         error_box ( sprintf(_("Could not open temporary file '%s'."),
-            htmlspecialchars($floc) ) , $color );
+            htmlspecialchars($floc) ) );
         // failed to open temp file. abort script.
-        echo "</body></html>";
+        $oTemplate->display('footer.tpl');
         exit();
     }
     if ( ! @fwrite($fp, $sqspell_new_text) ) {
         // TODO: replace error_box() with sqspell_makeWindow()
         error_box ( sprintf(_("Error while writing to temporary file '%s'."),
-            htmlspecialchars($floc) ) , $color );
+            htmlspecialchars($floc) ) );
         // close file descriptor
         fclose($fp);
         // failed writing to temp file. abort script.
-        echo "</body></html>";
+        $oTemplate->display('footer.tpl');
         exit();
     }
     fclose($fp);

+ 3 - 2
plugins/squirrelspell/sqspell_interface.php

@@ -46,7 +46,8 @@ sqspell_ckMOD($MOD);
 if (file_exists(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod")) {
     require_once(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod");
 } else {
-    error_box(_("Invalid SquirrelSpell module."),$color);
-    echo '</body></html>';
+    error_box(_("Invalid SquirrelSpell module."));
+    // display sm footer (closes html tags)
+    $oTemplate->display('footer.tpl');
 }
 ?>

+ 3 - 2
plugins/squirrelspell/sqspell_options.php

@@ -43,7 +43,8 @@ sqspell_ckMOD($MOD);
 if (file_exists(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod")) {
     require_once(SM_PATH . $SQSPELL_DIR . "modules/$MOD.mod");
 } else {
-    error_box(_("Invalid SquirrelSpell module."),$color);
-    echo '</body></html>';
+    error_box(_("Invalid SquirrelSpell module."));
+    // display footer (closes html tags)
+    $oTemplate->display('footer.tpl');
 }
 ?>

+ 1 - 1
plugins/translate/functions.php

@@ -85,7 +85,7 @@ function translate_read_form_function() {
     $translate_server_option='translate_' . $translate_server . '_enabled';
     if ($translate_server=='gpltrans' && $translate_gpltrans_url=='' ||
         ! $$translate_server_option || ! function_exists('translate_form_' . $translate_server)) {
-        error_box(_("Selected translation engine is disabled. Please update your translation preferences."),$color);
+        error_box(_("Selected translation engine is disabled. Please update your translation preferences."));
         return;
     }
     $translate_dir = 'to';

+ 1 - 1
src/delete_message.php

@@ -15,6 +15,6 @@
  * Include the SquirrelMail initialization file.
  */
 include('../include/init.php');
-error_box('delete_message.php script is obsolete since 1.5.1.',$color);
+error_box('delete_message.php script is obsolete since 1.5.1.');
 $oTemplate->display('footer.tpl');
 ?>

+ 7 - 5
src/help.php

@@ -111,12 +111,14 @@ if (!isset($squirrelmail_language)) {
 if (file_exists("../help/$squirrelmail_language")) {
     $user_language = $squirrelmail_language;
 } else if (file_exists('../help/en_US')) {
-    error_box(_("Help is not available in the selected language. It will be displayed in English instead."), $color);
+    error_box(_("Help is not available in the selected language. It will be displayed in English instead."));
     echo '<br />';
     $user_language = 'en_US';
 } else {
-    error_box( _("Help is not available. Please contact your system administrator for assistance."), $color );
-    exit;
+    error_box( _("Help is not available. Please contact your system administrator for assistance."));
+    // display footer (closes html tags) and stop script execution
+    $oTemplate->display('footer.tpl');
+    exit();
 }
 
 
@@ -195,7 +197,7 @@ if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) {
     } elseif (file_exists("../help/en_US/" . $helpdir[$chapter-1])) {
         // If the selected language can't be found, try English.
         $doc = file("../help/en_US/" . $helpdir[$chapter-1]);
-        error_box(_("This chapter in not available in the selected language. It will be displayed in English instead."), $color);
+        error_box(_("This chapter in not available in the selected language. It will be displayed in English instead."));
         echo '<br />';
     } else {
         // If English can't be found, the chapter went MIA.
@@ -245,7 +247,7 @@ if ( $chapter == 0 || !isset( $helpdir[$chapter-1] ) ) {
         echo '<br /><div style="text-align: center;"><a href="#pagetop">' . _("Top") . '</a></div>';
     } else {
         // If the help file went MIA, display an error message.
-        error_box(sprintf(_("For some reason, chapter %s is not available."), $chapter), $color);
+        error_box(sprintf(_("For some reason, chapter %s is not available."), $chapter));
     }
 }
 

+ 6 - 4
src/login.php

@@ -67,7 +67,9 @@ if($imap_auth_mech == 'login') {
                 $string .= _("Also, the use of TLS may allow SquirrelMail to login.").'<br />';
             }
             $string .= _("Please contact your system administrator and report this error.");
-            error_box($string,$color);
+            error_box($string);
+            // display footer (closes html tags) and stop script execution
+            $oTemplate->display('footer.tpl');
             exit;
         }
     }
@@ -131,10 +133,10 @@ if (isset($org_logo) && $org_logo) {
     }
     
     $logo_str = '<img src="'.$org_logo.'" ' .
-    			'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
-    			$width_and_height .
+                'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
+                $width_and_height .
                 'class="sqm_loginImage" ' .
-    			' /><br />'."\n";
+                ' /><br />'."\n";
 }
 
 $sm_attribute_str = '';

+ 1 - 1
src/printer_friendly_main.php

@@ -20,7 +20,7 @@ if ( ! sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_GET))
     $passed_ent_id = 0;
 if ( ! sqgetGlobalVar('mailbox',$mailbox,SQ_GET) ||
      ! sqgetGlobalVar('passed_id',$passed_id,SQ_GET)) {
-    error_box(_("Invalid URL"),$color);
+    error_box(_("Invalid URL"));
 } else {
     $passed_id= (int) $passed_id;
     $view_unsafe_images = (bool) $_GET['view_unsafe_images'];

+ 1 - 0
templates/default/footer.tpl

@@ -18,5 +18,6 @@
 extract($t);
 $this->display('error_message.tpl');
 ?>
+<!-- end of generated html -->
 </body>
 </html>