Changeset 325 in subversion


Ignore:
Timestamp:
Aug 25, 2006 7:51:11 AM (7 years ago)
Author:
thomasb
Message:

Finalized new message parsing. Attention: changes in database schema

Location:
trunk/roundcubemail
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r323 r325  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42006/08/25 (thomasb) 
     5---------- 
     6- Fixed folder renaming: unsubscribe before rename (Bug #1483920) 
     7- Finalized new message parsing (+ chaching) 
     8- Updated SQL scripts and UPGRADING instructions 
     9 
    310 
    4112006/08/23 (thomasb) 
     
    1724---------- 
    1825- Re-built message parsing (Bug #1327068) 
     26  Now based on the message structure delivered by the IMAP server. 
    1927- Fixed some XSS and SQL injection issues 
    2028 
  • trunk/roundcubemail/INSTALL

    r297 r325  
    4141 
    4242# mysql 
    43 > CREATE DATABASE 'roundcubemail'; 
     43> CREATE DATABASE roundcubemail; 
    4444> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost 
    4545        IDENTIFIED BY 'password'; 
     
    5454 
    5555# mysql 
    56 > CREATE DATABASE 'roundcubemail' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 
     56> CREATE DATABASE roundcubemail DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 
    5757> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost 
    5858        IDENTIFIED BY 'password'; 
  • trunk/roundcubemail/SQL/mysql.initial.sql

    r313 r325  
    11-- RoundCube Webmail initial database structure 
    2 -- Version 0.1beta2 
     2-- Version 0.1-beta2 
    33--  
    44 
     
    117117  `size` int(11) unsigned NOT NULL default '0', 
    118118  `headers` text NOT NULL, 
    119   `body` longtext, 
     119  `structure` text, 
    120120  PRIMARY KEY  (`message_id`), 
    121121  KEY `user_id` (`user_id`), 
    122   KEY `cache_key` (`cache_key`), 
    123122  KEY `idx` (`idx`), 
    124   KEY `uid` (`uid`) 
     123  KEY `uid` (`uid`), 
     124  UNIQUE `uniqueness` (`cache_key`, `uid`) 
    125125); 
    126126 
  • trunk/roundcubemail/SQL/mysql.update.sql

    r313 r325  
    11-- RoundCube Webmail update script for MySQL databases 
    2 -- Updates from version 0.1-20051007 
     2-- Updates from version 0.1-beta and 0.1-beta2 
    33 
     4ALTER TABLE `messages` 
     5  DROP `body`, 
     6  DROP INDEX `cache_key`, 
     7  ADD `structure` TEXT, 
     8  ADD UNIQUE `uniqueness` (`cache_key`, `uid`); 
    49 
    5 ALTER TABLE `session` ADD `ip` VARCHAR(15) NOT NULL AFTER changed; 
    6 ALTER TABLE `users` ADD `alias` VARCHAR(128) NOT NULL AFTER mail_host; 
    7  
    8  
    9  
    10 -- RoundCube Webmail update script for MySQL databases 
    11 -- Updates from version 0.1-20051021 
    12  
    13 ALTER TABLE `session` CHANGE `sess_id` `sess_id` VARCHAR(40) NOT NULL; 
    14  
    15 ALTER TABLE `contacts` CHANGE `del` `del` TINYINT(1) NOT NULL; 
    16 ALTER TABLE `contacts` ADD `changed` DATETIME NOT NULL AFTER `user_id`; 
    17  
    18 UPDATE `contacts`  SET `del`=0 WHERE `del`=1; 
    19 UPDATE `contacts`  SET `del`=1 WHERE `del`=2; 
    20  
    21 ALTER TABLE `identities` CHANGE `default` `standard` TINYINT(1) NOT NULL; 
    22 ALTER TABLE `identities` CHANGE `del` `del` TINYINT(1) NOT NULL; 
    23  
    24 UPDATE `identities`  SET `del`=0 WHERE `del`=1; 
    25 UPDATE `identities`  SET `del`=1 WHERE `del`=2; 
    26 UPDATE `identities`  SET `standard`=0 WHERE `standard`=1; 
    27 UPDATE `identities`  SET `standard`=1 WHERE `standard`=2; 
    28  
    29 CREATE TABLE `messages` ( 
    30   `message_id` int(11) unsigned NOT NULL auto_increment, 
    31   `user_id` int(11) unsigned NOT NULL default '0', 
    32   `del` tinyint(1) NOT NULL default '0', 
    33   `cache_key` varchar(128) NOT NULL default '', 
    34   `created` datetime NOT NULL default '0000-00-00 00:00:00', 
    35   `idx` int(11) unsigned NOT NULL default '0', 
    36   `uid` int(11) unsigned NOT NULL default '0', 
    37   `subject` varchar(255) NOT NULL default '', 
    38   `from` varchar(255) NOT NULL default '', 
    39   `to` varchar(255) NOT NULL default '', 
    40   `cc` varchar(255) NOT NULL default '', 
    41   `date` datetime NOT NULL default '0000-00-00 00:00:00', 
    42   `size` int(11) unsigned NOT NULL default '0', 
    43   `headers` text NOT NULL, 
    44   `body` longtext, 
    45   PRIMARY KEY  (`message_id`), 
    46   KEY `user_id` (`user_id`), 
    47   KEY `cache_key` (`cache_key`), 
    48   KEY `idx` (`idx`), 
    49   KEY `uid` (`uid`) 
    50 ) TYPE=MyISAM; 
    51  
    52  
    53  
    54 -- RoundCube Webmail update script for MySQL databases 
    55 -- Updates from version 0.1-20051216 
    56  
    57 ALTER TABLE `messages` ADD `created` DATETIME NOT NULL AFTER `cache_key` ; 
  • trunk/roundcubemail/SQL/mysql5.initial.sql

    r297 r325  
    11-- RoundCube Webmail initial database structure 
    2 -- Version 0.1beta2 
     2-- Version 0.1-beta2 
    33--  
    44 
     
    1717 `vars` text NOT NULL, 
    1818 PRIMARY KEY(`sess_id`) 
    19 ) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; 
     19) TYPE=MYISAM CHARACTER SET ascii COLLATE ascii_general_ci; 
    2020 
    2121 
     
    3232 `preferences` text NOT NULL, 
    3333 PRIMARY KEY(`user_id`) 
    34 ) TYPE=MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; 
     34) TYPE=MYISAM CHARACTER SET ascii COLLATE ascii_general_ci; 
    3535 
    3636 
     
    3939CREATE TABLE `messages` ( 
    4040 `message_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 
     41 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0', 
    4142 `del` tinyint(1) NOT NULL DEFAULT '0', 
    42  `cache_key` varchar(128) NOT NULL, 
     43 `cache_key` varchar(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL, 
    4344 `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
    4445 `idx` int(11) UNSIGNED NOT NULL DEFAULT '0', 
     
    5152 `size` int(11) UNSIGNED NOT NULL DEFAULT '0', 
    5253 `headers` text NOT NULL, 
    53  `body` longtext, 
    54  `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0', 
     54 `structure` text, 
    5555 PRIMARY KEY(`message_id`), 
    56  INDEX `cache_key`(`cache_key`), 
    5756 INDEX `idx`(`idx`), 
    5857 INDEX `uid`(`uid`), 
     58 UNIQUE `uniqueness` (`cache_key`, `uid`), 
    5959 CONSTRAINT `User_ID_FK_messages` FOREIGN KEY (`user_id`) 
    6060   REFERENCES `users`(`user_id`) 
     
    6868CREATE TABLE `cache` ( 
    6969 `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, 
    70  `session_id` varchar(40), 
    71  `cache_key` varchar(128) NOT NULL, 
     70 `session_id` varchar(40) CHARACTER SET ascii COLLATE ascii_general_ci, 
     71 `cache_key` varchar(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL, 
    7272 `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 
    7373 `data` longtext NOT NULL, 
  • trunk/roundcubemail/SQL/postgres.initial.sql

    r140 r325  
    164164    size integer DEFAULT 0 NOT NULL, 
    165165    headers text NOT NULL, 
    166     body text 
     166    structure text 
    167167); 
    168168 
     169ALTER TABLE "messages" ADD UNIQUE (cache_key, uid); 
  • trunk/roundcubemail/SQL/sqlite.initial.sql

    r131 r325  
    11-- RoundCube Webmail initial database structure 
    2 -- Version 0.1a 
     2-- Version 0.1-beta2 
    33--  
    44 
     
    119119  size integer NOT NULL default '0', 
    120120  headers text NOT NULL, 
    121   body text 
     121  structure text 
    122122); 
    123123 
  • trunk/roundcubemail/UPGRADING

    r297 r325  
    66 
    77 
     8from version 1.0-beta2 
     9---------------------------------------- 
     10* replace index.php 
     11* replace all files in folder /program/ 
     12* replace all files in folder /skins/default/ 
     13* run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
     14 
     15 
     16 
     17form version 0.1-beta 
     18---------------------------------------- 
     19* replace index.php 
     20* replace all files in folder /program/ 
     21* replace all files in folder /skins/default/ 
     22* run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
     23* add these line to /config/db.inc.php 
     24  $rcmail_config['db_persistent'] = TRUE; 
     25* add these lines to /config/main.inc.php 
     26  $rcmail_config['drafts_mbox'] = 'Drafts'; 
     27  $rcmail_config['junk_mbox'] = 'Junk'; 
     28  $rcmail_config['product_name'] = 'RoundCube Webmail'; 
     29  $rcmail_config['read_when_deleted'] = TRUE; 
     30  $rcmail_config['enable_spellcheck'] = TRUE; 
     31  $rcmail_config['protect_default_folders'] = TRUE; 
     32* replace the following line from /config/main.inc.php 
     33   @include($_SERVER['HTTP_HOST'].'.inc.php'); 
     34  with  
     35   $rcmail_config['include_host_config'] = TRUE; 
     36 
     37 
     38 
     39from version 0.1-20051021 
     40---------------------------------------- 
     41* replace index.php 
     42* replace all files in folder /program/ 
     43* replace all files in folder /skins/default/ 
     44* run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
     45* add these lines to /config/main.inc.php 
     46  $rcmail_config['skip_deleted'] = FALSE; 
     47  $rcmail_config['message_sort_col'] = 'date'; 
     48  $rcmail_config['message_sort_order'] = 'DESC'; 
     49  $rcmail_config['log_dir'] = 'logs/'; 
     50  $rcmail_config['temp_dir'] = 'temp/'; 
     51  $rcmail_config['message_cache_lifetime'] = '10d'; 
     52  $rcmail_config['drafts_mbox'] = 'Drafts'; 
     53  $rcmail_config['product_name'] = 'RoundCube Webmail'; 
     54  $rcmail_config['read_when_deleted'] = TRUE; 
     55  $rcmail_config['enable_spellcheck'] = TRUE; 
     56* add these lines to /config/db.inc.php 
     57  $rcmail_config['db_max_length'] = 512000; 
     58  $rcmail_config['db_sequence_user_ids'] = 'user_ids'; 
     59  $rcmail_config['db_sequence_identity_ids'] = 'identity_ids'; 
     60  $rcmail_config['db_sequence_contact_ids'] = 'contact_ids'; 
     61  $rcmail_config['db_sequence_cache_ids'] = 'cache_ids'; 
     62  $rcmail_config['db_sequence_message_ids'] = 'message_ids'; 
     63  $rcmail_config['db_persistent'] = TRUE; 
     64 
     65 
     66 
     67from version 0.1-20051007 
     68---------------------------------------- 
     69* replace index.php 
     70* replace all files in folder /program/ 
     71* replace all files in folder /skins/default/ 
     72* run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
     73* add these lines to /config/main.inc.php 
     74  $rcmail_config['smtp_auth_type'] = '';  // if you need to specify an auth method for SMTP 
     75  $rcmail_config['session_lifetime'] = 20;  // to specify the session lifetime in minutes 
     76  $rcmail_config['skip_deleted'] = FALSE; 
     77  $rcmail_config['message_sort_col'] = 'date'; 
     78  $rcmail_config['message_sort_order'] = 'DESC'; 
     79  $rcmail_config['log_dir'] = 'logs/'; 
     80  $rcmail_config['temp_dir'] = 'temp/'; 
     81  $rcmail_config['message_cache_lifetime'] = '10d'; 
     82  $rcmail_config['drafts_mbox'] = 'Drafts'; 
     83  $rcmail_config['product_name'] = 'RoundCube Webmail'; 
     84  $rcmail_config['read_when_deleted'] = TRUE; 
     85  $rcmail_config['enable_spellcheck'] = TRUE; 
     86* add these lines to /config/db.inc.php 
     87  $rcmail_config['db_max_length'] = 512000;   
     88  $rcmail_config['db_sequence_user_ids'] = 'user_ids'; 
     89  $rcmail_config['db_sequence_identity_ids'] = 'identity_ids'; 
     90  $rcmail_config['db_sequence_contact_ids'] = 'contact_ids'; 
     91  $rcmail_config['db_sequence_cache_ids'] = 'cache_ids'; 
     92  $rcmail_config['db_sequence_message_ids'] = 'message_ids';   
     93  $rcmail_config['db_persistent'] = TRUE; 
     94 
     95 
     96 
     97from version 0.1-20050820 
     98---------------------------------------- 
     99* replace index.php 
     100* replace all files in folder /program/ 
     101* replace all files in folder /skins/default/ 
     102* run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
     103* add these line to /config/main.inc.php 
     104  $rcmail_config['prettydate'] = TRUE; 
     105  $rcmail_config['smtp_port'] = 25; 
     106  $rcmail_config['default_port'] = 143; 
     107  $rcmail_config['session_lifetime'] = 20; 
     108  $rcmail_config['skip_deleted'] = FALSE; 
     109  $rcmail_config['message_sort_col'] = 'date'; 
     110  $rcmail_config['message_sort_order'] = 'DESC'; 
     111  $rcmail_config['log_dir'] = 'logs/'; 
     112  $rcmail_config['temp_dir'] = 'temp/'; 
     113  $rcmail_config['message_cache_lifetime'] = '10d'; 
     114* replace database properties (db_type, db_host, db_user, db_pass, $d_name) 
     115  in /config/db.inc.php with the following line: 
     116  $rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail'; 
     117* add these lines to /config/db.inc.php 
     118  $rcmail_config['db_max_length'] = 512000; 
     119 
     120 
     121 
    8122from versions 0.1-alpha and 0.1-20050811 
    9123---------------------------------------- 
    10 - replace index.php 
    11 - replace all files in folder /program/ 
    12 - replace all files in folder /skins/default/ 
    13 - run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
    14 - add these line to /config/main.inc.php 
     124* replace index.php 
     125* replace all files in folder /program/ 
     126* replace all files in folder /skins/default/ 
     127* run all commands in SQL/*.update-0.1a.sql or re-initalize database with *.initial.sql 
     128* add these line to /config/main.inc.php 
    15129  $rcmail_config['trash_mbox'] = 'Trash'; 
    16130  $rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash'); 
     
    26140  $rcmail_config['temp_dir'] = 'temp/'; 
    27141  $rcmail_config['message_cache_lifetime'] = '10d'; 
    28 - replace database properties (db_type, db_host, db_user, db_pass, $d_name) 
     142* replace database properties (db_type, db_host, db_user, db_pass, $d_name) 
    29143  in /config/db.inc.php with the following line: 
    30144  $rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail'; 
    31 - add these lines to /config/db.inc.php 
     145* add these lines to /config/db.inc.php 
    32146  $rcmail_config['db_max_length'] = 512000; 
    33147 
    34  
    35 from version 0.1-20050820 
    36 ---------------------------------------- 
    37 - replace index.php 
    38 - replace all files in folder /program/ 
    39 - replace all files in folder /skins/default/ 
    40 - run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
    41 - add these line to /config/main.inc.php 
    42   $rcmail_config['prettydate'] = TRUE; 
    43   $rcmail_config['smtp_port'] = 25; 
    44   $rcmail_config['default_port'] = 143; 
    45   $rcmail_config['session_lifetime'] = 20; 
    46   $rcmail_config['skip_deleted'] = FALSE; 
    47   $rcmail_config['message_sort_col'] = 'date'; 
    48   $rcmail_config['message_sort_order'] = 'DESC'; 
    49   $rcmail_config['log_dir'] = 'logs/'; 
    50   $rcmail_config['temp_dir'] = 'temp/'; 
    51   $rcmail_config['message_cache_lifetime'] = '10d'; 
    52 - replace database properties (db_type, db_host, db_user, db_pass, $d_name) 
    53   in /config/db.inc.php with the following line: 
    54   $rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail'; 
    55 - add these lines to /config/db.inc.php 
    56   $rcmail_config['db_max_length'] = 512000; 
    57  
    58  
    59 from version 0.1-20051007 
    60 ---------------------------------------- 
    61 - replace index.php 
    62 - replace all files in folder /program/ 
    63 - replace all files in folder /skins/default/ 
    64 - run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
    65 - add these lines to /config/main.inc.php 
    66   $rcmail_config['smtp_auth_type'] = '';  // if you need to specify an auth method for SMTP 
    67   $rcmail_config['session_lifetime'] = 20;  // to specify the session lifetime in minutes 
    68   $rcmail_config['skip_deleted'] = FALSE; 
    69   $rcmail_config['message_sort_col'] = 'date'; 
    70   $rcmail_config['message_sort_order'] = 'DESC'; 
    71   $rcmail_config['log_dir'] = 'logs/'; 
    72   $rcmail_config['temp_dir'] = 'temp/'; 
    73   $rcmail_config['message_cache_lifetime'] = '10d'; 
    74   $rcmail_config['drafts_mbox'] = 'Drafts'; 
    75   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    76   $rcmail_config['read_when_deleted'] = TRUE; 
    77   $rcmail_config['enable_spellcheck'] = TRUE; 
    78 - add these lines to /config/db.inc.php 
    79   $rcmail_config['db_max_length'] = 512000;   
    80   $rcmail_config['db_sequence_user_ids'] = 'user_ids'; 
    81   $rcmail_config['db_sequence_identity_ids'] = 'identity_ids'; 
    82   $rcmail_config['db_sequence_contact_ids'] = 'contact_ids'; 
    83   $rcmail_config['db_sequence_cache_ids'] = 'cache_ids'; 
    84   $rcmail_config['db_sequence_message_ids'] = 'message_ids';   
    85   $rcmail_config['db_persistent'] = TRUE; 
    86  
    87 from version 0.1-20051021 
    88 ---------------------------------------- 
    89 - replace index.php 
    90 - replace all files in folder /program/ 
    91 - replace all files in folder /skins/default/ 
    92 - run all commands in SQL/*.update.sql or re-initalize database with *.initial.sql 
    93 - add these lines to /config/main.inc.php 
    94   $rcmail_config['skip_deleted'] = FALSE; 
    95   $rcmail_config['message_sort_col'] = 'date'; 
    96   $rcmail_config['message_sort_order'] = 'DESC'; 
    97   $rcmail_config['log_dir'] = 'logs/'; 
    98   $rcmail_config['temp_dir'] = 'temp/'; 
    99   $rcmail_config['message_cache_lifetime'] = '10d'; 
    100   $rcmail_config['drafts_mbox'] = 'Drafts'; 
    101   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    102   $rcmail_config['read_when_deleted'] = TRUE; 
    103   $rcmail_config['enable_spellcheck'] = TRUE; 
    104 - add these lines to /config/db.inc.php 
    105   $rcmail_config['db_max_length'] = 512000; 
    106   $rcmail_config['db_sequence_user_ids'] = 'user_ids'; 
    107   $rcmail_config['db_sequence_identity_ids'] = 'identity_ids'; 
    108   $rcmail_config['db_sequence_contact_ids'] = 'contact_ids'; 
    109   $rcmail_config['db_sequence_cache_ids'] = 'cache_ids'; 
    110   $rcmail_config['db_sequence_message_ids'] = 'message_ids'; 
    111   $rcmail_config['db_persistent'] = TRUE; 
    112    
    113    
    114 form version 0.1-beta 
    115 ---------------------------------------- 
    116 - replace index.php 
    117 - replace all files in folder /program/ 
    118 - replace all files in folder /skins/default/ 
    119 - add these line to /config/db.inc.php 
    120   $rcmail_config['db_persistent'] = TRUE; 
    121 - add these lines to /config/main.inc.php 
    122   $rcmail_config['drafts_mbox'] = 'Drafts'; 
    123   $rcmail_config['junk_mbox'] = 'Junk'; 
    124   $rcmail_config['product_name'] = 'RoundCube Webmail'; 
    125   $rcmail_config['read_when_deleted'] = TRUE; 
    126   $rcmail_config['enable_spellcheck'] = TRUE; 
    127   $rcmail_config['protect_default_folders'] = TRUE; 
    128 - replace the following line from /config/main.inc.php 
    129    @include($_SERVER['HTTP_HOST'].'.inc.php'); 
    130   with  
    131    $rcmail_config['include_host_config'] = TRUE; 
    132    
    133    
  • trunk/roundcubemail/program/include/rcube_imap.inc

    r321 r325  
    3636 * @package    RoundCube Webmail 
    3737 * @author     Thomas Bruederli <roundcube@gmail.com> 
    38  * @version    1.31 
     38 * @version    1.34 
    3939 * @link       http://ilohamail.org 
    4040 */ 
     
    133133      } 
    134134 
    135     // get account namespace 
     135    // get server properties 
    136136    if ($this->conn) 
    137137      { 
    138138      $this->_parse_capability($this->conn->capability); 
    139       iil_C_NameSpace($this->conn); 
    140139       
    141140      if (!empty($this->conn->delimiter)) 
     
    884883 
    885884    // get cached headers 
    886     if ($uid && ($headers = $this->get_cached_message($mailbox.'.msg', $uid))) 
     885    if ($uid && ($headers = &$this->get_cached_message($mailbox.'.msg', $uid))) 
    887886      return $headers; 
    888887 
    889     $msg_id = $is_uid ? $this->_uid2id($id) : $id; 
    890     $headers = iil_C_FetchHeader($this->conn, $mailbox, $msg_id); 
     888    $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, $is_uid); 
    891889 
    892890    // write headers cache 
    893891    if ($headers) 
    894       $this->add_message_cache($mailbox.'.msg', $msg_id, $headers); 
     892      { 
     893      if ($is_uid) 
     894        $this->uid_id_map[$mbox_name][$uid] = $headers->id; 
     895 
     896      $this->add_message_cache($mailbox.'.msg', $headers->id, $headers); 
     897      } 
    895898 
    896899    return $headers; 
     
    907910  function &get_structure($uid) 
    908911    { 
     912    $cache_key = $this->mailbox.'.msg'; 
     913    $headers = &$this->get_cached_message($cache_key, $uid, true); 
     914 
     915    // return cached message structure 
     916    if (is_object($headers) && is_object($headers->structure)) 
     917      return $headers->structure; 
     918     
     919    // resolve message sequence number 
    909920    if (!($msg_id = $this->_uid2id($uid))) 
    910921      return FALSE; 
     
    930941        list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype); 
    931942        } 
     943 
     944      // write structure to cache 
     945      if ($this->caching_enabled) 
     946        $this->add_message_cache($cache_key, $msg_id, $headers, $struct); 
    932947      } 
    933948         
     
    11101125 
    11111126      // convert charset (if text or message part) 
    1112       if (!empty($o_part->charset) && ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') && !stristr($body, 'charset=')) 
     1127      if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') 
     1128        { 
     1129        // assume ISO-8859-1 if no charset specified 
     1130        if (empty($o_part->charset)) 
     1131          $o_part->charset = 'ISO-8859-1'; 
     1132 
    11131133        $body = rcube_charset_convert($body, $o_part->charset); 
     1134        } 
    11141135      } 
    11151136 
     
    15341555    $mailbox = $this->_mod_mailbox($mbox_name); 
    15351556    $abs_name = $this->_mod_mailbox($name); 
     1557     
     1558    // check if mailbox is subscribed 
     1559    $a_subscribed = $this->_list_mailboxes(); 
     1560    $subscribed = in_array($mailbox, $a_subscribed); 
     1561     
     1562    // unsubscribe folder 
     1563    if ($subscribed) 
     1564      iil_C_UnSubscribe($this->conn, $mailbox); 
    15361565 
    15371566    if (strlen($abs_name)) 
     
    15421571      { 
    15431572      $this->clear_message_cache($mailbox.'.msg'); 
    1544       $this->clear_cache('mailboxes'); 
    1545       } 
    1546        
     1573      $this->clear_cache('mailboxes');       
     1574      } 
     1575 
    15471576    // try to subscribe it 
    1548     $this->subscribe($name); 
     1577    if ($result && $subscribed) 
     1578      iil_C_Subscribe($this->conn, $abs_name); 
    15491579 
    15501580    return $result ? $name : FALSE; 
     
    18431873 
    18441874 
    1845   function &get_cached_message($key, $uid, $body=FALSE) 
     1875  function &get_cached_message($key, $uid, $struct=false) 
    18461876    { 
    18471877    if (!$this->caching_enabled) 
     
    18491879 
    18501880    $internal_key = '__single_msg'; 
    1851     if ($this->caching_enabled && (!isset($this->cache[$internal_key][$uid]) || $body)) 
    1852       { 
    1853       $sql_select = "idx, uid, headers"; 
    1854       if ($body) 
    1855         $sql_select .= ", body"; 
    1856        
     1881    if ($this->caching_enabled && (!isset($this->cache[$internal_key][$uid]) || 
     1882        ($struct && empty($this->cache[$internal_key][$uid]->structure)))) 
     1883      { 
     1884      $sql_select = "idx, uid, headers" . ($struct ? ", structure" : ''); 
    18571885      $sql_result = $this->db->query( 
    18581886        "SELECT $sql_select 
     
    18641892        $key, 
    18651893        $uid); 
    1866        
     1894 
    18671895      if ($sql_arr = $this->db->fetch_assoc($sql_result)) 
    18681896        { 
    1869         $headers = unserialize($sql_arr['headers']); 
    1870         if (is_object($headers) && !empty($sql_arr['body'])) 
    1871           $headers->body = $sql_arr['body']; 
    1872  
    1873         $this->cache[$internal_key][$uid] = $headers; 
     1897        $this->cache[$internal_key][$uid] = unserialize($sql_arr['headers']); 
     1898        if (is_object($this->cache[$internal_key][$uid]) && !empty($sql_arr['structure'])) 
     1899          $this->cache[$internal_key][$uid]->structure = unserialize($sql_arr['structure']); 
    18741900        } 
    18751901      } 
     
    19071933 
    19081934 
    1909   function add_message_cache($key, $index, $headers) 
    1910     { 
    1911     if (!$key || !is_object($headers) || empty($headers->uid)) 
     1935  function add_message_cache($key, $index, $headers, $struct=null) 
     1936    { 
     1937    if (empty($key) || !is_object($headers) || empty($headers->uid)) 
    19121938      return; 
    1913  
    1914     $this->db->query( 
    1915       "INSERT INTO ".get_table_name('messages')." 
    1916        (user_id, del, cache_key, created, idx, uid, subject, ".$this->db->quoteIdentifier('from').", ".$this->db->quoteIdentifier('to').", cc, date, size, headers) 
    1917        VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, ".$this->db->fromunixtime($headers->timestamp).", ?, ?)", 
    1918       $_SESSION['user_id'], 
    1919       $key, 
    1920       $index, 
    1921       $headers->uid, 
    1922       (string)substr($this->decode_header($headers->subject, TRUE), 0, 128), 
    1923       (string)substr($this->decode_header($headers->from, TRUE), 0, 128), 
    1924       (string)substr($this->decode_header($headers->to, TRUE), 0, 128), 
    1925       (string)substr($this->decode_header($headers->cc, TRUE), 0, 128), 
    1926       (int)$headers->size, 
    1927       serialize($headers)); 
     1939       
     1940    // check for an existing record (probly headers are cached but structure not) 
     1941    $sql_result = $this->db->query( 
     1942        "SELECT message_id 
     1943         FROM ".get_table_name('messages')." 
     1944         WHERE  user_id=? 
     1945         AND    cache_key=? 
     1946         AND    uid=? 
     1947         AND    del<>1", 
     1948        $_SESSION['user_id'], 
     1949        $key, 
     1950        $headers->uid); 
     1951 
     1952    // update cache record 
     1953    if ($sql_arr = $this->db->fetch_assoc($sql_result)) 
     1954      { 
     1955      $this->db->query( 
     1956        "UPDATE ".get_table_name('messages')." 
     1957         SET   idx=?, headers=?, structure=? 
     1958         WHERE message_id=?", 
     1959        $index, 
     1960        serialize($headers), 
     1961        is_object($struct) ? serialize($struct) : NULL, 
     1962        $sql_arr['message_id'] 
     1963        ); 
     1964      } 
     1965    else  // insert new record 
     1966      { 
     1967      $this->db->query( 
     1968        "INSERT INTO ".get_table_name('messages')." 
     1969         (user_id, del, cache_key, created, idx, uid, subject, ".$this->db->quoteIdentifier('from').", ".$this->db->quoteIdentifier('to').", cc, date, size, headers, structure) 
     1970         VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, ".$this->db->fromunixtime($headers->timestamp).", ?, ?, ?)", 
     1971        $_SESSION['user_id'], 
     1972        $key, 
     1973        $index, 
     1974        $headers->uid, 
     1975        (string)substr($this->decode_header($headers->subject, TRUE), 0, 128), 
     1976        (string)substr($this->decode_header($headers->from, TRUE), 0, 128), 
     1977        (string)substr($this->decode_header($headers->to, TRUE), 0, 128), 
     1978        (string)substr($this->decode_header($headers->cc, TRUE), 0, 128), 
     1979        (int)$headers->size, 
     1980        serialize($headers), 
     1981        is_object($struct) ? serialize($struct) : NULL 
     1982        ); 
     1983      } 
    19281984    } 
    19291985     
  • trunk/roundcubemail/program/lib/imap.inc

    r282 r325  
    4747                - Also acceppt LIST responses in iil_C_ListSubscribed() 
    4848                - Sanity check of $message_set in iil_C_FetchHeaders(), iil_C_FetchHeaderIndex(), iil_C_FetchThreadHeaders() 
     49                - Implemented UID FETCH in iil_C_FetchHeaders() 
    4950                - Removed some debuggers (echo ...) 
    5051 
     
    11961197} 
    11971198 
    1198 function iil_C_FetchHeaders(&$conn, $mailbox, $message_set){ 
     1199function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false){ 
    11991200        global $IMAP_USE_INTERNAL_DATE; 
    12001201         
     
    12321233        /* FETCH date,from,subject headers */ 
    12331234        $key="fh".($c++); 
    1234         $request=$key." FETCH $message_set (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID REFERENCE)])\r\n"; 
     1235        $prefix=$uidfetch?" UID":""; 
     1236        $request=$key.$prefix." FETCH $message_set (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID REFERENCE)])\r\n"; 
    12351237 
    12361238        if (!fputs($fp, $request)) return false; 
     
    13101312        */ 
    13111313        $command_key="fh".($c++); 
    1312         $request= $command_key." FETCH $message_set (UID RFC822.SIZE FLAGS INTERNALDATE)\r\n"; 
     1314        $request= $command_key.$prefix." FETCH $message_set (UID RFC822.SIZE FLAGS INTERNALDATE)\r\n"; 
    13131315        if (!fputs($fp, $request)) return false; 
    13141316        do{ 
     
    14021404 
    14031405 
    1404 function iil_C_FetchHeader(&$conn, $mailbox, $id){ 
    1405         $fp = $conn->fp; 
    1406         $a=iil_C_FetchHeaders($conn, $mailbox, $id); 
    1407         if (is_array($a)) return $a[$id]; 
     1406function iil_C_FetchHeader(&$conn, $mailbox, $id, $uidfetch=false){ 
     1407        $fp = $conn->fp; 
     1408        $a=iil_C_FetchHeaders($conn, $mailbox, $id, $uidfetch); 
     1409        if (is_array($a)) return array_shift($a); 
    14081410        else return false; 
    14091411} 
  • trunk/roundcubemail/program/steps/mail/func.inc

    r320 r325  
    672672  if ($part->ctype_secondary=='html') 
    673673    { 
     674    // remove charset specification in HTML message 
     675    $body = preg_replace('/charset=[a-z0-9\-]+/i', '', $body); 
     676 
    674677    if (!$safe)  // remove remote images and scripts 
    675678      { 
     
    12481251 
    12491252 
    1250 // get source code of a specific message and cache it 
    1251 // deprecated 
    1252 function rcmail_message_source($uid) 
    1253   { 
    1254   global $IMAP, $DB, $CONFIG; 
    1255  
    1256   // get message ID if uid is given 
    1257   $cache_key = $IMAP->mailbox.'.msg'; 
    1258   $cached = $IMAP->get_cached_message($cache_key, $uid, FALSE); 
    1259    
    1260   // message is cached in database 
    1261   if ($cached && !empty($cached->body)) 
    1262     return $cached->body; 
    1263  
    1264   if (!$cached) 
    1265     $headers = $IMAP->get_headers($uid); 
    1266   else 
    1267     $headers = &$cached; 
    1268  
    1269   // create unique identifier based on message_id 
    1270   if (!empty($headers->messageID)) 
    1271     $message_id = md5($headers->messageID); 
    1272   else 
    1273     $message_id = md5($headers->uid.'@'.$_SESSION['imap_host']); 
    1274    
    1275   $temp_dir = $CONFIG['temp_dir'].(!eregi('\/$', $CONFIG['temp_dir']) ? '/' : ''); 
    1276   $cache_dir = $temp_dir.$_SESSION['client_id']; 
    1277   $cache_path = $cache_dir.'/'.$message_id; 
    1278  
    1279   // message is cached in temp dir 
    1280   if ($CONFIG['enable_caching'] && is_dir($cache_dir) && is_file($cache_path)) 
    1281     { 
    1282     if ($fp = fopen($cache_path, 'r')) 
    1283       { 
    1284       $msg_source = fread($fp, filesize($cache_path)); 
    1285       fclose($fp); 
    1286       return $msg_source; 
    1287       } 
    1288     } 
    1289  
    1290  
    1291   // get message from server 
    1292   $msg_source = $IMAP->get_raw_body($uid); 
    1293    
    1294   // return message source without caching 
    1295   if (!$CONFIG['enable_caching']) 
    1296     return $msg_source; 
    1297  
    1298  
    1299   // let's cache the message body within the database 
    1300   if ($cached && ($CONFIG['db_max_length'] -300) > $headers->size) 
    1301     { 
    1302     $DB->query("UPDATE ".get_table_name('messages')." 
    1303                 SET    body=? 
    1304                 WHERE  user_id=? 
    1305                 AND    cache_key=? 
    1306                 AND    uid=?", 
    1307                $msg_source, 
    1308                $_SESSION['user_id'], 
    1309                $cache_key, 
    1310                $uid); 
    1311  
    1312     return $msg_source; 
    1313     } 
    1314  
    1315  
    1316   // create dir for caching 
    1317   if (!is_dir($cache_dir)) 
    1318     $dir = mkdir($cache_dir); 
    1319   else 
    1320     $dir = true; 
    1321  
    1322   // attempt to write a file with the message body     
    1323   if ($dir && ($fp = fopen($cache_path, 'w'))) 
    1324     { 
    1325     fwrite($fp, $msg_source); 
    1326     fclose($fp); 
    1327     } 
    1328   else 
    1329     { 
    1330     raise_error(array('code' => 403, 'type' => 'php', 'line' => __LINE__, 'file' => __FILE__,  
    1331                       'message' => "Failed to write to temp dir"), TRUE, FALSE); 
    1332     } 
    1333  
    1334   return $msg_source; 
    1335   } 
    1336  
    1337  
    13381253// decode address string and re-format it as HTML links 
    13391254function rcmail_address_string($input, $max=NULL, $addicon=NULL) 
     
    14131328    $out .= sprintf('<tr><td class="title">%s</td><td>%s</td><td>[<a href="./?%s">%s</a>]</tr>'."\n", 
    14141329                    rcube_label('filename'), 
    1415                     rep_specialchars_output($filename), 
     1330                    rep_specialchars_output(rcube_imap::decode_mime_string($filename)), 
    14161331                    str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']), 
    14171332                    rcube_label('download')); 
  • trunk/roundcubemail/program/steps/mail/get.inc

    r320 r325  
    7070      header("Content-Type: application/octet-stream"); 
    7171      header(sprintf('Content-Disposition: attachment; filename="%s"', 
    72                      $filename ? $filename : "roundcube.$ctype_secondary")); 
     72                     $filename ? rcube_imap::decode_mime_string($filename) : "roundcube.$ctype_secondary")); 
    7373      } 
    7474    else 
    7575      { 
    7676      header("Content-Type: $mimetype"); 
    77       header(sprintf('Content-Disposition: inline; filename="%s"', $filename)); 
     77      header(sprintf('Content-Disposition: inline; filename="%s"', rcube_imap::decode_mime_string($filename))); 
    7878      } 
    7979 
     
    9090      // get part body if not available 
    9191      if (!$part->body) 
    92         $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part);         
     92        $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part);       
    9393 
    9494      list($MESSAGE['parts']) = rcmail_parse_message($part, 
     
    9797                                                           'get_url' => $GET_URL.'&_part=%s')); 
    9898 
    99       print rcmail_print_body($MESSAGE['parts'][0], (bool)$_GET['_safe']); 
     99      $OUTPUT = new rcube_html_page(); 
     100      $OUTPUT->write(rcmail_print_body($MESSAGE['parts'][0], (bool)$_GET['_safe'])); 
    100101      } 
    101102    else 
Note: See TracChangeset for help on using the changeset viewer.