From 202bcbcc2b67c7c153db1b09b608b62beeba0496 Mon Sep 17 00:00:00 2001 From: stekkel Date: Wed, 5 Apr 2006 00:22:11 +0000 Subject: [PATCH] Centralized init git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11012 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/abook_database.php | 1 - functions/addressbook.php | 72 +- functions/attachment_common.php | 29 +- functions/auth.php | 83 +- functions/date.php | 18 +- functions/db_prefs.php | 11 +- functions/display_messages.php | 23 +- functions/file_prefs.php | 7 +- functions/folder_manip.php | 2 +- functions/gettext.php | 6 +- functions/global.php | 213 ++-- functions/html.php | 42 - functions/identity.php | 17 +- functions/imap.php | 10 +- functions/imap_asearch.php | 4 +- functions/imap_general.php | 18 +- functions/imap_mailbox.php | 7 +- functions/mailbox_display.php | 13 +- functions/mime.php | 48 +- functions/page_header.php | 19 +- functions/plugin.php | 31 +- functions/prefs.php | 56 +- functions/strings.php | 51 - functions/tree.php | 5 - include/constants.php | 158 +++ include/errors.php | 2 +- include/init.php | 420 +++++++ include/languages.php | 1090 +++++++++++++++++ include/load_prefs.php | 40 +- include/options/display.php | 3 +- include/options/folder.php | 3 +- include/validate.php | 135 +- plugins/abook_take/functions.php | 4 - plugins/abook_take/setup.php | 7 - plugins/abook_take/take.php | 10 +- plugins/administrator/auth.php | 1 - plugins/administrator/defines.php | 9 - plugins/bug_report/bug_report.php | 17 +- plugins/bug_report/functions.php | 11 +- plugins/bug_report/show_system_specs.php | 9 +- plugins/bug_report/system_specs.php | 15 +- plugins/calendar/calendar.php | 8 +- plugins/calendar/day.php | 12 +- plugins/calendar/event_create.php | 9 +- plugins/calendar/event_delete.php | 8 +- plugins/calendar/event_edit.php | 10 +- plugins/change_password/backend/ldap.php | 13 +- plugins/change_password/backend/merak.php | 11 - plugins/change_password/backend/peardb.php | 31 +- plugins/change_password/backend/poppassd.php | 4 +- plugins/change_password/backend/template.php | 11 - plugins/change_password/backend/vmailmgrd.php | 11 - plugins/change_password/options.php | 7 +- plugins/filters/filters.php | 50 +- plugins/filters/options.php | 10 +- plugins/filters/setup.php | 13 +- plugins/filters/spamoptions.php | 10 +- plugins/fortune/setup.php | 8 - plugins/info/options.php | 11 +- plugins/listcommands/mailout.php | 18 +- plugins/mail_fetch/README | 2 +- plugins/mail_fetch/fetch.php | 9 +- plugins/mail_fetch/functions.php | 13 +- plugins/mail_fetch/options.php | 9 +- plugins/mail_fetch/setup.php | 3 - .../message_details_bottom.php | 15 +- .../message_details/message_details_main.php | 8 +- .../message_details/message_details_top.php | 11 +- plugins/newmail/functions.php | 11 +- plugins/newmail/loadfile.php | 7 +- plugins/newmail/newmail.php | 13 +- plugins/newmail/newmail_opt.php | 19 +- plugins/newmail/setup.php | 2 - plugins/newmail/testsound.php | 10 +- plugins/spamcop/options.php | 9 +- plugins/spamcop/spamcop.php | 12 +- plugins/squirrelspell/setup.php | 2 - plugins/squirrelspell/sqspell_config.php | 12 +- plugins/squirrelspell/sqspell_functions.php | 17 +- plugins/squirrelspell/sqspell_interface.php | 9 +- plugins/squirrelspell/sqspell_options.php | 9 +- plugins/translate/functions.php | 18 +- plugins/translate/options.php | 7 +- plugins/translate/setup.php | 7 - src/about.php | 10 +- src/addrbook_popup.php | 9 +- src/addrbook_search.php | 10 +- src/addrbook_search_html.php | 16 +- src/addressbook.php | 12 +- src/compose.php | 17 +- src/delete_message.php | 11 +- src/download.php | 11 +- src/empty_trash.php | 13 +- src/folders.php | 10 +- src/help.php | 10 +- src/image.php | 14 +- src/left_main.php | 19 +- src/login.php | 56 +- src/mailto.php | 14 +- src/options.php | 17 +- src/options_highlight.php | 17 +- src/options_identities.php | 11 +- src/options_order.php | 16 +- src/printer_friendly_bottom.php | 12 +- src/printer_friendly_main.php | 8 +- src/printer_friendly_top.php | 7 +- src/read_body.php | 35 +- src/redirect.php | 52 +- src/right_main.php | 22 +- src/search.php | 20 +- src/signout.php | 12 +- src/style.php | 26 +- src/vcard.php | 10 +- src/view_header.php | 50 +- src/view_html.php | 11 +- src/view_text.php | 16 +- src/webmail.php | 57 +- 117 files changed, 2414 insertions(+), 1426 deletions(-) create mode 100644 include/constants.php create mode 100644 include/init.php create mode 100644 include/languages.php diff --git a/functions/abook_database.php b/functions/abook_database.php index 5721d3a8..db7e1a00 100644 --- a/functions/abook_database.php +++ b/functions/abook_database.php @@ -13,7 +13,6 @@ /** Needs the DB functions */ if (!include_once('DB.php')) { // same error also in db_prefs.php - require_once(SM_PATH . 'functions/display_messages.php'); $error = _("Could not include PEAR database functions required for the database backend.") . "
\n"; $error .= sprintf(_("Is PEAR installed, and is the include path set correctly to find %s?"), 'DB.php') . "
\n"; diff --git a/functions/addressbook.php b/functions/addressbook.php index 863d7d81..75eb5596 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -12,20 +12,11 @@ * @subpackage addressbook */ -/** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore - */ -if (!defined('SM_PATH')) { - define('SM_PATH','../'); -} /* required includes */ -include_once(SM_PATH . 'functions/display_messages.php'); +// FIXME, NO display code in functions files include_once(SM_PATH . 'templates/util_global.php'); -global $addrbook_dsn, $addrbook_global_dsn; - /** * Create and initialize an addressbook object. * @param boolean $showerr display any address book init errors. html page header @@ -450,13 +441,13 @@ class AddressBook { var $localbackendname = ''; /** * Controls use of 'extra' field - * - * Extra field can be used to add link to form, which allows - * to modify all fields supported by backend. This is the only field + * + * Extra field can be used to add link to form, which allows + * to modify all fields supported by backend. This is the only field * that is not sanitized with htmlspecialchars. Backends MUST make * sure that field data is sanitized and displayed correctly inside * table cell. Use of html formating in other address book fields is - * not allowed. Backends that don't return 'extra' row in address book + * not allowed. Backends that don't return 'extra' row in address book * data should not modify this object property. * @var boolean * @since 1.5.1 @@ -498,8 +489,31 @@ class AddressBook { * @return integer number of backends */ function add_backend($backend, $param = '') { + static $backend_classes; + if (!isset($backend_classes)) { + $backend_classes = array(); + } + if (!isset($backend_classes[$backend])) { + /** + * Support backend provided by plugins. Plugin function must + * return an associative array with as key the backend name ($backend) + * and as value the file including the path containing the backend class. + * i.e.: $aBackend = array('backend_template' => SM_PATH . 'plugins/abook_backend_template/functions.php') + * + * NB: Because the backend files are included from within this function they DO NOT have access to + * vars in the global scope. This function is the global scope for the included backend !!! + */ + $aBackend = do_hook('abook_add_class'); + if (isset($aBackend) && is_array($aBackend) && isset($aBackend[$backend])) { + require_once($aBackend[$backend]); + } else { + require_once(SM_PATH . 'functions/abook_'.$backend.'.php'); + } + $backend_classes[$backend] = true; + } $backend_name = 'abook_' . $backend; - eval('$newback = new ' . $backend_name . '($param);'); + $newback = new $backend_name($param); + //eval('$newback = new ' . $backend_name . '($param);'); if(!empty($newback->error)) { $this->error = $newback->error; return false; @@ -880,9 +894,9 @@ class addressbook_backend { /** * Search for entries in backend * - * Working backend should support use of wildcards. * symbol + * Working backend should support use of wildcards. * symbol * should match one or more symbols. ? symbol should match any - * single symbol. + * single symbol. * @param string $expression * @return bool */ @@ -944,28 +958,4 @@ class addressbook_backend { return false; } } - -/* - PHP 5 requires that the class be made first, which seems rather - logical, and should have been the way it was generated the first time. -*/ - -require_once(SM_PATH . 'functions/abook_local_file.php'); -require_once(SM_PATH . 'functions/abook_ldap_server.php'); - -/* Only load database backend if database is configured */ -if((isset($addrbook_dsn) && !empty($addrbook_dsn)) || - (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn))) { - include_once(SM_PATH . 'functions/abook_database.php'); -} - -/* - * hook allows adding different address book classes. - * class must follow address book class coding standards. - * - * see addressbook_backend class and functions/abook_*.php files. - * @since 1.5.1 and 1.4.5 - */ -do_hook('abook_add_class'); - ?> diff --git a/functions/attachment_common.php b/functions/attachment_common.php index 3b9e561a..0aec18e7 100644 --- a/functions/attachment_common.php +++ b/functions/attachment_common.php @@ -12,18 +12,7 @@ * @todo document attachment $type hook arguments */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../'); -/** sqgetGlobalVar() */ -include_once(SM_PATH . 'functions/global.php'); -/** sqm_baseuri() */ -include_once(SM_PATH . 'functions/display_messages.php'); - -global $attachment_common_show_images_list; -$attachment_common_show_images_list = array(); - -global $FileExtensionToMimeType, $attachment_common_types; /** * Mapping of file extensions to mime types * @@ -70,7 +59,7 @@ if (isset($attachment_common_types)) { register_attachment_common('image/x-xbitmap', 'link_image'); elseif ($val == '*/*' || $val == 'image/*') { /** - * browser (Firefox) declared that anything is acceptable. + * browser (Firefox) declared that anything is acceptable. * Lets register some common image types. */ if (! isset($jpeg_done)) { @@ -131,6 +120,7 @@ function register_attachment_common($type, $func) { * @since 1.2.0 */ function attachment_common_link_text(&$Args) { + global $base_uri; /* If there is a text attachment, we would like to create a "View" button that links to the text attachment viewer. @@ -144,7 +134,7 @@ function attachment_common_link_text(&$Args) { sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); // if htmlspecialchars() breaks something - find other way to encode & in url. - $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING); + $Args[1]['attachment_common']['href'] = $base_uri . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING); $Args[1]['attachment_common']['href'] = set_url_var($Args[1]['attachment_common']['href'], 'ent_id',$Args[5]); @@ -169,7 +159,8 @@ function attachment_common_link_text(&$Args) { * @since 1.2.6 */ function attachment_common_link_message(&$Args) { - $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/read_body.php?startMessage=' . + global $base_uri; + $Args[1]['attachment_common']['href'] = $base_uri . 'src/read_body.php?startMessage=' . $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] . '&passed_ent_id=' . $Args[5] . '&override_type0=message&override_type1=rfc822'; @@ -184,9 +175,10 @@ function attachment_common_link_message(&$Args) { * @since 1.2.0 */ function attachment_common_link_html(&$Args) { + global $base_uri; sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); - $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING). + $Args[1]['attachment_common']['href'] = $base_uri . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING). /* why use the overridetype? can this be removed */ /* override_type might be needed only when we want view other type of messages as html */ '&override_type0=text&override_type1=html'; @@ -205,7 +197,7 @@ function attachment_common_link_html(&$Args) { * @since 1.2.0 */ function attachment_common_link_image(&$Args) { - global $attachment_common_show_images_list; + global $attachment_common_show_images_list, $base_uri ; sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); @@ -215,7 +207,7 @@ function attachment_common_link_image(&$Args) { $attachment_common_show_images_list[] = $info; - $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/image.php?'. htmlspecialchars($QUERY_STRING); + $Args[1]['attachment_common']['href'] = $base_uri . 'src/image.php?'. htmlspecialchars($QUERY_STRING); $Args[1]['attachment_common']['href'] = set_url_var($Args[1]['attachment_common']['href'], 'ent_id',$Args[5]); @@ -231,9 +223,10 @@ function attachment_common_link_image(&$Args) { * @since 1.2.0 */ function attachment_common_link_vcard(&$Args) { + global $base_uri; sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); - $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/vcard.php?'. htmlspecialchars($QUERY_STRING); + $Args[1]['attachment_common']['href'] = $base_uri . 'src/vcard.php?'. htmlspecialchars($QUERY_STRING); $Args[1]['attachment_common']['href'] = set_url_var($Args[1]['attachment_common']['href'], 'ent_id',$Args[5]); diff --git a/functions/auth.php b/functions/auth.php index a051aeaf..f5be2704 100644 --- a/functions/auth.php +++ b/functions/auth.php @@ -3,8 +3,8 @@ /** * auth.php * - * Contains functions used to do authentication. Library depends on - * functions from functions/global.php, functions/i18n.php and + * Contains functions used to do authentication. Library depends on + * functions from functions/global.php, functions/i18n.php and * functions/strings.php. * * @copyright © 1999-2006 The SquirrelMail Project Team @@ -13,75 +13,16 @@ * @package squirrelmail */ -/** Put in a safety net here, in case a naughty admin didn't run conf.pl when they upgraded */ - -if (! isset($smtp_auth_mech)) { - $smtp_auth_mech = 'none'; -} - -if (! isset($imap_auth_mech)) { - $imap_auth_mech = 'login'; -} - -if (! isset($use_imap_tls)) { - $use_imap_tls = false; -} - -if (! isset($use_smtp_tls)) { - $use_smtp_tls = false; -} - -/** - * Check if user has previously logged in to the SquirrelMail session. If user - * has not logged in, execution will stop inside this function. - * - * @return int A positive value is returned if user has previously logged in - * successfully. - * @since 1.0 - */ -function is_logged_in() { - - if ( sqsession_is_registered('user_is_logged_in') ) { - return; - } else { - global $PHP_SELF, $session_expired_post, - $session_expired_location, $squirrelmail_language; - - // First we store some information in the new session to prevent - // information-loss. - // - $session_expired_post = $_POST; - $session_expired_location = $PHP_SELF; - if (!sqsession_is_registered('session_expired_post')) { - sqsession_register($session_expired_post,'session_expired_post'); - } - if (!sqsession_is_registered('session_expired_location')) { - sqsession_register($session_expired_location,'session_expired_location'); - } - - // signout page will deal with users who aren't logged - // in on its own; don't show error here - // - if (strpos($PHP_SELF, 'signout.php') !== FALSE) { - return; - } - - include_once( SM_PATH . 'functions/display_messages.php' ); - set_up_language($squirrelmail_language, true); - logout_error( _("You must be logged in to access this page.") ); - exit; - } -} /** * Detect logged user - * - * Function is similar to is_logged_in() function. If user is logged in, function + * + * Function is similar to is_logged_in() function. If user is logged in, function * returns true. If user is not logged in or session is expired, function saves $_POST - * and $PHP_SELF in session and returns false. POST information is saved in + * and $PHP_SELF in session and returns false. POST information is saved in * 'session_expired_post' variable, PHP_SELF is saved in 'session_expired_location'. * - * Script that uses this function instead of is_logged_in() function, must handle user + * Script that uses this function instead of is_logged_in() function, must handle user * level messages. * @return boolean * @since 1.5.1 @@ -124,18 +65,18 @@ function sqauth_read_password() { /** * Saves or updates user password information - * + * * This function is used to update password information that SquirrelMail - * stores during existing web session. It does not modify password stored + * stores during existing web session. It does not modify password stored * in authentication system used by IMAP server. * - * Function must be called before any html output started. Direct access - * to password information is deprecated. Saved password information is + * Function must be called before any html output started. Direct access + * to password information is deprecated. Saved password information is * available only to next executed SquirrelMail script. If your script needs - * access to saved password after sqauth_save_password() call, use returned + * access to saved password after sqauth_save_password() call, use returned * OTP encrypted key. * @param string $pass password - * @return string password encrypted with OTP. In case script wants to access + * @return string password encrypted with OTP. In case script wants to access * password information before reloading page. * @since 1.5.1 */ diff --git a/functions/date.php b/functions/date.php index b362d15c..50bb101a 100644 --- a/functions/date.php +++ b/functions/date.php @@ -15,8 +15,10 @@ * @subpackage date */ -/** Load up some useful constants */ -require_once(SM_PATH . 'functions/constants.php'); +/** + * dependency information + * - none + */ /** * Corrects a time stamp to be the local time. @@ -443,15 +445,3 @@ function getTimeStamp($dateParts) { return getGMTSeconds($stamp, $dateParts[0]); } } - -/* I use this function for profiling. Should never be called in - actual versions of SquirrelMail released to public. */ -/* - function getmicrotime() { - $mtime = microtime(); - $mtime = explode(' ',$mtime); - $mtime = $mtime[1] + $mtime[0]; - return ($mtime); - } -*/ -?> \ No newline at end of file diff --git a/functions/db_prefs.php b/functions/db_prefs.php index a1ee7178..f116c837 100644 --- a/functions/db_prefs.php +++ b/functions/db_prefs.php @@ -39,10 +39,9 @@ define('SMDB_MYSQL', 1); /** PostgreSQL */ define('SMDB_PGSQL', 2); -require_once(SM_PATH . 'config/config.php'); + if (!include_once('DB.php')) { // same error also in abook_database.php - require_once(SM_PATH . 'functions/display_messages.php'); $error = _("Could not include PEAR database functions required for the database backend.") . "
\n"; $error .= sprintf(_("Is PEAR installed, and is the include path set correctly to find %s?"), 'DB.php') . "
\n"; @@ -212,7 +211,7 @@ class dbPrefs { /** * Function used to handle database connection errors - * @param object PEAR Error object + * @param object PEAR Error object */ function failQuery($res = NULL) { if($res == NULL) { @@ -250,7 +249,7 @@ class dbPrefs { /** * Delete user's prefs setting - * @param string $user user name + * @param string $user user name * @param string $key preference name * @return boolean */ @@ -298,8 +297,8 @@ class dbPrefs { ." See doc/db-backend.txt or contact your system administrator."; /** - * Debugging function. Can be used to log all issues that trigger - * oversized field errors. Function should be enabled in all three + * Debugging function. Can be used to log all issues that trigger + * oversized field errors. Function should be enabled in all three * strlen checks. See http://www.php.net/error-log */ // error_log($user.'|'.$key.'|'.$value."\n",3,'/tmp/oversized_log'); diff --git a/functions/display_messages.php b/functions/display_messages.php index 7f94acd5..f01808f5 100644 --- a/functions/display_messages.php +++ b/functions/display_messages.php @@ -12,13 +12,6 @@ * @package squirrelmail */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../'); - -/** - * including plugin functions - */ -include_once(SM_PATH . 'functions/plugin.php'); /** * Displays error message and URL to message listing @@ -52,7 +45,7 @@ function plain_error_message($message, $color) { /** * Displays error when user is logged out - * + * * Error strings can be overriden by logout_error hook * @param string $errString error message * @param string $errTitle title of page with error message @@ -60,16 +53,11 @@ 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, $squirrelmail_language, + $hide_sm_attributions, $version, $squirrelmail_language, $color, $theme, $theme_default; $base_uri = sqm_baseuri(); - include_once( SM_PATH . 'functions/page_header.php' ); - if ( !isset( $org_logo ) ) { - // Don't know yet why, but in some accesses $org_logo is not set. - include( SM_PATH . 'config/config.php' ); - } /* Display width and height like good little people */ $width_and_height = ''; if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) { @@ -132,7 +120,7 @@ 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, @@ -152,8 +140,6 @@ function error_box($string, $color) { /* check if the page header has been sent; if not, send it! */ if(!isset($pageheader_sent) && !$pageheader_sent) { - /* include this just to be sure */ - include_once( SM_PATH . 'functions/page_header.php' ); displayHtmlHeader('SquirrelMail: '.$err); $pageheader_sent = TRUE; echo "\n\n"; @@ -177,5 +163,4 @@ function error_option_save($message) { $optpage_save_error=array(); $optpage_save_error=array_merge($optpage_save_error,array($message)); -} -?> +} \ No newline at end of file diff --git a/functions/file_prefs.php b/functions/file_prefs.php index e35e4df4..161f2ef7 100644 --- a/functions/file_prefs.php +++ b/functions/file_prefs.php @@ -13,11 +13,6 @@ * @since 1.2.5 */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../'); - -/** include this for error messages */ -include_once(SM_PATH . 'functions/display_messages.php'); /** * Check the preferences into the session cache. @@ -31,6 +26,8 @@ function cachePrefValues($data_dir, $username) { sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION ); if ( isset($prefs_are_cached) && $prefs_are_cached) { sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION ); +// sm_print_r($prefs_cache); +// exit; return; } diff --git a/functions/folder_manip.php b/functions/folder_manip.php index a5e5c02c..3211c888 100644 --- a/functions/folder_manip.php +++ b/functions/folder_manip.php @@ -222,7 +222,7 @@ function folders_delete_ask ($imapConnection, $folder_name) */ function folders_delete_do ($imapConnection, $delimiter, $folder_name) { - require_once(SM_PATH . 'functions/tree.php'); + include(SM_PATH . 'functions/tree.php'); $boxes = sqimap_mailbox_list ($imapConnection); diff --git a/functions/gettext.php b/functions/gettext.php index 5a8f180a..f311150e 100644 --- a/functions/gettext.php +++ b/functions/gettext.php @@ -16,8 +16,6 @@ * @subpackage i18n */ -/** Almost everything requires global.php... */ -require_once(SM_PATH . 'functions/global.php'); /** Load classes and other functions */ include_once(SM_PATH . 'class/l10n.class.php'); @@ -36,7 +34,7 @@ function _($str) { global $l10n, $gettext_domain; if (! isset($l10n[$gettext_domain]) || ! is_object($l10n[$gettext_domain]) || - $l10n[$gettext_domain]->error==1) + $l10n[$gettext_domain]->error==1) return $str; return $l10n[$gettext_domain]->translate($str); } @@ -98,7 +96,7 @@ if (! function_exists('dgettext')) { global $l10n; if (! isset($l10n[$domain]) || ! is_object($l10n[$domain]) || - $l10n[$domain]->error==1) + $l10n[$domain]->error==1) return $str; return $l10n[$domain]->translate($str); } diff --git a/functions/global.php b/functions/global.php index aeee4ff8..f9c189fe 100644 --- a/functions/global.php +++ b/functions/global.php @@ -23,6 +23,7 @@ define('SQ_COOKIE',4); define('SQ_SERVER',5); define('SQ_FORM',6); + /** * returns true if current php version is at mimimum a.b.c * @@ -148,12 +149,10 @@ function sqsession_is_registered ($name) { * @param int search constant defining where to look * @return bool whether variable is found. */ -function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) { +function sqgetGlobalVar($name, &$value, $search = SQ_INORDER, $default = NULL, $typecast = false) { + + $result = false; - /* NOTE: DO NOT enclose the constants in the switch - statement with quotes. They are constant values, - enclosing them in quotes will cause them to evaluate - as strings. */ switch ($search) { /* we want the default case to be first here, so that if a valid value isn't specified, @@ -163,7 +162,8 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) { case SQ_SESSION: if( isset($_SESSION[$name]) ) { $value = $_SESSION[$name]; - return TRUE; + $result = TRUE; + break; } elseif ( $search == SQ_SESSION ) { break; } @@ -171,32 +171,44 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) { case SQ_POST: if( isset($_POST[$name]) ) { $value = $_POST[$name]; - return TRUE; + $result = TRUE; + break; } elseif ( $search == SQ_POST ) { break; } case SQ_GET: if ( isset($_GET[$name]) ) { $value = $_GET[$name]; - return TRUE; + $result = TRUE; + break; } /* NO IF HERE. FOR SQ_INORDER CASE, EXIT after GET */ break; case SQ_COOKIE: if ( isset($_COOKIE[$name]) ) { $value = $_COOKIE[$name]; - return TRUE; + $result = TRUE; + break; } break; case SQ_SERVER: if ( isset($_SERVER[$name]) ) { $value = $_SERVER[$name]; - return TRUE; + $result = TRUE; + break; } break; } - /* Nothing found, return FALSE */ - return FALSE; + if ($result && $typecast) { + switch ($typecast) { + case 'int': $value = (int) $value; break; + case 'bool': $value = (bool) $value; break; + default: break; + } + } else if (!is_null($default)) { + $value = $default; + } + return $result; } /** @@ -227,7 +239,6 @@ function sqsession_destroy() { $_SESSION = array(); @session_destroy(); } - } /** @@ -249,18 +260,14 @@ function sqsession_is_active() { * (IE6 only) */ function sqsession_start() { - global $PHP_SELF; - - $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|'); - $repl = array('', '', ''); - $base_uri = preg_replace($dirs, $repl, $PHP_SELF); - + global $base_uri; session_start(); - $sessid = session_id(); + $session_id = session_id(); + // session_starts sets the sessionid cookie buth without the httponly var // setting the cookie again sets the httponly cookie attribute - sqsetcookie(session_name(),$sessid,false,$base_uri); + sqsetcookie(session_name(),session_id(),false,$base_uri); } @@ -275,7 +282,21 @@ function sqsession_start() { * @param boolean $bHttpOnly Disallow JS to access the cookie (IE6 only) * @return void */ -function sqsetcookie($sName,$sValue,$iExpire=false,$sPath="",$sDomain="",$bSecure=false,$bHttpOnly=true) { +function sqsetcookie($sName,$sValue,$iExpire=false,$sPath="",$sDomain="",$bSecure=false,$bHttpOnly=true,$bFlush=false) { + static $sCookieCache; + if (!isset($sCache)) { + $sCache = ''; + } + /** + * We have to send all cookies with one header call otherwise we loose cookies. + * In order to achieve that the sqsetcookieflush function calls this function with $bFlush = true. + * If that happens we send the cookie header. + */ + if ($bFlush) { + header($sCookieCache); + return; + } + $sHeader = "Set-Cookie: $sName=$sValue"; if ($sPath) { $sHeader .= "; path=$sPath"; @@ -295,10 +316,71 @@ function sqsetcookie($sName,$sValue,$iExpire=false,$sPath="",$sDomain="",$bSecur $sHeader .= "; HttpOnly"; } // $sHeader .= "; Version=1"; + $sCookieCache .= $sHeader ."\r\n"; + if ($bFlush) { + header($sCookieCache); + } +} + +/** + * Send the cookie header + * + * Cookies set with sqsetcookie will bet set after a sqsetcookieflush call. + * @return void + */ +function sqsetcookieflush() { + sqsetcookie('','','','','','','',true); +} + +/** + * session_regenerate_id replacement for PHP < 4.3.2 + * + * This code is borrowed from Gallery, session.php version 1.53.2.1 + */ +if (!function_exists('session_regenerate_id')) { + function make_seed() { + list($usec, $sec) = explode(' ', microtime()); + return (float)$sec + ((float)$usec * 100000); + } + + function php_combined_lcg() { + mt_srand(make_seed()); + $tv = gettimeofday(); + $lcg['s1'] = $tv['sec'] ^ (~$tv['usec']); + $lcg['s2'] = mt_rand(); + $q = (int) ($lcg['s1'] / 53668); + $lcg['s1'] = (int) (40014 * ($lcg['s1'] - 53668 * $q) - 12211 * $q); + if ($lcg['s1'] < 0) { + $lcg['s1'] += 2147483563; + } + $q = (int) ($lcg['s2'] / 52774); + $lcg['s2'] = (int) (40692 * ($lcg['s2'] - 52774 * $q) - 3791 * $q); + if ($lcg['s2'] < 0) { + $lcg['s2'] += 2147483399; + } + $z = (int) ($lcg['s1'] - $lcg['s2']); + if ($z < 1) { + $z += 2147483562; + } + return $z * 4.656613e-10; + } - header($sHeader); + function session_regenerate_id() { + global $base_uri; + $tv = gettimeofday(); + sqgetGlobalVar('REMOTE_ADDR',$remote_addr,SQ_SERVER); + $buf = sprintf("%.15s%ld%ld%0.8f", $remote_addr, $tv['sec'], $tv['usec'], php_combined_lcg() * 10); + session_id(md5($buf)); + if (ini_get('session.use_cookies')) { + // at a later stage we use sqsetcookie. At this point just do + // what session_regenerate_id would do + setcookie(session_name(), session_id(), NULL, $base_uri); + } + return TRUE; + } } + /** * php_self * @@ -328,89 +410,4 @@ function php_self () { return ''; } -/** set the name of the session cookie */ -if(isset($session_name) && $session_name) { - ini_set('session.name' , $session_name); -} else { - ini_set('session.name' , 'SQMSESSID'); -} - -/** - * If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways. - * Force magic_quotes_runtime off. - * tassium@squirrelmail.org - I put it here in the hopes that all SM code includes this. - * If there's a better place, please let me know. - */ -ini_set('magic_quotes_runtime','0'); - -/* Since we decided all IMAP servers must implement the UID command as defined in - * the IMAP RFC, we force $uid_support to be on. - */ - -global $uid_support; -$uid_support = true; - -/* if running with magic_quotes_gpc then strip the slashes - from POST and GET global arrays */ -if (get_magic_quotes_gpc()) { - sqstripslashes($_GET); - sqstripslashes($_POST); -} - -/** - * If register_globals are on, unregister globals. - * Code requires PHP 4.1.0 or newer. - */ -if ((bool) @ini_get('register_globals')) { - /** - * Remove all globals from $_GET, $_POST, and $_COOKIE. - */ - foreach ($_REQUEST as $key => $value) { - unset($GLOBALS[$key]); - } - /** - * Remove globalized $_FILES variables - * Before 4.3.0 $_FILES are included in $_REQUEST. - * Unglobalize them in separate call in order to remove dependency - * on PHP version. - */ - foreach ($_FILES as $key => $value) { - unset($GLOBALS[$key]); - // there are three undocumented $_FILES globals. - unset($GLOBALS[$key.'_type']); - unset($GLOBALS[$key.'_name']); - unset($GLOBALS[$key.'_size']); - } - /** - * Remove globalized environment variables. - */ - foreach ($_ENV as $key => $value) { - unset($GLOBALS[$key]); - } - /** - * Remove globalized server variables. - */ - foreach ($_SERVER as $key => $value) { - unset($GLOBALS[$key]); - } -} - -/* strip any tags added to the url from PHP_SELF. - This fixes hand crafted url XXS expoits for any - page that uses PHP_SELF as the FORM action */ -$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); - -$PHP_SELF = php_self(); - -sqsession_is_active(); - -/** - * Remove globalized session data in rg=on setups - */ -if ((bool) @ini_get('register_globals')) { - foreach ($_SESSION as $key => $value) { - unset($GLOBALS[$key]); - } -} -?> diff --git a/functions/html.php b/functions/html.php index 9597cc92..59f69a25 100644 --- a/functions/html.php +++ b/functions/html.php @@ -157,46 +157,4 @@ function set_url_var($url, $var, $val=0, $link=true) { } return $url; } - -/** - * Temporary test function to process template vars with formatting. - * I use it for viewing the message_header (view_header.php) with - * a sort of template. - * @param mixed $var - * @param mixed $format_ar - * @since 1.3.0 - * @todo if function is temporary, then why it is used. - * @deprecated - */ -function echo_template_var($var, $format_ar = array() ) { - $frm_last = count($format_ar) -1; - - if (isset($format_ar[0])) echo $format_ar[0]; - $i = 1; - - switch (true) { - case (is_string($var)): - echo $var; - break; - case (is_array($var)): - $frm_a = array_slice($format_ar,1,$frm_last-1); - foreach ($var as $a_el) { - if (is_array($a_el)) { - echo_template_var($a_el,$frm_a); - } else { - echo $a_el; - if (isset($format_ar[$i])) { - echo $format_ar[$i]; - } - $i++; - } - } - break; - default: - break; - } - if (isset($format_ar[$frm_last]) && $frm_last>$i ) { - echo $format_ar[$frm_last]; - } -} ?> \ No newline at end of file diff --git a/functions/identity.php b/functions/identity.php index fb90144e..10c377eb 100644 --- a/functions/identity.php +++ b/functions/identity.php @@ -12,15 +12,6 @@ * @since 1.4.2 */ -/** Used to simplify includes - * @ignore - */ -if (!defined('SM_PATH')) { - define('SM_PATH','../'); -} - -/** preference and signature functions */ -include_once(SM_PATH . 'include/load_prefs.php'); /** * Returns an array of all the identities. @@ -79,7 +70,7 @@ function save_identities($identities) { $num_cur = getPref($data_dir, $username, 'identities'); - + $cnt = count($identities); // Remove any additional identities in prefs // @@ -185,9 +176,9 @@ function sqfixidentities( $identities, $id, $action ) { // Process actions from plugins and save/update action // default: /** - * send action and id information. number of hook arguments - * differs from 1.4.4 or older and 1.5.0. count($args) can - * be used to detect modified hook. Older hook does not + * send action and id information. number of hook arguments + * differs from 1.4.4 or older and 1.5.0. count($args) can + * be used to detect modified hook. Older hook does not * provide information that can be useful for plugins. */ do_hook('options_identities_process', $action, $id); diff --git a/functions/imap.php b/functions/imap.php index ae7704b3..84dfa9c9 100644 --- a/functions/imap.php +++ b/functions/imap.php @@ -14,13 +14,7 @@ */ /** Includes */ -require_once(SM_PATH . 'functions/imap_mailbox.php'); -require_once(SM_PATH . 'functions/imap_messages.php'); -require_once(SM_PATH . 'functions/imap_general.php'); - -/** This is here for bc */ -require_once(SM_PATH . 'functions/date.php'); -require_once(SM_PATH . 'functions/mailbox_display.php'); -require_once(SM_PATH . 'functions/mime.php'); +include_once(SM_PATH . 'functions/imap_messages.php'); +include_once(SM_PATH . 'functions/imap_general.php'); ?> \ No newline at end of file diff --git a/functions/imap_asearch.php b/functions/imap_asearch.php index 88684694..957591e6 100644 --- a/functions/imap_asearch.php +++ b/functions/imap_asearch.php @@ -19,8 +19,8 @@ /** This functionality requires the IMAP and date functions */ -require_once(SM_PATH . 'functions/imap_general.php'); -require_once(SM_PATH . 'functions/date.php'); +//require_once(SM_PATH . 'functions/imap_general.php'); +//require_once(SM_PATH . 'functions/date.php'); /** Set to TRUE to dump the IMAP dialogue * @global bool $imap_asearch_debug_dump diff --git a/functions/imap_general.php b/functions/imap_general.php index 1373a20e..1afcafff 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -13,9 +13,8 @@ */ /** Includes.. */ -require_once(SM_PATH . 'functions/page_header.php'); -require_once(SM_PATH . 'functions/auth.php'); -include_once(SM_PATH . 'functions/rfc822address.php'); + +require_once(SM_PATH . 'functions/rfc822address.php'); /** @@ -64,7 +63,6 @@ function sqimap_run_command_list ($imap_stream, $query, $handle_errors, &$respon } else { global $squirrelmail_language, $color; set_up_language($squirrelmail_language); - require_once(SM_PATH . 'functions/display_messages.php'); $string = "\n" . _("ERROR: No available IMAP stream.") . "\n"; @@ -115,7 +113,6 @@ function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response, } else { global $squirrelmail_language, $color; set_up_language($squirrelmail_language); - require_once(SM_PATH . 'functions/display_messages.php'); $string = "\n" . _("ERROR: No available IMAP stream.") . "\n"; @@ -319,7 +316,6 @@ function sqimap_read_data_list($imap_stream, $tag, $handle_errors, &$response, &$message, $query = '') { global $color, $squirrelmail_language; set_up_language($squirrelmail_language); - require_once(SM_PATH . 'functions/display_messages.php'); $string = "\n" . _("ERROR: Bad function call.") . "
\n" . @@ -350,7 +346,6 @@ function sqimap_error_box($title, $query = '', $message_title = '', $message = ' global $color, $squirrelmail_language; set_up_language($squirrelmail_language); - require_once(SM_PATH . 'functions/display_messages.php'); $string = "\n" . $title . "
\n"; $cmd = explode(' ',$query); $cmd= strtolower($cmd[0]); @@ -461,7 +456,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors, case '*': { - if (($sCommand == "FETCH" || $sCommand == "STORE") && preg_match('/^\*\s\d+\sFETCH/',$read)) { + if (($sCommand == "FETCH" || $sCommand == "STORE") && preg_match('/^\*\s\d+\sFETCH/',$read)) { /* check for literal */ $s = substr($read,-3); $fetch_data = array(); @@ -863,7 +858,6 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $ /* "BAD" and anything else gets reported here. */ $message = htmlspecialchars($message); set_up_language($squirrelmail_language, true); - require_once(SM_PATH . 'functions/display_messages.php'); if ($response == 'BAD') { $string = sprintf (_("Bad request: %s")."
\r\n", $message); } else { @@ -890,8 +884,8 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $ */ set_up_language($squirrelmail_language, true); - include_once(SM_PATH . 'functions/display_messages.php' ); sqsession_destroy(); + sqsetcookieflush(); /* terminate the session nicely */ sqimap_logout($imap_stream); logout_error( _("Unknown user or password incorrect.") ); @@ -911,7 +905,6 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $ if ( stristr($message, 'REFERRAL imap') === TRUE ) { sqimap_logout($imap_stream); set_up_language($squirrelmail_language, true); - include_once(SM_PATH . 'functions/display_messages.php' ); sqsession_destroy(); logout_error( _("Your mailbox is not located at this server. Try a different server or consult your system administrator") ); exit; @@ -948,7 +941,6 @@ function sqimap_capability($imap_stream, $capability='', $bUseCache=true) { if (!$bUseCache || ! sqgetGlobalVar('sqimap_capabilities', $sqimap_capabilities, SQ_SESSION)) { $read = sqimap_run_command($imap_stream, 'CAPABILITY', true, $a, $b); - $c = explode(' ', $read[0]); for ($i=2; $i < count($c); $i++) { $cap_list = explode('=', $c[$i]); @@ -1297,4 +1289,4 @@ function map_yp_alias($username) { return chop(substr($yp, strlen($username)+1)); } -?> +?> \ No newline at end of file diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 41d8fd53..921ec31b 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -12,13 +12,9 @@ * @subpackage imap */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../'); - /** UTF7 support */ require_once(SM_PATH . 'functions/imap_utf7_local.php'); -global $boxesnew; /** * Mailboxes class @@ -769,7 +765,7 @@ function sqimap_get_mailboxes($imap_stream,$force=false,$show_only_subscribed=tr if ($show_only_subscribed) { $show_only_subscribed=$show_only_subscribed_folders; } - require_once(SM_PATH . 'include/load_prefs.php'); + //require_once(SM_PATH . 'include/load_prefs.php'); /** * There are three main listing commands we can use in IMAP: @@ -814,7 +810,6 @@ function sqimap_get_mailboxes($imap_stream,$force=false,$show_only_subscribed=tr // get subscribed mailbox list from cache (session) // if not there, then get it from the imap server and store in cache - sqsession_is_active(); if (!$force) { sqgetGlobalVar($sub_cache_name,$lsub_cache,SQ_SESSION); diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 2b1d756f..f17071d3 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -12,15 +12,6 @@ * @package squirrelmail */ -/** The standard includes.. */ -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'functions/html.php'); -require_once(SM_PATH . 'functions/imap_mailbox.php'); -require_once(SM_PATH . 'functions/imap_messages.php'); -require_once(SM_PATH . 'functions/imap_asearch.php'); -require_once(SM_PATH . 'functions/mime.php'); -require_once(SM_PATH . 'functions/forms.php'); - /** * Selects a mailbox for header retrieval. @@ -609,9 +600,9 @@ function prepareMessageList(&$aMailbox, $aProps) { $link = $sTargetModule.'.php?' . implode('&',$aQuery); // see top of this function for which attributes are available - // in the global scope for plugin use (like $link, $target, + // in the global scope for plugin use (like $link, $target, // $onclick, $link_extra, $title, and so forth) - // plugins are responsible for sharing nicely (such as for + // plugins are responsible for sharing nicely (such as for // setting the target, etc) do_hook('subject_link', array($iPageOffset, $sSearch, $aSearch)); } diff --git a/functions/mime.php b/functions/mime.php index 8f232695..d06aecde 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -12,11 +12,32 @@ * @package squirrelmail */ -/** The typical includes... */ -require_once(SM_PATH . 'functions/imap.php'); -require_once(SM_PATH . 'functions/attachment_common.php'); -/** add sqm_baseuri()*/ -include_once(SM_PATH . 'functions/display_messages.php'); +/** + * dependency information + functions dependency + mime_structure + class/mime/Message.class.php + Message::parseStructure + functions/page_header.php + displayPageHeader + functions/display_messages.php + plain_error_message + mime_fetch_body + functions/imap_general.php + sqimap_run_command + mime_print_body_lines + + + +functions/imap.php +functions/attachment_common.php +functions/display_messages.php + +magicHtml => url_parser +translateText => url_parser + +*/ + /* -------------------------------------------------------------------------- */ /* MIME DECODING */ @@ -37,7 +58,6 @@ function mime_structure ($bodystructure, $flags=array()) { $i = 0; $msg = Message::parseStructure($read,$i); if (!is_object($msg)) { - include_once(SM_PATH . 'functions/display_messages.php'); global $color, $mailbox; /* removed urldecode because $_GET is auto urldecoded ??? */ displayPageHeader( $color, $mailbox ); @@ -264,7 +284,7 @@ function translateText(&$body, $wrap_at, $charset) { global $where, $what; /* from searching */ global $color; /* color theme */ - require_once(SM_PATH . 'functions/url_parser.php'); + // require_once(SM_PATH . 'functions/url_parser.php'); $body_ary = explode("\n", $body); for ($i=0; $i < count($body_ary); $i++) { @@ -489,7 +509,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma * @return string html formated attachment information. */ function formatAttachments($message, $exclude_id, $mailbox, $id) { - global $where, $what, $startMessage, $color, $passed_ent_id; + global $where, $what, $startMessage, $color, $passed_ent_id, $base_uri; $att_ar = $message->getAttachments($exclude_id); @@ -506,10 +526,10 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) { $type1 = strtolower($header->type1); $name = ''; $links['download link']['text'] = _("Download"); - $links['download link']['href'] = sqm_baseuri() . + $links['download link']['href'] = $base_uri . "src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent"; if ($type0 =='message' && $type1 == 'rfc822') { - $default_page = sqm_baseuri() . 'src/read_body.php'; + $default_page = $base_uri . 'src/read_body.php'; $rfc822_header = $att->rfc822_header; $filename = $rfc822_header->subject; if (trim( $filename ) == '') { @@ -530,7 +550,7 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) { } $description = $from_name; } else { - $default_page = sqm_baseuri() . 'src/download.php'; + $default_page = $base_uri . 'src/download.php'; $filename = $att->getFilename(); if ($header->description) { $description = decodeHeader($header->description); @@ -2073,7 +2093,7 @@ function sq_sanitize($body, */ function magicHTML($body, $id, $message, $mailbox = 'INBOX', $take_mailto_links =true) { - require_once(SM_PATH . 'functions/url_parser.php'); // for $MailTo_PReg_Match + // require_once(SM_PATH . 'functions/url_parser.php'); // for $MailTo_PReg_Match global $attachment_common_show_images, $view_unsafe_images, $has_unsafe_images; @@ -2235,7 +2255,7 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX', $take_mailto_links if ($take_mailto_links) { // parseUrl($trusted); // this even parses URLs inside of tags... too aggressive global $MailTo_PReg_Match; - $MailTo_PReg_Match = '/mailto:' . substr($MailTo_PReg_Match, 1); + $MailTo_PReg_Match = '/mailto:' . substr($MailTo_PReg_Match, 1) ; if ((preg_match_all($MailTo_PReg_Match, $trusted, $regs)) && ($regs[0][0] != '')) { foreach ($regs[0] as $i => $mailto_before) { $mailto_params = $regs[10][$i]; @@ -2390,4 +2410,4 @@ function SendDownloadHeaders($type0, $type1, $filename, $force, $filesize=0) { } // end fn SendDownloadHeaders -?> +?> \ No newline at end of file diff --git a/functions/page_header.php b/functions/page_header.php index 5b4789cc..9c60b63c 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -11,15 +11,8 @@ * @package squirrelmail */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../'); - /** Include required files from SM */ -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'functions/html.php'); -require_once(SM_PATH . 'functions/imap_mailbox.php'); -require_once(SM_PATH . 'functions/global.php'); -include_once(SM_PATH . 'class/template/template.class.php'); +include_once(SM_PATH . 'functions/imap_mailbox.php'); /** * Output a SquirrelMail page header, from to @@ -71,6 +64,7 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE .(!empty($used_fontsize) ? '&fontsize='.$used_fontsize : '') .(!empty($text_direction) ? '&dir='.$text_direction : '')."\">\n"; + // load custom style sheet (deprecated) if ( ! empty($theme_css) ) { echo "\n"; @@ -125,7 +119,8 @@ ECHO; * @param string target the target frame for this link */ function makeInternalLink($path, $text, $target='') { - sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); + global $base_uri; +// sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); if ($target != '') { $target = " target=\"$target\""; } @@ -210,7 +205,10 @@ function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { displayHtmlHeader ('SquirrelMail'); $sBodyTagJs = ''; } - + /* + * this explains the imap_mailbox.php dependency. We should instead store + * the selected mailbox in the session and fallback to the session var. + */ $shortBoxName = htmlspecialchars(imap_utf7_decode_local( readShortMailboxName($mailbox, $delimiter))); if ( $shortBoxName == 'INBOX' ) { @@ -293,4 +291,3 @@ function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { } echo "\n\n"; } -?> \ No newline at end of file diff --git a/functions/plugin.php b/functions/plugin.php index ab8d5184..6e66aa60 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -13,14 +13,6 @@ * @package squirrelmail */ -/** Everything needs global.. */ -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'config/config.php'); -require_once(SM_PATH . 'functions/prefs.php'); - -global $squirrelmail_plugin_hooks; -$squirrelmail_plugin_hooks = array(); - /** * This function adds a plugin. * @param string $name Internal plugin name (ie. delete_move_next) @@ -200,7 +192,7 @@ function is_plugin_enabled($plugin_name) { global $plugins; /** - * check if variable is empty. if var is not set, php empty + * check if variable is empty. if var is not set, php empty * returns true without error notice. * * then check if it is an array @@ -214,25 +206,4 @@ function is_plugin_enabled($plugin_name) { return false; } } - -/*************************************/ -/*** MAIN PLUGIN LOADING CODE HERE ***/ -/*************************************/ - -/* On startup, register all plugins configured for use. */ -if (isset($plugins) && is_array($plugins)) { - // turn on output buffering in order to prevent output of new lines - ob_start(); - foreach ($plugins as $name) { - use_plugin($name); - } - // get output and remove whitespace - $output = trim(ob_get_contents()); - ob_end_clean(); - // if plugins output more than newlines and spacing, stop script execution. - if (!empty($output)) { - die($output); - } -} - ?> diff --git a/functions/prefs.php b/functions/prefs.php index ec3bc71c..49244419 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -3,7 +3,7 @@ /** * prefs.php * - * This contains functions for manipulating user preferences + * This contains functions for filebased user prefs locations * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License @@ -12,32 +12,7 @@ * @subpackage prefs */ -/** @ignore */ -if (!defined('SM_PATH')) define('SM_PATH','../'); -/** Include global.php */ -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'functions/plugin.php'); - -sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION ); -sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION ); - -if ( !sqsession_is_registered('prefs_are_cached') || - !isset( $prefs_cache) || - !is_array( $prefs_cache) - ) { - $prefs_are_cached = false; - $prefs_cache = array(); -} - -$prefs_backend = do_hook_function('prefs_backend'); -if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { - require_once(SM_PATH . $prefs_backend); -} elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { - require_once(SM_PATH . 'functions/db_prefs.php'); -} else { - require_once(SM_PATH . 'functions/file_prefs.php'); -} /* Hashing functions */ @@ -151,33 +126,4 @@ function computeHashDirs($username) { /* Return our array of hash directories. */ return ($hash_dirs); } - -/** - * Javascript support detection function - * @param boolean $reset recheck javascript support if set to true. - * @return integer SMPREF_JS_ON or SMPREF_JS_OFF ({@see functions/constants.php}) - * @since 1.5.1 - */ -function checkForJavascript($reset = FALSE) { - global $data_dir, $username, $javascript_on, $javascript_setting; - - if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) ) - return $javascript_on; - - if ( $reset || !isset($javascript_setting) ) - $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); - - if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && - !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) ) - $js_autodetect_results = SMPREF_JS_OFF; - - if ( $javascript_setting == SMPREF_JS_AUTODETECT ) - $javascript_on = $js_autodetect_results; - else - $javascript_on = $javascript_setting; - - sqsession_register($javascript_on, 'javascript_on'); - return $javascript_on; -} - ?> \ No newline at end of file diff --git a/functions/strings.php b/functions/strings.php index 613f342c..00761057 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -12,35 +12,6 @@ * @package squirrelmail */ -/** @ignore */ -if (!defined('SM_PATH')) define('SM_PATH','../'); - -/** - * SquirrelMail version number -- DO NOT CHANGE - */ -global $version; -$version = '1.5.2 [CVS]'; - -/** - * SquirrelMail internal version number -- DO NOT CHANGE - * $sm_internal_version = array (release, major, minor) - */ -global $SQM_INTERNAL_VERSION; -$SQM_INTERNAL_VERSION = array(1,5,2); - -/** - * There can be a circular issue with includes, where the $version string is - * referenced by the include of global.php, etc. before it's defined. - * For that reason, bring in global.php AFTER we define the version strings. - */ -include_once(SM_PATH . 'functions/global.php'); - -/** - * Include Compatibility plugin if available. - */ -if (file_exists(SM_PATH . 'plugins/compatibility/functions.php')) - include_once(SM_PATH . 'plugins/compatibility/functions.php'); - /** * Appends citation markers to the string. * Also appends a trailing space. @@ -483,28 +454,6 @@ function readShortMailboxName($haystack, $needle) { return( $elem ); } -/** - * 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 string the base uri of SquirrelMail installation. - * @since 1.2.6 - */ -function sqm_baseuri(){ - global $base_uri, $PHP_SELF; - /** - * If it is in the session, just return it. - */ - if (sqgetGlobalVar('base_uri',$base_uri,SQ_SESSION)){ - return $base_uri; - } - $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|'); - $repl = array('', '', ''); - $base_uri = preg_replace($dirs, $repl, $PHP_SELF); - return $base_uri; -} /** * get_location diff --git a/functions/tree.php b/functions/tree.php index 9df95a5e..14c32383 100644 --- a/functions/tree.php +++ b/functions/tree.php @@ -12,11 +12,6 @@ * @package squirrelmail */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../'); - -/** Clearly, this needs the IMAP functions.. */ -require_once(SM_PATH . 'functions/imap.php'); /** * Recursive function to find the correct parent for a new node. diff --git a/include/constants.php b/include/constants.php new file mode 100644 index 00000000..2a602585 --- /dev/null +++ b/include/constants.php @@ -0,0 +1,158 @@ + \ No newline at end of file diff --git a/include/errors.php b/include/errors.php index 983a594c..e23e2885 100644 --- a/include/errors.php +++ b/include/errors.php @@ -54,7 +54,7 @@ $aErrors['SQM_IMAP_APPEND_QUOTA_ERROR'] = array( 'category' => SQM_ERROR_IMAP, 'message' => _( "Out of quota error."), 'link' => '', - 'tip' => _("Remove unneccessary messages from your folders. Start with your Trash folder.") + 'tip' => _("Remove unneccessary messages from your folder. Start with your Trash folder.") ); $aErrors['SQM_IMAP_APPEND_ERROR'] = array( diff --git a/include/init.php b/include/init.php new file mode 100644 index 00000000..80a17c5c --- /dev/null +++ b/include/init.php @@ -0,0 +1,420 @@ + -1; --$i) { + $sSM_PATH .= '../'; + if ($a[$i] === 'src' || $a[$i] === 'plugins') { + break; + } +} + +$base_uri = implode('/',array_slice($a,0,$i)). '/'; + + + +define('SM_PATH',$sSM_PATH); + +/** + * global var $bInit is used to check if initialisation took place. + * At this moment it's a workarounf for the include of addrbook_search_html + * inside compose.php. If we found a better way then remove this. Do only use + * this var if you know for sure a page can be called stand alone and be included + * in another file. + */ +$bInit = true; + +require(SM_PATH . 'functions/global.php'); +require(SM_PATH . 'config/config.php'); +require(SM_PATH . 'functions/plugin.php'); +require(SM_PATH . 'include/constants.php'); +require(SM_PATH . 'include/languages.php'); + +/** + * If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways. + * Force magic_quotes_runtime off. + * tassium@squirrelmail.org - I put it here in the hopes that all SM code includes this. + * If there's a better place, please let me know. + */ +ini_set('magic_quotes_runtime','0'); + + +/* if running with magic_quotes_gpc then strip the slashes + from POST and GET global arrays */ +if (get_magic_quotes_gpc()) { + sqstripslashes($_GET); + sqstripslashes($_POST); +} + +/** + * If register_globals are on, unregister globals. + * Code requires PHP 4.1.0 or newer. + */ +if ((bool) @ini_get('register_globals')) { + /** + * Remove all globals from $_GET, $_POST, and $_COOKIE. + */ + foreach ($_REQUEST as $key => $value) { + unset($GLOBALS[$key]); + } + /** + * Remove globalized $_FILES variables + * Before 4.3.0 $_FILES are included in $_REQUEST. + * Unglobalize them in separate call in order to remove dependency + * on PHP version. + */ + foreach ($_FILES as $key => $value) { + unset($GLOBALS[$key]); + // there are three undocumented $_FILES globals. + unset($GLOBALS[$key.'_type']); + unset($GLOBALS[$key.'_name']); + unset($GLOBALS[$key.'_size']); + } + /** + * Remove globalized environment variables. + */ + foreach ($_ENV as $key => $value) { + unset($GLOBALS[$key]); + } + /** + * Remove globalized server variables. + */ + foreach ($_SERVER as $key => $value) { + unset($GLOBALS[$key]); + } +} + +/* strip any tags added to the url from PHP_SELF. +This fixes hand crafted url XXS expoits for any + page that uses PHP_SELF as the FORM action */ +$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); + +$PHP_SELF = php_self(); + +/** + * Initialize the session + */ + +/** + * includes from classes stored in the session + */ +require(SM_PATH . 'class/mime.class.php'); + +/** set the name of the session cookie */ +if (!isset($session_name) || !$session_name) { + $session_name = 'SQMSESSID'; +} +ini_set('session.name' , $session_name); +session_set_cookie_params (0, $base_uri); +sqsession_is_active(); + +sqsession_register($base_uri, 'base_uri'); + +/** + * Remove globalized session data in rg=on setups + */ +if ((bool) @ini_get('register_globals')) { + foreach ($_SESSION as $key => $value) { + unset($GLOBALS[$key]); + } +} +/** + * Retrieve the language cookie + */ +if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) { + $squirrelmail_language = ''; +} + + +/** + * @var $sInitlocation From where do we include. + */ +if (!isset($sInitLocation)) { + $sInitLocation=NULL; +} + +/** + * MAIN PLUGIN LOADING CODE HERE + */ + +/** + * Include Compatibility plugin if available. + */ +if (file_exists(SM_PATH . 'plugins/compatibility/functions.php')) + include_once(SM_PATH . 'plugins/compatibility/functions.php'); +$squirrelmail_plugin_hooks = array(); + +/* On init, register all plugins configured for use. */ +if (isset($plugins) && is_array($plugins)) { + // turn on output buffering in order to prevent output of new lines + ob_start(); + foreach ($plugins as $name) { + use_plugin($name); + } + // get output and remove whitespace + $output = trim(ob_get_contents()); + ob_end_clean(); + // if plugins output more than newlines and spacing, stop script execution. + if (!empty($output)) { + die($output); + } +} + + +switch ($sInitLocation) { + case 'style': session_write_close(); sqsetcookieflush(); break; + case 'redirect': + $prefs_backend = do_hook_function('prefs_backend'); + if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { + require(SM_PATH . $prefs_backend); + } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { + require(SM_PATH . 'functions/db_prefs.php'); + } else { + require(SM_PATH . 'functions/prefs.php'); + require(SM_PATH . 'functions/file_prefs.php'); + } + //nobreak; + case 'login': + require(SM_PATH . 'functions/display_messages.php' ); + require(SM_PATH . 'functions/page_header.php'); + require(SM_PATH . 'functions/html.php'); + break; + default: + require(SM_PATH . 'functions/display_messages.php' ); + require(SM_PATH . 'functions/page_header.php'); + require(SM_PATH . 'functions/html.php'); + require(SM_PATH . 'functions/strings.php'); + + + /** + * Check if we are logged in + */ + require(SM_PATH . 'functions/auth.php'); + + if ( !sqsession_is_registered('user_is_logged_in') ) { + // First we store some information in the new session to prevent + // information-loss. + // + $session_expired_post = $_POST; + $session_expired_location = $PHP_SELF; + if (!sqsession_is_registered('session_expired_post')) { + sqsession_register($session_expired_post,'session_expired_post'); + } + if (!sqsession_is_registered('session_expired_location')) { + sqsession_register($session_expired_location,'session_expired_location'); + } + // signout page will deal with users who aren't logged + // in on its own; don't show error here + // + if (strpos($PHP_SELF, 'signout.php') !== FALSE) { + return; + } + + set_up_language($squirrelmail_language, true); + logout_error( _("You must be logged in to access this page.") ); + exit; + } + + sqgetGlobalVar('username',$username,SQ_SESSION); + + /** + * Setting the prefs backend + */ + sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION ); + sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION ); + + if ( !sqsession_is_registered('prefs_are_cached') || + !isset( $prefs_cache) || + !is_array( $prefs_cache)) { + $prefs_are_cached = false; + $prefs_cache = false; //array(); + } + + $prefs_backend = do_hook_function('prefs_backend'); + if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { + require(SM_PATH . $prefs_backend); + } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { + require(SM_PATH . 'functions/db_prefs.php'); + } else { + require(SM_PATH . 'functions/prefs.php'); + require(SM_PATH . 'functions/file_prefs.php'); + } + + /** + * initializing user settings + */ + require(SM_PATH . 'include/load_prefs.php'); + + +// i do not understand the frames language cookie story + /** + * We'll need this to later have a noframes version + * + * Check if the user has a language preference, but no cookie. + * Send him a cookie with his language preference, if there is + * such discrepancy. + */ + $my_language = getPref($data_dir, $username, 'language'); + if ($my_language != $squirrelmail_language) { + sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri); + } +// /dont understand + + /** + * Set up the language. + */ + $err=set_up_language(getPref($data_dir, $username, 'language')); + /* this is the last cookie we set so flush it. */ + sqsetcookieflush(); + + // Japanese translation used without mbstring support + if ($err==2) { + $sError = + "

You need to have PHP installed with the multibyte string function \n". + "enabled (using configure option --enable-mbstring).

\n". + "

System assumed that you accidently switched to Japanese translation \n". + "and reverted your language preference to English.

\n". + "

Please refresh this page in order to use webmail.

\n"; + error_box($sError); + } + + $timeZone = getPref($data_dir, $username, 'timezone'); + + /* Check to see if we are allowed to set the TZ environment variable. + * We are able to do this if ... + * safe_mode is disabled OR + * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR + * safe_mode_allowed_env_vars contains TZ + */ + $tzChangeAllowed = (!ini_get('safe_mode')) || + !strcmp(ini_get('safe_mode_allowed_env_vars'),'') || + preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')); + + if ( $timeZone != SMPREF_NONE && ($timeZone != "") + && $tzChangeAllowed ) { + + // get time zone key, if strict or custom strict timezones are used + if (isset($time_zone_type) && + ($time_zone_type == 1 || $time_zone_type == 3)) { + /* load time zone functions */ + require(SM_PATH . 'include/timezones.php'); + $realTimeZone = sq_get_tz_key($timeZone); + } else { + $realTimeZone = $timeZone; + } + + // set time zone + if ($realTimeZone) { + putenv("TZ=".$realTimeZone); + } + } + break; +} + +/** + * Initialize the template object + */ +require(SM_PATH . 'class/template/template.class.php'); +/* + * $sTplDir is not initialized when a user is not logged in, so we will use + * the config file defaults here. If the neccesary variables are net set, + * force a default value. + */ +$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet ); +$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default ); + +$sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ? + SM_PATH . 'templates/default/' : + $aTemplateSet[$templateset_default]['PATH'] ); +$oTemplate = new Template($sTplDir); + +/** + * Initialize our custom error handler object + */ +require(SM_PATH . 'class/error.class.php'); +$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl'); + +/** + * Activate custom error handling + */ +if (version_compare(PHP_VERSION, "4.3.0", ">=")) { + $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler')); +} else { + $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler'); +} + +/** + * Javascript support detection function + * @param boolean $reset recheck javascript support if set to true. + * @return integer SMPREF_JS_ON or SMPREF_JS_OFF ({@see functions/constants.php}) + * @since 1.5.1 + */ + +function checkForJavascript($reset = FALSE) { + global $data_dir, $username, $javascript_on, $javascript_setting; + + if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) ) + return $javascript_on; + + if ( $reset || !isset($javascript_setting) ) + $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); + + if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && + !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) ) + $js_autodetect_results = SMPREF_JS_OFF; + + if ( $javascript_setting == SMPREF_JS_AUTODETECT ) + $javascript_on = $js_autodetect_results; + else + $javascript_on = $javascript_setting; + + sqsession_register($javascript_on, 'javascript_on'); + return $javascript_on; +} + +function sqm_baseuri() { + global $base_uri; + return $base_uri; +} \ No newline at end of file diff --git a/include/languages.php b/include/languages.php new file mode 100644 index 00000000..342b9336 --- /dev/null +++ b/include/languages.php @@ -0,0 +1,1090 @@ +'),$string); + return $string; + } + } + + // iconv functions does not have html target and can be used only with utf-8 + if ( $use_php_iconv && $default_charset=='utf-8') { + $string = iconv($charset,$default_charset,$string); + return ($save_html ? $string : htmlspecialchars($string)); + } + + // If we don't use recode and iconv, we'll do it old way. + + /* All HTML special characters are 7 bit and can be replaced first */ + if (! $save_html) $string = htmlspecialchars ($string); + + /* controls cpu and memory intensive decoding cycles */ + if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) { + $aggressive_decoding=false; } + + $decode=fixcharset($charset); + $decodefile=SM_PATH . 'functions/decode/' . $decode . '.php'; + if (file_exists($decodefile)) { + include_once($decodefile); + // send $save_html argument to decoding function. needed for iso-2022-xx decoding. + $ret = call_user_func('charset_decode_'.$decode, $string, $save_html); + } else { + $ret = $string; + } + return( $ret ); +} + +/** + * Converts html string to given charset + * @since 1.5.1 and 1.4.4 + * @param string $string + * @param string $charset + * @param boolean $htmlencode keep htmlspecialchars encoding + * @param string + */ +function charset_encode($string,$charset,$htmlencode=true) { + global $default_charset; + + $encode=fixcharset($charset); + $encodefile=SM_PATH . 'functions/encode/' . $encode . '.php'; + if (file_exists($encodefile)) { + include_once($encodefile); + $ret = call_user_func('charset_encode_'.$encode, $string); + } elseif(file_exists(SM_PATH . 'functions/encode/us_ascii.php')) { + // function replaces all 8bit html entities with question marks. + // it is used when other encoding functions are unavailable + include_once(SM_PATH . 'functions/encode/us_ascii.php'); + $ret = charset_encode_us_ascii($string); + } else { + /** + * fix for yahoo users that remove all us-ascii related things + */ + $ret = $string; + } + + /** + * Undo html special chars, some places (like compose form) have + * own sanitizing functions and don't need html symbols. + * Undo chars only after encoding in order to prevent conversion of + * html entities in plain text emails. + */ + if (! $htmlencode ) { + $ret = str_replace(array('&','>','<','"'),array('&','>','<','"'),$ret); + } + return( $ret ); +} + +/** + * Combined decoding and encoding functions + * + * If conversion is done to charset different that utf-8, unsupported symbols + * will be replaced with question marks. + * @since 1.5.1 and 1.4.4 + * @param string $in_charset initial charset + * @param string $string string that has to be converted + * @param string $out_charset final charset + * @param boolean $htmlencode keep htmlspecialchars encoding + * @return string converted string + */ +function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) { + $string=charset_decode($in_charset,$string,true); + $string=sqi18n_convert_entities($string); + $string=charset_encode($string,$out_charset,$htmlencode); + return $string; +} + +/** + * Makes charset name suitable for decoding cycles + * + * @since 1.5.0 and 1.4.4 + * @param string $charset Name of charset + * @return string $charset Adjusted name of charset + */ +function fixcharset($charset) { + /* remove minus and characters that might be used in paths from charset + * name in order to be able to use it in function names and include calls. + */ + $charset=preg_replace("/[-:.\/\\\]/",'_',$charset); + + // OE ks_c_5601_1987 > cp949 + $charset=str_replace('ks_c_5601_1987','cp949',$charset); + // Moz x-euc-tw > euc-tw + $charset=str_replace('x_euc','euc',$charset); + // Moz x-windows-949 > cp949 + $charset=str_replace('x_windows_','cp',$charset); + + // windows-125x and cp125x charsets + $charset=str_replace('windows_','cp',$charset); + + // ibm > cp + $charset=str_replace('ibm','cp',$charset); + + // iso-8859-8-i -> iso-8859-8 + // use same cycle until I'll find differences + $charset=str_replace('iso_8859_8_i','iso_8859_8',$charset); + + return $charset; +} + +/** + * Set up the language to be output + * if $do_search is true, then scan the browser information + * for a possible language that we know + * + * Function sets system locale environment (LC_ALL, LANG, LANGUAGE), + * gettext translation bindings and html header information. + * + * Function returns error codes, if there is some fatal error. + * 0 = no error, + * 1 = mbstring support is not present, + * 2 = mbstring support is not present, user's translation reverted to en_US. + * + * @param string $sm_language translation used by user's interface + * @param bool $do_search use browser's preferred language detection functions. Defaults to false. + * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false. + * @return int function execution error codes. + */ +function set_up_language($sm_language, $do_search = false, $default = false) { + + static $SetupAlready = 0; + global $use_gettext, $languages, + $squirrelmail_language, $squirrelmail_default_language, $default_charset, + $sm_notAlias, $username, $data_dir; + + if ($SetupAlready) { + return; + } + + $SetupAlready = TRUE; + sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER); + + /** + * If function is asked to detect preferred language + * OR squirrelmail default language is set to empty string + * AND + * squirrelmail language ($sm_language) is empty string + * (not set in user's prefs and no cookie with language info) + * AND + * browser provides list of preferred languages + * THEN + * get preferred language from HTTP_ACCEPT_LANGUAGE header + */ + if (($do_search || empty($squirrelmail_default_language)) && + ! $sm_language && + isset($accept_lang)) { + // TODO: use more than one language, if first language is not available + // FIXME: function assumes that string contains two or more characters. + // FIXME: some languages use 5 chars + $sm_language = substr($accept_lang, 0, 2); + } + + /** + * If language preference is not set OR script asks to use default language + * AND + * default squirrelmail language is not set to empty string + * THEN + * use default squirrelmail language value from configuration. + */ + if ((!$sm_language||$default) && + ! empty($squirrelmail_default_language)) { + $squirrelmail_language = $squirrelmail_default_language; + $sm_language = $squirrelmail_default_language; + } + + /** provide failsafe language when detection fails */ + if (! $sm_language) $sm_language='en_US'; + + $sm_notAlias = $sm_language; + + // Catching removed translation + // System reverts to English translation if user prefs contain translation + // that is not available in $languages array + if (!isset($languages[$sm_notAlias])) { + $sm_notAlias="en_US"; + } + + while (isset($languages[$sm_notAlias]['ALIAS'])) { + $sm_notAlias = $languages[$sm_notAlias]['ALIAS']; + } + + if ( isset($sm_language) && + $use_gettext && + $sm_language != '' && + isset($languages[$sm_notAlias]['CHARSET']) ) { + sq_bindtextdomain( 'squirrelmail', SM_PATH . 'locale/' ); + sq_textdomain( 'squirrelmail' ); + + // set codeset in order to avoid gettext charset conversions + if (function_exists('bind_textdomain_codeset')) { + // Japanese translation uses different internal charset + if ($sm_notAlias == 'ja_JP') { + bind_textdomain_codeset ('squirrelmail', 'EUC-JP'); + } else { + bind_textdomain_codeset ('squirrelmail', $languages[$sm_notAlias]['CHARSET'] ); + } + } + + // Use LOCALE key, if it is set. + if (isset($languages[$sm_notAlias]['LOCALE'])){ + $longlocale=$languages[$sm_notAlias]['LOCALE']; + } else { + $longlocale=$sm_notAlias; + } + + // try setting locale + $retlocale=sq_setlocale(LC_ALL, $longlocale); + + // check if locale is set and assign that locale to $longlocale + // in order to use it in putenv calls. + if (! is_bool($retlocale)) { + $longlocale=$retlocale; + } elseif (is_array($longlocale)) { + // setting of all locales failed. + // we need string instead of array used in LOCALE key. + $longlocale=$sm_notAlias; + } + + if ( !((bool)ini_get('safe_mode')) && + getenv( 'LC_ALL' ) != $longlocale ) { + putenv( "LC_ALL=$longlocale" ); + putenv( "LANG=$longlocale" ); + putenv( "LANGUAGE=$longlocale" ); + putenv( "LC_NUMERIC=C" ); + if ($sm_notAlias=='tr_TR') putenv( "LC_CTYPE=C" ); + } + // Workaround for plugins that use numbers with floating point + // It might be removed if plugins use correct decimal delimiters + // according to locale settings. + setlocale(LC_NUMERIC, 'C'); + // Workaround for specific Turkish strtolower/strtoupper rules. + // Many functions expect English conversion rules. + if ($sm_notAlias=='tr_TR') setlocale(LC_CTYPE,'C'); + + /** + * Set text direction/alignment variables + * When language environment is setup, scripts can use these globals + * without accessing $languages directly and making checks for optional + * array key. + */ + global $text_direction, $left_align, $right_align; + if (isset($languages[$sm_notAlias]['DIR']) && + $languages[$sm_notAlias]['DIR'] == 'rtl') { + /** + * Text direction + * @global string $text_direction + */ + $text_direction='rtl'; + /** + * Left alignment + * @global string $left_align + */ + $left_align='right'; + /** + * Right alignment + * @global string $right_align + */ + $right_align='left'; + } else { + $text_direction='ltr'; + $left_align='left'; + $right_align='right'; + } + + $squirrelmail_language = $sm_notAlias; + if ($squirrelmail_language == 'ja_JP') { + header ('Content-Type: text/html; charset=EUC-JP'); + if (!function_exists('mb_internal_encoding')) { + // Error messages can't be displayed here + $error = 1; + // Revert to English if possible. + if (function_exists('setPref') && $username!='' && $data_dir!="") { + setPref($data_dir, $username, 'language', "en_US"); + $error = 2; + } + // stop further execution in order not to get php errors on mb_internal_encoding(). + return $error; + } + if (function_exists('mb_language')) { + mb_language('Japanese'); + } + mb_internal_encoding('EUC-JP'); + mb_http_output('pass'); + } elseif ($squirrelmail_language == 'en_US') { + header( 'Content-Type: text/html; charset=' . $default_charset ); + } else { + header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] ); + } + /** + * mbstring.func_overload fix (#929644). + * + * php mbstring extension can replace standard string functions with their multibyte + * equivalents. See http://www.php.net/ref.mbstring#mbstring.overload. This feature + * was added in php v.4.2.0 + * + * Some SquirrelMail functions work with 8bit strings in bytes. If interface is forced + * to use mbstring functions and mbstring internal encoding is set to multibyte charset, + * interface can't trust regular string functions. Due to mbstring overloading design + * limits php scripts can't control this setting. + * + * This hack should fix some issues related to 8bit strings in passwords. Correct fix is + * to disable mbstring overloading. Japanese translation uses different internal encoding. + */ + if ($squirrelmail_language != 'ja_JP' && + function_exists('mb_internal_encoding') && + check_php_version(4,2,0) && + (int)ini_get('mbstring.func_overload')!=0) { + mb_internal_encoding('pass'); + } + } + return 0; +} + +/** + * Sets default_charset variable according to the one that is used by user's translations. + * + * Function changes global $default_charset variable in order to be sure, that it + * contains charset used by user's translation. Sanity of $squirrelmail_language + * and $default_charset combination is also tested. + * + * There can be a $default_charset setting in the + * config.php file, but the user may have a different language + * selected for a user interface. This function checks the + * language selected by the user and tags the outgoing messages + * with the appropriate charset corresponding to the language + * selection. This is "more right" (tm), than just stamping the + * message blindly with the system-wide $default_charset. + */ +function set_my_charset(){ + global $data_dir, $username, $default_charset, $languages, $squirrelmail_language; + + $my_language = getPref($data_dir, $username, 'language'); + if (!$my_language) { + $my_language = $squirrelmail_language ; + } + // Catch removed translation + if (!isset($languages[$my_language])) { + $my_language="en_US"; + } + while (isset($languages[$my_language]['ALIAS'])) { + $my_language = $languages[$my_language]['ALIAS']; + } + $my_charset = $languages[$my_language]['CHARSET']; + if ($my_language!='en_US') { + $default_charset = $my_charset; + } +} + +/** + * Replaces non-braking spaces inserted by some browsers with regular space + * + * This function can be used to replace non-braking space symbols + * that are inserted in forms by some browsers instead of normal + * space symbol. + * + * @param string $string Text that needs to be cleaned + * @param string $charset Charset used in text + * @return string Cleaned text + */ +function cleanup_nbsp($string,$charset) { + + // reduce number of case statements + if (stristr('iso-8859-',substr($charset,0,9))){ + $output_charset="iso-8859-x"; + } + if (stristr('windows-125',substr($charset,0,11))){ + $output_charset="cp125x"; + } + if (stristr('koi8',substr($charset,0,4))){ + $output_charset="koi8-x"; + } + if (! isset($output_charset)){ + $output_charset=strtolower($charset); + } + +// where is non-braking space symbol +switch($output_charset): + case "iso-8859-x": + case "cp125x": + case "iso-2022-jp": + $nbsp="\xA0"; + break; + case "koi8-x": + $nbsp="\x9A"; + break; + case "utf-8": + $nbsp="\xC2\xA0"; + break; + default: + // don't change string if charset is unmatched + return $string; +endswitch; + +// return space instead of non-braking space. + return str_replace($nbsp,' ',$string); +} + +/** + * Function informs if it is safe to convert given charset to the one that is used by user. + * + * It is safe to use conversion only if user uses utf-8 encoding and when + * converted charset is similar to the one that is used by user. + * + * @param string $input_charset Charset of text that needs to be converted + * @return bool is it possible to convert to user's charset + */ +function is_conversion_safe($input_charset) { + global $languages, $sm_notAlias, $default_charset, $lossy_encoding; + + if (isset($lossy_encoding) && $lossy_encoding ) + return true; + + // convert to lower case + $input_charset = strtolower($input_charset); + + // Is user's locale Unicode based ? + if ( $default_charset == "utf-8" ) { + return true; + } + + // Charsets that are similar + switch ($default_charset) { + case "windows-1251": + if ( $input_charset == "iso-8859-5" || + $input_charset == "koi8-r" || + $input_charset == "koi8-u" ) { + return true; + } else { + return false; + } + case "windows-1257": + if ( $input_charset == "iso-8859-13" || + $input_charset == "iso-8859-4" ) { + return true; + } else { + return false; + } + case "iso-8859-4": + if ( $input_charset == "iso-8859-13" || + $input_charset == "windows-1257" ) { + return true; + } else { + return false; + } + case "iso-8859-5": + if ( $input_charset == "windows-1251" || + $input_charset == "koi8-r" || + $input_charset == "koi8-u" ) { + return true; + } else { + return false; + } + case "iso-8859-13": + if ( $input_charset == "iso-8859-4" || + $input_charset == "windows-1257" ) { + return true; + } else { + return false; + } + case "koi8-r": + if ( $input_charset == "windows-1251" || + $input_charset == "iso-8859-5" || + $input_charset == "koi8-u" ) { + return true; + } else { + return false; + } + case "koi8-u": + if ( $input_charset == "windows-1251" || + $input_charset == "iso-8859-5" || + $input_charset == "koi8-r" ) { + return true; + } else { + return false; + } + default: + return false; + } +} + +/** + * Converts html character entities to numeric entities + * + * SquirrelMail encoding functions work only with numeric entities. + * This function fixes issues with decoding functions that might convert + * some symbols to character entities. Issue is specific to PHP recode + * extension decoding. Function is used internally in charset_convert() + * function. + * @param string $str string that might contain html character entities + * @return string string with character entities converted to decimals. + * @since 1.5.2 + */ +function sqi18n_convert_entities($str) { + + $entities = array( + // Latin 1 + ' ' => ' ', + '¡' => '¡', + '¢' => '¢', + '£' => '£', + '¤' => '¤', + '¥' => '¥', + '¦' => '¦', + '§' => '§', + '¨' => '¨', + '©' => '©', + 'ª' => 'ª', + '«' => '«', + '¬' => '¬', + '­' => '­', + '®' => '®', + '¯' => '¯', + '°' => '°', + '±' => '±', + '²' => '²', + '³' => '³', + '´' => '´', + 'µ' => 'µ', + '¶' => '¶', + '·' => '·', + '¸' => '¸', + '¹' => '¹', + 'º' => 'º', + '»' => '»', + '¼' => '¼', + '½' => '½', + '¾' => '¾', + '¿' => '¿', + 'À' => 'À', + 'Á' => 'Á', + 'Â' => 'Â', + 'Ã' => 'Ã', + 'Ä' => 'Ä', + 'Å' => 'Å', + 'Æ' => 'Æ', + 'Ç' => 'Ç', + 'È' => 'È', + 'É' => 'É', + 'Ê' => 'Ê', + 'Ë' => 'Ë', + 'Ì' => 'Ì', + 'Í' => 'Í', + 'Î' => 'Î', + 'Ï' => 'Ï', + 'Ð' => 'Ð', + 'Ñ' => 'Ñ', + 'Ò' => 'Ò', + 'Ó' => 'Ó', + 'Ô' => 'Ô', + 'Õ' => 'Õ', + 'Ö' => 'Ö', + '×' => '×', + 'Ø' => 'Ø', + 'Ù' => 'Ù', + 'Ú' => 'Ú', + 'Û' => 'Û', + 'Ü' => 'Ü', + 'Ý' => 'Ý', + 'Þ' => 'Þ', + 'ß' => 'ß', + 'à' => 'à', + 'á' => 'á', + 'â' => 'â', + 'ã' => 'ã', + 'ä' => 'ä', + 'å' => 'å', + 'æ' => 'æ', + 'ç' => 'ç', + 'è' => 'è', + 'é' => 'é', + 'ê' => 'ê', + 'ë' => 'ë', + 'ì' => 'ì', + 'í' => 'í', + 'î' => 'î', + 'ï' => 'ï', + 'ð' => 'ð', + 'ñ' => 'ñ', + 'ò' => 'ò', + 'ó' => 'ó', + 'ô' => 'ô', + 'õ' => 'õ', + 'ö' => 'ö', + '÷' => '÷', + 'ø' => 'ø', + 'ù' => 'ù', + 'ú' => 'ú', + 'û' => 'û', + 'ü' => 'ü', + 'ý' => 'ý', + 'þ' => 'þ', + 'ÿ' => 'ÿ', + // Latin Extended-A + 'Œ' => 'Œ', + 'œ' => 'œ', + 'Š' => 'Š', + 'š' => 'š', + 'Ÿ' => 'Ÿ', + // Spacing Modifier Letters + 'ˆ' => 'ˆ', + '˜' => '˜', + // General Punctuation + ' ' => ' ', + ' ' => ' ', + ' ' => ' ', + '‌' => '‌', + '‍' => '‍', + '‎' => '‎', + '‏' => '‏', + '–' => '–', + '—' => '—', + '‘' => '‘', + '’' => '’', + '‚' => '‚', + '“' => '“', + '”' => '”', + '„' => '„', + '†' => '†', + '‡' => '‡', + '‰' => '‰', + '‹' => '‹', + '›' => '›', + '€' => '€', + // Latin Extended-B + 'ƒ' => 'ƒ', + // Greek + 'Α' => 'Α', + 'Β' => 'Β', + 'Γ' => 'Γ', + 'Δ' => 'Δ', + 'Ε' => 'Ε', + 'Ζ' => 'Ζ', + 'Η' => 'Η', + 'Θ' => 'Θ', + 'Ι' => 'Ι', + 'Κ' => 'Κ', + 'Λ' => 'Λ', + 'Μ' => 'Μ', + 'Ν' => 'Ν', + 'Ξ' => 'Ξ', + 'Ο' => 'Ο', + 'Π' => 'Π', + 'Ρ' => 'Ρ', + 'Σ' => 'Σ', + 'Τ' => 'Τ', + 'Υ' => 'Υ', + 'Φ' => 'Φ', + 'Χ' => 'Χ', + 'Ψ' => 'Ψ', + 'Ω' => 'Ω', + 'α' => 'α', + 'β' => 'β', + 'γ' => 'γ', + 'δ' => 'δ', + 'ε' => 'ε', + 'ζ' => 'ζ', + 'η' => 'η', + 'θ' => 'θ', + 'ι' => 'ι', + 'κ' => 'κ', + 'λ' => 'λ', + 'μ' => 'μ', + 'ν' => 'ν', + 'ξ' => 'ξ', + 'ο' => 'ο', + 'π' => 'π', + 'ρ' => 'ρ', + 'ς' => 'ς', + 'σ' => 'σ', + 'τ' => 'τ', + 'υ' => 'υ', + 'φ' => 'φ', + 'χ' => 'χ', + 'ψ' => 'ψ', + 'ω' => 'ω', + 'ϑ' => 'ϑ', + 'ϒ' => 'ϒ', + 'ϖ' => 'ϖ', + // General Punctuation + '•' => '•', + '…' => '…', + '′' => '′', + '″' => '″', + '‾' => '‾', + '⁄' => '⁄', + // Letterlike Symbols + '℘' => '℘', + 'ℑ' => 'ℑ', + 'ℜ' => 'ℜ', + '™' => '™', + 'ℵ' => 'ℵ', + // Arrows + '←' => '←', + '↑' => '↑', + '→' => '→', + '↓' => '↓', + '↔' => '↔', + '↵' => '↵', + '⇐' => '⇐', + '⇑' => '⇑', + '⇒' => '⇒', + '⇓' => '⇓', + '⇔' => '⇔', + // Mathematical Operators + '∀' => '∀', + '∂' => '∂', + '∃' => '∃', + '∅' => '∅', + '∇' => '∇', + '∈' => '∈', + '∉' => '∉', + '∋' => '∋', + '∏' => '∏', + '∑' => '∑', + '−' => '−', + '∗' => '∗', + '√' => '√', + '∝' => '∝', + '∞' => '∞', + '∠' => '∠', + '∧' => '∧', + '∨' => '∨', + '∩' => '∩', + '∪' => '∪', + '∫' => '∫', + '∴' => '∴', + '∼' => '∼', + '≅' => '≅', + '≈' => '≈', + '≠' => '≠', + '≡' => '≡', + '≤' => '≤', + '≥' => '≥', + '⊂' => '⊂', + '⊃' => '⊃', + '⊄' => '⊄', + '⊆' => '⊆', + '⊇' => '⊇', + '⊕' => '⊕', + '⊗' => '⊗', + '⊥' => '⊥', + '⋅' => '⋅', + // Miscellaneous Technical + '⌈' => '⌈', + '⌉' => '⌉', + '⌊' => '⌊', + '⌋' => '⌋', + '⟨' => '〈', + '⟩' => '〉', + // Geometric Shapes + '◊' => '◊', + // Miscellaneous Symbols + '♠' => '♠', + '♣' => '♣', + '♥' => '♥', + '♦' => '♦'); + + $str = str_replace(array_keys($entities), array_values($entities), $str); + + return $str; +} + +/* ------------------------------ main --------------------------- */ + +global $squirrelmail_language, $languages, $use_gettext; + +if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) { + $squirrelmail_language = ''; +} + +/** + * Array specifies the available translations. + * + * Structure of array: + * $languages['language']['variable'] = 'value' + * + * Possible 'variable' names: + * NAME - Translation name in English + * CHARSET - Encoding used by translation + * ALIAS - used when 'language' is only short name and 'value' should provide long language name + * ALTNAME - Native translation name. Any 8bit symbols must be html encoded. + * LOCALE - Full locale name (in xx_XX.charset format). It can use array with more than one locale name since 1.4.5 and 1.5.1 + * DIR - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr' + * XTRA_CODE - translation uses special functions. See doc/i18n.txt + * + * Each 'language' definition requires NAME+CHARSET or ALIAS variables. + * + * @name $languages + * @global array $languages + */ +$languages['en_US']['NAME'] = 'English'; +$languages['en_US']['CHARSET'] = 'iso-8859-1'; +$languages['en_US']['LOCALE'] = 'en_US.ISO8859-1'; +$languages['en']['ALIAS'] = 'en_US'; + +/** + * Automatic translation loading from setup.php files. + * Solution for bug. 1240889. + * setup.php file can contain $languages array entries and XTRA_CODE functions. + */ +if (is_dir(SM_PATH . 'locale') && + is_readable(SM_PATH . 'locale')) { + $localedir = dir(SM_PATH . 'locale'); + while($lang_dir=$localedir->read()) { + // remove trailing slash, if present + if (substr($lang_dir,-1)=='/') { + $lang_dir = substr($lang_dir,0,-1); + } + if ($lang_dir != '..' && $lang_dir != '.' && $lang_dir != 'CVS' && + is_dir(SM_PATH.'locale/'.$lang_dir) && + file_exists(SM_PATH.'locale/'.$lang_dir.'/setup.php')) { + include_once(SM_PATH.'locale/'.$lang_dir.'/setup.php'); + } + } + $localedir->close(); +} + +/* Detect whether gettext is installed. */ +$gettext_flags = 0; +if (function_exists('_')) { + $gettext_flags += 1; +} +if (function_exists('bindtextdomain')) { + $gettext_flags += 2; +} +if (function_exists('textdomain')) { + $gettext_flags += 4; +} +if (function_exists('ngettext')) { + $gettext_flags += 8; +} + +/* If gettext is fully loaded, cool */ +if ($gettext_flags == 15) { + $use_gettext = true; +} + +/* If ngettext support is missing, load it */ +elseif ($gettext_flags == 7) { + $use_gettext = true; + // load internal ngettext functions + include_once(SM_PATH . 'class/l10n.class.php'); + include_once(SM_PATH . 'functions/ngettext.php'); +} + +/* If we can fake gettext, try that */ +elseif ($gettext_flags == 0) { + $use_gettext = true; + include_once(SM_PATH . 'functions/gettext.php'); +} else { + /* Uh-ho. A weird install */ + if (! $gettext_flags & 1) { + /** + * Function is used as replacement in broken installs + * @ignore + */ + function _($str) { + return $str; + } + } + if (! $gettext_flags & 2) { + /** + * Function is used as replacement in broken installs + * @ignore + */ + function bindtextdomain() { + return; + } + } + if (! $gettext_flags & 4) { + /** + * Function is used as replacemet in broken installs + * @ignore + */ + function textdomain() { + return; + } + } + if (! $gettext_flags & 8) { + /** + * Function is used as replacemet in broken installs + * @ignore + */ + function ngettext($str,$str2,$number) { + if ($number>1) { + return $str2; + } else { + return $str; + } + } + } + if (! function_exists('dgettext')) { + /** + * Replacement for broken setups. + * @ignore + */ + function dgettext($domain,$str) { + return $str; + } + } + if (! function_exists('dngettext')) { + /** + * Replacement for broken setups + * @ignore + */ + function dngettext($domain,$str1,$strn,$number) { + return ($number==1 ? $str1 : $strn); + } + } +} +?> \ No newline at end of file diff --git a/include/load_prefs.php b/include/load_prefs.php index 5e11b45f..d25426ea 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -12,16 +12,20 @@ * @package squirrelmail */ -/** SquirrelMail required files. */ -include_once(SM_PATH . 'functions/constants.php'); -include_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/plugin.php'); +/** + * do not allow to call this file directly + */ +if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || + (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { + header("Location: ../src/login.php"); + die(); +} if( ! sqgetGlobalVar('username', $username, SQ_SESSION) ) { $username = ''; } - +// TODO Get rid of "none" strings when NULL or false should be used, i hate them i hate them i hate them!!!. $custom_css = getPref($data_dir, $username, 'custom_css', 'none' ); $theme = ( !isset($theme) ? array() : $theme ); @@ -107,9 +111,8 @@ $icon_theme = getPref($data_dir, $username, 'icon_theme', 'images/themes/xp/' ); if ($icon_theme == 'template') { $icon_theme = $sTplDir . 'images/'; } - /* - * NOTE: The $icon_theme_path var should contain the path to the icon + * NOTE: The $icon_theme_path var should contain the path to the icon * theme to use. If the admin has disabled icons, or the user has * set the icon theme to "None," no icons will be used. */ @@ -272,8 +275,6 @@ if (!$index_order) { setPref($data_dir, $username, 'index_order', serialize($index_order)); } - - if (!isset($default_mailbox_pref)) { $show_num = (isset($show_num)) ? $show_num : 15; @@ -401,6 +402,27 @@ $chosen_fontset = getPref($data_dir, $username, 'chosen_fontset', $default_fonts if (! isset($default_fontsize)) $default_fontsize=SMPREF_NONE; $chosen_fontsize = getPref($data_dir, $username, 'chosen_fontsize', $default_fontsize); + + +/** Put in a safety net for authentication here, in case a naughty admin didn't run conf.pl when they upgraded */ + +// TODO Get rid of "none" strings when NULL should be used, i hate them i hate them i hate them!!!. +if (! isset($smtp_auth_mech)) { + $smtp_auth_mech = 'none'; +} + +if (! isset($imap_auth_mech)) { + $imap_auth_mech = 'login'; +} + +if (! isset($use_imap_tls)) { + $use_imap_tls = false; +} + +if (! isset($use_smtp_tls)) { + $use_smtp_tls = false; +} + do_hook('loading_prefs'); ?> diff --git a/include/options/display.php b/include/options/display.php index f7dfc022..33dcbe39 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -224,7 +224,7 @@ function load_optpage_data_display() { /* Icon theme selection */ if ($use_icons) { global $icon_themes, $icon_theme; - + $temp = array(); for ($count = 0; $count < sizeof($icon_themes); $count++) { $temp[$count] = $icon_themes[$count]['NAME']; @@ -247,6 +247,7 @@ function load_optpage_data_display() { } } + /*** Load the General Options into the array ***/ $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options"); $optvals[SMOPT_GRP_MAILBOX] = array(); diff --git a/include/options/folder.php b/include/options/folder.php index faecf3d1..ce55f516 100644 --- a/include/options/folder.php +++ b/include/options/folder.php @@ -12,8 +12,7 @@ */ /** SquirrelMail required files. */ -require_once(SM_PATH . 'functions/imap.php'); -require_once(SM_PATH . 'functions/imap_general.php'); +include(SM_PATH . 'functions/imap_general.php'); /* Define the group constants for the folder options page. */ define('SMOPT_GRP_SPCFOLDER', 0); diff --git a/include/validate.php b/include/validate.php index 735aec49..9155b83a 100644 --- a/include/validate.php +++ b/include/validate.php @@ -9,137 +9,6 @@ * @package squirrelmail */ -/** include the mime class before the session start ! otherwise we can't store - * messages with a session_register. - * - * From http://www.php.net/manual/en/language.oop.serialization.php: - * In case this isn't clear: - * In 4.2 and below: - * session.auto_start and session objects are mutually exclusive. - * - * We need to load the classes before the session is started, - * except that the session could be started automatically - * via session.auto_start. So, we'll close the session, - * then load the classes, and reopen the session which should - * make everything happy. - * - * ** Note this means that for the 1.3.2 release, we should probably - * recommend that people set session.auto_start=0 to avoid this altogether. - */ - -session_write_close(); - -/** - * Reset the $theme() array in case a value was passed via a cookie. - * This is until theming is rewritten. - */ -global $theme; -unset($theme); -$theme=array(); - -/* SquirrelMail required files. */ -include_once(SM_PATH . 'class/mime.class.php'); -include_once(SM_PATH . 'functions/global.php'); -include_once(SM_PATH . 'functions/strings.php'); - -/* set the name of the session cookie */ -if(isset($session_name) && $session_name) { - ini_set('session.name' , $session_name); -} else { - ini_set('session.name' , 'SQMSESSID'); -} - -sqsession_is_active(); - -include_once(SM_PATH . 'functions/i18n.php'); -include_once(SM_PATH . 'functions/auth.php'); - -is_logged_in(); - -/** - * Auto-detection - * - * if $send (the form button's name) contains "\n" as the first char - * and the script is compose.php, then trim everything. Otherwise, we - * don't have to worry. - * - * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug - */ -global $send, $PHP_SELF; -if (isset($send) - && (substr($send, 0, 1) == "\n") - && (substr($PHP_SELF, -12) == '/compose.php')) { - if ($REQUEST_METHOD == 'POST') { - global $HTTP_POST_VARS; - TrimArray($HTTP_POST_VARS); - } else { - global $HTTP_GET_VARS; - TrimArray($HTTP_GET_VARS); - } -} - -include_once(SM_PATH . 'functions/page_header.php'); -include_once(SM_PATH . 'functions/prefs.php'); -include_once(SM_PATH . 'config/config.php'); -include_once(SM_PATH . 'include/load_prefs.php'); - -/* Set up the language (i18n.php was included by auth.php). */ -global $username, $data_dir; -set_up_language(getPref($data_dir, $username, 'language')); - -$timeZone = getPref($data_dir, $username, 'timezone'); - -/* Check to see if we are allowed to set the TZ environment variable. - * We are able to do this if ... - * safe_mode is disabled OR - * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR - * safe_mode_allowed_env_vars contains TZ - */ -$tzChangeAllowed = (!ini_get('safe_mode')) || - !strcmp(ini_get('safe_mode_allowed_env_vars'),'') || - preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')); - -if ( $timeZone != SMPREF_NONE && ($timeZone != "") - && $tzChangeAllowed ) { - - // get time zone key, if strict or custom strict timezones are used - if (isset($time_zone_type) && - ($time_zone_type == 1 || $time_zone_type == 3)) { - /* load time zone functions */ - require_once(SM_PATH . 'include/timezones.php'); - $realTimeZone = sq_get_tz_key($timeZone); - } else { - $realTimeZone = $timeZone; - } - - // set time zone - if ($realTimeZone) { - putenv("TZ=".$realTimeZone); - } -} - -/* temporary sm_init section */ - -include_once(SM_PATH . 'class/template/template.class.php'); -include_once(SM_PATH . 'class/error.class.php'); -/* - * Initialize the template object - */ -global $sTplDir; -$oTemplate = new Template($sTplDir); - -/* - * Initialize our custom error handler object - */ -$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl'); - -/* - * Activate custom error handling - */ -if (version_compare(PHP_VERSION, "4.3.0", ">=")) { - $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler')); -} else { - $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler'); -} - +echo "Rewrite your code, we now use init.php"; +die(); ?> \ No newline at end of file diff --git a/plugins/abook_take/functions.php b/plugins/abook_take/functions.php index 0e046eb7..24b1bd52 100644 --- a/plugins/abook_take/functions.php +++ b/plugins/abook_take/functions.php @@ -12,10 +12,6 @@ * @subpackage abook_take */ -/** SquirrelMail required files. */ -require_once(SM_PATH . 'functions/url_parser.php'); -require_once(SM_PATH . 'functions/forms.php'); - function valid_email ($email, $verify) { global $Email_RegExp_Match; diff --git a/plugins/abook_take/setup.php b/plugins/abook_take/setup.php index 00e94394..af71969f 100755 --- a/plugins/abook_take/setup.php +++ b/plugins/abook_take/setup.php @@ -14,13 +14,6 @@ * @subpackage abook_take */ -/** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore - */ -if (!defined('SM_PATH')) { - define('SM_PATH','../../'); -} /** * Initialize the plugin diff --git a/plugins/abook_take/take.php b/plugins/abook_take/take.php index 59fa6841..045c6224 100644 --- a/plugins/abook_take/take.php +++ b/plugins/abook_take/take.php @@ -14,13 +14,13 @@ */ /** - * Path for SquirrelMail required files. - * @ignore */ -define('SM_PATH','../../'); + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); /* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/addressbook.php'); +require(SM_PATH . 'functions/forms.php'); +require(SM_PATH . 'functions/addressbook.php'); displayPageHeader($color, 'None'); diff --git a/plugins/administrator/auth.php b/plugins/administrator/auth.php index dd4560f2..cb189380 100644 --- a/plugins/administrator/auth.php +++ b/plugins/administrator/auth.php @@ -21,7 +21,6 @@ */ function adm_check_user() { global $PHP_SELF, $plugins; - require_once(SM_PATH . 'functions/global.php'); /* fail if the plugin is not enabled */ if ( !in_array('administrator', $plugins) ) { diff --git a/plugins/administrator/defines.php b/plugins/administrator/defines.php index 9f46f482..d985aa45 100644 --- a/plugins/administrator/defines.php +++ b/plugins/administrator/defines.php @@ -11,15 +11,6 @@ * @subpackage administrator */ -/** @ignore */ -if (!defined('SM_PATH')) define('SM_PATH','../../'); - -/** - * Load SquirrelMail SMPREF constants for default_unseen_notify and - * default_unseen_type variables. - */ -require_once( SM_PATH . 'functions/constants.php' ); - /* Define constants for the various option types. */ define('SMOPT_TYPE_UNDEFINED', -1); define('SMOPT_TYPE_STRING', 0); diff --git a/plugins/bug_report/bug_report.php b/plugins/bug_report/bug_report.php index 7bb658b6..5f95e243 100644 --- a/plugins/bug_report/bug_report.php +++ b/plugins/bug_report/bug_report.php @@ -14,18 +14,15 @@ * @subpackage bug_report */ + /** - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); -/** load system functions */ -require_once(SM_PATH . 'include/validate.php'); +require('../../include/init.php'); /** load form functions */ -include_once(SM_PATH . 'functions/forms.php'); -/** load error_box() function */ -include_once(SM_PATH . 'functions/display_messages.php'); +require_once(SM_PATH . 'functions/forms.php'); /** load plugin functions */ -include_once(SM_PATH . 'plugins/bug_report/functions.php'); +require_once(SM_PATH . 'plugins/bug_report/functions.php'); displayPageHeader($color, 'None'); @@ -37,7 +34,7 @@ if (! is_plugin_enabled('bug_report') || ! bug_report_check_user()) { } /** get system specs */ -include_once(SM_PATH . 'plugins/bug_report/system_specs.php'); +require_once(SM_PATH . 'plugins/bug_report/system_specs.php'); global $body; $body_top = "I am subscribed to the this mailing list.\n" . @@ -107,7 +104,7 @@ echo "

\n"; '; if (! empty($bug_report_admin_email)) { - // if admin's email is set - add 'report to admin' option and make it default one + // if admin's email is set - add 'report to admin' option and make it default one echo ''; } diff --git a/plugins/bug_report/functions.php b/plugins/bug_report/functions.php index 4db6358e..e524057c 100644 --- a/plugins/bug_report/functions.php +++ b/plugins/bug_report/functions.php @@ -9,8 +9,15 @@ * @subpackage bug_report */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../../'); + +/** + * do not allow to call this file directly + */ +if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || + (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { + header("Location: ../../src/login.php"); + die(); +} /** Declare plugin configuration vars */ global $bug_report_admin_email, $bug_report_allow_users; diff --git a/plugins/bug_report/show_system_specs.php b/plugins/bug_report/show_system_specs.php index 20b9bbe5..6d79a4fd 100644 --- a/plugins/bug_report/show_system_specs.php +++ b/plugins/bug_report/show_system_specs.php @@ -10,13 +10,10 @@ */ /** - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); -/** load system functions */ -include_once(SM_PATH . 'include/validate.php'); -/** load error_box() function */ -include_once(SM_PATH . 'functions/display_messages.php'); +require('../../include/init.php'); + /** load plugin functions */ include_once(SM_PATH.'plugins/bug_report/functions.php'); diff --git a/plugins/bug_report/system_specs.php b/plugins/bug_report/system_specs.php index b3c48c55..9c6b7889 100644 --- a/plugins/bug_report/system_specs.php +++ b/plugins/bug_report/system_specs.php @@ -10,15 +10,20 @@ * @subpackage bug_report */ -/** @ignore */ -if (!defined('SM_PATH')) define('SM_PATH','../../'); +/** + * do not allow to call this file directly + */ +if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || + (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { + header("Location: ../../src/login.php"); + die(); +} /** * load required libraries */ -include_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); -global $body, $username; +include_once(SM_PATH . 'functions/imap_general.php'); + /** diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 866fb060..956f4b29 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -10,11 +10,11 @@ * @subpackage calendar */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -/* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); /* load date_intl() */ include_once(SM_PATH . 'functions/date.php'); diff --git a/plugins/calendar/day.php b/plugins/calendar/day.php index 220341ca..abb70db7 100644 --- a/plugins/calendar/day.php +++ b/plugins/calendar/day.php @@ -10,11 +10,11 @@ * @subpackage calendar */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -/* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); /* date_intl() */ include_once(SM_PATH . 'functions/date.php'); @@ -126,8 +126,8 @@ function display_events() { echo html_tag( 'tr', '', '', $color[$eo] ) . html_tag( 'td', date_intl(_("H:i"),mktime($ehour,$eminute,0,1,1,0)) . $elength, 'left' ) . html_tag( 'td', '', 'left' ) . '['; - echo ($calbar['priority']==1) ? - "".htmlspecialchars($calbar['title']).'' : + echo ($calbar['priority']==1) ? + "".htmlspecialchars($calbar['title']).'' : htmlspecialchars($calbar['title']); echo']
'.nl2br(htmlspecialchars($calbar['message'])).'
' . html_tag( 'td', diff --git a/plugins/calendar/event_create.php b/plugins/calendar/event_create.php index d40fcbb2..9dc78570 100644 --- a/plugins/calendar/event_create.php +++ b/plugins/calendar/event_create.php @@ -9,12 +9,11 @@ * @package plugins * @subpackage calendar */ +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -/** @ignore */ -define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); /* date_intl() */ include_once(SM_PATH . 'functions/date.php'); diff --git a/plugins/calendar/event_delete.php b/plugins/calendar/event_delete.php index 6e31dd70..55070d93 100644 --- a/plugins/calendar/event_delete.php +++ b/plugins/calendar/event_delete.php @@ -10,11 +10,11 @@ * @subpackage calendar */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -/* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); /* date_intl() */ include_once(SM_PATH . 'functions/date.php'); diff --git a/plugins/calendar/event_edit.php b/plugins/calendar/event_edit.php index 97e6ef87..1631033c 100644 --- a/plugins/calendar/event_edit.php +++ b/plugins/calendar/event_edit.php @@ -10,11 +10,13 @@ * @subpackage calendar */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); /* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); + /* date_intl() */ include_once(SM_PATH . 'functions/date.php'); /* form functions */ @@ -150,7 +152,7 @@ function update_event_form() { */ function confirm_update() { global $calself, $year, $month, $day, $hour, $minute, $calendardata, - $color, $event_year, $event_month, $event_day, $event_hour, + $color, $event_year, $event_month, $event_day, $event_hour, $event_minute, $event_length, $event_priority, $event_title, $event_text; $tmparray = $calendardata["$month$day$year"]["$hour$minute"]; diff --git a/plugins/change_password/backend/ldap.php b/plugins/change_password/backend/ldap.php index 348cf3b4..34697600 100644 --- a/plugins/change_password/backend/ldap.php +++ b/plugins/change_password/backend/ldap.php @@ -11,17 +11,18 @@ */ /** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore + * do not allow to call this file directly */ -if (!defined('SM_PATH')) define('SM_PATH','../../../'); +if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || + (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { + header("Location: ../../../src/login.php"); + die(); +} /** load required functions */ -/** error_box() function */ -include_once(SM_PATH . 'functions/display_messages.php'); /** sqimap_get_user_server() function */ -include_once(SM_PATH . 'functions/imap_general.php'); +include_once(SM_PATH . '../functions/imap_general.php'); /** get imap server and username globals */ global $imapServerAddress, $username; diff --git a/plugins/change_password/backend/merak.php b/plugins/change_password/backend/merak.php index a7132919..ea845f9d 100644 --- a/plugins/change_password/backend/merak.php +++ b/plugins/change_password/backend/merak.php @@ -43,17 +43,6 @@ $squirrelmail_plugin_hooks['change_password_init']['merak'] = function cpw_merak_init() { global $color; - /** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore - */ - if (!defined('SM_PATH')) { - define('SM_PATH','../../../'); - } - - // load error_box() function - include_once(SM_PATH . 'functions/display_messages.php'); - 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); diff --git a/plugins/change_password/backend/peardb.php b/plugins/change_password/backend/peardb.php index 58f74c80..e3d10413 100644 --- a/plugins/change_password/backend/peardb.php +++ b/plugins/change_password/backend/peardb.php @@ -10,15 +10,15 @@ * @subpackage change_password */ -/** load Pear DB. - * Global is needed because library must be loaded before configuration +/** load Pear DB. + * Global is needed because library must be loaded before configuration * in order to use DB constants. */ global $cpw_peardb_detect; $cpw_peardb_detect=@include_once('DB.php'); /** declare configuration globals */ -global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table, +global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table, $cpw_peardb_uid_field, $cpw_peardb_domain_field, $cpw_peardb_passwd_field, $cpw_peardb_crypted_passwd, $cpw_peardb_debug; @@ -108,17 +108,6 @@ $squirrelmail_plugin_hooks['change_password_init']['peardb'] = function cpw_peardb_init() { global $color, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table; - /** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore - */ - if (!defined('SM_PATH')) { - define('SM_PATH','../../../'); - } - - // load error_box() function - include_once(SM_PATH . 'functions/display_messages.php'); - 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 "\n"; @@ -126,7 +115,7 @@ function cpw_peardb_init() { } // Test required settings - if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='') + 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 "\n"; @@ -142,7 +131,7 @@ function cpw_peardb_init() { */ function cpw_peardb_dochange($data) { global $cpw_peardb_dsn, $cpw_peardb_table, $cpw_peardb_connect_opts, $cpw_peardb_debug, - $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field, + $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field, $cpw_peardb_crypted_passwd, $domain; $username = $data['username']; @@ -159,7 +148,7 @@ function cpw_peardb_dochange($data) { $user=$username; $user_domain=$domain; } - + // connect to database and make sure that table exists $cpw_db = DB::connect($cpw_peardb_dsn, $cpw_peardb_connect_opts); if (PEAR::isError($cpw_db)) { @@ -187,9 +176,9 @@ function cpw_peardb_dochange($data) { $cpw_peardb_passwd_check=false; $cpw_peardb_domain_check=(($cpw_peardb_domain_field=='')? true : false); foreach($table_info as $key => $field_data) { - if ($field_data['name']==$cpw_peardb_uid_field) + if ($field_data['name']==$cpw_peardb_uid_field) $cpw_peardb_uid_check=true; - if ($field_data['name']==$cpw_peardb_passwd_field) + if ($field_data['name']==$cpw_peardb_passwd_field) $cpw_peardb_passwd_check=true; if ($cpw_peardb_domain_field!='' && $field_data['name']==$cpw_peardb_domain_field) $cpw_peardb_domain_check=true; @@ -216,7 +205,7 @@ function cpw_peardb_dochange($data) { .' FROM '.$cpw_db->quoteIdentifier($cpw_peardb_table) .' WHERE ' .$cpw_db->quoteIdentifier($cpw_peardb_uid_field).'='.$cpw_db->quoteSmart($user) - .(($cpw_peardb_domain_field!='') ? + .(($cpw_peardb_domain_field!='') ? ' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain): ''); $cpw_res=$cpw_db->query($query); @@ -286,7 +275,7 @@ function cpw_peardb_dochange($data) { .'='.$cpw_db->quoteSmart($hashed_passwd) .' WHERE '.$cpw_db->quoteIdentifier($cpw_peardb_uid_field) .'='.$cpw_db->quoteSmart($user) - .(($cpw_peardb_domain_field!='') ? + .(($cpw_peardb_domain_field!='') ? ' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain) : ''); diff --git a/plugins/change_password/backend/poppassd.php b/plugins/change_password/backend/poppassd.php index a35b720f..7a0f574c 100644 --- a/plugins/change_password/backend/poppassd.php +++ b/plugins/change_password/backend/poppassd.php @@ -86,10 +86,8 @@ function cpw_poppassd_go($username, $old_pw, $new_pw, $debug = 0) { global $poppassd_server; global $imapServerAddress; - /** @ignore */ - if (!defined('SM_PATH')) define('SM_PATH','../../../'); /** sqimap_get_user_server() function */ - include_once(SM_PATH . 'functions/imap_general.php'); + include_once(SM_PATH . '../functions/imap_general.php'); if($poppassd_server == '') { // if poppassd address is not set, use imap server's address diff --git a/plugins/change_password/backend/template.php b/plugins/change_password/backend/template.php index 6f54de22..e7b0a8b4 100644 --- a/plugins/change_password/backend/template.php +++ b/plugins/change_password/backend/template.php @@ -41,17 +41,6 @@ function cpw_template_init() { global $color; - /** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore - */ - if (!defined('SM_PATH')) { - define('SM_PATH','../../../'); - } - - // load error_box() function - include_once(SM_PATH . 'functions/display_messages.php'); - // plugin is not configured. Handle error gracefully. error_box(_("No valid backend defined."),$color); // close html and stop script execution diff --git a/plugins/change_password/backend/vmailmgrd.php b/plugins/change_password/backend/vmailmgrd.php index 6504c329..e8f70a62 100644 --- a/plugins/change_password/backend/vmailmgrd.php +++ b/plugins/change_password/backend/vmailmgrd.php @@ -106,17 +106,6 @@ $squirrelmail_plugin_hooks['change_password_init']['vmailmgrd'] = function cpw_vmailmgrd_init(){ global $vmail_inc_path, $color, $username; - /** - * If SM_PATH isn't defined, define it. Required to include files. - * @ignore - */ - if (!defined('SM_PATH')) { - define('SM_PATH','../../../'); - } - - // load error_box() function - include_once(SM_PATH . 'functions/display_messages.php'); - 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); diff --git a/plugins/change_password/options.php b/plugins/change_password/options.php index 0246bfa5..4400a015 100644 --- a/plugins/change_password/options.php +++ b/plugins/change_password/options.php @@ -10,10 +10,11 @@ * @subpackage change_password */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -include_once (SM_PATH . 'include/validate.php'); include_once (SM_PATH . 'plugins/change_password/functions.php'); include_once (SM_PATH . 'functions/forms.php'); diff --git a/plugins/filters/filters.php b/plugins/filters/filters.php index b5f64a38..09dd04f1 100644 --- a/plugins/filters/filters.php +++ b/plugins/filters/filters.php @@ -10,8 +10,14 @@ * @subpackage filters */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../../'); +/** + * do not allow to call this file directly + */ +if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || + (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { + header("Location: ../../src/login.php"); + die(); +} /** load globals */ global $UseSeparateImapConnection, @@ -40,6 +46,28 @@ if (file_exists(SM_PATH . 'config/filters_config.php')) { include_once (SM_PATH . 'plugins/filters/config.php'); } +/** + * Init Hooks + * @access private + */ +function filters_init_hooks () { + global $squirrelmail_plugin_hooks; + + if (! sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) { + $mailbox = 'INBOX'; + } + + $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook'; + if (isset($mailbox) && $mailbox == 'INBOX') { + $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook'; + } + $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook'; + $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; + $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook'; + $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook'; + $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status'; +} + /** * Register option blocks * @access private @@ -70,6 +98,10 @@ function filters_folder_status($statusarr) { global $filter_inbox_count; if (empty($filter_inbox_count)) $filter_inbox_count=0; + //echo "GOT HOOK
";
+    //var_dump($statusarr);
+    //echo "

\n"; + if ($statusarr['MAILBOX'] == 'INBOX') { if (!empty($statusarr['MESSAGES'])) $filter_inbox_count=$statusarr['MESSAGES']; @@ -174,26 +206,15 @@ function filters_bulkquery($filters, $IPs) { /** * Starts the filtering process - * @param array $hook_args (since 1.5.2) do hook arguments. Is used to check - * hook name, array key = 0. * @access private */ -function start_filters($hook_args) { +function start_filters() { global $imapServerAddress, $imapPort, $imap_stream, $imapConnection, $UseSeparateImapConnection, $AllowSpamFilters, $filter_inbox_count; sqgetGlobalVar('username', $username, SQ_SESSION); sqgetGlobalVar('key', $key, SQ_COOKIE); - /** - * check hook that calls filtering. If filters are called by right_main_after_header, - * do filtering only when we are in INBOX folder. - */ - if ($hook_args[0]=='right_main_after_header' && - (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM) && $mailbox!='INBOX')) { - return; - } - $filters = load_filters(); // No point running spam filters if there aren't any to run // @@ -349,6 +370,7 @@ function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_ /* read data back from IMAP */ $read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, TRUE); } else { + // TODO BADCHARSET $search_str .= ' ' . $where . ' {' . strlen($what) . "}"; $sid = sqimap_session_id(true); fputs ($imap_stream, $sid . ' ' . $search_str . "\r\n"); diff --git a/plugins/filters/options.php b/plugins/filters/options.php index 8978818e..222ca749 100644 --- a/plugins/filters/options.php +++ b/plugins/filters/options.php @@ -11,14 +11,10 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); +require('../../include/init.php'); +include_once(SM_PATH . 'functions/imap_general.php'); include_once(SM_PATH . 'plugins/filters/filters.php'); displayPageHeader($color, 'None'); diff --git a/plugins/filters/setup.php b/plugins/filters/setup.php index 47ab5f5f..1dcd1e92 100644 --- a/plugins/filters/setup.php +++ b/plugins/filters/setup.php @@ -15,15 +15,8 @@ * @access private */ function squirrelmail_plugin_init_filters() { - global $squirrelmail_plugin_hooks; - - $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook'; - $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook'; - $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook'; - $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; - $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook'; - $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook'; - $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status'; + include_once(SM_PATH . 'plugins/filters/filters.php'); + filters_init_hooks (); } /** @@ -53,7 +46,7 @@ function filters_optpage_register_block_hook() { */ function start_filters_hook($args) { include_once(SM_PATH . 'plugins/filters/filters.php'); - start_filters ($args); + start_filters (); } /** diff --git a/plugins/filters/spamoptions.php b/plugins/filters/spamoptions.php index b4977941..b228298f 100644 --- a/plugins/filters/spamoptions.php +++ b/plugins/filters/spamoptions.php @@ -11,14 +11,12 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); +require('../../include/init.php'); -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); +include_once(SM_PATH . 'functions/imap_general.php'); +include_once(SM_PATH . 'functions/imap_messages.php'); include_once(SM_PATH . 'plugins/filters/filters.php'); /* get globals */ diff --git a/plugins/fortune/setup.php b/plugins/fortune/setup.php index 89dfc68d..fb7609c9 100644 --- a/plugins/fortune/setup.php +++ b/plugins/fortune/setup.php @@ -10,14 +10,6 @@ * @subpackage fortune */ -/** - * If SM_PATH isn't defined, define it. - * @ignore - */ -if (!defined('SM_PATH')) { - define('SM_PATH','../../'); -} - /** * Init plugin * @access private diff --git a/plugins/info/options.php b/plugins/info/options.php index 5489441e..e27ae576 100644 --- a/plugins/info/options.php +++ b/plugins/info/options.php @@ -13,13 +13,14 @@ * @subpackage info */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Path for SquirrelMail required files. + * @ignore + */ +require('../../include/init.php'); /* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/page_header.php'); -require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/imap_general.php'); require_once(SM_PATH . 'functions/forms.php'); require_once(SM_PATH . 'plugins/info/functions.php'); diff --git a/plugins/listcommands/mailout.php b/plugins/listcommands/mailout.php index 4cd2ab06..c319fc10 100644 --- a/plugins/listcommands/mailout.php +++ b/plugins/listcommands/mailout.php @@ -9,18 +9,16 @@ * @package plugins * @subpackage listcommands */ - -/** @ignore */ -define('SM_PATH','../../'); +/** + * Path for SquirrelMail required files. + * @ignore + */ +require('../../include/init.php'); /* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/page_header.php'); -include_once(SM_PATH . 'include/load_prefs.php'); -include_once(SM_PATH . 'functions/html.php'); -require_once(SM_PATH . 'functions/identity.php'); -require_once(SM_PATH . 'functions/forms.php'); -include_once(SM_PATH . 'plugins/listcommands/functions.php'); +require(SM_PATH . 'functions/identity.php'); +require(SM_PATH . 'functions/forms.php'); +require(SM_PATH . 'plugins/listcommands/functions.php'); /* get globals */ sqgetGlobalVar('mailbox', $mailbox, SQ_GET); diff --git a/plugins/mail_fetch/README b/plugins/mail_fetch/README index 5e7879b2..e246a2fc 100644 --- a/plugins/mail_fetch/README +++ b/plugins/mail_fetch/README @@ -91,7 +91,7 @@ Go back to the main directory, run configure and add the plugin. Some plugin settings can be adjusted in config/mail_fetch_config.php or plugins/mail_fetch/config.php files. -See plugins/mail_fetch/config_default.php +See plugins/mail_fetch/config_sample.php Note for mod_gzip users diff --git a/plugins/mail_fetch/fetch.php b/plugins/mail_fetch/fetch.php index 268f22e4..7bf720b1 100644 --- a/plugins/mail_fetch/fetch.php +++ b/plugins/mail_fetch/fetch.php @@ -12,11 +12,12 @@ * @subpackage mail_fetch */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); +include_once(SM_PATH . 'functions/imap_general.php'); include_once(SM_PATH . 'plugins/mail_fetch/class.POP3.php'); include_once(SM_PATH . 'plugins/mail_fetch/functions.php' ); diff --git a/plugins/mail_fetch/functions.php b/plugins/mail_fetch/functions.php index 7bb8fa53..bdcfd71d 100644 --- a/plugins/mail_fetch/functions.php +++ b/plugins/mail_fetch/functions.php @@ -16,8 +16,6 @@ * @subpackage mail_fetch */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../../'); /** pop3 class */ include_once (SM_PATH . 'plugins/mail_fetch/class.POP3.php'); @@ -81,9 +79,9 @@ function mail_fetch_load_pref_function() { * @private */ function mail_fetch_login_function() { - include_once (SM_PATH . 'include/validate.php'); - include_once (SM_PATH . 'functions/imap.php'); - + //include_once (SM_PATH . 'include/validate.php'); + include_once (SM_PATH . 'functions/imap_general.php'); + global $data_dir, $imapServerAddress, $imapPort; sqgetGlobalVar('username', $username, SQ_SESSION); @@ -232,9 +230,6 @@ function mail_fetch_login_function() { function mail_fetch_setnew_function() { global $data_dir; - // FIXME: check if function is already loaded in login_verified hook - include_once(SM_PATH . 'functions/prefs.php'); - sqgetGlobalVar('username', $username, SQ_SESSION); setPref( $data_dir, $username, 'mailfetch_newlog', 'on' ); } @@ -256,7 +251,7 @@ function mailfetch_optpage_register_block_function() { } /** - * Internal function used to update mail_fetch settings + * Internal function used to update mail_fetch settings * when folders are renamed or deleted. * @since 1.5.1 * @private diff --git a/plugins/mail_fetch/options.php b/plugins/mail_fetch/options.php index 6bf63ca2..6cea5271 100644 --- a/plugins/mail_fetch/options.php +++ b/plugins/mail_fetch/options.php @@ -12,11 +12,12 @@ * @subpackage mail_fetch */ -/** @ignore */ -define('SM_PATH','../../'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/imap.php'); +include_once(SM_PATH . 'functions/imap_general.php'); /* globals */ sqgetGlobalVar('username', $username, SQ_SESSION); diff --git a/plugins/mail_fetch/setup.php b/plugins/mail_fetch/setup.php index c4085cdd..616ba1d0 100644 --- a/plugins/mail_fetch/setup.php +++ b/plugins/mail_fetch/setup.php @@ -12,9 +12,6 @@ * @subpackage mail_fetch */ -/** @ignore */ -if (! defined('SM_PATH')) define('SM_PATH','../../'); - /** * Initialize the plugin */ diff --git a/plugins/message_details/message_details_bottom.php b/plugins/message_details/message_details_bottom.php index 0852e5ca..f3eee63a 100644 --- a/plugins/message_details/message_details_bottom.php +++ b/plugins/message_details/message_details_bottom.php @@ -14,14 +14,13 @@ * @subpackage message_details */ -/** @ignore */ -if (!defined('SM_PATH')) - define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/imap.php'); -require_once(SM_PATH . 'functions/mime.php'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); +require(SM_PATH . 'functions/imap_general.php'); +require(SM_PATH . 'functions/imap_messages.php'); +require(SM_PATH . 'functions/mime.php'); sqgetGlobalVar('get_message_details', $md_action, SQ_GET); diff --git a/plugins/message_details/message_details_main.php b/plugins/message_details/message_details_main.php index d8f9ef0e..b089df55 100644 --- a/plugins/message_details/message_details_main.php +++ b/plugins/message_details/message_details_main.php @@ -15,13 +15,9 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); +require('../../include/init.php'); displayHtmlHeader( _("Message Details"), '', FALSE ); diff --git a/plugins/message_details/message_details_top.php b/plugins/message_details/message_details_top.php index bed4f618..27fd6407 100644 --- a/plugins/message_details/message_details_top.php +++ b/plugins/message_details/message_details_top.php @@ -14,12 +14,11 @@ * @subpackage message_details */ -/** @ignore */ -define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/forms.php'); +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); +require(SM_PATH . 'functions/forms.php'); displayHtmlHeader( _("Message Details"), "' ."\n"; } - + // get mailbox list and cache it $mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders); diff --git a/src/login.php b/src/login.php index a9dbd436..2fea9d04 100644 --- a/src/login.php +++ b/src/login.php @@ -12,21 +12,16 @@ * @package squirrelmail */ +// reduces the files included in init.php +$sInitLocation = 'login'; + /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +require('../include/init.php'); + /* SquirrelMail required files. */ -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'config/config.php'); -require_once(SM_PATH . 'functions/i18n.php'); -require_once(SM_PATH . 'functions/plugin.php'); -require_once(SM_PATH . 'functions/constants.php'); -require_once(SM_PATH . 'functions/page_header.php'); -require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'functions/imap_general.php'); require_once(SM_PATH . 'functions/forms.php'); @@ -36,26 +31,23 @@ require_once(SM_PATH . 'functions/forms.php'); */ set_up_language($squirrelmail_language, TRUE, TRUE); -/** - * Find out the base URI to set cookies. - */ -$base_uri = sqm_baseuri(); - /* * In case the last session was not terminated properly, make sure * we get a new one. */ - sqsession_destroy(); +sqsession_is_active(); +$_SESSION=array(); + + /** * PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and * http://bugs.php.net/13834 - * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other + * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other * versions. Produces warning on login page. Bug should be fixed only in 4.3.0 */ -@sqsession_start(); -header('Pragma: no-cache'); +//exit; /** * This detects if the IMAP server has logins disabled, and if so, * squelches the display of the login form and puts up a message @@ -83,26 +75,6 @@ if($imap_auth_mech == 'login') { } } -/* - * Initialize the template object and custom error handler object - */ -include_once(SM_PATH . 'class/template/template.class.php'); -include_once(SM_PATH . 'class/error.class.php'); - -/* - * $sTplDir is not initialized when a user is not logged in, so we will use - * the config file defaults here. If the neccesary variables are net set, - * force a default value. - */ -$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet ); -$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default ); -$sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ? - SM_PATH . 'templates/default/' : - $aTemplateSet[$templateset_default]['PATH'] ); - -$oTemplate = new Template($sTplDir); -$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl'); - do_hook('login_cookie'); $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); @@ -155,7 +127,7 @@ if (isset($org_logo) && $org_logo) { $org_logo_height>0) { $width_and_height .= " height=\"$org_logo_height\""; } - + $logo_str = 'assign('color', $color); $oTemplate->assign('logo_str', $logo_str); $oTemplate->assign('sm_attribute_str', $sm_attribute_str); diff --git a/src/mailto.php b/src/mailto.php index 87d6a4e9..0ad9224f 100644 --- a/src/mailto.php +++ b/src/mailto.php @@ -17,16 +17,13 @@ * @package squirrelmail */ +// reduce the included files in int.php +$bLogin = true; + /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'config/config.php'); -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'functions/strings.php'); +require('../include/init.php'); /* Force users to login each time? */ $force_login = true; @@ -65,7 +62,6 @@ if(sqgetGlobalVar('emailaddress', $emailaddress)) { } $url = substr($url, 0, -1); } -sqsession_is_active(); if($force_login == false && sqsession_is_registered('user_is_logged_in')) { if($compose_only == true) { diff --git a/src/options.php b/src/options.php index 9607582d..6256fb8e 100644 --- a/src/options.php +++ b/src/options.php @@ -14,20 +14,15 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +require('../include/init.php'); /* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/global.php'); -include_once(SM_PATH . 'functions/display_messages.php'); -include_once(SM_PATH . 'functions/imap.php'); -include_once(SM_PATH . 'functions/options.php'); -include_once(SM_PATH . 'functions/strings.php'); -include_once(SM_PATH . 'functions/html.php'); -include_once(SM_PATH . 'functions/forms.php'); + +//include(SM_PATH . 'functions/imap_general.php'); +require_once(SM_PATH . 'functions/options.php'); +require_once(SM_PATH . 'functions/forms.php'); /*********************************/ /*** Build the resultant page. ***/ diff --git a/src/options_highlight.php b/src/options_highlight.php index 167169f0..aa6fae03 100644 --- a/src/options_highlight.php +++ b/src/options_highlight.php @@ -13,19 +13,12 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); - -/* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/display_messages.php'); -include_once(SM_PATH . 'functions/imap.php'); -include_once(SM_PATH . 'functions/plugin.php'); -include_once(SM_PATH . 'functions/strings.php'); -include_once(SM_PATH . 'functions/html.php'); -include_once(SM_PATH . 'functions/forms.php'); +require('../include/init.php'); + +// include_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/forms.php'); /* get globals */ sqGetGlobalVar('action', $action); diff --git a/src/options_identities.php b/src/options_identities.php index db9b0531..026ae1f1 100644 --- a/src/options_identities.php +++ b/src/options_identities.php @@ -14,17 +14,12 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +require('../include/init.php'); /* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/global.php'); -include_once(SM_PATH . 'functions/display_messages.php'); -include_once(SM_PATH . 'functions/html.php'); -include_once(SM_PATH . 'functions/identity.php'); +require_once(SM_PATH . 'functions/identity.php'); if (!sqgetGlobalVar('identities', $identities, SQ_SESSION)) { $identities = get_identities(); diff --git a/src/options_order.php b/src/options_order.php index 5e1c36f2..cd3c2d40 100644 --- a/src/options_order.php +++ b/src/options_order.php @@ -13,21 +13,13 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +require('../include/init.php'); /* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); -include_once(SM_PATH . 'functions/global.php'); -include_once(SM_PATH . 'functions/display_messages.php'); -include_once(SM_PATH . 'functions/imap.php'); -include_once(SM_PATH . 'functions/plugin.php'); -include_once(SM_PATH . 'functions/html.php'); -include_once(SM_PATH . 'functions/forms.php'); -include_once(SM_PATH . 'functions/arrays.php'); -//require_once(SM_PATH . 'functions/options.php'); +require_once(SM_PATH . 'functions/forms.php'); +require_once(SM_PATH . 'functions/arrays.php'); /* get globals */ if (sqgetGlobalVar('num', $num, SQ_GET)) { diff --git a/src/printer_friendly_bottom.php b/src/printer_friendly_bottom.php index 3e4e95fa..350c466b 100644 --- a/src/printer_friendly_bottom.php +++ b/src/printer_friendly_bottom.php @@ -15,14 +15,16 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +require('../include/init.php'); /* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/imap_general.php'); +require_once(SM_PATH . 'functions/imap_messages.php'); +require_once(SM_PATH . 'functions/date.php'); +require_once(SM_PATH . 'functions/mime.php'); +require_once(SM_PATH . 'functions/url_parser.php'); /* get some of these globals */ sqgetGlobalVar('username', $username, SQ_SESSION); diff --git a/src/printer_friendly_main.php b/src/printer_friendly_main.php index 7d877fe6..fa6de8f4 100644 --- a/src/printer_friendly_main.php +++ b/src/printer_friendly_main.php @@ -10,13 +10,9 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); +include('../include/init.php'); /* get those globals into gear */ global $color; diff --git a/src/printer_friendly_top.php b/src/printer_friendly_top.php index d068b8a8..837e58c9 100644 --- a/src/printer_friendly_top.php +++ b/src/printer_friendly_top.php @@ -13,13 +13,10 @@ */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +include('../include/init.php'); -/* SquirrelMail required files. */ -include_once(SM_PATH . 'include/validate.php'); displayHtmlHeader( _("Printer Friendly"), "