Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pull from upstream

  • Loading branch information...
commit 3a0adc24b4cd48ea478c825abab1f69ceff50386 2 parents fe847df + 41b3fe1
Katie Poskaitis katiepru authored
Showing with 2,857 additions and 1,640 deletions.
  1. +43 −14 CHANGELOG
  2. +17 −10 config/main.inc.php.dist
  3. +6 −5 installer/rcube_install.php
  4. +1 −2  plugins/acl/acl.php
  5. +4 −0 plugins/acl/skins/larry/acl.css
  6. +4 −4 plugins/acl/skins/larry/templates/table.html
  7. +1 −5 plugins/hide_blockquote/hide_blockquote.php
  8. 0  plugins/hide_blockquote/skins/{default → larry}/style.css
  9. +0 −7 plugins/managesieve/tests/Makefile
  10. +54 −0 plugins/managesieve/tests/Parser.php
  11. +33 −0 plugins/managesieve/tests/Tokenizer.php
  12. +0 −120 plugins/managesieve/tests/parser.phpt
  13. +0 −49 plugins/managesieve/tests/parser_body.phpt
  14. +0 −28 plugins/managesieve/tests/parser_imapflags.phpt
  15. +0 −30 plugins/managesieve/tests/parser_include.phpt
  16. +0 −19 plugins/managesieve/tests/parser_kep14.phpt
  17. +0 −25 plugins/managesieve/tests/parser_prefix.phpt
  18. +0 −25 plugins/managesieve/tests/parser_relational.phpt
  19. +0 −39 plugins/managesieve/tests/parser_vacation.phpt
  20. +0 −39 plugins/managesieve/tests/parser_variables.phpt
  21. +0 −38 plugins/managesieve/tests/parset_subaddress.phpt
  22. +52 −0 plugins/managesieve/tests/src/parser
  23. +52 −0 plugins/managesieve/tests/src/parser.out
  24. +17 −0 plugins/managesieve/tests/src/parser_body
  25. +7 −0 plugins/managesieve/tests/src/parser_imapflags
  26. +7 −0 plugins/managesieve/tests/src/parser_include
  27. +2 −0  plugins/managesieve/tests/src/parser_kep14
  28. +3 −0  plugins/managesieve/tests/src/parser_kep14.out
  29. +5 −0 plugins/managesieve/tests/src/parser_prefix
  30. +6 −0 plugins/managesieve/tests/src/parser_relational
  31. +11 −0 plugins/managesieve/tests/src/parser_subaddress
  32. +12 −0 plugins/managesieve/tests/src/parser_vacation
  33. +12 −0 plugins/managesieve/tests/src/parser_variables
  34. +0 −66 plugins/managesieve/tests/tokenize.phpt
  35. +9 −1 plugins/password/config.inc.php.dist
  36. +33 −8 plugins/password/drivers/sql.php
  37. +4 −0 plugins/password/drivers/virtualmin.php
  38. +4 −1 plugins/virtuser_query/virtuser_query.php
  39. +1 −1  program/include/html.php
  40. +24 −19 program/include/rcmail.php
  41. +744 −695 program/include/rcube.php
  42. +0 −5 program/include/rcube_bc.inc
  43. +0 −2  program/include/rcube_browser.php
  44. +25 −6 program/include/rcube_charset.php
  45. +1 −0  program/include/rcube_config.php
  46. +11 −1 program/include/rcube_imap.php
  47. +33 −19 program/include/rcube_imap_cache.php
  48. +5 −2 program/include/rcube_imap_generic.php
  49. +19 −7 program/include/rcube_message.php
  50. +2 −2 program/include/rcube_mime.php
  51. +35 −1 program/include/rcube_output_html.php
  52. +1 −1  program/include/rcube_plugin.php
  53. +4 −0 program/include/rcube_result_index.php
  54. +2 −0  program/include/rcube_result_thread.php
  55. +19 −6 program/include/rcube_shared.inc
  56. +1 −1  program/include/rcube_storage.php
  57. +56 −5 program/include/rcube_utils.php
  58. +2 −1  program/include/rcube_vcard.php
  59. +88 −66 program/js/app.js
  60. +5 −2 program/js/common.js
  61. +2 −2 program/js/googiespell.js
  62. +2 −2 program/js/list.js
  63. +6 −7 program/localization/en_US/labels.inc
  64. +1 −0  program/localization/pl_PL/labels.inc
  65. +1 −1  program/steps/addressbook/export.inc
  66. +24 −20 program/steps/mail/compose.inc
  67. +13 −4 program/steps/mail/func.inc
  68. +2 −1  program/steps/mail/headers.inc
  69. +1 −1  program/steps/mail/search.inc
  70. +51 −4 program/steps/mail/sendmail.inc
  71. +19 −7 program/steps/settings/folders.inc
  72. +9 −7 program/steps/settings/func.inc
  73. +12 −4 program/steps/settings/save_folder.inc
  74. +2 −2 program/steps/settings/save_prefs.inc
  75. +5 −10 skins/classic/functions.js
  76. +1 −0  skins/classic/includes/links.html
  77. +1 −1  skins/classic/includes/messagetoolbar.html
  78. +2 −2 skins/classic/splitter.js
  79. +1 −1  skins/classic/templates/compose.html
  80. +2 −13 skins/classic/templates/message.html
  81. +2 −13 skins/classic/templates/messageerror.html
  82. +0 −1  skins/larry/addressbook.css
  83. +11 −5 skins/larry/ie7hacks.css
  84. +1 −1  skins/larry/iehacks.css
  85. BIN  skins/larry/images/contactpic_32px.png
  86. BIN  skins/larry/images/contactpic_48px.png
  87. +1 −0  skins/larry/includes/links.html
  88. +1 −1  skins/larry/includes/mailtoolbar.html
  89. +40 −50 skins/larry/mail.css
  90. +4 −2 skins/larry/styles.css
  91. +2 −0  skins/larry/svggradient.php
  92. +1 −1  skins/larry/svggradients.css
  93. +38 −23 skins/larry/templates/message.html
  94. +4 −6 skins/larry/templates/messageerror.html
  95. +3 −2 skins/larry/templates/messagepreview.html
  96. +44 −20 skins/larry/ui.js
  97. +20 −0 tests/Framework/BaseReplacer.php
  98. +20 −0 tests/Framework/Browser.php
  99. +20 −0 tests/Framework/Cache.php
  100. +162 −0 tests/Framework/Charset.php
  101. +20 −0 tests/Framework/ContentFilter.php
  102. +46 −0 tests/Framework/Html.php
  103. +20 −0 tests/Framework/Image.php
  104. +20 −0 tests/Framework/Imap.php
  105. +20 −0 tests/Framework/ImapGeneric.php
  106. +20 −0 tests/Framework/MessageHeader.php
  107. +20 −0 tests/Framework/MessagePart.php
  108. +2 −2 tests/{MailDecode.php → Framework/Mime.php}
  109. +20 −0 tests/Framework/Rcube.php
  110. +20 −0 tests/Framework/ResultIndex.php
  111. +20 −0 tests/Framework/ResultSet.php
  112. +20 −0 tests/Framework/ResultThread.php
  113. +232 −0 tests/Framework/Shared.php
  114. +20 −0 tests/Framework/Smtp.php
  115. +20 −0 tests/Framework/Spellchecker.php
  116. +20 −0 tests/Framework/StringReplacer.php
  117. +20 −0 tests/Framework/User.php
  118. +196 −0 tests/Framework/Utils.php
  119. +16 −2 tests/{VCards.php → Framework/VCard.php}
  120. +2 −2 tests/HtmlToText.php
  121. +1 −1  tests/MailFunc.php
  122. +0 −39 tests/ModCss.php
  123. +2 −0  tests/bootstrap.php
  124. +27 −3 tests/phpunit.xml
  125. +45 −0 tests/src/photo.vcf
57 CHANGELOG
View
@@ -1,21 +1,32 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix so "Edit as new" on draft creates a new message (#1488687)
+- Fix invalid error message on deleting mail from read only folder (#1488694)
+- Fix error where session wasn't updated after folder rename/delete (#1488692)
+- Replace data URIs of images (pasted in HTML editor) with inline attachments (#1488502)
+- Fix PLAIN authentication for some IMAP servers (#1488674)
+- Fix encoding vCard file when contains PHOTO;ENCODING=b (#1488683)
+- Fix focus issue in IE when selecting message row (#1488620)
+- Remove (too big) min-width on mail screen
+- Add full headers view in message preview window (#1488538)
+- Fix message display page issues - unified with message preview (#1488590, #1488642)
+- Fix displaying all headers when they contain malformed characters (#1488666)
+- Fix decoding of HTML messages with UTF-16 charset specified (#1488654)
+- Fix quota capability detection so it can be overwritten by a plugin (#1488655)
+- Added template object 'frame'
+- Fix identity selection on reply (#1488101)
+- Add option to enable HTML editor on forwarding (#1488517)
+- Add option to not include original message on reply, rename option top_posting to reply_mode (#1485149)
+- Fix Larry's messages list filter in IE (#1488632)
+- Fix more IE issues by disabling Compat. mode with X-UA-Compatible meta tag (#1488626)
+- Fix setting locales under Solaris - use additional .UTF-8 suffix (#1488628)
+- Fix email address validation for addresses with IP address in domain part
+- Fix Larry skin issues in IE7 compat. mode (#1488618)
+- Fix so subscribed non-existing/non-accessible shared folder can be unsubscribed
+- Added session_path config option and unified cookies settings in javascript
+- Added "Undeleted" option to messages list filter
- Rewritten test scripts for PHPUnit
-- Fix lower-casing email address on replies (#1488598)
-- Fix line separator in exported messages (#1488603)
-- Fix XSS issue where plain signatures wasn't secured in HTML mode (#1488613)
-- Fix XSS issue where href="javascript:" wasn't secured (#1488613)
-- Fix impossible to create message with empty plain text part (#1488610)
-- Fix stripped apostrophes when replying in plain text to HTML message (#1488606)
-- Fix inactive Save search option after advanced search (#1488607)
-- Fix Remove from group option is active for contact search result (#1488608)
-- Disable autocapitalization in login form on iPad/iPhone (#1488609)
-- Fix focus on the list when list row is clicked (#1488600)
-- Added separate From and To columns apart from smart From/To column (#1486891)
-- Fix fallback to Larry skin when configured skin isn't available (#1488591)
-- Fix (workaround) delete operations with some versions of memcache (#1488592)
-- Fix (disable) request validation for spell and spell_html actions
- Add new DB abstraction layer based on PHP PDO, supporting SQLite3 (#1488332)
- Removed PEAR::MDB2 package
- Removed users.alias column, added option ('user_aliases')
@@ -41,6 +52,24 @@ CHANGELOG Roundcube Webmail
Move global functions from main.inc and rcube_shared.inc into classes
Better classes separation
+RELEASE 0.8.1
+-------------
+- Fix bug where domain name was converted to lower-case even with login_lc=false (#1488593)
+- Fix lower-casing email address on replies (#1488598)
+- Fix line separator in exported messages (#1488603)
+- Fix XSS issue where plain signatures wasn't secured in HTML mode (#1488613)
+- Fix XSS issue where href="javascript:" wasn't secured (#1488613)
+- Fix impossible to create message with empty plain text part (#1488610)
+- Fix stripped apostrophes when replying in plain text to HTML message (#1488606)
+- Fix inactive Save search option after advanced search (#1488607)
+- Fix Remove from group option is active for contact search result (#1488608)
+- Disable autocapitalization in login form on iPad/iPhone (#1488609)
+- Fix focus on the list when list row is clicked (#1488600)
+- Added separate From and To columns apart from smart From/To column (#1486891)
+- Fix fallback to Larry skin when configured skin isn't available (#1488591)
+- Fix (workaround) delete operations with some versions of memcache (#1488592)
+- Fix (disable) request validation for spell and spell_html actions
+
RELEASE 0.8.0
-------------
- Don't show product version on login screen (can be enabled by config)
27 config/main.inc.php.dist
View
@@ -21,7 +21,7 @@ $rcmail_config = array();
// LOGGING/DEBUGGING
// ----------------------------------
-// system error reporting: 1 = log; 2 = report (not implemented yet), 4 = show, 8 = trace
+// system error reporting, sum of: 1 = log; 4 = show, 8 = trace
$rcmail_config['debug_level'] = 1;
// log driver: 'syslog' or 'file'.
@@ -78,7 +78,7 @@ $rcmail_config['default_host'] = '';
// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;
-// IMAP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or empty to use
+// IMAP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or null to use
// best server supported one)
$rcmail_config['imap_auth_type'] = null;
@@ -224,11 +224,12 @@ $rcmail_config['use_https'] = false;
// 0 - disabled, 1 - username and host only, 2 - username, host, password
$rcmail_config['login_autocomplete'] = 0;
-// If users authentication is not case sensitive this must be enabled.
-// You can also use it to force conversion of logins to lower case.
+// Forces conversion of logins to lower case.
+// 0 - disabled, 1 - only domain part, 2 - domain and local part.
+// If users authentication is not case-sensitive this must be enabled.
// After enabling it all user records need to be updated, e.g. with query:
// UPDATE users SET username = LOWER(username);
-$rcmail_config['login_lc'] = false;
+$rcmail_config['login_lc'] = 0;
// Includes should be interpreted as PHP files
$rcmail_config['skin_include_php'] = false;
@@ -240,12 +241,15 @@ $rcmail_config['display_version'] = false;
// must be greater than 'keep_alive'/60
$rcmail_config['session_lifetime'] = 10;
-// session domain: .example.org
+// Session domain: .example.org
$rcmail_config['session_domain'] = '';
-// session name. Default: 'roundcube_sessid'
+// Session name. Default: 'roundcube_sessid'
$rcmail_config['session_name'] = null;
+// Session path. Defaults to PHP session.cookie_path setting.
+$rcmail_config['session_path'] = null;
+
// Backend to use for session storage. Can either be 'db' (default) or 'memcache'
// If set to memcache, a list of servers need to be specified in 'memcache_hosts'
// Make sure the Memcache extension (http://pecl.php.net/package/memcache) version >= 2.0.0 is installed
@@ -721,7 +725,7 @@ $rcmail_config['prefer_html'] = true;
$rcmail_config['show_images'] = 0;
// compose html formatted messages by default
-// 0 - never, 1 - always, 2 - on reply to HTML message only
+// 0 - never, 1 - always, 2 - on reply to HTML message, 3 - on forward or reply to HTML message
$rcmail_config['htmleditor'] = 0;
// show pretty dates as standard
@@ -779,8 +783,11 @@ $rcmail_config['display_next'] = true;
// 2 - Expand only threads with unread messages
$rcmail_config['autoexpand_threads'] = 0;
-// When replying place cursor above original message (top posting)
-$rcmail_config['top_posting'] = false;
+// When replying:
+// -1 - don't cite the original message
+// 0 - place cursor below the original message
+// 1 - place cursor above original message (top posting)
+$rcmail_config['reply_mode'] = 0;
// When replying strip original signature from message
$rcmail_config['strip_existing_sig'] = true;
11 installer/rcube_install.php
View
@@ -35,13 +35,14 @@ class rcube_install
var $obsolete_config = array('db_backend', 'double_auth');
var $replaced_config = array(
- 'skin_path' => 'skin',
- 'locale_string' => 'language',
- 'multiple_identities' => 'identities_level',
+ 'skin_path' => 'skin',
+ 'locale_string' => 'language',
+ 'multiple_identities' => 'identities_level',
'addrbook_show_images' => 'show_images',
- 'imap_root' => 'imap_ns_personal',
- 'pagesize' => 'mail_pagesize',
+ 'imap_root' => 'imap_ns_personal',
+ 'pagesize' => 'mail_pagesize',
'default_imap_folders' => 'default_folders',
+ 'top_posting' => 'reply_mode',
);
// these config options are required for a working system
3  plugins/acl/acl.php
View
@@ -233,8 +233,7 @@ function templ_rights($attrib)
// Advanced rights
$attrib['id'] = 'advancedrights';
- foreach ($supported as $val) {
- $id = "acl$val";
+ foreach ($supported as $idx => $val) {
$ul .= html::tag('li', null,
$input->show('', array(
'name' => "acl[$val]", 'value' => $val, 'id' => $id))
4 plugins/acl/skins/larry/acl.css
View
@@ -123,3 +123,7 @@
{
margin-left: 0.5em;
}
+
+ul.toolbarmenu li span.delete {
+ background-position: 0 -1509px;
+}
8 plugins/acl/skins/larry/templates/table.html
View
@@ -3,14 +3,14 @@
<roundcube:object name="acltable" id="acltable" class="records-table" />
</div>
<div id="acllist-footer" class="boxfooter">
- <roundcube:button command="acl-create" id="aclcreatelink" type="link" title="acl.newuser" class="listbutton add disabled" classAct="listbutton add" innerClass="inner" content="+" /><roundcube:button name="aclmenulink" id="aclmenulink" type="link" title="acl.actions" class="listbutton groupactions"onclick="UI.show_popup('aclmenu');return false" innerClass="inner" content="&#9881;" />
+ <roundcube:button command="acl-create" id="aclcreatelink" type="link" title="acl.newuser" class="listbutton add disabled" classAct="listbutton add" innerClass="inner" content="+" /><roundcube:button name="aclmenulink" id="aclmenulink" type="link" title="acl.actions" class="listbutton groupactions"onclick="UI.show_popup('aclmenu', undefined, {above:1});return false" innerClass="inner" content="&#9881;" />
</div>
</div>
<div id="aclmenu" class="popupmenu">
- <ul class="toolbarmenu selectable">
- <li><roundcube:button command="acl-edit" label="edit" classAct="active" /></li>
- <li><roundcube:button command="acl-delete" label="delete" classAct="active" /></li>
+ <ul class="toolbarmenu selectable iconized">
+ <li><roundcube:button command="acl-edit" label="edit" class="icon" classAct="icon active" innerclass="icon edit" /></li>
+ <li><roundcube:button command="acl-delete" label="delete" class="icon" classAct="icon active" innerclass="icon delete" /></li>
<roundcube:if condition="!in_array('acl_advanced_mode', (array)config:dont_override)" />
<li><roundcube:button name="acl-switch" id="acl-switch" label="acl.advanced" onclick="rcmail.command('acl-mode-switch')" class="active" /></li>
<roundcube:endif />
6 plugins/hide_blockquote/hide_blockquote.php
View
@@ -27,11 +27,7 @@ function init()
&& ($limit = $rcmail->config->get('hide_blockquote_limit'))
) {
// include styles
- $skin = $rcmail->config->get('skin');
- if (!file_exists($this->home."/skins/$skin/style.css")) {
- $skin = 'default';
- }
- $this->include_stylesheet("skins/$skin/style.css");
+ $this->include_stylesheet($this->local_skin_path() . "/style.css");
// Script and localization
$this->include_script('hide_blockquote.js');
0  plugins/hide_blockquote/skins/default/style.css → plugins/hide_blockquote/skins/larry/style.css
View
File renamed without changes
7 plugins/managesieve/tests/Makefile
View
@@ -1,7 +0,0 @@
-
-clean:
- rm -f *.log *.php *.diff *.exp *.out
-
-
-test:
- pear run-tests *.phpt
54 plugins/managesieve/tests/Parser.php
View
@@ -0,0 +1,54 @@
+<?php
+
+class Parser extends PHPUnit_Framework_TestCase
+{
+
+ function setUp()
+ {
+ include_once dirname(__FILE__) . '/../lib/rcube_sieve_script.php';
+ }
+
+ /**
+ * Sieve script parsing
+ *
+ * @dataProvider data_parser
+ */
+ function test_parser($input, $output, $message)
+ {
+ $script = new rcube_sieve_script($input);
+ $result = $script->as_text();
+
+ $this->assertEquals(trim($result), trim($output), $message);
+ }
+
+ /**
+ * Data provider for test_parser()
+ */
+ function data_parser()
+ {
+ $dir_path = realpath(dirname(__FILE__) . '/src');
+ $dir = opendir($dir_path);
+ $result = array();
+
+ while ($file = readdir($dir)) {
+ if (preg_match('/^[a-z0-9_]+$/', $file)) {
+ $input = file_get_contents($dir_path . '/' . $file);
+
+ if (file_exists($dir_path . '/' . $file . '.out')) {
+ $output = file_get_contents($dir_path . '/' . $file . '.out');
+ }
+ else {
+ $output = $input;
+ }
+
+ $result[] = array(
+ 'input' => $input,
+ 'output' => $output,
+ 'message' => "Error in parsing '$file' file",
+ );
+ }
+ }
+
+ return $result;
+ }
+}
33 plugins/managesieve/tests/Tokenizer.php
View
@@ -0,0 +1,33 @@
+<?php
+
+class Tokenizer extends PHPUnit_Framework_TestCase
+{
+
+ function setUp()
+ {
+ include_once dirname(__FILE__) . '/../lib/rcube_sieve_script.php';
+ }
+
+ function data_tokenizer()
+ {
+ return array(
+ array(1, "text: #test\nThis is test ; message;\nMulti line\n.\n;\n", '"This is test ; message;\nMulti line"'),
+ array(0, '["test1","test2"]', '[["test1","test2"]]'),
+ array(1, '["test"]', '["test"]'),
+ array(1, '"te\\"st"', '"te\\"st"'),
+ array(0, 'test #comment', '["test"]'),
+ array(0, "text:\ntest\n.\ntext:\ntest\n.\n", '["test","test"]'),
+ array(1, '"\\a\\\\\\"a"', '"a\\\\\\"a"'),
+ );
+ }
+
+ /**
+ * @dataProvider data_tokenizer
+ */
+ function test_tokenizer($num, $input, $output)
+ {
+ $res = json_encode(rcube_sieve_script::tokenize($input, $num));
+
+ $this->assertEquals(trim($res), trim($output));
+ }
+}
120 plugins/managesieve/tests/parser.phpt
View
@@ -1,120 +0,0 @@
---TEST--
-Main test of script parser
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["fileinto","reject","envelope"];
-# rule:[spam]
-if anyof (header :contains "X-DSPAM-Result" "Spam")
-{
- fileinto "Spam";
- stop;
-}
-# rule:[test1]
-if anyof (header :comparator "i;ascii-casemap" :contains ["From","To"] "test@domain.tld")
-{
- discard;
- stop;
-}
-# rule:[test2]
-if anyof (not header :comparator "i;octet" :contains ["Subject"] "[test]", header :contains "Subject" "[test2]")
-{
- fileinto "test";
- stop;
-}
-# rule:[comments]
-if anyof (true) /* comment
- * "comment" #comment */ {
- /* comment */ stop;
-# comment
-}
-# rule:[reject]
-if size :over 5000K {
- reject "Message over 5MB size limit. Please contact me before sending this.";
-}
-# rule:[false]
-if false # size :over 5000K
-{
- stop; /* rule disabled */
-}
-# rule:[true]
-if true
-{
- stop;
-}
-fileinto "Test";
-# rule:[address test]
-if address :all :is "From" "nagios@domain.tld"
-{
- fileinto "domain.tld";
- stop;
-}
-# rule:[envelope test]
-if envelope :domain :is "From" "domain.tld"
-{
- fileinto "domain.tld";
- stop;
-}
-';
-
-$s = new rcube_sieve_script($txt);
-echo $s->as_text();
-
-// -------------------------------------------------------------------------------
-?>
---EXPECT--
-require ["fileinto","reject","envelope"];
-# rule:[spam]
-if header :contains "X-DSPAM-Result" "Spam"
-{
- fileinto "Spam";
- stop;
-}
-# rule:[test1]
-if header :contains ["From","To"] "test@domain.tld"
-{
- discard;
- stop;
-}
-# rule:[test2]
-if anyof (not header :comparator "i;octet" :contains "Subject" "[test]", header :contains "Subject" "[test2]")
-{
- fileinto "test";
- stop;
-}
-# rule:[comments]
-if true
-{
- stop;
-}
-# rule:[reject]
-if size :over 5000K
-{
- reject "Message over 5MB size limit. Please contact me before sending this.";
-}
-# rule:[false]
-if false # size :over 5000K
-{
- stop;
-}
-# rule:[true]
-if true
-{
- stop;
-}
-fileinto "Test";
-# rule:[address test]
-if address :all :is "From" "nagios@domain.tld"
-{
- fileinto "domain.tld";
- stop;
-}
-# rule:[envelope test]
-if envelope :domain :is "From" "domain.tld"
-{
- fileinto "domain.tld";
- stop;
-}
49 plugins/managesieve/tests/parser_body.phpt
View
@@ -1,49 +0,0 @@
---TEST--
-Test of Sieve body extension (RFC5173)
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["body","fileinto"];
-if body :raw :contains "MAKE MONEY FAST"
-{
- stop;
-}
-if body :content "text" :contains ["missile","coordinates"]
-{
- fileinto "secrets";
-}
-if body :content "audio/mp3" :contains ""
-{
- fileinto "jukebox";
-}
-if body :text :contains "project schedule"
-{
- fileinto "project/schedule";
-}
-';
-
-$s = new rcube_sieve_script($txt);
-echo $s->as_text();
-
-?>
---EXPECT--
-require ["body","fileinto"];
-if body :raw :contains "MAKE MONEY FAST"
-{
- stop;
-}
-if body :content "text" :contains ["missile","coordinates"]
-{
- fileinto "secrets";
-}
-if body :content "audio/mp3" :contains ""
-{
- fileinto "jukebox";
-}
-if body :text :contains "project schedule"
-{
- fileinto "project/schedule";
-}
28 plugins/managesieve/tests/parser_imapflags.phpt
View
@@ -1,28 +0,0 @@
---TEST--
-Test of Sieve vacation extension (RFC5232)
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["imapflags"];
-# rule:[imapflags]
-if header :matches "Subject" "^Test$" {
- setflag "\\\\Seen";
- addflag ["\\\\Answered","\\\\Deleted"];
-}
-';
-
-$s = new rcube_sieve_script($txt, array('imapflags'));
-echo $s->as_text();
-
-?>
---EXPECT--
-require ["imapflags"];
-# rule:[imapflags]
-if header :matches "Subject" "^Test$"
-{
- setflag "\\Seen";
- addflag ["\\Answered","\\Deleted"];
-}
30 plugins/managesieve/tests/parser_include.phpt
View
@@ -1,30 +0,0 @@
---TEST--
-Test of Sieve include extension
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["include"];
-
-include "script.sieve";
-# rule:[two]
-if true
-{
- include :optional "second.sieve";
-}
-';
-
-$s = new rcube_sieve_script($txt, array(), array('variables'));
-echo $s->as_text();
-
-?>
---EXPECT--
-require ["include"];
-include "script.sieve";
-# rule:[two]
-if true
-{
- include :optional "second.sieve";
-}
19 plugins/managesieve/tests/parser_kep14.phpt
View
@@ -1,19 +0,0 @@
---TEST--
-Test of Kolab's KEP:14 implementation
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-# EDITOR Roundcube
-# EDITOR_VERSION 123
-';
-
-$s = new rcube_sieve_script($txt, array('body'));
-echo $s->as_text();
-
-?>
---EXPECT--
-# EDITOR Roundcube
-# EDITOR_VERSION 123
25 plugins/managesieve/tests/parser_prefix.phpt
View
@@ -1,25 +0,0 @@
---TEST--
-Test of prefix comments handling
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-# this is a comment
-# and the second line
-
-require ["variables"];
-set "b" "c";
-';
-
-$s = new rcube_sieve_script($txt, array(), array('variables'));
-echo $s->as_text();
-
-?>
---EXPECT--
-# this is a comment
-# and the second line
-
-require ["variables"];
-set "b" "c";
25 plugins/managesieve/tests/parser_relational.phpt
View
@@ -1,25 +0,0 @@
---TEST--
-Test of Sieve relational extension (RFC5231)
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["relational","comparator-i;ascii-numeric"];
-# rule:[redirect]
-if header :value "ge" :comparator "i;ascii-numeric"
- ["X-Spam-score"] ["14"] {redirect "test@test.tld";}
-';
-
-$s = new rcube_sieve_script($txt);
-echo $s->as_text();
-
-?>
---EXPECT--
-require ["relational","comparator-i;ascii-numeric"];
-# rule:[redirect]
-if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "14"
-{
- redirect "test@test.tld";
-}
39 plugins/managesieve/tests/parser_vacation.phpt
View
@@ -1,39 +0,0 @@
---TEST--
-Test of Sieve vacation extension (RFC5230)
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["vacation"];
-# rule:[test-vacation]
-if anyof (header :contains "Subject" "vacation")
-{
- vacation :days 1 text:
-# test
-test test /* test */
-test
-.
-;
- stop;
-}
-';
-
-$s = new rcube_sieve_script($txt);
-echo $s->as_text();
-
-?>
---EXPECT--
-require ["vacation"];
-# rule:[test-vacation]
-if header :contains "Subject" "vacation"
-{
- vacation :days 1 text:
-# test
-test test /* test */
-test
-.
-;
- stop;
-}
39 plugins/managesieve/tests/parser_variables.phpt
View
@@ -1,39 +0,0 @@
---TEST--
-Test of Sieve variables extension
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["variables"];
-set "honorific" "Mr";
-set "vacation" text:
-Dear ${HONORIFIC} ${last_name},
-I am out, please leave a message after the meep.
-.
-;
-set :length "b" "${a}";
-set :lower "b" "${a}";
-set :upperfirst "b" "${a}";
-set :upperfirst :lower "b" "${a}";
-set :quotewildcard "b" "Rock*";
-';
-
-$s = new rcube_sieve_script($txt, array(), array('variables'));
-echo $s->as_text();
-
-?>
---EXPECT--
-require ["variables"];
-set "honorific" "Mr";
-set "vacation" text:
-Dear ${HONORIFIC} ${last_name},
-I am out, please leave a message after the meep.
-.
-;
-set :length "b" "${a}";
-set :lower "b" "${a}";
-set :upperfirst "b" "${a}";
-set :upperfirst :lower "b" "${a}";
-set :quotewildcard "b" "Rock*";
38 plugins/managesieve/tests/parset_subaddress.phpt
View
@@ -1,38 +0,0 @@
---TEST--
-Test of Sieve subaddress extension (RFC5233)
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt = '
-require ["envelope","subaddress","fileinto"];
-if envelope :user "To" "postmaster"
-{
- fileinto "postmaster";
- stop;
-}
-if envelope :detail :is "To" "mta-filters"
-{
- fileinto "mta-filters";
- stop;
-}
-';
-
-$s = new rcube_sieve_script($txt);
-echo $s->as_text();
-
-// -------------------------------------------------------------------------------
-?>
---EXPECT--
-require ["envelope","subaddress","fileinto"];
-if envelope :user "To" "postmaster"
-{
- fileinto "postmaster";
- stop;
-}
-if envelope :detail :is "To" "mta-filters"
-{
- fileinto "mta-filters";
- stop;
-}
52 plugins/managesieve/tests/src/parser
View
@@ -0,0 +1,52 @@
+require ["fileinto","reject","envelope"];
+# rule:[spam]
+if anyof (header :contains "X-DSPAM-Result" "Spam")
+{
+ fileinto "Spam";
+ stop;
+}
+# rule:[test1]
+if anyof (header :comparator "i;ascii-casemap" :contains ["From","To"] "test@domain.tld")
+{
+ discard;
+ stop;
+}
+# rule:[test2]
+if anyof (not header :comparator "i;octet" :contains ["Subject"] "[test]", header :contains "Subject" "[test2]")
+{
+ fileinto "test";
+ stop;
+}
+# rule:[comments]
+if anyof (true) /* comment
+ * "comment" #comment */ {
+ /* comment */ stop;
+# comment
+}
+# rule:[reject]
+if size :over 5000K {
+ reject "Message over 5MB size limit. Please contact me before sending this.";
+}
+# rule:[false]
+if false # size :over 5000K
+{
+ stop; /* rule disabled */
+}
+# rule:[true]
+if true
+{
+ stop;
+}
+fileinto "Test";
+# rule:[address test]
+if address :all :is "From" "nagios@domain.tld"
+{
+ fileinto "domain.tld";
+ stop;
+}
+# rule:[envelope test]
+if envelope :domain :is "From" "domain.tld"
+{
+ fileinto "domain.tld";
+ stop;
+}
52 plugins/managesieve/tests/src/parser.out
View
@@ -0,0 +1,52 @@
+require ["fileinto","reject","envelope"];
+# rule:[spam]
+if header :contains "X-DSPAM-Result" "Spam"
+{
+ fileinto "Spam";
+ stop;
+}
+# rule:[test1]
+if header :contains ["From","To"] "test@domain.tld"
+{
+ discard;
+ stop;
+}
+# rule:[test2]
+if anyof (not header :comparator "i;octet" :contains "Subject" "[test]", header :contains "Subject" "[test2]")
+{
+ fileinto "test";
+ stop;
+}
+# rule:[comments]
+if true
+{
+ stop;
+}
+# rule:[reject]
+if size :over 5000K
+{
+ reject "Message over 5MB size limit. Please contact me before sending this.";
+}
+# rule:[false]
+if false # size :over 5000K
+{
+ stop;
+}
+# rule:[true]
+if true
+{
+ stop;
+}
+fileinto "Test";
+# rule:[address test]
+if address :all :is "From" "nagios@domain.tld"
+{
+ fileinto "domain.tld";
+ stop;
+}
+# rule:[envelope test]
+if envelope :domain :is "From" "domain.tld"
+{
+ fileinto "domain.tld";
+ stop;
+}
17 plugins/managesieve/tests/src/parser_body
View
@@ -0,0 +1,17 @@
+require ["body","fileinto"];
+if body :raw :contains "MAKE MONEY FAST"
+{
+ stop;
+}
+if body :content "text" :contains ["missile","coordinates"]
+{
+ fileinto "secrets";
+}
+if body :content "audio/mp3" :contains ""
+{
+ fileinto "jukebox";
+}
+if body :text :contains "project schedule"
+{
+ fileinto "project/schedule";
+}
7 plugins/managesieve/tests/src/parser_imapflags
View
@@ -0,0 +1,7 @@
+require ["imap4flags"];
+# rule:[imapflags]
+if header :matches "Subject" "^Test$"
+{
+ setflag "\\Seen";
+ addflag ["\\Answered","\\Deleted"];
+}
7 plugins/managesieve/tests/src/parser_include
View
@@ -0,0 +1,7 @@
+require ["include"];
+include "script.sieve";
+# rule:[two]
+if true
+{
+ include :optional "second.sieve";
+}
2  plugins/managesieve/tests/src/parser_kep14
View
@@ -0,0 +1,2 @@
+# EDITOR Roundcube
+# EDITOR_VERSION 123
3  plugins/managesieve/tests/src/parser_kep14.out
View
@@ -0,0 +1,3 @@
+require ["variables"];
+set "EDITOR" "Roundcube";
+set "EDITOR_VERSION" "123";
5 plugins/managesieve/tests/src/parser_prefix
View
@@ -0,0 +1,5 @@
+# this is a comment
+# and the second line
+
+require ["variables"];
+set "b" "c";
6 plugins/managesieve/tests/src/parser_relational
View
@@ -0,0 +1,6 @@
+require ["relational","comparator-i;ascii-numeric"];
+# rule:[redirect]
+if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "14"
+{
+ redirect "test@test.tld";
+}
11 plugins/managesieve/tests/src/parser_subaddress
View
@@ -0,0 +1,11 @@
+require ["envelope","subaddress","fileinto"];
+if envelope :user "To" "postmaster"
+{
+ fileinto "postmaster";
+ stop;
+}
+if envelope :detail :is "To" "mta-filters"
+{
+ fileinto "mta-filters";
+ stop;
+}
12 plugins/managesieve/tests/src/parser_vacation
View
@@ -0,0 +1,12 @@
+require ["vacation"];
+# rule:[test-vacation]
+if header :contains "Subject" "vacation"
+{
+ vacation :days 1 text:
+# test
+test test /* test */
+test
+.
+;
+ stop;
+}
12 plugins/managesieve/tests/src/parser_variables
View
@@ -0,0 +1,12 @@
+require ["variables"];
+set "honorific" "Mr";
+set "vacation" text:
+Dear ${HONORIFIC} ${last_name},
+I am out, please leave a message after the meep.
+.
+;
+set :length "b" "${a}";
+set :lower "b" "${a}";
+set :upperfirst "b" "${a}";
+set :upperfirst :lower "b" "${a}";
+set :quotewildcard "b" "Rock*";
66 plugins/managesieve/tests/tokenize.phpt
View
@@ -1,66 +0,0 @@
---TEST--
-Script parsing: tokenizer
---SKIPIF--
---FILE--
-<?php
-include '../lib/rcube_sieve_script.php';
-
-$txt[1] = array(1, 'text: #test
-This is test ; message;
-Multi line
-.
-;
-');
-$txt[2] = array(0, '["test1","test2"]');
-$txt[3] = array(1, '["test"]');
-$txt[4] = array(1, '"te\\"st"');
-$txt[5] = array(0, 'test #comment');
-$txt[6] = array(0, 'text:
-test
-.
-text:
-test
-.
-');
-$txt[7] = array(1, '"\\a\\\\\\"a"');
-
-foreach ($txt as $idx => $t) {
- echo "[$idx]---------------\n";
- var_dump(rcube_sieve_script::tokenize($t[1], $t[0]));
-}
-?>
---EXPECT--
-[1]---------------
-string(34) "This is test ; message;
-Multi line"
-[2]---------------
-array(1) {
- [0]=>
- array(2) {
- [0]=>
- string(5) "test1"
- [1]=>
- string(5) "test2"
- }
-}
-[3]---------------
-array(1) {
- [0]=>
- string(4) "test"
-}
-[4]---------------
-string(5) "te"st"
-[5]---------------
-array(1) {
- [0]=>
- string(4) "test"
-}
-[6]---------------
-array(2) {
- [0]=>
- string(4) "test"
- [1]=>
- string(4) "test"
-}
-[7]---------------
-string(4) "a\"a"
10 plugins/password/config.inc.php.dist
View
@@ -36,7 +36,8 @@ $rcmail_config['password_db_dsn'] = '';
// The query can contain the following macros that will be expanded as follows:
// %p is replaced with the plaintext new password
// %c is replaced with the crypt version of the new password, MD5 if available
-// otherwise DES.
+// otherwise DES. More hash function can be enabled using the password_crypt_hash
+// configuration parameter.
// %D is replaced with the dovecotpw-crypted version of the new password
// %o is replaced with the password before the change
// %n is replaced with the hashed version of the new password
@@ -51,6 +52,13 @@ $rcmail_config['password_db_dsn'] = '';
// Default: "SELECT update_passwd(%c, %u)"
$rcmail_config['password_query'] = 'SELECT update_passwd(%c, %u)';
+// By default the crypt() function which is used to create the '%c'
+// parameter uses the md5 algorithm. To use different algorithms
+// you can choose between: des, md5, blowfish, sha256, sha512.
+// Before using other hash functions than des or md5 please make sure
+// your operating system supports the other hash functions.
+$rcmail_config['password_crypt_hash'] = 'md5';
+
// By default domains in variables are using unicode.
// Enable this option to use punycoded names
$rcmail_config['password_idn_ascii'] = false;
41 plugins/password/drivers/sql.php
View
@@ -40,13 +40,38 @@ function save($curpass, $passwd)
// crypted password
if (strpos($sql, '%c') !== FALSE) {
$salt = '';
- if (CRYPT_MD5) {
- // Always use eight salt characters for MD5 (#1488136)
- $len = 8;
- } else if (CRYPT_STD_DES) {
- $len = 2;
- } else {
- return PASSWORD_CRYPT_ERROR;
+
+ if (!($crypt_hash = $rcmail->config->get('password_crypt_hash')))
+ {
+ if (CRYPT_MD5)
+ $crypt_hash = 'md5';
+ else if (CRYPT_STD_DES)
+ $crypt_hash = 'des';
+ }
+
+ switch ($crypt_hash)
+ {
+ case 'md5':
+ $len = 8;
+ $salt_hashindicator = '$1$';
+ break;
+ case 'des':
+ $len = 2;
+ break;
+ case 'blowfish':
+ $len = 22;
+ $salt_hashindicator = '$2a$';
+ break;
+ case 'sha256':
+ $len = 16;
+ $salt_hashindicator = '$5$';
+ break;
+ case 'sha512':
+ $len = 16;
+ $salt_hashindicator = '$6$';
+ break;
+ default:
+ return PASSWORD_CRYPT_ERROR;
}
//Restrict the character set used as salt (#1488136)
@@ -55,7 +80,7 @@ function save($curpass, $passwd)
$salt .= $seedchars[rand(0, 63)];
}
- $sql = str_replace('%c', $db->quote(crypt($passwd, CRYPT_MD5 ? '$1$'.$salt.'$' : $salt)), $sql);
+ $sql = str_replace('%c', $db->quote(crypt($passwd, $salt_hashindicator ? $salt_hashindicator .$salt.'$' : $salt)), $sql);
}
// dovecotpw
4 plugins/password/drivers/virtualmin.php
View
@@ -48,6 +48,10 @@ function save($currpass, $newpass)
$pieces = explode("_", $username);
$domain = $pieces[0];
break;
+ case 8: // domain taken from alias, username left as it was
+ $email = $rcmail->user->data['alias'];
+ $domain = substr(strrchr($email, "@"), 1);
+ break;
default: // username@domain
$domain = substr(strrchr($username, "@"), 1);
}
5 plugins/virtuser_query/virtuser_query.php
View
@@ -14,8 +14,11 @@
*
* $rcmail_config['virtuser_query'] = array('email' => '', 'user' => '', 'host' => '');
*
+ * The email query can return more than one record to create more identities.
+ * This requires identities_level option to be set to value less than 2.
+ *
* @version @package_version@
- * @author Aleksander Machniak
+ * @author Aleksander Machniak <alec@alec.pl>
* @author Steffen Vogel
*/
class virtuser_query extends rcube_plugin
2  program/include/html.php
View
@@ -154,7 +154,7 @@ public static function img($attr = null)
$attr = array('src' => $attr);
}
return self::tag('img', $attr + array('alt' => ''), null, array_merge(self::$common_attrib,
- array('src','alt','width','height','border','usemap','onclick')));
+ array('src','alt','width','height','border','usemap','onclick')));
}
/**
43 program/include/rcmail.php
View
@@ -157,14 +157,16 @@ public function set_user($user)
$this->config->set_user_prefs((array)$this->user->get_prefs());
}
- $_SESSION['language'] = $this->user->language = $this->language_prop($this->config->get('language', $_SESSION['language']));
+ $lang = $this->language_prop($this->config->get('language', $_SESSION['language']));
+ $_SESSION['language'] = $this->user->language = $lang;
// set localization
- setlocale(LC_ALL, $_SESSION['language'] . '.utf8', 'en_US.utf8');
+ setlocale(LC_ALL, $lang . '.utf8', $lang . '.UTF-8', 'en_US.utf8', 'en_US.UTF-8');
// workaround for http://bugs.php.net/bug.php?id=18556
- if (in_array($_SESSION['language'], array('tr_TR', 'ku', 'az_AZ')))
- setlocale(LC_CTYPE, 'en_US' . '.utf8');
+ if (in_array($lang, array('tr_TR', 'ku', 'az_AZ'))) {
+ setlocale(LC_CTYPE, 'en_US.utf8', 'en_US.UTF-8');
+ }
}
@@ -306,7 +308,7 @@ public function get_address_sources($writeable = false)
/**
* Init output object for GUI and add common scripts.
- * This will instantiate a rcmail_template object and set
+ * This will instantiate a rcube_output_html object and set
* environment vars according to the current session and configuration
*
* @param boolean True if this request is loaded in a (i)frame
@@ -453,7 +455,14 @@ function login($username, $pass, $host = null, $cookiecheck = false)
// Convert username to lowercase. If storage backend
// is case-insensitive we need to store always the same username (#1487113)
if ($config['login_lc']) {
- $username = mb_strtolower($username);
+ if ($config['login_lc'] == 2 || $config['login_lc'] === true) {
+ $username = mb_strtolower($username);
+ }
+ else if (strpos($username, '@')) {
+ // lowercase domain name
+ list($local, $domain) = explode('@', $username);
+ $username = $local . '@' . mb_strtolower($domain);
+ }
}
// try to resolve email address from virtuser table
@@ -463,17 +472,13 @@ function login($username, $pass, $host = null, $cookiecheck = false)
// Here we need IDNA ASCII
// Only rcube_contacts class is using domain names in Unicode
- $host = rcube_utils::idn_to_ascii($host);
- if (strpos($username, '@')) {
- // lowercase domain name
- list($local, $domain) = explode('@', $username);
- $username = $local . '@' . mb_strtolower($domain);
- $username = rcube_utils::idn_to_ascii($username);
- }
+ $host = rcube_utils::idn_to_ascii($host);
+ $username = rcube_utils::idn_to_ascii($username);
// user already registered -> overwrite username
- if ($user = rcube_user::query($username, $host))
+ if ($user = rcube_user::query($username, $host)) {
$username = $user->data['username'];
+ }
$storage = $this->get_storage();
@@ -1204,7 +1209,7 @@ public function format_date($date, $format = null, $convert = true)
}
else {
if (!empty($date)) {
- $timestamp = rcube_strtotime($date);
+ $timestamp = rcube_utils::strtotime($date);
}
if (empty($timestamp)) {
@@ -1769,10 +1774,7 @@ public function display_server_error($fallback = null, $fallback_args = null)
$err_code = $this->storage->get_error_code();
$res_code = $this->storage->get_response_code();
- if ($err_code < 0) {
- $this->output->show_message('storageerror', 'error');
- }
- else if ($res_code == rcube_storage::NOPERM) {
+ if ($res_code == rcube_storage::NOPERM) {
$this->output->show_message('errornoperm', 'error');
}
else if ($res_code == rcube_storage::READONLY) {
@@ -1787,6 +1789,9 @@ public function display_server_error($fallback = null, $fallback_args = null)
$this->output->show_message('servererrormsg', 'error', array('msg' => $err_str));
}
}
+ else if ($err_code < 0) {
+ $this->output->show_message('storageerror', 'error');
+ }
else if ($fallback) {
$this->output->show_message($fallback, 'error', $fallback_args);
}
1,439 program/include/rcube.php
View
@@ -25,364 +25,372 @@
* Base class of the Roundcube Framework
* implemented as singleton
*
- * @package Core
+ * @package Framework
+ * @subpackage Core
*/
class rcube
{
- const INIT_WITH_DB = 1;
- const INIT_WITH_PLUGINS = 2;
-
- /**
- * Singleton instace of rcube
- *
- * @var rcmail
- */
- static protected $instance;
-
- /**
- * Stores instance of rcube_config.
- *
- * @var rcube_config
- */
- public $config;
-
- /**
- * Instace of database class.
- *
- * @var rcube_pdo
- */
- public $db;
-
- /**
- * Instace of Memcache class.
- *
- * @var Memcache
- */
- public $memcache;
-
- /**
- * Instace of rcube_session class.
- *
- * @var rcube_session
- */
- public $session;
-
- /**
- * Instance of rcube_smtp class.
- *
- * @var rcube_smtp
- */
- public $smtp;
-
- /**
- * Instance of rcube_storage class.
- *
- * @var rcube_storage
- */
- public $storage;
-
- /**
- * Instance of rcube_output class.
- *
- * @var rcube_output
- */
- public $output;
-
- /**
- * Instance of rcube_plugin_api.
- *
- * @var rcube_plugin_api
- */
- public $plugins;
-
-
- /* private/protected vars */
- protected $texts;
- protected $caches = array();
- protected $shutdown_functions = array();
- protected $expunge_cache = false;
-
-
- /**
- * This implements the 'singleton' design pattern
- *
- * @param integer Options to initialize with this instance. See rcube::INIT_WITH_* constants
- * @return rcube The one and only instance
- */
- static function get_instance($mode = 0)
- {
- if (!self::$instance) {
- self::$instance = new rcube();
- self::$instance->init($mode);
- }
+ const INIT_WITH_DB = 1;
+ const INIT_WITH_PLUGINS = 2;
- return self::$instance;
- }
-
-
- /**
- * Private constructor
- */
- protected function __construct()
- {
- // load configuration
- $this->config = new rcube_config();
- $this->plugins = new rcube_dummy_plugin_api;
-
- register_shutdown_function(array($this, 'shutdown'));
- }
-
-
- /**
- * Initial startup function
- */
- protected function init($mode = 0)
- {
- // initialize syslog
- if ($this->config->get('log_driver') == 'syslog') {
- $syslog_id = $this->config->get('syslog_id', 'roundcube');
- $syslog_facility = $this->config->get('syslog_facility', LOG_USER);
- openlog($syslog_id, LOG_ODELAY, $syslog_facility);
- }
+ /**
+ * Singleton instace of rcube
+ *
+ * @var rcmail
+ */
+ static protected $instance;
- // connect to database
- if ($mode & self::INIT_WITH_DB) {
- $this->get_dbh();
- }
+ /**
+ * Stores instance of rcube_config.
+ *
+ * @var rcube_config
+ */
+ public $config;
+
+ /**
+ * Instace of database class.
+ *
+ * @var rcube_db
+ */
+ public $db;
+
+ /**
+ * Instace of Memcache class.
+ *
+ * @var Memcache
+ */
+ public $memcache;
+
+ /**
+ * Instace of rcube_session class.
+ *
+ * @var rcube_session
+ */
+ public $session;
+
+ /**
+ * Instance of rcube_smtp class.
+ *
+ * @var rcube_smtp
+ */
+ public $smtp;
+
+ /**
+ * Instance of rcube_storage class.
+ *
+ * @var rcube_storage
+ */
+ public $storage;
+
+ /**
+ * Instance of rcube_output class.
+ *
+ * @var rcube_output
+ */
+ public $output;
+
+ /**
+ * Instance of rcube_plugin_api.
+ *
+ * @var rcube_plugin_api
+ */
+ public $plugins;
- // create plugin API and load plugins
- if ($mode & self::INIT_WITH_PLUGINS) {
- $this->plugins = rcube_plugin_api::get_instance();
+
+ /* private/protected vars */
+ protected $texts;
+ protected $caches = array();
+ protected $shutdown_functions = array();
+ protected $expunge_cache = false;
+
+
+ /**
+ * This implements the 'singleton' design pattern
+ *
+ * @param integer Options to initialize with this instance. See rcube::INIT_WITH_* constants
+ *
+ * @return rcube The one and only instance
+ */
+ static function get_instance($mode = 0)
+ {
+ if (!self::$instance) {
+ self::$instance = new rcube();
+ self::$instance->init($mode);
+ }
+
+ return self::$instance;
}
- }
-
-
- /**
- * Get the current database connection
- *
- * @return rcube_pdo Database connection object
- */
- public function get_dbh()
- {
- if (!$this->db) {
- $config_all = $this->config->all();
- $this->db = rcube_db::factory($config_all['db_dsnw'], $config_all['db_dsnr'], $config_all['db_persistent']);
- $this->db->set_debug((bool)$config_all['sql_debug']);
+
+
+ /**
+ * Private constructor
+ */
+ protected function __construct()
+ {
+ // load configuration
+ $this->config = new rcube_config;
+ $this->plugins = new rcube_dummy_plugin_api;
+
+ register_shutdown_function(array($this, 'shutdown'));
}
- return $this->db;
- }
-
-
- /**
- * Get global handle for memcache access
- *
- * @return object Memcache
- */
- public function get_memcache()
- {
- if (!isset($this->memcache)) {
- // no memcache support in PHP
- if (!class_exists('Memcache')) {
- $this->memcache = false;
- return false;
- }
- $this->memcache = new Memcache;
- $this->mc_available = 0;
+ /**
+ * Initial startup function
+ */
+ protected function init($mode = 0)
+ {
+ // initialize syslog
+ if ($this->config->get('log_driver') == 'syslog') {
+ $syslog_id = $this->config->get('syslog_id', 'roundcube');
+ $syslog_facility = $this->config->get('syslog_facility', LOG_USER);
+ openlog($syslog_id, LOG_ODELAY, $syslog_facility);
+ }
- // add all configured hosts to pool
- $pconnect = $this->config->get('memcache_pconnect', true);
- foreach ($this->config->get('memcache_hosts', array()) as $host) {
- if (substr($host, 0, 7) != 'unix://') {
- list($host, $port) = explode(':', $host);
- if (!$port) $port = 11211;
+ // connect to database
+ if ($mode & self::INIT_WITH_DB) {
+ $this->get_dbh();
}
- else {
- $port = 0;
+
+ // create plugin API and load plugins
+ if ($mode & self::INIT_WITH_PLUGINS) {
+ $this->plugins = rcube_plugin_api::get_instance();
}
+ }
- $this->mc_available += intval($this->memcache->addServer($host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure')));
- }
- // test connection and failover (will result in $this->mc_available == 0 on complete failure)
- $this->memcache->increment('__CONNECTIONTEST__', 1); // NOP if key doesn't exist
+ /**
+ * Get the current database connection
+ *
+ * @return rcube_db Database object
+ */
+ public function get_dbh()
+ {
+ if (!$this->db) {
+ $config_all = $this->config->all();
+ $this->db = rcube_db::factory($config_all['db_dsnw'], $config_all['db_dsnr'], $config_all['db_persistent']);
+ $this->db->set_debug((bool)$config_all['sql_debug']);
+ }
- if (!$this->mc_available)
- $this->memcache = false;
+ return $this->db;
}
- return $this->memcache;
- }
+ /**
+ * Get global handle for memcache access
+ *
+ * @return object Memcache
+ */
+ public function get_memcache()
+ {
+ if (!isset($this->memcache)) {
+ // no memcache support in PHP
+ if (!class_exists('Memcache')) {
+ $this->memcache = false;
+ return false;
+ }
- /**
- * Callback for memcache failure
- */
- public function memcache_failure($host, $port)
- {
- static $seen = array();
+ $this->memcache = new Memcache;
+ $this->mc_available = 0;
- // only report once
- if (!$seen["$host:$port"]++) {
- $this->mc_available--;
- self::raise_error(array('code' => 604, 'type' => 'db',
- 'line' => __LINE__, 'file' => __FILE__,
- 'message' => "Memcache failure on host $host:$port"),
- true, false);
- }
- }
-
-
- /**
- * Initialize and get cache object
- *
- * @param string $name Cache identifier
- * @param string $type Cache type ('db', 'apc' or 'memcache')
- * @param string $ttl Expiration time for cache items
- * @param bool $packed Enables/disables data serialization
- *
- * @return rcube_cache Cache object
- */
- public function get_cache($name, $type='db', $ttl=0, $packed=true)
- {
- if (!isset($this->caches[$name]) && ($userid = $this->get_user_id())) {
- $this->caches[$name] = new rcube_cache($type, $userid, $name, $ttl, $packed);
- }
+ // add all configured hosts to pool
+ $pconnect = $this->config->get('memcache_pconnect', true);
+ foreach ($this->config->get('memcache_hosts', array()) as $host) {
+ if (substr($host, 0, 7) != 'unix://') {
+ list($host, $port) = explode(':', $host);
+ if (!$port) $port = 11211;
+ }
+ else {
+ $port = 0;
+ }
- return $this->caches[$name];
- }
-
-
- /**
- * Create SMTP object and connect to server
- *
- * @param boolean True if connection should be established
- */
- public function smtp_init($connect = false)
- {
- $this->smtp = new rcube_smtp();
-
- if ($connect)
- $this->smtp->connect();
- }
-
-
- /**
- * Initialize and get storage object
- *
- * @return rcube_storage Storage object
- */
- public function get_storage()
- {
- // already initialized
- if (!is_object($this->storage)) {
- $this->storage_init();
- }
+ $this->mc_available += intval($this->memcache->addServer(
+ $host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure')));
+ }
- return $this->storage;
- }
+ // test connection and failover (will result in $this->mc_available == 0 on complete failure)
+ $this->memcache->increment('__CONNECTIONTEST__', 1); // NOP if key doesn't exist
+ if (!$this->mc_available) {
+ $this->memcache = false;
+ }
+ }
- /**
- * Initialize storage object
- */
- public function storage_init()
- {
- // already initialized
- if (is_object($this->storage)) {
- return;
+ return $this->memcache;
}
- $driver = $this->config->get('storage_driver', 'imap');
- $driver_class = "rcube_{$driver}";
- if (!class_exists($driver_class)) {
- self::raise_error(array(
- 'code' => 700, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Storage driver class ($driver) not found!"),
- true, true);
+ /**
+ * Callback for memcache failure
+ */
+ public function memcache_failure($host, $port)
+ {
+ static $seen = array();
+
+ // only report once
+ if (!$seen["$host:$port"]++) {
+ $this->mc_available--;
+ self::raise_error(array(
+ 'code' => 604, 'type' => 'db',
+ 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => "Memcache failure on host $host:$port"),
+ true, false);
+ }
}
- // Initialize storage object
- $this->storage = new $driver_class;
- // for backward compat. (deprecated, will be removed)
- $this->imap = $this->storage;
+ /**
+ * Initialize and get cache object
+ *
+ * @param string $name Cache identifier
+ * @param string $type Cache type ('db', 'apc' or 'memcache')
+ * @param string $ttl Expiration time for cache items
+ * @param bool $packed Enables/disables data serialization
+ *
+ * @return rcube_cache Cache object
+ */
+ public function get_cache($name, $type='db', $ttl=0, $packed=true)
+ {
+ if (!isset($this->caches[$name]) && ($userid = $this->get_user_id())) {
+ $this->caches[$name] = new rcube_cache($type, $userid, $name, $ttl, $packed);
+ }
- // enable caching of mail data
- $storage_cache = $this->config->get("{$driver}_cache");
- $messages_cache = $this->config->get('messages_cache');
- // for backward compatybility
- if ($storage_cache === null && $messages_cache === null && $this->config->get('enable_caching')) {
- $storage_cache = 'db';
- $messages_cache = true;
+ return $this->caches[$name];
}
- if ($storage_cache)
- $this->storage->set_caching($storage_cache);
- if ($messages_cache)
- $this->storage->set_messages_caching(true);
- // set pagesize from config
- $pagesize = $this->config->get('mail_pagesize');
- if (!$pagesize) {
- $pagesize = $this->config->get('pagesize', 50);
+ /**
+ * Create SMTP object and connect to server
+ *
+ * @param boolean True if connection should be established
+ */
+ public function smtp_init($connect = false)
+ {
+ $this->smtp = new rcube_smtp();
+
+ if ($connect) {
+ $this->smtp->connect();
+ }
}
- $this->storage->set_pagesize($pagesize);
-
- // set class options
- $options = array(
- 'auth_type' => $this->config->get("{$driver}_auth_type", 'check'),
- 'auth_cid' => $this->config->get("{$driver}_auth_cid"),
- 'auth_pw' => $this->config->get("{$driver}_auth_pw"),
- 'debug' => (bool) $this->config->get("{$driver}_debug"),
- 'force_caps' => (bool) $this->config->get("{$driver}_force_caps"),
- 'timeout' => (int) $this->config->get("{$driver}_timeout"),
- 'skip_deleted' => (bool) $this->config->get('skip_deleted'),
- 'driver' => $driver,
- );
-
- if (!empty($_SESSION['storage_host'])) {
- $options['host'] = $_SESSION['storage_host'];
- $options['user'] = $_SESSION['username'];
- $options['port'] = $_SESSION['storage_port'];
- $options['ssl'] = $_SESSION['storage_ssl'];
- $options['password'] = $this->decrypt($_SESSION['password']);
- $_SESSION[$driver.'_host'] = $_SESSION['storage_host'];
+
+
+ /**
+ * Initialize and get storage object
+ *
+ * @return rcube_storage Storage object
+ */
+ public function get_storage()
+ {
+ // already initialized
+ if (!is_object($this->storage)) {
+ $this->storage_init();
+ }
+
+ return $this->storage;
}
- $options = $this->plugins->exec_hook("storage_init", $options);
- // for backward compat. (deprecated, to be removed)
- $options = $this->plugins->exec_hook("imap_init", $options);
+ /**
+ * Initialize storage object
+ */
+ public function storage_init()
+ {
+ // already initialized
+ if (is_object($this->storage)) {
+ return;
+ }
- $this->storage->set_options($options);
- $this->set_storage_prop();
- }
+ $driver = $this->config->get('storage_driver', 'imap');
+ $driver_class = "rcube_{$driver}";
+ if (!class_exists($driver_class)) {
+ self::raise_error(array(
+ 'code' => 700, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Storage driver class ($driver) not found!"),
+ true, true);
+ }
- /**
- * Set storage parameters.
- * This must be done AFTER connecting to the server!
- */
- protected function set_storage_prop()
- {
- $storage = $this->get_storage();
+ // Initialize storage object
+ $this->storage = new $driver_class;
- $storage->set_charset($this->config->get('default_charset', RCMAIL_CHARSET));
+ // for backward compat. (deprecated, will be removed)
+ $this->imap = $this->storage;
- if ($default_folders = $this->config->get('default_folders')) {
- $storage->set_default_folders($default_folders);
- }
- if (isset($_SESSION['mbox'])) {
- $storage->set_folder($_SESSION['mbox']);
+ // enable caching of mail data
+ $storage_cache = $this->config->get("{$driver}_cache");
+ $messages_cache = $this->config->get('messages_cache');
+ // for backward compatybility
+ if ($storage_cache === null && $messages_cache === null && $this->config->get('enable_caching')) {
+ $storage_cache = 'db';
+ $messages_cache = true;
+ }
+
+ if ($storage_cache) {
+ $this->storage->set_caching($storage_cache);
+ }
+ if ($messages_cache) {
+ $this->storage->set_messages_caching(true);
+ }
+
+ // set pagesize from config
+ $pagesize = $this->config->get('mail_pagesize');
+ if (!$pagesize) {
+ $pagesize = $this->config->get('pagesize', 50);
+ }
+ $this->storage->set_pagesize($pagesize);
+
+ // set class options
+ $options = array(
+ 'auth_type' => $this->config->get("{$driver}_auth_type", 'check'),
+ 'auth_cid' => $this->config->get("{$driver}_auth_cid"),
+ 'auth_pw' => $this->config->get("{$driver}_auth_pw"),
+ 'debug' => (bool) $this->config->get("{$driver}_debug"),
+ 'force_caps' => (bool) $this->config->get("{$driver}_force_caps"),
+ 'timeout' => (int) $this->config->get("{$driver}_timeout"),
+ 'skip_deleted' => (bool) $this->config->get('skip_deleted'),
+ 'driver' => $driver,
+ );
+
+ if (!empty($_SESSION['storage_host'])) {
+ $options['host'] = $_SESSION['storage_host'];
+ $options['user'] = $_SESSION['username'];
+ $options['port'] = $_SESSION['storage_port'];
+ $options['ssl'] = $_SESSION['storage_ssl'];
+ $options['password'] = $this->decrypt($_SESSION['password']);
+ $_SESSION[$driver.'_host'] = $_SESSION['storage_host'];
+ }
+
+ $options = $this->plugins->exec_hook("storage_init", $options);
+
+ // for backward compat. (deprecated, to be removed)
+ $options = $this->plugins->exec_hook("imap_init", $options);
+
+ $this->storage->set_options($options);
+ $this->set_storage_prop();
}
- if (isset($_SESSION['page'])) {
- $storage->set_page($_SESSION['page']);
+
+
+ /**
+ * Set storage parameters.
+ * This must be done AFTER connecting to the server!
+ */
+ protected function set_storage_prop()
+ {
+ $storage = $this->get_storage();
+
+ $storage->set_charset($this->config->get('default_charset', RCMAIL_CHARSET));
+
+ if ($default_folders = $this->config->get('default_folders')) {
+ $storage->set_default_folders($default_folders);
+ }
+ if (isset($_SESSION['mbox'])) {
+ $storage->set_folder($_SESSION['mbox']);
+ }
+ if (isset($_SESSION['page'])) {
+ $storage->set_page($_SESSION['page']);
+ }
}
- }
/**
@@ -397,12 +405,17 @@ public function session_init()
$sess_name = $this->config->get('session_name');
$sess_domain = $this->config->get('session_domain');
+ $sess_path = $this->config->get('session_path');
$lifetime = $this->config->get('session_lifetime', 0) * 60;
// set session domain
if ($sess_domain) {
ini_set('session.cookie_domain', $sess_domain);
}
+ // set session path
+ if ($sess_path) {
+ ini_set('session.cookie_path', $sess_path);
+ }
// set session garbage collecting time according to session_lifetime
if ($lifetime) {
ini_set('session.gc_maxlifetime', $lifetime * 2);
@@ -492,433 +505,469 @@ public function cache_gc()
}
- /**
- * Get localized text in the desired language
- *
- * @param mixed $attrib Named parameters array or label name
- * @param string $domain Label domain (plugin) name
- *
- * @return string Localized text
- */
- public function gettext($attrib, $domain=null)
- {
- // load localization files if not done yet
- if (empty($this->texts))
- $this->load_language();
-
- // extract attributes
- if (is_string($attrib))
- $attrib = array('name' => $attrib);
-
- $name = $attrib['name'] ? $attrib['name'] : '';
-
- // attrib contain text values: use them from now
- if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us']))
- $this->texts[$name] = $setval;
-
- // check for text with domain
- if ($domain && ($text = $this->texts[$domain.'.'.$name]))
- ;
- // text does not exist
- else if (!($text = $this->texts[$name])) {
- return "[$name]";
- }
+ /**
+ * Get localized text in the desired language
+ *
+ * @param mixed $attrib Named parameters array or label name
+ * @param string $domain Label domain (plugin) name
+ *
+ * @return string Localized text
+ */
+ public function gettext($attrib, $domain=null)
+ {
+ // load localization files if not done yet
+ if (empty($this->texts)) {
+ $this->load_language();
+ }
- // replace vars in text
- if (is_array($attrib['vars'])) {
- foreach ($attrib['vars'] as $var_key => $var_value)
- $text = str_replace($var_key[0]!='$' ? '$'.$var_key : $var_key, $var_value, $text);
- }
+ // extract attributes
+ if (is_string($attrib)) {
+ $attrib = array('name' => $attrib);
+ }
- // format output
- if (($attrib['uppercase'] && strtolower($attrib['uppercase']=='first')) || $attrib['ucfirst'])
- return ucfirst($text);
- else if ($attrib['uppercase'])
- return mb_strtoupper($text);
- else if ($attrib['lowercase'])
- return mb_strtolower($text);
-
- return strtr($text, array('\n' => "\n"));
- }
-
-
- /**
- * Check if the given text label exists
- *
- * @param string $name Label name
- * @param string $domain Label domain (plugin) name or '*' for all domains
- * @param string $ref_domain Sets domain name if label is found
- *
- * @return boolean True if text exists (either in the current language or in en_US)
- */
- public function text_exists($name, $domain = null, &$ref_domain = null)
- {
- // load localization files if not done yet
- if (empty($this->texts))
- $this->load_language();
-
- if (isset($this->texts[$name])) {
- $ref_domain = '';
- return true;
- }
+ $name = $attrib['name'] ? $attrib['name'] : '';
+
+ // attrib contain text values: use them from now
+ if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us'])) {
+ $this->texts[$name] = $setval;
+ }
- // any of loaded domains (plugins)
-