diff options
Diffstat (limited to 'plugins')
47 files changed, 320 insertions, 63 deletions
diff --git a/plugins/acl/tests/Acl.php b/plugins/acl/tests/Acl.php index e752ac977..56ae3b5bb 100644 --- a/plugins/acl/tests/Acl.php +++ b/plugins/acl/tests/Acl.php @@ -5,7 +5,7 @@ class Acl_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../acl.php'; + include_once __DIR__ . '/../acl.php'; } /** diff --git a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php index 1c54ffc42..55e8c441e 100644 --- a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php +++ b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php @@ -5,7 +5,7 @@ class AdditionalMessageHeaders_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../additional_message_headers.php'; + include_once __DIR__ . '/../additional_message_headers.php'; } /** diff --git a/plugins/archive/tests/Archive.php b/plugins/archive/tests/Archive.php index 0a1eeae11..17fcdf7a1 100644 --- a/plugins/archive/tests/Archive.php +++ b/plugins/archive/tests/Archive.php @@ -5,7 +5,7 @@ class Archive_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../archive.php'; + include_once __DIR__ . '/../archive.php'; } /** diff --git a/plugins/autologon/tests/Autologon.php b/plugins/autologon/tests/Autologon.php index 0de193e4a..f3f6b4206 100644 --- a/plugins/autologon/tests/Autologon.php +++ b/plugins/autologon/tests/Autologon.php @@ -5,7 +5,7 @@ class Autologon_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../autologon.php'; + include_once __DIR__ . '/../autologon.php'; } /** diff --git a/plugins/database_attachments/tests/DatabaseAttachments.php b/plugins/database_attachments/tests/DatabaseAttachments.php index f260737ab..15ea5f44e 100644 --- a/plugins/database_attachments/tests/DatabaseAttachments.php +++ b/plugins/database_attachments/tests/DatabaseAttachments.php @@ -5,7 +5,7 @@ class DatabaseAttachments_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../database_attachments.php'; + include_once __DIR__ . '/../database_attachments.php'; } /** diff --git a/plugins/debug_logger/debug_logger.php b/plugins/debug_logger/debug_logger.php index 88237d767..07190e5a1 100644 --- a/plugins/debug_logger/debug_logger.php +++ b/plugins/debug_logger/debug_logger.php @@ -66,8 +66,8 @@ class debug_logger extends rcube_plugin { function init() { - require_once(dirname(__FILE__).'/runlog/runlog.php'); - $this->runlog = new runlog(); + require_once(__DIR__ . '/runlog/runlog.php'); + $this->runlog = new runlog(); if(!rcmail::get_instance()->config->get('log_dir')){ rcmail::get_instance()->config->set('log_dir',INSTALL_PATH.'logs'); @@ -83,10 +83,10 @@ class debug_logger extends rcube_plugin $action = rcmail::get_instance()->action; $task = rcmail::get_instance()->task; if($action){ - $start_string .= "Action: ".$action.". "; + $start_string .= "Action: ".$action.". "; } if($task){ - $start_string .= "Task: ".$task.". "; + $start_string .= "Task: ".$task.". "; } $this->runlog->start($start_string); diff --git a/plugins/debug_logger/tests/DebugLogger.php b/plugins/debug_logger/tests/DebugLogger.php index de20a069d..8dd0c03fe 100644 --- a/plugins/debug_logger/tests/DebugLogger.php +++ b/plugins/debug_logger/tests/DebugLogger.php @@ -5,7 +5,7 @@ class DebugLogger_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../debug_logger.php'; + include_once __DIR__ . '/../debug_logger.php'; } /** diff --git a/plugins/emoticons/tests/Emoticons.php b/plugins/emoticons/tests/Emoticons.php index 4b6c303c2..e04502285 100644 --- a/plugins/emoticons/tests/Emoticons.php +++ b/plugins/emoticons/tests/Emoticons.php @@ -5,7 +5,7 @@ class Emoticons_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../emoticons.php'; + include_once __DIR__ . '/../emoticons.php'; } /** diff --git a/plugins/enigma/tests/Enigma.php b/plugins/enigma/tests/Enigma.php index 0d0d8f8ae..3972694fc 100644 --- a/plugins/enigma/tests/Enigma.php +++ b/plugins/enigma/tests/Enigma.php @@ -5,7 +5,7 @@ class Enigma_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../enigma.php'; + include_once __DIR__ . '/../enigma.php'; } /** diff --git a/plugins/example_addressbook/example_addressbook.php b/plugins/example_addressbook/example_addressbook.php index 31077adf7..22e230c6f 100644 --- a/plugins/example_addressbook/example_addressbook.php +++ b/plugins/example_addressbook/example_addressbook.php @@ -1,6 +1,6 @@ <?php -require_once(dirname(__FILE__) . '/example_addressbook_backend.php'); +require_once(__DIR__ . '/example_addressbook_backend.php'); /** * Sample plugin to add a new address book diff --git a/plugins/example_addressbook/tests/ExampleAddressbook.php b/plugins/example_addressbook/tests/ExampleAddressbook.php index 4a54bd950..762ee7307 100644 --- a/plugins/example_addressbook/tests/ExampleAddressbook.php +++ b/plugins/example_addressbook/tests/ExampleAddressbook.php @@ -5,7 +5,7 @@ class ExampleAddressbook_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../example_addressbook.php'; + include_once __DIR__ . '/../example_addressbook.php'; } /** diff --git a/plugins/filesystem_attachments/tests/FilesystemAttachments.php b/plugins/filesystem_attachments/tests/FilesystemAttachments.php index dcab315d3..3b60e12c9 100644 --- a/plugins/filesystem_attachments/tests/FilesystemAttachments.php +++ b/plugins/filesystem_attachments/tests/FilesystemAttachments.php @@ -5,7 +5,7 @@ class FilesystemAttachments_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../filesystem_attachments.php'; + include_once __DIR__ . '/../filesystem_attachments.php'; } /** diff --git a/plugins/help/skins/larry/help.png b/plugins/help/skins/larry/help.png Binary files differindex fe88ed4c9..e815e5444 100644 --- a/plugins/help/skins/larry/help.png +++ b/plugins/help/skins/larry/help.png diff --git a/plugins/help/tests/Help.php b/plugins/help/tests/Help.php index baba492ae..ff5771bf9 100644 --- a/plugins/help/tests/Help.php +++ b/plugins/help/tests/Help.php @@ -5,7 +5,7 @@ class Help_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../help.php'; + include_once __DIR__ . '/../help.php'; } /** diff --git a/plugins/hide_blockquote/tests/HideBlockquote.php b/plugins/hide_blockquote/tests/HideBlockquote.php index 030c05324..90e209459 100644 --- a/plugins/hide_blockquote/tests/HideBlockquote.php +++ b/plugins/hide_blockquote/tests/HideBlockquote.php @@ -5,7 +5,7 @@ class HideBlockquote_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../hide_blockquote.php'; + include_once __DIR__ . '/../hide_blockquote.php'; } /** diff --git a/plugins/http_authentication/tests/HttpAuthentication.php b/plugins/http_authentication/tests/HttpAuthentication.php index c17236821..5de968d87 100644 --- a/plugins/http_authentication/tests/HttpAuthentication.php +++ b/plugins/http_authentication/tests/HttpAuthentication.php @@ -5,7 +5,7 @@ class HttpAuthentication_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../http_authentication.php'; + include_once __DIR__ . '/../http_authentication.php'; } /** diff --git a/plugins/identity_select/tests/IdentitySelect.php b/plugins/identity_select/tests/IdentitySelect.php index 3d7269711..461e79d85 100644 --- a/plugins/identity_select/tests/IdentitySelect.php +++ b/plugins/identity_select/tests/IdentitySelect.php @@ -5,7 +5,7 @@ class IdentitySelect_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../identity_select.php'; + include_once __DIR__ . '/../identity_select.php'; } /** diff --git a/plugins/jqueryui/tests/Jqueryui.php b/plugins/jqueryui/tests/Jqueryui.php index 3bcd27c9f..ee25818ec 100644 --- a/plugins/jqueryui/tests/Jqueryui.php +++ b/plugins/jqueryui/tests/Jqueryui.php @@ -5,7 +5,7 @@ class Jqueryui_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../jqueryui.php'; + include_once __DIR__ . '/../jqueryui.php'; } /** diff --git a/plugins/jqueryui/themes/larry/images/animated-overlay.gif b/plugins/jqueryui/themes/larry/images/animated-overlay.gif Binary files differindex d441f75eb..d441f75eb 100755..100644 --- a/plugins/jqueryui/themes/larry/images/animated-overlay.gif +++ b/plugins/jqueryui/themes/larry/images/animated-overlay.gif diff --git a/plugins/jqueryui/themes/larry/images/ui-dialog-close.png b/plugins/jqueryui/themes/larry/images/ui-dialog-close.png Binary files differindex 3fc403f52..bc2e244ac 100644 --- a/plugins/jqueryui/themes/larry/images/ui-dialog-close.png +++ b/plugins/jqueryui/themes/larry/images/ui-dialog-close.png diff --git a/plugins/jqueryui/themes/larry/images/ui-icons-datepicker.png b/plugins/jqueryui/themes/larry/images/ui-icons-datepicker.png Binary files differindex 144ecfe77..77ebd0c5c 100644 --- a/plugins/jqueryui/themes/larry/images/ui-icons-datepicker.png +++ b/plugins/jqueryui/themes/larry/images/ui-icons-datepicker.png diff --git a/plugins/jqueryui/themes/larry/images/ui-icons_004458_256x240.png b/plugins/jqueryui/themes/larry/images/ui-icons_004458_256x240.png Binary files differindex 083a564f0..31a4ccacf 100755..100644 --- a/plugins/jqueryui/themes/larry/images/ui-icons_004458_256x240.png +++ b/plugins/jqueryui/themes/larry/images/ui-icons_004458_256x240.png diff --git a/plugins/jqueryui/themes/larry/images/ui-icons_d7211e_256x240.png b/plugins/jqueryui/themes/larry/images/ui-icons_d7211e_256x240.png Binary files differindex fdc2c494f..0ad2dc38d 100755..100644 --- a/plugins/jqueryui/themes/larry/images/ui-icons_d7211e_256x240.png +++ b/plugins/jqueryui/themes/larry/images/ui-icons_d7211e_256x240.png diff --git a/plugins/legacy_browser/tests/LegacyBrowser.php b/plugins/legacy_browser/tests/LegacyBrowser.php index 8e9762fb2..7a35ee5b6 100644 --- a/plugins/legacy_browser/tests/LegacyBrowser.php +++ b/plugins/legacy_browser/tests/LegacyBrowser.php @@ -5,7 +5,7 @@ class Legacy_Browser_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../legacy_browser.php'; + include_once __DIR__ . '/../legacy_browser.php'; } /** diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js index 8340b179d..4d60833be 100644 --- a/plugins/managesieve/managesieve.js +++ b/plugins/managesieve/managesieve.js @@ -736,6 +736,9 @@ function smart_field_init(field) if (field.attr('disabled')) area.hide(); + // disable the original field anyway, we don't want it in POST + else + field.prop('disabled', true); field.after(area); diff --git a/plugins/managesieve/tests/Managesieve.php b/plugins/managesieve/tests/Managesieve.php index d802f5614..6e930b81d 100644 --- a/plugins/managesieve/tests/Managesieve.php +++ b/plugins/managesieve/tests/Managesieve.php @@ -5,7 +5,7 @@ class Managesieve_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../managesieve.php'; + include_once __DIR__ . '/../managesieve.php'; } /** diff --git a/plugins/managesieve/tests/Parser.php b/plugins/managesieve/tests/Parser.php index 9050f09c6..33edce0f0 100644 --- a/plugins/managesieve/tests/Parser.php +++ b/plugins/managesieve/tests/Parser.php @@ -5,7 +5,7 @@ class Parser extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_script.php'; + include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_script.php'; } /** @@ -34,7 +34,7 @@ class Parser extends PHPUnit_Framework_TestCase */ function data_parser() { - $dir_path = realpath(dirname(__FILE__) . '/src'); + $dir_path = realpath(__DIR__ . '/src'); $dir = opendir($dir_path); $result = array(); diff --git a/plugins/managesieve/tests/Tokenizer.php b/plugins/managesieve/tests/Tokenizer.php index e71bae015..f50ed75b7 100644 --- a/plugins/managesieve/tests/Tokenizer.php +++ b/plugins/managesieve/tests/Tokenizer.php @@ -5,7 +5,7 @@ class Tokenizer extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_script.php'; + include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_script.php'; } function data_tokenizer() diff --git a/plugins/managesieve/tests/Vacation.php b/plugins/managesieve/tests/Vacation.php index e34eb7aa2..942525c2f 100644 --- a/plugins/managesieve/tests/Vacation.php +++ b/plugins/managesieve/tests/Vacation.php @@ -5,8 +5,8 @@ class Managesieve_Vacation extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_engine.php'; - include_once dirname(__FILE__) . '/../lib/Roundcube/rcube_sieve_vacation.php'; + include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_engine.php'; + include_once __DIR__ . '/../lib/Roundcube/rcube_sieve_vacation.php'; } /** diff --git a/plugins/markasjunk/tests/Markasjunk.php b/plugins/markasjunk/tests/Markasjunk.php index cdf13255e..73494b0ec 100644 --- a/plugins/markasjunk/tests/Markasjunk.php +++ b/plugins/markasjunk/tests/Markasjunk.php @@ -5,7 +5,7 @@ class Markasjunk_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../markasjunk.php'; + include_once __DIR__ . '/../markasjunk.php'; } /** diff --git a/plugins/new_user_dialog/tests/NewUserDialog.php b/plugins/new_user_dialog/tests/NewUserDialog.php index 3a52f20f3..e58489a09 100644 --- a/plugins/new_user_dialog/tests/NewUserDialog.php +++ b/plugins/new_user_dialog/tests/NewUserDialog.php @@ -5,7 +5,7 @@ class NewUserDialog_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../new_user_dialog.php'; + include_once __DIR__ . '/../new_user_dialog.php'; } /** diff --git a/plugins/new_user_identity/tests/NewUserIdentity.php b/plugins/new_user_identity/tests/NewUserIdentity.php index c1d385853..21197362e 100644 --- a/plugins/new_user_identity/tests/NewUserIdentity.php +++ b/plugins/new_user_identity/tests/NewUserIdentity.php @@ -5,7 +5,7 @@ class NewUserIdentity_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../new_user_identity.php'; + include_once __DIR__ . '/../new_user_identity.php'; } /** diff --git a/plugins/newmail_notifier/tests/NewmailNotifier.php b/plugins/newmail_notifier/tests/NewmailNotifier.php index 571912a61..ccddccd39 100644 --- a/plugins/newmail_notifier/tests/NewmailNotifier.php +++ b/plugins/newmail_notifier/tests/NewmailNotifier.php @@ -5,7 +5,7 @@ class NewmailNotifier_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../newmail_notifier.php'; + include_once __DIR__ . '/../newmail_notifier.php'; } /** diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index 6610b4dae..94c4368fe 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -204,10 +204,11 @@ $config['password_ldap_search_filter'] = '(uid=%login)'; // LDAP password hash type // Standard LDAP encryption type which must be one of: crypt, -// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, ad or clear. +// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, ad, cram-md5 (dovecot style) or clear. // Please note that most encodage types require external libraries // to be included in your PHP installation, see function hashPassword in drivers/ldap.php for more info. -// Default: 'crypt' +// Multiple password Values can be generated by concatenating encodings with a +. E.g. 'cram-md5+crypt' +// Default: 'crypt'. $config['password_ldap_encodage'] = 'crypt'; // LDAP password attribute diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index 0c932372d..ac2ea3bd3 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -38,7 +38,8 @@ class rcube_ldap_password // Building user DN if ($userDN = $rcmail->config->get('password_ldap_userDN_mask')) { $userDN = self::substitute_vars($userDN); - } else { + } + else { $userDN = $this->search_userdn($rcmail); } @@ -78,13 +79,25 @@ class rcube_ldap_password return PASSWORD_CONNECT_ERROR; } - $crypted_pass = self::hash_password($passwd, $rcmail->config->get('password_ldap_encodage')); $force = $rcmail->config->get('password_ldap_force_replace'); $pwattr = $rcmail->config->get('password_ldap_pwattr'); $lchattr = $rcmail->config->get('password_ldap_lchattr'); $smbpwattr = $rcmail->config->get('password_ldap_samba_pwattr'); $smblchattr = $rcmail->config->get('password_ldap_samba_lchattr'); $samba = $rcmail->config->get('password_ldap_samba'); + $encodage = $rcmail->config->get('password_ldap_encodage'); + + // Support multiple userPassword values where desired. + // multiple encodings can be specified separated by '+' (e.g. "cram-md5+ssha") + $encodages = explode('+', $encodage); + $crypted_pass = array(); + + foreach ($encodages as $enc) { + $cpw = self::hash_password($passwd, $enc); + if (!empty($cpw)) { + $crypted_pass[] = $cpw; + } + } // Support password_ldap_samba option for backward compat. if ($samba && !$smbpwattr) { @@ -93,7 +106,7 @@ class rcube_ldap_password } // Crypt new password - if (!$crypted_pass) { + if (empty($crypted_pass)) { return PASSWORD_CRYPT_ERROR; } @@ -220,75 +233,124 @@ class rcube_ldap_password case 'crypt': $crypted_password = '{CRYPT}' . crypt($password_clear, self::random_salt(2)); break; + case 'ext_des': /* Extended DES crypt. see OpenBSD crypt man page */ if (!defined('CRYPT_EXT_DES') || CRYPT_EXT_DES == 0) { /* Your system crypt library does not support extended DES encryption */ return false; } + $crypted_password = '{CRYPT}' . crypt($password_clear, '_' . self::random_salt(8)); break; + case 'md5crypt': if (!defined('CRYPT_MD5') || CRYPT_MD5 == 0) { /* Your system crypt library does not support md5crypt encryption */ return false; } + $crypted_password = '{CRYPT}' . crypt($password_clear, '$1$' . self::random_salt(9)); break; + case 'blowfish': if (!defined('CRYPT_BLOWFISH') || CRYPT_BLOWFISH == 0) { /* Your system crypt library does not support blowfish encryption */ return false; } + /* Hardcoded to second blowfish version and set number of rounds */ $crypted_password = '{CRYPT}' . crypt($password_clear, '$2a$12$' . self::random_salt(13)); break; + case 'md5': $crypted_password = '{MD5}' . base64_encode(pack('H*', md5($password_clear))); break; + case 'sha': if (function_exists('sha1')) { /* Use PHP 4.3.0+ sha1 function, if it is available */ $crypted_password = '{SHA}' . base64_encode(pack('H*', sha1($password_clear))); - } else if (function_exists('mhash')) { + } + else if (function_exists('hash')) { + $crypted_password = '{SHA}' . base64_encode(hash('sha1', $password_clear, true)); + } + else if (function_exists('mhash')) { $crypted_password = '{SHA}' . base64_encode(mhash(MHASH_SHA1, $password_clear)); - } else { - /* Your PHP install does not have the mhash() function */ + } + else { + /* Your PHP install does not have the mhash()/hash() nor sha1() function */ return false; } break; + case 'ssha': + mt_srand((double) microtime() * 1000000); + $salt = substr(pack('h*', md5(mt_rand())), 0, 8); + if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) { - mt_srand((double) microtime() * 1000000 ); - $salt = mhash_keygen_s2k(MHASH_SHA1, $password_clear, substr(pack('h*', md5(mt_rand())), 0, 8), 4); - $crypted_password = '{SSHA}' . base64_encode(mhash(MHASH_SHA1, $password_clear . $salt) . $salt); - } else { - /* Your PHP install does not have the mhash() function */ + $salt = mhash_keygen_s2k(MHASH_SHA1, $password_clear, $salt, 4); + $password = mhash(MHASH_SHA1, $password_clear . $salt); + } + else if (function_exists('sha1')) { + $salt = substr(pack("H*", sha1($salt . $password_clear)), 0, 4); + $password = sha1($password_clear . $salt, true); + } + else if (function_exists('hash')) { + $salt = substr(pack("H*", hash('sha1', $salt . $password_clear)), 0, 4); + $password = hash('sha1', $password_clear . $salt, true); + } + + if ($password) { + $crypted_password = '{SSHA}' . base64_encode($password . $salt); + } + else { + /* Your PHP install does not have the mhash()/hash() nor sha1() function */ return false; } break; + + case 'smd5': + mt_srand((double) microtime() * 1000000); + $salt = substr(pack('h*', md5(mt_rand())), 0, 8); + if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) { - mt_srand((double) microtime() * 1000000 ); - $salt = mhash_keygen_s2k(MHASH_MD5, $password_clear, substr(pack('h*', md5(mt_rand())), 0, 8), 4); - $crypted_password = '{SMD5}' . base64_encode(mhash(MHASH_MD5, $password_clear . $salt) . $salt); - } else { - /* Your PHP install does not have the mhash() function */ - return false; + $salt = mhash_keygen_s2k(MHASH_MD5, $password_clear, $salt, 4); + $password = mhash(MHASH_MD5, $password_clear . $salt); } + else if (function_exists('hash')) { + $salt = substr(pack("H*", hash('md5', $salt . $password_clear)), 0, 4); + $password = hash('md5', $password_clear . $salt, true); + } + else { + $salt = substr(pack("H*", md5($salt . $password_clear)), 0, 4); + $password = md5($password_clear . $salt, true); + } + + $crypted_password = '{SMD5}' . base64_encode($password . $salt); break; + case 'samba': if (function_exists('hash')) { $crypted_password = hash('md4', rcube_charset::convert($password_clear, RCUBE_CHARSET, 'UTF-16LE')); $crypted_password = strtoupper($crypted_password); - } else { + } + else { /* Your PHP install does not have the hash() function */ return false; } break; + case 'ad': $crypted_password = rcube_charset::convert('"' . $password_clear . '"', RCUBE_CHARSET, 'UTF-16LE'); break; + + case 'cram-md5': + require_once __DIR__ . '/../helpers/dovecot_hmacmd5.php'; + return dovecot_hmacmd5($password_clear); + break; + case 'clear': default: $crypted_password = $password_clear; diff --git a/plugins/password/helpers/dovecot_hmacmd5.php b/plugins/password/helpers/dovecot_hmacmd5.php new file mode 100644 index 000000000..644b5377e --- /dev/null +++ b/plugins/password/helpers/dovecot_hmacmd5.php @@ -0,0 +1,191 @@ +<?php + +/** + * + * dovecot_hmacmd5.php V1.01 + * + * Generates HMAC-MD5 'contexts' for Dovecot's password files. + * + * (C) 2008 Hajo Noerenberg + * + * http://www.noerenberg.de/hajo/pub/dovecot_hmacmd5.php.txt + * + * Most of the code has been shamelessly stolen from various sources: + * + * (C) Paul Johnston 1999 - 2000 / http://pajhome.org.uk/crypt/md5/ + * (C) William K. Cole 2008 / http://www.scconsult.com/bill/crampass.pl + * (C) Borfast 2002 / http://www.zend.com/code/codex.php?ozid=962&single=1 + * (C) Thomas Weber / http://pajhome.org.uk/crypt/md5/contrib/md5.java.txt + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3.0 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>. + * + */ + +/* Convert a 32-bit number to a hex string with ls-byte first + */ + +function rhex($n) { + $hex_chr = "0123456789abcdef"; $r = ''; + for($j = 0; $j <= 3; $j++) + $r .= $hex_chr[($n >> ($j * 8 + 4)) & 0x0F] . $hex_chr[($n >> ($j * 8)) & 0x0F]; + return $r; +} + +/* zeroFill() is needed because PHP doesn't have a zero-fill + * right shift operator like JavaScript's >>> + */ + +function zeroFill($a, $b) { + $z = hexdec(80000000); + if ($z & $a) { + $a >>= 1; + $a &= (~$z); + $a |= 0x40000000; + $a >>= ($b-1); + } else { + $a >>= $b; + } + return $a; +} + +/* Bitwise rotate a 32-bit number to the left + */ + +function bit_rol($num, $cnt) { + return ($num << $cnt) | (zeroFill($num, (32 - $cnt))); +} + +/* Add integers, wrapping at 2^32 + */ + +function safe_add($x, $y) { + return (($x&0x7FFFFFFF) + ($y&0x7FFFFFFF)) ^ ($x&0x80000000) ^ ($y&0x80000000); +} + +/* These functions implement the four basic operations the algorithm uses. + */ + +function md5_cmn($q, $a, $b, $x, $s, $t) { + return safe_add(bit_rol(safe_add(safe_add($a, $q), safe_add($x, $t)), $s), $b); +} +function md5_ff($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn(($b & $c) | ((~$b) & $d), $a, $b, $x, $s, $t); +} +function md5_gg($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn(($b & $d) | ($c & (~$d)), $a, $b, $x, $s, $t); +} +function md5_hh($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn($b ^ $c ^ $d, $a, $b, $x, $s, $t); +} +function md5_ii($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn($c ^ ($b | (~$d)), $a, $b, $x, $s, $t); +} + +/* Calculate the first round of the MD5 algorithm + */ + +function md5_oneround($s, $io) { + + $s = str_pad($s, 64, chr(0x00)); + + $x = array_fill(0, 16, 0); + + for($i = 0; $i < 64; $i++) + $x[$i >> 2] |= (($io ? 0x36 : 0x5c) ^ ord($s[$i])) << (($i % 4) * 8); + + $a = $olda = 1732584193; + $b = $oldb = -271733879; + $c = $oldc = -1732584194; + $d = $oldd = 271733878; + + $a = md5_ff($a, $b, $c, $d, $x[ 0], 7 , -680876936); + $d = md5_ff($d, $a, $b, $c, $x[ 1], 12, -389564586); + $c = md5_ff($c, $d, $a, $b, $x[ 2], 17, 606105819); + $b = md5_ff($b, $c, $d, $a, $x[ 3], 22, -1044525330); + $a = md5_ff($a, $b, $c, $d, $x[ 4], 7 , -176418897); + $d = md5_ff($d, $a, $b, $c, $x[ 5], 12, 1200080426); + $c = md5_ff($c, $d, $a, $b, $x[ 6], 17, -1473231341); + $b = md5_ff($b, $c, $d, $a, $x[ 7], 22, -45705983); + $a = md5_ff($a, $b, $c, $d, $x[ 8], 7 , 1770035416); + $d = md5_ff($d, $a, $b, $c, $x[ 9], 12, -1958414417); + $c = md5_ff($c, $d, $a, $b, $x[10], 17, -42063); + $b = md5_ff($b, $c, $d, $a, $x[11], 22, -1990404162); + $a = md5_ff($a, $b, $c, $d, $x[12], 7 , 1804603682); + $d = md5_ff($d, $a, $b, $c, $x[13], 12, -40341101); + $c = md5_ff($c, $d, $a, $b, $x[14], 17, -1502002290); + $b = md5_ff($b, $c, $d, $a, $x[15], 22, 1236535329); + + $a = md5_gg($a, $b, $c, $d, $x[ 1], 5 , -165796510); + $d = md5_gg($d, $a, $b, $c, $x[ 6], 9 , -1069501632); + $c = md5_gg($c, $d, $a, $b, $x[11], 14, 643717713); + $b = md5_gg($b, $c, $d, $a, $x[ 0], 20, -373897302); + $a = md5_gg($a, $b, $c, $d, $x[ 5], 5 , -701558691); + $d = md5_gg($d, $a, $b, $c, $x[10], 9 , 38016083); + $c = md5_gg($c, $d, $a, $b, $x[15], 14, -660478335); + $b = md5_gg($b, $c, $d, $a, $x[ 4], 20, -405537848); + $a = md5_gg($a, $b, $c, $d, $x[ 9], 5 , 568446438); + $d = md5_gg($d, $a, $b, $c, $x[14], 9 , -1019803690); + $c = md5_gg($c, $d, $a, $b, $x[ 3], 14, -187363961); + $b = md5_gg($b, $c, $d, $a, $x[ 8], 20, 1163531501); + $a = md5_gg($a, $b, $c, $d, $x[13], 5 , -1444681467); + $d = md5_gg($d, $a, $b, $c, $x[ 2], 9 , -51403784); + $c = md5_gg($c, $d, $a, $b, $x[ 7], 14, 1735328473); + $b = md5_gg($b, $c, $d, $a, $x[12], 20, -1926607734); + + $a = md5_hh($a, $b, $c, $d, $x[ 5], 4 , -378558); + $d = md5_hh($d, $a, $b, $c, $x[ 8], 11, -2022574463); + $c = md5_hh($c, $d, $a, $b, $x[11], 16, 1839030562); + $b = md5_hh($b, $c, $d, $a, $x[14], 23, -35309556); + $a = md5_hh($a, $b, $c, $d, $x[ 1], 4 , -1530992060); + $d = md5_hh($d, $a, $b, $c, $x[ 4], 11, 1272893353); + $c = md5_hh($c, $d, $a, $b, $x[ 7], 16, -155497632); + $b = md5_hh($b, $c, $d, $a, $x[10], 23, -1094730640); + $a = md5_hh($a, $b, $c, $d, $x[13], 4 , 681279174); + $d = md5_hh($d, $a, $b, $c, $x[ 0], 11, -358537222); + $c = md5_hh($c, $d, $a, $b, $x[ 3], 16, -722521979); + $b = md5_hh($b, $c, $d, $a, $x[ 6], 23, 76029189); + $a = md5_hh($a, $b, $c, $d, $x[ 9], 4 , -640364487); + $d = md5_hh($d, $a, $b, $c, $x[12], 11, -421815835); + $c = md5_hh($c, $d, $a, $b, $x[15], 16, 530742520); + $b = md5_hh($b, $c, $d, $a, $x[ 2], 23, -995338651); + + $a = md5_ii($a, $b, $c, $d, $x[ 0], 6 , -198630844); + $d = md5_ii($d, $a, $b, $c, $x[ 7], 10, 1126891415); + $c = md5_ii($c, $d, $a, $b, $x[14], 15, -1416354905); + $b = md5_ii($b, $c, $d, $a, $x[ 5], 21, -57434055); + $a = md5_ii($a, $b, $c, $d, $x[12], 6 , 1700485571); + $d = md5_ii($d, $a, $b, $c, $x[ 3], 10, -1894986606); + $c = md5_ii($c, $d, $a, $b, $x[10], 15, -1051523); + $b = md5_ii($b, $c, $d, $a, $x[ 1], 21, -2054922799); + $a = md5_ii($a, $b, $c, $d, $x[ 8], 6 , 1873313359); + $d = md5_ii($d, $a, $b, $c, $x[15], 10, -30611744); + $c = md5_ii($c, $d, $a, $b, $x[ 6], 15, -1560198380); + $b = md5_ii($b, $c, $d, $a, $x[13], 21, 1309151649); + $a = md5_ii($a, $b, $c, $d, $x[ 4], 6 , -145523070); + $d = md5_ii($d, $a, $b, $c, $x[11], 10, -1120210379); + $c = md5_ii($c, $d, $a, $b, $x[ 2], 15, 718787259); + $b = md5_ii($b, $c, $d, $a, $x[ 9], 21, -343485551); + + $a = safe_add($a, $olda); + $b = safe_add($b, $oldb); + $c = safe_add($c, $oldc); + $d = safe_add($d, $oldd); + + return rhex($a) . rhex($b) . rhex($c) . rhex($d); +} + +function dovecot_hmacmd5 ($s) { + if (strlen($s) > 64) $s=pack("H*", md5($s)); + return "{CRAM-MD5}" . md5_oneround($s, 0) . md5_oneround($s, 1); +} diff --git a/plugins/password/password.php b/plugins/password/password.php index 0db57afc6..9239cd0b0 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -306,10 +306,10 @@ class password extends rcube_plugin switch ($result) { case PASSWORD_SUCCESS: return; - case PASSWORD_CRYPT_ERROR; + case PASSWORD_CRYPT_ERROR: $reason = $this->gettext('crypterror'); break; - case PASSWORD_CONNECT_ERROR; + case PASSWORD_CONNECT_ERROR: $reason = $this->gettext('connecterror'); break; case PASSWORD_ERROR: diff --git a/plugins/password/tests/Password.php b/plugins/password/tests/Password.php index a9663a946..b64c6b889 100644 --- a/plugins/password/tests/Password.php +++ b/plugins/password/tests/Password.php @@ -5,7 +5,7 @@ class Password_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../password.php'; + include_once __DIR__ . '/../password.php'; } /** diff --git a/plugins/redundant_attachments/tests/RedundantAttachments.php b/plugins/redundant_attachments/tests/RedundantAttachments.php index 386f97e59..53f0c0138 100644 --- a/plugins/redundant_attachments/tests/RedundantAttachments.php +++ b/plugins/redundant_attachments/tests/RedundantAttachments.php @@ -5,7 +5,7 @@ class RedundantAttachments_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../redundant_attachments.php'; + include_once __DIR__ . '/../redundant_attachments.php'; } /** diff --git a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php index 902ce510b..ab77351a4 100644 --- a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php +++ b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php @@ -5,7 +5,7 @@ class ShowAdditionalHeaders_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../show_additional_headers.php'; + include_once __DIR__ . '/../show_additional_headers.php'; } /** diff --git a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php index 2e35509f0..0e3a5c48a 100644 --- a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php +++ b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php @@ -5,7 +5,7 @@ class SquirrelmailUsercopy_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../squirrelmail_usercopy.php'; + include_once __DIR__ . '/../squirrelmail_usercopy.php'; } /** diff --git a/plugins/subscriptions_option/tests/SubscriptionsOption.php b/plugins/subscriptions_option/tests/SubscriptionsOption.php index 6932a955f..10168315e 100644 --- a/plugins/subscriptions_option/tests/SubscriptionsOption.php +++ b/plugins/subscriptions_option/tests/SubscriptionsOption.php @@ -5,7 +5,7 @@ class SubscriptionsOption_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../subscriptions_option.php'; + include_once __DIR__ . '/../subscriptions_option.php'; } /** diff --git a/plugins/userinfo/tests/Userinfo.php b/plugins/userinfo/tests/Userinfo.php index 762d5a1fa..7eb0758b5 100644 --- a/plugins/userinfo/tests/Userinfo.php +++ b/plugins/userinfo/tests/Userinfo.php @@ -5,7 +5,7 @@ class Userinfo_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../userinfo.php'; + include_once __DIR__ . '/../userinfo.php'; } /** diff --git a/plugins/vcard_attachments/tests/VcardAttachments.php b/plugins/vcard_attachments/tests/VcardAttachments.php index 35fd7f447..4b37cfc01 100644 --- a/plugins/vcard_attachments/tests/VcardAttachments.php +++ b/plugins/vcard_attachments/tests/VcardAttachments.php @@ -5,7 +5,7 @@ class VcardAttachments_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../vcard_attachments.php'; + include_once __DIR__ . '/../vcard_attachments.php'; } /** diff --git a/plugins/virtuser_file/tests/VirtuserFile.php b/plugins/virtuser_file/tests/VirtuserFile.php index a4362c3dc..80feecd15 100644 --- a/plugins/virtuser_file/tests/VirtuserFile.php +++ b/plugins/virtuser_file/tests/VirtuserFile.php @@ -5,7 +5,7 @@ class VirtuserFile_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../virtuser_file.php'; + include_once __DIR__ . '/../virtuser_file.php'; } /** diff --git a/plugins/virtuser_query/tests/VirtuserQuery.php b/plugins/virtuser_query/tests/VirtuserQuery.php index d5bd4ee4b..6c68f4c64 100644 --- a/plugins/virtuser_query/tests/VirtuserQuery.php +++ b/plugins/virtuser_query/tests/VirtuserQuery.php @@ -5,7 +5,7 @@ class VirtuserQuery_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../virtuser_query.php'; + include_once __DIR__ . '/../virtuser_query.php'; } /** diff --git a/plugins/zipdownload/tests/Zipdownload.php b/plugins/zipdownload/tests/Zipdownload.php index f3b4e1b35..3882dea87 100644 --- a/plugins/zipdownload/tests/Zipdownload.php +++ b/plugins/zipdownload/tests/Zipdownload.php @@ -5,7 +5,7 @@ class Zipdownload_Plugin extends PHPUnit_Framework_TestCase function setUp() { - include_once dirname(__FILE__) . '/../zipdownload.php'; + include_once __DIR__ . '/../zipdownload.php'; } /** |