From 2d367c687f9813a45a3d2f1911036cfc0425fdd0 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Tue, 20 Nov 2001 20:08:28 +0000 Subject: [PATCH] Some fixup: - Operation foo_once step 2 (and final) - Create folders bugfix - None folder bugfix - Fixed some tabs, structs etc. - Added some (c) stuff - Removed some debug stuff This changes should result in a faster SM. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1782 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/addressbook.php | 5 +- functions/array.php | 3 - functions/auth.php | 49 ++-- functions/date.php | 4 - functions/db_prefs.php | 242 ++++++++-------- functions/display_messages.php | 4 - functions/gettext.php | 4 - functions/i18n.php | 12 +- functions/imap.php | 8 +- functions/imap_general.php | 4 - functions/imap_mailbox.php | 6 +- functions/imap_messages.php | 4 - functions/imap_search.php | 4 - functions/index.php | 20 +- functions/mailbox_display.php | 6 +- functions/mime.php | 4 - functions/page_header.php | 4 - functions/plugin.php | 137 ++++------ functions/prefs.php | 4 - functions/smtp.php | 4 - functions/strings.php | 3 - functions/tree.php | 15 +- functions/url_parser.php | 15 +- src/addressbook.php | 6 +- src/compose.php | 2 +- src/download.php | 2 +- src/draft_actions.php | 13 +- src/folders.php | 2 +- src/folders_rename_getname.php | 2 +- src/folders_subscribe.php | 2 +- src/help.php | 56 ++-- src/image.php | 17 +- src/index.php | 20 +- src/left_main.php | 486 ++++++++++++++++----------------- src/options.php | 2 +- src/search.php | 11 +- src/validate.php | 14 +- src/vcard.php | 3 + 38 files changed, 566 insertions(+), 633 deletions(-) diff --git a/functions/addressbook.php b/functions/addressbook.php index e1e13d8a..ca57150e 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -7,10 +7,7 @@ ** ** $Id$ **/ - - if (defined ('addressbook_php')) - return; - define ('addressbook_php', true); + // This is the path to the global site-wide addressbook. // It looks and feels just like a user's .abook file diff --git a/functions/array.php b/functions/array.php index e7d8237c..d17662bb 100644 --- a/functions/array.php +++ b/functions/array.php @@ -8,9 +8,6 @@ * $Id$ */ - if (defined ('array_php')) - return; - define ('array_php', true); function ary_sort($ary,$col, $dir = 1){ // The globals are used because USORT determines what is passed to comp2 diff --git a/functions/auth.php b/functions/auth.php index 8cddd002..7dd58a7a 100644 --- a/functions/auth.php +++ b/functions/auth.php @@ -1,33 +1,28 @@ \n"; - echo "

"; - echo "
"; - echo ""._("You must be logged in to access this page.")."
"; - echo ""._("Go to the login page")."\n"; - echo "
"; - echo "\n"; - exit; - } + function is_logged_in () { + global $squirrelmail_language; + + if ( session_is_registered('user_is_logged_in') ) + return; + + set_up_language($squirrelmail_language, true); + + echo "\n" . + '

echo "
'. + _("You must be logged in to access this page.").'
'. + ""._("Go to the login page")."\n". + "
\n"; + exit; + } ?> diff --git a/functions/date.php b/functions/date.php index e4c9b62a..d822396b 100644 --- a/functions/date.php +++ b/functions/date.php @@ -10,10 +10,6 @@ ** $Id$ **/ - if (defined ('date_php')) - return; - define ('date_php', true); - // corrects a time stamp to be the local time function getGMTSeconds($stamp, $gmt) { global $invert_time; diff --git a/functions/db_prefs.php b/functions/db_prefs.php index 6a606db7..e23f320f 100644 --- a/functions/db_prefs.php +++ b/functions/db_prefs.php @@ -28,155 +28,151 @@ ** $Id$ **/ - if (defined('prefs_php')) - return; - define('prefs_php', true); - require_once('DB.php'); class dbPrefs { var $DSN = 'mysql://user@host/database'; var $table = 'userprefs'; - + var $dbh = NULL; var $error = NULL; var $default = Array('chosen_theme' => '../themes/default_theme.php', - 'show_html_default' => '0'); - + 'show_html_default' => '0'); + function dbPrefs() { - $this->open(); + $this->open(); } - + function open() { - if(isset($this->dbh)) return true; - $dbh = DB::connect($this->DSN, true); - - if(DB::isError($dbh) || DB::isWarning($dbh)) { - $this->error = DB::errorMessage($dbh); - return false; - } - - $this->dbh = $dbh; - return true; + if(isset($this->dbh)) return true; + $dbh = DB::connect($this->DSN, true); + + if(DB::isError($dbh) || DB::isWarning($dbh)) { + $this->error = DB::errorMessage($dbh); + return false; + } + + $this->dbh = $dbh; + return true; } - + function failQuery($res = NULL) { - if($res == NULL) { - printf(_("Preference database error (%s). Exiting abnormally"), - $this->error); - } else { - printf(_("Preference database error (%s). Exiting abnormally"), - DB::errorMessage($res)); - } - exit; + if($res == NULL) { + printf(_("Preference database error (%s). Exiting abnormally"), + $this->error); + } else { + printf(_("Preference database error (%s). Exiting abnormally"), + DB::errorMessage($res)); + } + exit; } function getKey($user, $key) { - $this->open(); - $query = sprintf("SELECT prefval FROM %s ". - "WHERE user='%s' AND prefkey='%s'", - $this->table, - $this->dbh->quoteString($user), - $this->dbh->quoteString($key)); - - $res = $this->dbh->query($query); - if(DB::isError($res)) - $this->failQuery($res); - - if($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { - return $row['prefval']; - } else { - if(isset($this->default[$key])) { - return $this->default[$key]; - } else { - return ''; - } - } - - return ''; + $this->open(); + $query = sprintf("SELECT prefval FROM %s ". + "WHERE user='%s' AND prefkey='%s'", + $this->table, + $this->dbh->quoteString($user), + $this->dbh->quoteString($key)); + + $res = $this->dbh->query($query); + if(DB::isError($res)) + $this->failQuery($res); + + if($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { + return $row['prefval']; + } else { + if(isset($this->default[$key])) { + return $this->default[$key]; + } else { + return ''; + } + } + + return ''; } function deleteKey($user, $key) { - $this->open(); - $query = sprintf("DELETE FROM %s WHERE user='%s' AND prefkey='%s'", - $this->table, - $this->dbh->quoteString($user), - $this->dbh->quoteString($key)); + $this->open(); + $query = sprintf("DELETE FROM %s WHERE user='%s' AND prefkey='%s'", + $this->table, + $this->dbh->quoteString($user), + $this->dbh->quoteString($key)); - $res = $this->dbh->simpleQuery($query); - if(DB::isError($res)) - $this->failQuery($res); + $res = $this->dbh->simpleQuery($query); + if(DB::isError($res)) + $this->failQuery($res); - if(substr($key, 0, 9) == 'highlight') { - $this->renumberHighlightList($user); - } + if(substr($key, 0, 9) == 'highlight') { + $this->renumberHighlightList($user); + } - return true; + return true; } function setKey($user, $key, $value) { - $this->open(); - $query = sprintf("REPLACE INTO %s (user,prefkey,prefval) ". - "VALUES('%s','%s','%s')", - $this->table, - $this->dbh->quoteString($user), - $this->dbh->quoteString($key), - $this->dbh->quoteString($value)); - - $res = $this->dbh->simpleQuery($query); - if(DB::isError($res)) - $this->failQuery($res); - - return true; + $this->open(); + $query = sprintf("REPLACE INTO %s (user,prefkey,prefval) ". + "VALUES('%s','%s','%s')", + $this->table, + $this->dbh->quoteString($user), + $this->dbh->quoteString($key), + $this->dbh->quoteString($value)); + + $res = $this->dbh->simpleQuery($query); + if(DB::isError($res)) + $this->failQuery($res); + + return true; } - + /** ** When a highlight option is deleted the preferences module ** must renumber the list. This should be done somewhere else, - ** but it is not, so.... + ** but it is not, so.... **/ function renumberHighlightList($user) { - $this->open(); - $query = sprintf("SELECT * FROM %s WHERE user='%s' ". - "AND prefkey LIKE 'highlight%%' ORDER BY prefkey", - $this->table, - $this->dbh->quoteString($user)); - - $res = $this->dbh->query($query); - if(DB::isError($res)) - $this->failQuery($res); - - // Store old data in array - $rows = Array(); - while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) - $rows[] = $row; - - // Renumber keys of old data - $hilinum = 0; - for($i = 0; $i < count($rows) ; $i++) { - $oldkey = $rows[$i]['prefkey']; - $newkey = substr($oldkey, 0, 9) . $hilinum; - $hilinum++; - - if($oldkey != $newkey) { - $query = sprintf("UPDATE %s SET prefkey='%s' WHERE user='%s' ". - "AND prefkey='%s'", - $this->table, - $this->dbh->quoteString($newkey), - $this->dbh->quoteString($user), - $this->dbh->quoteString($oldkey)); - - $res = $this->dbh->simpleQuery($query); - if(DB::isError($res)) - $this->failQuery($res); - } - } - - return; + $this->open(); + $query = sprintf("SELECT * FROM %s WHERE user='%s' ". + "AND prefkey LIKE 'highlight%%' ORDER BY prefkey", + $this->table, + $this->dbh->quoteString($user)); + + $res = $this->dbh->query($query); + if(DB::isError($res)) + $this->failQuery($res); + + // Store old data in array + $rows = Array(); + while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) + $rows[] = $row; + + // Renumber keys of old data + $hilinum = 0; + for($i = 0; $i < count($rows) ; $i++) { + $oldkey = $rows[$i]['prefkey']; + $newkey = substr($oldkey, 0, 9) . $hilinum; + $hilinum++; + + if($oldkey != $newkey) { + $query = sprintf("UPDATE %s SET prefkey='%s' WHERE user='%s' ". + "AND prefkey='%s'", + $this->table, + $this->dbh->quoteString($newkey), + $this->dbh->quoteString($user), + $this->dbh->quoteString($oldkey)); + + $res = $this->dbh->simpleQuery($query); + if(DB::isError($res)) + $this->failQuery($res); + } + } + + return; } } // end class dbPrefs @@ -186,9 +182,9 @@ function getPref($data_dir, $username, $string, $default ) { $db = new dbPrefs; if(isset($db->error)) { - printf(_("Preference database error (%s). Exiting abnormally"), - $db->error); - exit; + printf( _("Preference database error (%s). Exiting abnormally"), + $db->error); + exit; } return $db->getKey($username, $string); @@ -202,12 +198,12 @@ $db->deleteKey($username, $string); return; } - + /** sets the pref, $string, to $set_to **/ function setPref($data_dir, $username, $string, $set_to) { $db = new dbPrefs; if(isset($db->error)) - $db->failQuery(); + $db->failQuery(); $db->setKey($username, $string, $set_to); return; @@ -217,14 +213,14 @@ function checkForPrefs($data_dir, $username) { $db = new dbPrefs; if(isset($db->error)) - $db->failQuery(); + $db->failQuery(); } /** Writes the Signature **/ function setSig($data_dir, $username, $string) { $db = new dbPrefs; - if(isset($db->error)) - $db->failQuery(); + if(isset($db->error)) + $db->failQuery(); $db->setKey($username, "___signature___", $string); return; @@ -234,7 +230,7 @@ function getSig($data_dir, $username) { $db = new dbPrefs; if(isset($db->error)) - $db->failQuery(); + $db->failQuery(); return $db->getKey($username, "___signature___"); } diff --git a/functions/display_messages.php b/functions/display_messages.php index 7c787d3b..06bc2fcb 100644 --- a/functions/display_messages.php +++ b/functions/display_messages.php @@ -8,10 +8,6 @@ ** $Id$ **/ - if (defined ('display_messages_php')) - return; - define ('display_messages_php', true); - function error_username_password_incorrect($color) { echo '
'; echo " "; diff --git a/functions/gettext.php b/functions/gettext.php index af05df9a..90da1db6 100644 --- a/functions/gettext.php +++ b/functions/gettext.php @@ -9,10 +9,6 @@ * Very special thanks to Konstantin Riabitsev for letting me use a * server that didn't already have gettext on it! */ - - if (defined('gettext_php')) - return; - define('gettext_php', true); global $gettext_php_domain, $gettext_php_dir, $gettext_php_loaded, $gettext_php_translateStrings, $gettext_php_loaded_language, diff --git a/functions/i18n.php b/functions/i18n.php index 992178de..22d83a8b 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -12,10 +12,6 @@ ** $Id$ **/ - if (defined ('i18n_php')) - return; - define ('i18n_php', true); - global $squirrelmail_language, $languages; if (! isset($squirrelmail_language)) { $squirrelmail_language = ''; } @@ -26,9 +22,9 @@ /* PLEASE DON'T TOUCH!!! * Correct locale name, which should be set by setlocale and/or putenv('LC_ALL='...) - * is 'cs_CZ' and NOT 'cs', this applies to all locale names, look into docs, if you - * don't believe me. Ondrej Sury, czech and slovak translator. - */ + * is 'cs_CZ' and NOT 'cs', this applies to all locale names, look into docs, if you + * don't believe me. Ondrej Sury, czech and slovak translator. + */ $languages['cs_CZ']['NAME'] = 'Czech'; $languages['cs_CZ']['CHARSET'] = 'iso-8859-2'; $languages['cs']['ALIAS'] = 'cs_CZ'; @@ -882,4 +878,4 @@ if ($my_charset) $default_charset=$my_charset; } -?> +?> \ No newline at end of file diff --git a/functions/imap.php b/functions/imap.php index fc65a681..384753f7 100644 --- a/functions/imap.php +++ b/functions/imap.php @@ -1,18 +1,16 @@ \ No newline at end of file diff --git a/functions/imap_general.php b/functions/imap_general.php index df3cf24d..16f19b0c 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -10,10 +10,6 @@ ** $Id$ **/ - if (defined ('imap_general_php')) - return; - define ('imap_general_php', true); - global $imap_general_debug; $imap_general_debug = false; diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index a0d3e7b6..35fe479e 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -40,9 +40,9 @@ function sqimap_mailbox_select ($imap_stream, $mailbox, $hide=true, $recent=false) { global $auto_expunge; - if( $mailbox == _("None") ) + if( $mailbox == 'None' ) return; - + fputs ($imap_stream, sqimap_session_id() . " SELECT \"$mailbox\"\r\n"); $read = sqimap_read_data($imap_stream, sqimap_session_id(), true, $response, $message); if ($recent) { @@ -66,7 +66,7 @@ ******************************************************************************/ function sqimap_mailbox_create ($imap_stream, $mailbox, $type) { global $delimiter; - if (strtolower($type) == "noselect") { + if (strtolower($type) == 'noselect') { $mailbox = $mailbox.$delimiter; } fputs ($imap_stream, sqimap_session_id() . " CREATE \"$mailbox\"\r\n"); diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 8cbf6ae2..8a1956c4 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -7,10 +7,6 @@ ** $Id$ **/ - if (defined ('imap_messages_php')) - return; - define ('imap_messages_php', true); - /****************************************************************************** ** Copies specified messages to specified folder ******************************************************************************/ diff --git a/functions/imap_search.php b/functions/imap_search.php index a546b4e6..e65126fc 100644 --- a/functions/imap_search.php +++ b/functions/imap_search.php @@ -3,10 +3,6 @@ ** IMAP SEARCH ROUTIES ** $Id$ *****************************************************************/ - - if (defined ('imap_search_php')) - return; - define ('imap_search_php', true); require_once('../functions/imap.php'); require_once('../functions/date.php'); diff --git a/functions/index.php b/functions/index.php index 9d9ed2ca..a7e26508 100644 --- a/functions/index.php +++ b/functions/index.php @@ -1,14 +1,14 @@ diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 7aa739e6..d0f62013 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -11,10 +11,6 @@ * $Id$ */ - if (defined('mailbox_display_php')) - return; - define('mailbox_display_php', true); - define('PG_SEL_MAX', 10); /* Default value for page_selector_max. */ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $start_msg, $where, $what) { @@ -39,7 +35,7 @@ $msg = $msgs[$key]; $senderName = htmlspecialchars(sqimap_find_displayable_name($msg['FROM'])); - if( $mailbox == _("None") ) { + if( $mailbox == 'None' ) { // $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); // sqimap_logout($imapConnection); diff --git a/functions/mime.php b/functions/mime.php index 74dd9258..750a48ae 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -7,10 +7,6 @@ ** $Id$ **/ - if (defined('mime_php')) - return; - define('mime_php', true); - require_once('../functions/imap.php'); require_once('../functions/attachment_common.php'); diff --git a/functions/page_header.php b/functions/page_header.php index f6ab137f..e664170e 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -7,10 +7,6 @@ ** $Id$ **/ - if (defined('page_header_php')) - return; - define('page_header_php', true); - // Always set up the language before calling these functions function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { diff --git a/functions/plugin.php b/functions/plugin.php index de8d4687..7d209e84 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -1,90 +1,63 @@ \n"; - include_once('../plugins/'.$name.'/setup.php'); - $function = 'squirrelmail_plugin_init_'.$name; - if (function_exists($function)) - { - if ($plugin_general_debug) - echo "plugin: ---- Executing $function to init plugin
\n"; - $function($plugin_general_debug); - } - elseif ($plugin_general_debug) - echo "plugin: -- Init function $function doesn't exist.
\n"; - } - elseif ($plugin_general_debug) - echo "plugin: Couldn't find $name/setup.php
\n"; - } - - // This function executes a hook - function do_hook ($name) { - global $squirrelmail_plugin_hooks; - $Data = func_get_args(); - if (isset($squirrelmail_plugin_hooks[$name]) && - is_array($squirrelmail_plugin_hooks[$name])) { - foreach ($squirrelmail_plugin_hooks[$name] as $id => $function) { - // Add something to set correct gettext domain for plugin + /** + ** plugin.php + ** + ** This file provides the framework for a plugin architecture. + ** + ** Plugins will eventually be a way to provide added functionality + ** without having to patch the SquirrelMail source code. Have some + ** patience, though, as the these funtions might change in the near + ** future. + ** + ** Documentation on how to write plugins might show up some time. + ** + ** $Id$ + **/ + + global $squirrelmail_plugin_hooks; + + $squirrelmail_plugin_hooks = array(); + + // This function adds a plugin + function use_plugin ($name) { + + if (file_exists('../plugins/'.$name.'/setup.php')) { + include_once('../plugins/'.$name.'/setup.php'); + $function = 'squirrelmail_plugin_init_'.$name; if (function_exists($function)) { - $function($Data); + $function(); + } + } + + } + + // This function executes a hook + function do_hook ($name) { + global $squirrelmail_plugin_hooks; + $Data = func_get_args(); + if (isset($squirrelmail_plugin_hooks[$name]) && + is_array($squirrelmail_plugin_hooks[$name])) { + foreach ($squirrelmail_plugin_hooks[$name] as $function) { + // Add something to set correct gettext domain for plugin + if (function_exists($function)) { + $function($Data); + } } - } - } - - // Variable-length argument lists have a slight problem when - // passing values by reference. Pity. This is a workaround. - return $Data; - } + } + + // Variable-length argument lists have a slight problem when + // passing values by reference. Pity. This is a workaround. + return $Data; + } - // On startup, register all plugins configured for use - if (isset($plugins) && is_array($plugins)) - foreach ($plugins as $id => $name) - { - if ($plugin_general_debug) - echo "plugin: Attempting load of plugin $name
\n"; - use_plugin($name); - } + /* -------------------- MAIN --------------------- */ - if ($plugin_general_debug) - { - echo "plugin: Hook list
\n"; - foreach ($squirrelmail_plugin_hooks as $Hook => $Plugins) - { - foreach ($Plugins as $Name => $Func) - { - echo "[$Hook][$Name] = $Func
\n"; - } - } - } + // On startup, register all plugins configured for use + if (isset($plugins) && is_array($plugins)) { + foreach ($plugins as $name) { + use_plugin($name); + } + } ?> \ No newline at end of file diff --git a/functions/prefs.php b/functions/prefs.php index 4f9d2a68..210e9e3c 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -7,10 +7,6 @@ ** $Id$ **/ - if (defined('prefs_php')) - return; - define('prefs_php', true); - global $prefs_are_cached, $prefs_cache; if (!session_is_registered('prefs_are_cached')) { $prefs_are_cached = false; diff --git a/functions/smtp.php b/functions/smtp.php index 92ab7f72..c2b43307 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -7,10 +7,6 @@ ** $Id$ **/ - if (defined('smtp_php')) - return; - define('smtp_php', true); - require_once('../functions/addressbook.php'); require_once('../functions/plugin.php'); diff --git a/functions/strings.php b/functions/strings.php index b3c2f763..4cd1388a 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -10,9 +10,6 @@ * $Id$ */ - if (defined('strings_php')) { return; } - define('strings_php', true); - /** * SquirrelMail version number -- DO NOT CHANGE */ diff --git a/functions/tree.php b/functions/tree.php index d218e29b..3e139252 100644 --- a/functions/tree.php +++ b/functions/tree.php @@ -1,10 +1,15 @@ $b['backend']) - return 1; - else if($a['backend'] < $b['backend']) - return -1; + return 1; + else if($a['backend'] < $b['backend']) + return -1; return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1; } diff --git a/src/compose.php b/src/compose.php index 5e1e910e..b2bae15f 100644 --- a/src/compose.php +++ b/src/compose.php @@ -453,7 +453,7 @@ $attachments[] = $newAttachment; } - if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None")) + if (!isset($mailbox) || $mailbox == '' || ($mailbox == 'None')) $mailbox = "INBOX"; if (isset($draft)) { diff --git a/src/download.php b/src/download.php index 1d73a47b..820ac207 100644 --- a/src/download.php +++ b/src/download.php @@ -25,7 +25,7 @@ global $where, $what, $charset; global $startMessage; - displayPageHeader($color, "None"); + displayPageHeader($color, 'None'); echo "
"; echo "
"; diff --git a/src/draft_actions.php b/src/draft_actions.php index dff29f79..76869cf2 100644 --- a/src/draft_actions.php +++ b/src/draft_actions.php @@ -1,5 +1,16 @@ diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php index c297f146..d86bd4fb 100644 --- a/src/folders_rename_getname.php +++ b/src/folders_rename_getname.php @@ -30,7 +30,7 @@ $old_parent = ""; } - displayPageHeader($color, "None"); + displayPageHeader($color, 'None'); echo "
"; echo "
"; echo _("Rename a folder"); diff --git a/src/folders_subscribe.php b/src/folders_subscribe.php index 6f387986..c000722c 100644 --- a/src/folders_subscribe.php +++ b/src/folders_subscribe.php @@ -37,7 +37,7 @@ sqimap_logout($imapConnection); /* - displayPageHeader($color, "None"); + displayPageHeader($color, 'None'); echo "


"; if ($method == "sub") { echo _("Subscribed Successfully!"); diff --git a/src/help.php b/src/help.php index 67aa1c0d..262d2979 100644 --- a/src/help.php +++ b/src/help.php @@ -16,20 +16,20 @@ require_once('../functions/array.php'); - displayPageHeader($color, "None"); - - $helpdir[0] = "basic.hlp"; - $helpdir[1] = "main_folder.hlp"; - $helpdir[2] = "read_mail.hlp"; - $helpdir[3] = "compose.hlp"; - $helpdir[4] = "addresses.hlp"; - $helpdir[5] = "folders.hlp"; - $helpdir[6] = "options.hlp"; - $helpdir[7] = "search.hlp"; - $helpdir[8] = "FAQ.hlp"; + displayPageHeader($color, 'None' ); + + $helpdir[0] = 'basic.hlp'; + $helpdir[1] = 'main_folder.hlp'; + $helpdir[2] = 'read_mail.hlp'; + $helpdir[3] = 'compose.hlp'; + $helpdir[4] = 'addresses.hlp'; + $helpdir[5] = 'folders.hlp'; + $helpdir[6] = 'options.hlp'; + $helpdir[7] = 'search.hlp'; + $helpdir[8] = 'FAQ.hlp'; /****************[ HELP FUNCTIONS ]********************/ - // parses through and gets the information from the different documents. + // parses through and gets the information from the different documents. // this returns one section at a time. You must keep track of the position // so that it knows where to start to look for the next section. @@ -42,18 +42,18 @@ $ary[0] = trim($doc[$n]); } if (trim(strtolower($doc[$n])) == "") { - $ary[1] = ""; + $ary[1] = ""; for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != ""); $n++) { $ary[1] .= $doc[$n]; } } if (trim(strtolower($doc[$n])) == "") { - $ary[2] = ""; + $ary[2] = ""; for ($n++;$n < count($doc) && (trim(strtolower($doc[$n])) != ""); $n++) { $ary[2] .= $doc[$n]; } } - } + } if (isset($ary)) { $ary[3] = $n; return $ary; @@ -62,14 +62,14 @@ $ary[1] = "ERROR: Help files are not in the right format!"; $ary[2] = "ERROR: Help files are not in the right format!"; return $ary; - } + } } } $ary[0] = "ERROR: Help files are not in the right format!"; $ary[1] = "ERROR: Help files are not in the right format!"; return $ary; } - + /**************[ END HELP FUNCTIONS ]******************/ ?> @@ -87,21 +87,21 @@ if ($HTTP_REFERER) { $ref = strtolower($HTTP_REFERER); if (strpos($ref, "src/compose")) - $context = "compose"; + $context = "compose"; else if (strpos($ref, "src/addr")) - $context = "address"; + $context = "address"; else if (strpos($ref, "src/folders")) - $context = "folders"; + $context = "folders"; else if (strpos($ref, "src/options")) - $context = "options"; + $context = "options"; else if (strpos($ref, "src/right_main")) - $context = "index"; + $context = "index"; else if (strpos($ref, "src/read_body")) - $context = "read"; + $context = "read"; else if (strpos($ref, "src/search")) - $context = "search"; + $context = "search"; } - + if (!$squirrelmail_language) $squirrelmail_language = "en"; @@ -122,7 +122,7 @@ echo "
"; exit; } - + if ($help_exists) { if (! isset($context)) $context = ''; @@ -170,7 +170,7 @@ echo "$chapter - $help_info[0]

\n"; if (isset($help_info[1])) echo "$help_info[1]\n"; - else + else echo "

$help_info[2]

\n"; $section = 0; @@ -187,7 +187,7 @@ echo "
" . _("Top") . "
\n"; } } - do_hook("help_bottom"); + do_hook("help_bottom"); ?>
 
diff --git a/src/image.php b/src/image.php index 8ae17e0a..b575dc14 100644 --- a/src/image.php +++ b/src/image.php @@ -1,11 +1,14 @@ diff --git a/src/left_main.php b/src/left_main.php index 0d48932e..af7d09ff 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -1,6 +1,7 @@ 0) { + $unseen_string = "($unseen)"; + $unseen_found = true; + } else if ($unseen_type == 2) { + $numMessages = sqimap_get_num_messages($imapConnection, $real_box); + $unseen_string = "($unseen/$numMessages)"; + $unseen_found = true; } } - /* Autocreate the drafts folder, if needed. */ - if (isset ($draft_folder) && $draft_folder != 'none') { - if (!sqimap_mailbox_exists ($imapConnection, $draft_folder)) { - sqimap_mailbox_create ($imapConnection, $draft_folder, ''); - } else if (! sqimap_mailbox_is_subscribed($imapConnection, $draft_folder)) { - sqimap_subscribe($imapConnection, $draft_folder); + $special_color = false; + if ($use_special_folder_color) { + if ((strtolower($real_box) == 'inbox') + || (($real_box == $trash_folder) && ($move_to_trash)) + || (($real_box == $sent_folder) && ($move_to_sent)) + || (($real_box == $draft_folder) && ($save_as_draft))) { + $special_color = true; } } - /* Let the world know that autocreation is complete! Hurrah! */ - $auto_create_done = true; - session_register('auto_create_done'); - } + /* Start off with a blank line. */ + $line = ''; - function formatMailboxName($imapConnection, $box_array) { - global $folder_prefix, $trash_folder, $sent_folder; - global $color, $move_to_sent, $move_to_trash; - global $unseen_notify, $unseen_type, $collapse_folders; - global $draft_folder, $save_as_draft; - global $use_special_folder_color; - - $real_box = $box_array['unformatted']; - $mailbox = str_replace(' ','',$box_array['formatted']); - $mailboxURL = urlencode($real_box); - - /* Strip down the mailbox name. */ - if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) { - $mailbox = $regs[2]; - } - - $unseen = 0; - - if (($unseen_notify == 2 && $real_box == 'INBOX') || - $unseen_notify == 3) { - $unseen = sqimap_unseen_messages($imapConnection, $real_box); - if ($unseen_type == 1 && $unseen > 0) { - $unseen_string = "($unseen)"; - $unseen_found = true; - } else if ($unseen_type == 2) { - $numMessages = sqimap_get_num_messages($imapConnection, $real_box); - $unseen_string = "($unseen/$numMessages)"; - $unseen_found = true; - } - } - - $special_color = false; - if ($use_special_folder_color) { - if ((strtolower($real_box) == 'inbox') - || (($real_box == $trash_folder) && ($move_to_trash)) - || (($real_box == $sent_folder) && ($move_to_sent)) - || (($real_box == $draft_folder) && ($save_as_draft))) { - $special_color = true; - } - } - - /* Start off with a blank line. */ - $line = ''; - - /* If there are unseen message, bold the line. */ - if ($unseen > 0) { $line .= ''; } - - /* Crate the link for this folder. */ - $line .= ""; - if ($special_color == true) - $line .= ""; - $line .= str_replace(' ',' ',$mailbox); - if ($special_color == true) - $line .= ""; - $line .= ''; - - /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $line .= ""; } - - /* Print unseen information. */ - if (isset($unseen_found) && $unseen_found) { - $line .= " $unseen_string"; - } - - if (($move_to_trash == true) && ($real_box == $trash_folder)) { - if (! isset($numMessages)) { - $numMessages = sqimap_get_num_messages($imapConnection, $real_box); - } - - if ($numMessages > 0) { - $urlMailbox = urlencode($real_box); - $line .= "\n\n"; - $line .= "  ("._("empty").")"; - $line .= "\n\n"; - } - } - - /* Return the final product. */ - return ($line); - } - - /**********************************/ - /* END OF FUNCTION - BACK TO MAIN */ - /**********************************/ + /* If there are unseen message, bold the line. */ + if ($unseen > 0) { $line .= ''; } - if (isset($left_refresh) && ($left_refresh != 'none') && ($left_refresh != '')) { - echo "\n"; - echo "\n"; - echo "\n"; - } - - echo "\n\n"; + /* Crate the link for this folder. */ + $line .= ""; + if ($special_color == true) + $line .= ""; + $line .= str_replace(' ',' ',$mailbox); + if ($special_color == true) + $line .= ""; + $line .= ''; - do_hook("left_main_before"); + /* If there are unseen message, close bolding. */ + if ($unseen > 0) { $line .= ""; } - $boxes = sqimap_mailbox_list($imapConnection); + /* Print unseen information. */ + if (isset($unseen_found) && $unseen_found) { + $line .= " $unseen_string"; + } - echo '
'; - echo _("Folders") . "
\n\n"; + if (($move_to_trash == true) && ($real_box == $trash_folder)) { + if (! isset($numMessages)) { + $numMessages = sqimap_get_num_messages($imapConnection, $real_box); + } - if ($date_format != 6) { - /* First, display the clock. */ - if ($hour_format == 1) { - if ($date_format == 4) { - $hr = "G:i:s"; - } else { - $hr = "G:i"; - } - } else { - if ($date_format == 4) { - $hr = "g:i:s a"; - } else { - $hr = "g:i a"; - } + if ($numMessages > 0) { + $urlMailbox = urlencode($real_box); + $line .= "\n\n" . + "  ("._("empty").")" . + "\n\n"; + } } - - switch( $date_format ) { - case 1: - $clk = date("m/d/y ".$hr, time()); - break; - case 2: - $clk = date("d/m/y ".$hr, time()); - break; - case 4: - case 5: - $clk = date($hr, time()); - break; - default: - $clk = date("D, ".$hr, time()); - } - $clk = str_replace(' ',' ',$clk); - - echo '
' . str_replace(' ',' ',_("Last Refresh")) - . ": $clk
"; + + /* Return the final product. */ + return ($line); } - /* Next, display the refresh button. */ - echo '('; - echo _("refresh folder list"); - echo ')

'; + /** + * Recursive function that computes the collapsed status and parent + * (or not parent) status of this box, and the visiblity and collapsed + * status and parent (or not parent) status for all children boxes. + */ + function compute_folder_children(&$parbox, $boxcount) { + global $boxes, $data_dir, $username, $collapse_folders; + $nextbox = $parbox + 1; - /* Lastly, display the folder list. */ - if (isset($collapse_folders) && $collapse_folders ) { - /* If directed, collapse or uncollapse a folder. */ - if (isset($fold)) { - setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED); - } else if (isset($unfold)) { - setPref($data_dir, $username, 'collapse_folder_' . $unfold, $SM_BOX_UNCOLLAPSED); + /* Retreive the name for the parent box. */ + $parbox_name = $boxes[$parbox]['unformatted']; + + /* 'Initialize' this parent box to childless. */ + $boxes[$parbox]['parent'] = false; + + /* Compute the collapse status for this box. */ + if( isset($collapse_folders) && $collapse_folders ) { + $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name); + $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); + } else { + $collapse = SM_BOX_UNCOLLAPSED; } - } + $boxes[$parbox]['collapse'] = $collapse; - /* Prepare do do out collapsedness and visibility computation. */ - $curbox = 0; - $boxcount = count($boxes); + /* Otherwise, get the name of the next box. */ + if (isset($boxes[$nextbox]['unformatted'])) + $nextbox_name = $boxes[$nextbox]['unformatted']; + else + $nextbox_name = ''; - /* Compute the collapsedness and visibility of each box. */ - while ($curbox < $boxcount) { - $boxes[$curbox]['visible'] = true; - compute_folder_children($curbox, $boxcount); - } - - for ($i = 0;$i < count($boxes); $i++) { - if ($boxes[$i]['visible'] == true) { - $mailbox = $boxes[$i]['formatted']; - $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1; + /* Compute any children boxes for this box. */ + while (($nextbox < $boxcount) && + (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) { - /* Create the prefix for the folder name and link. */ - $prefix = str_repeat(' ',$mblevel); - if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) { - $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)); - $prefix .= create_collapse_link($i) . ' '; - } else { - $prefix = str_replace(' ',' ',$prefix); - } - $line = "$prefix"; + /* Note that this 'parent' box has at least one child. */ + $boxes[$parbox]['parent'] = true; - /* Add the folder name and link. */ - if (in_array('noselect', $boxes[$i]['flags'])) { - $line .= ""; - if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { - $mailbox = str_replace(' ','',$mailbox); - $line .= str_replace(' ', ' ', $mailbox); - } - $line .= ''; + /* Compute the visiblity of this box. */ + if ($boxes[$parbox]['visible'] && + ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED)) { + $boxes[$nextbox]['visible'] = true; } else { - $line .= formatMailboxName($imapConnection, $boxes[$i]); + $boxes[$nextbox]['visible'] = false; } - /* Put the final touches on our folder line. */ - $line .= "
\n"; - - /* Output the line for this folder. */ - echo $line; + /* Compute the visibility of any child boxes. */ + compute_folder_children($nextbox, $boxcount); } + + /* Set the parent box to the current next box. */ + $parbox = $nextbox; } - sqimap_logout($imapConnection); - do_hook("left_main_after"); /** * Create the link for a parent folder that will allow that @@ -280,7 +179,7 @@ /* Return the finished product. */ return ($link); } - + /** * This simple function checks if a box is another box's parent. */ @@ -297,57 +196,150 @@ return ($parbox_name == $actual_parname); } - /** - * Recursive function that computes the collapsed status and parent - * (or not parent) status of this box, and the visiblity and collapsed - * status and parent (or not parent) status for all children boxes. - */ - function compute_folder_children(&$parbox, $boxcount) { - global $boxes, $data_dir, $username, $collapse_folders; - $nextbox = $parbox + 1; - /* Retreive the name for the parent box. */ - $parbox_name = $boxes[$parbox]['unformatted']; + /* -------------------- MAIN ------------------------ */ - /* 'Initialize' this parent box to childless. */ - $boxes[$parbox]['parent'] = false; + global $delimiter, $default_folder_prefix; - /* Compute the collapse status for this box. */ - if( isset($collapse_folders) && $collapse_folders ) { - $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name); - $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); - } else { - $collapse = SM_BOX_UNCOLLAPSED; + // open a connection on the imap port (143) + $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output + + + if (isset($left_refresh) && ($left_refresh != 'none') && ($left_refresh != '')) { + $xtra = "\n\n" . + "\n". + "\n"; + } else { + $xtra = ''; + } + + displayHtmlHeader( 'SquirrelMail', $xtra ); + + /* If requested and not yet complete, attempt to autocreate folders. */ + if ($auto_create_special && !isset($auto_create_done)) { + $autocreate = array( $sent_folder, + $trash_folder, + $draft_folder ); + foreach( $autocreate as $folder ) { + if ($folder != '' && $folder != 'none') { + if ( !sqimap_mailbox_exists($imapConnection, $folder)) { + sqimap_mailbox_create($imapConnection, $default_folder_prefix.$folder, ''); + } elseif ( !sqimap_mailbox_is_subscribed($imapConnection, $folder)) { + sqimap_subscribe($imapConnection, $folder); + } + } } - $boxes[$parbox]['collapse'] = $collapse; - /* Otherwise, get the name of the next box. */ - if (isset($boxes[$nextbox]['unformatted'])) - $nextbox_name = $boxes[$nextbox]['unformatted']; - else - $nextbox_name = ''; + /* Let the world know that autocreation is complete! Hurrah! */ + $auto_create_done = true; + session_register('auto_create_done'); + } - /* Compute any children boxes for this box. */ - while (($nextbox < $boxcount) && - (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) { + echo "\n\n"; - /* Note that this 'parent' box has at least one child. */ - $boxes[$parbox]['parent'] = true; + do_hook('left_main_before'); - /* Compute the visiblity of this box. */ - if ($boxes[$parbox]['visible'] && - ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED)) { - $boxes[$nextbox]['visible'] = true; + $boxes = sqimap_mailbox_list($imapConnection); + + echo '
'. _("Folders") . "
\n\n"; + + if ($date_format != 6) { + /* First, display the clock. */ + if ($hour_format == 1) { + $hr = 'G:i'; + if ($date_format == 4) { + $hr .= ':s'; + } + } else { + if ($date_format == 4) { + $hr = 'g:i:s a'; } else { - $boxes[$nextbox]['visible'] = false; + $hr = 'g:i a'; } + } - /* Compute the visibility of any child boxes. */ - compute_folder_children($nextbox, $boxcount); + switch( $date_format ) { + case 1: + $clk = date('m/d/y '.$hr, time()); + break; + case 2: + $clk = date('d/m/y '.$hr, time()); + break; + case 4: + case 5: + $clk = date($hr, time()); + break; + default: + $clk = date('D, '.$hr, time()); } + $clk = str_replace(' ',' ',$clk); - /* Set the parent box to the current next box. */ - $parbox = $nextbox; + echo '
' . str_replace(' ',' ',_("Last Refresh")) . + ": $clk
"; } + + /* Next, display the refresh button. */ + echo '('. + _("refresh folder list") . ')

'; + + /* Lastly, display the folder list. */ + if ( $collapse_folders ) { + /* If directed, collapse or uncollapse a folder. */ + if (isset($fold)) { + setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED); + } else if (isset($unfold)) { + setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED); + } + } + + /* Prepare do do out collapsedness and visibility computation. */ + $curbox = 0; + $boxcount = count($boxes); + + /* Compute the collapsedness and visibility of each box. */ + while ($curbox < $boxcount) { + $boxes[$curbox]['visible'] = TRUE; + compute_folder_children($curbox, $boxcount); + } + + for ($i = 0;$i < count($boxes); $i++) { + if ( $boxes[$i]['visible'] ) { + $mailbox = $boxes[$i]['formatted']; + $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1; + + /* Create the prefix for the folder name and link. */ + $prefix = str_repeat(' ',$mblevel); + if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) { + $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)). + create_collapse_link($i) . ' '; + } else { + $prefix = str_replace(' ',' ',$prefix); + } + $line = "$prefix"; + + /* Add the folder name and link. */ + if (in_array('noselect', $boxes[$i]['flags'])) { + $line .= ""; + if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { + $mailbox = str_replace(' ','',$mailbox); + $line .= str_replace(' ', ' ', $mailbox); + } + $line .= ''; + } else { + $line .= formatMailboxName($imapConnection, $boxes[$i]); + } + + /* Put the final touches on our folder line. */ + $line .= "
\n"; + + /* Output the line for this folder. */ + echo $line; + } + } + + sqimap_logout($imapConnection); + do_hook('left_main_after'); + echo "\n"; -?> + +?> \ No newline at end of file diff --git a/src/options.php b/src/options.php index 4594d5b7..91503a70 100644 --- a/src/options.php +++ b/src/options.php @@ -34,7 +34,7 @@ if (isset($language)) { /*** Build the resultant page. ***/ /*********************************/ -displayPageHeader($color, _("None")); +displayPageHeader($color, 'None'); define('SMOPT_MODE_DISPLAY', 'display'); define('SMOPT_MODE_SUBMIT', 'submit'); diff --git a/src/search.php b/src/search.php index e090e887..47c96209 100644 --- a/src/search.php +++ b/src/search.php @@ -1,6 +1,15 @@