Permalink
Browse files

- Merge devel-framework branch, resolved conflicts

  • Loading branch information...
alecpl committed Apr 13, 2012
1 parent ce64332 commit 0c259682f65eaaf23ea4ccb56a706d6baf3007e4
Showing with 5,335 additions and 4,411 deletions.
  1. +11 −0 CHANGELOG
  2. +1 −1 bin/msgexport.sh
  3. +14 −13 index.php
  4. +2 −0 installer/index.php
  5. +3 −13 installer/utils.php
  6. +1 −1 program/include/clisetup.php
  7. +54 −12 program/include/html.php
  8. +5 −55 program/include/iniset.php
  9. +105 −2,005 program/include/main.inc
  10. +411 −836 program/include/rcmail.php
  11. +1,226 −0 program/include/rcube.php
  12. +5 −2 program/include/rcube_addressbook.php
  13. +110 −0 program/include/rcube_base_replacer.php
  14. +7 −7 program/include/rcube_cache.php
  15. +7 −7 program/include/rcube_config.php
  16. +21 −21 program/include/rcube_contacts.php
  17. +0 −323 program/include/rcube_html_page.php
  18. +27 −26 program/include/rcube_imap.php
  19. +36 −33 program/include/rcube_imap_cache.php
  20. +4 −45 program/include/rcube_imap_generic.php
  21. +16 −16 program/include/rcube_ldap.php
  22. +220 −125 program/include/rcube_mdb2.php
  23. +10 −8 program/include/rcube_message.php
  24. +238 −0 program/include/rcube_message_header.php
  25. +103 −0 program/include/rcube_message_part.php
  26. +259 −0 program/include/rcube_output.php
  27. +438 −208 program/include/{rcube_template.php → rcube_output_html.php}
  28. +37 −64 program/include/{rcube_json_output.php → rcube_output_json.php}
  29. +9 −7 program/include/rcube_plugin.php
  30. +49 −34 program/include/rcube_plugin_api.php
  31. +11 −10 program/include/rcube_session.php
  32. +306 −306 program/include/rcube_shared.inc
  33. +3 −3 program/include/rcube_smtp.php
  34. +10 −10 program/include/rcube_spellchecker.php
  35. +0 −79 program/include/rcube_sqlite.inc
  36. +5 −87 program/include/rcube_storage.php
  37. +3 −3 program/include/rcube_string_replacer.php
  38. +1,468 −0 program/include/rcube_ui.php
  39. +18 −18 program/include/rcube_user.php
  40. +3 −3 program/include/rcube_vcard.php
  41. +1 −1 program/steps/addressbook/func.inc
  42. +14 −2 program/steps/mail/compose.inc
  43. +20 −5 program/steps/mail/func.inc
  44. +21 −4 program/steps/mail/get.inc
  45. +15 −11 program/steps/mail/show.inc
  46. +8 −7 program/steps/utils/error.inc
View
@@ -1,6 +1,17 @@
CHANGELOG Roundcube Webmail
===========================
+- Roundcube Framework:
+ Add possibility to replace IMAP driver with custom class
+ Add IMAP auto-connection feature, improving performance with caching enabled
+ Replace imap_init hook with storage_init (with additional 'driver' argument)
+ Improved performance by caching IMAP server's capabilities in session
+ Unified global functions naming (rcube_ prefix)
+ Move global functions from main.inc and rcube_shared.inc into classes
+ Better classes separation
+
+RELEASE 0.8-rc
+----------------
- Set flexible width to login form fields (#1488418)
- Fix re-draw bug on list columns change in IE8 (#1487822)
- Allow mass-removal of addresses from a group (#1487748)
View
@@ -34,7 +34,7 @@ function export_mailbox($mbox, $filename)
$IMAP->set_folder($mbox);
$index = $IMAP->index($mbox, null, 'ASC');
- $count = $index->countMessages();
+ $count = $index->count();
$index = $index->get();
vputs("Getting message list of {$mbox}...");
View
@@ -2,7 +2,7 @@
/*
+-------------------------------------------------------------------------+
| Roundcube Webmail IMAP Client |
- | Version 0.8-svn |
+ | Version 0.9-svn |
| |
| Copyright (C) 2005-2012, The Roundcube Dev Team |
| |
@@ -45,7 +45,7 @@
$RCMAIL = rcmail::get_instance();
// Make the whole PHP output non-cacheable (#1487797)
-send_nocacheing_headers();
+$RCMAIL->output->nocacheing_headers();
// turn on output buffering
ob_start();
@@ -67,14 +67,14 @@
}
// error steps
-if ($RCMAIL->action=='error' && !empty($_GET['_code'])) {
+if ($RCMAIL->action == 'error' && !empty($_GET['_code'])) {
raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE);
}
// check if https is required (for login) and redirect if necessary
if (empty($_SESSION['user_id']) && ($force_https = $RCMAIL->config->get('force_https', false))) {
$https_port = is_bool($force_https) ? 443 : $force_https;
- if (!rcube_https_check($https_port)) {
+ if (!rcube_ui::https_check($https_port)) {
$host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
$host .= ($https_port != 443 ? ':' . $https_port : '');
header('Location: https://' . $host . $_SERVER['REQUEST_URI']);
@@ -89,15 +89,15 @@
// try to log in
if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') {
- $request_valid = $_SESSION['temp'] && $RCMAIL->check_request(RCUBE_INPUT_POST, 'login');
+ $request_valid = $_SESSION['temp'] && $RCMAIL->check_request(rcube_ui::INPUT_POST, 'login');
// purge the session in case of new login when a session already exists
$RCMAIL->kill_session();
$auth = $RCMAIL->plugins->exec_hook('authenticate', array(
'host' => $RCMAIL->autoselect_host(),
- 'user' => trim(get_input_value('_user', RCUBE_INPUT_POST)),
- 'pass' => get_input_value('_pass', RCUBE_INPUT_POST, true,
+ 'user' => trim(rcube_ui::get_input_value('_user', rcube_ui::INPUT_POST)),
+ 'pass' => rcube_ui::get_input_value('_pass', rcube_ui::INPUT_POST, true,
$RCMAIL->config->get('password_charset', 'ISO-8859-1')),
'cookiecheck' => true,
'valid' => $request_valid,
@@ -119,11 +119,11 @@
$RCMAIL->session->set_auth_cookie();
// log successful login
- rcmail_log_login();
+ $RCMAIL->log_login();
// restore original request parameters
$query = array();
- if ($url = get_input_value('_url', RCUBE_INPUT_POST)) {
+ if ($url = rcube_ui::get_input_value('_url', rcube_ui::INPUT_POST)) {
parse_str($url, $query);
// prevent endless looping on login page
@@ -149,7 +149,7 @@
}
// end session (after optional referer check)
-else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) && (!$RCMAIL->config->get('referer_check') || rcube_check_referer())) {
+else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) && (!$RCMAIL->config->get('referer_check') || rcmail::check_referer())) {
$userdata = array(
'user' => $_SESSION['username'],
'host' => $_SESSION['storage_host'],
@@ -172,7 +172,8 @@
// not logged in -> show login page
if (empty($RCMAIL->user->ID)) {
// log session failures
- if (($task = get_input_value('_task', RCUBE_INPUT_GPC)) && !in_array($task, array('login','logout')) && !$session_error && ($sess_id = $_COOKIE[ini_get('session.name')])) {
+ $task = rcube_ui::get_input_value('_task', rcube_ui::INPUT_GPC);
+ if ($task && !in_array($task, array('login','logout')) && !$session_error && ($sess_id = $_COOKIE[ini_get('session.name')])) {
$RCMAIL->session->log("Aborted session " . $sess_id . "; no valid session data found");
$session_error = true;
}
@@ -208,7 +209,7 @@
// check client X-header to verify request origin
if ($OUTPUT->ajax_call) {
- if (rc_request_header('X-Roundcube-Request') != $RCMAIL->get_request_token() && !$RCMAIL->config->get('devel_mode')) {
+ if (rcube_request_header('X-Roundcube-Request') != $RCMAIL->get_request_token() && !$RCMAIL->config->get('devel_mode')) {
header('HTTP/1.1 403 Forbidden');
die("Invalid Request");
}
@@ -220,7 +221,7 @@
}
// check referer if configured
- if (!$request_check_whitelist[$RCMAIL->action] && $RCMAIL->config->get('referer_check') && !rcube_check_referer()) {
+ if (!$request_check_whitelist[$RCMAIL->action] && $RCMAIL->config->get('referer_check') && !rcmail::check_referer()) {
raise_error(array(
'code' => 403,
'type' => 'php',
View
@@ -53,6 +53,8 @@
set_include_path($include_path);
require_once 'utils.php';
+require_once 'rcube_shared.inc';
+// deprecated aliases (to be removed)
require_once 'main.inc';
session_start();
View
@@ -45,26 +45,16 @@ function __autoload($classname)
include_once $filename. '.php';
}
-
-/**
- * Fake internal error handler to catch errors
- */
-function raise_error($p)
-{
- $rci = rcube_install::get_instance();
- $rci->raise_error($p);
-}
-
/**
* Local callback function for PEAR errors
*/
-function rcube_pear_error($err)
+function __pear_error($err)
{
- raise_error(array(
+ rcmail::raise_error(array(
'code' => $err->getCode(),
'message' => $err->getMessage(),
));
}
// set PEAR error handling (will also load the PEAR main class)
-PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
+PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, '__pear_error');
@@ -55,7 +55,7 @@ function get_opt($aliases=array())
continue;
$args[$key] = preg_replace(array('/^["\']/', '/["\']$/'), '', $value);
-
+
if ($alias = $aliases[$key])
$args[$alias] = $args[$key];
}
View
@@ -277,7 +277,7 @@ public static function attrib_string($attrib = array(), $allowed = null)
$attrib_arr = array();
foreach ($attrib as $key => $value) {
// skip size if not numeric
- if (($key=='size' && !is_numeric($value))) {
+ if ($key == 'size' && !is_numeric($value)) {
continue;
}
@@ -297,17 +297,57 @@ public static function attrib_string($attrib = array(), $allowed = null)
$attrib_arr[] = $key . '="' . $key . '"';
}
}
- else if ($key=='value') {
- $attrib_arr[] = $key . '="' . Q($value, 'strict', false) . '"';
- }
else {
- $attrib_arr[] = $key . '="' . Q($value) . '"';
+ $attrib_arr[] = $key . '="' . self::quote($value) . '"';
}
}
+
return count($attrib_arr) ? ' '.implode(' ', $attrib_arr) : '';
}
+
+ /**
+ * Convert a HTML attribute string attributes to an associative array (name => value)
+ *
+ * @param string Input string
+ * @return array Key-value pairs of parsed attributes
+ */
+ public static function parse_attrib_string($str)
+ {
+ $attrib = array();
+ $regexp = '/\s*([-_a-z]+)=(["\'])??(?(2)([^\2]*)\2|(\S+?))/Ui';
+
+ preg_match_all($regexp, stripslashes($str), $regs, PREG_SET_ORDER);
+
+ // convert attributes to an associative array (name => value)
+ if ($regs) {
+ foreach ($regs as $attr) {
+ $attrib[strtolower($attr[1])] = html_entity_decode($attr[3] . $attr[4]);
+ }
+ }
+
+ return $attrib;
+ }
+
+ /**
+ * Replacing specials characters in html attribute value
+ *
+ * @param string $str Input string
+ *
+ * @return string The quoted string
+ */
+ public static function quote($str)
+ {
+ $str = htmlspecialchars($str, ENT_COMPAT, RCMAIL_CHARSET);
+
+ // avoid douple quotation of &
+ // @TODO: get rid of it?
+ $str = preg_replace('/&([A-Za-z]{2,6}|#[0-9]{2,4});/', '&\\1;', $str);
+
+ return $str;
+ }
}
+
/**
* Class to create an HTML input field
*
@@ -317,9 +357,11 @@ class html_inputfield extends html
{
protected $tagname = 'input';
protected $type = 'text';
- protected $allowed = array('type','name','value','size','tabindex',
+ protected $allowed = array(
+ 'type','name','value','size','tabindex',
'autocomplete','checked','onchange','onclick','disabled','readonly',
- 'spellcheck','results','maxlength','src','multiple','placeholder');
+ 'spellcheck','results','maxlength','src','multiple','placeholder',
+ );
/**
* Object constructor
@@ -517,11 +559,11 @@ public function show($value = '', $attrib = null)
}
if (!empty($value) && !preg_match('/mce_editor/', $this->attrib['class'])) {
- $value = Q($value, 'strict', false);
+ $value = self::quote($value);
}
return self::tag($this->tagname, $this->attrib, $value,
- array_merge(self::$common_attrib, $this->allowed));
+ array_merge(self::$common_attrib, $this->allowed));
}
}
@@ -550,7 +592,7 @@ class html_select extends html
protected $options = array();
protected $allowed = array('name','size','tabindex','autocomplete',
'multiple','onchange','disabled','rel');
-
+
/**
* Add a new option to this drop-down
*
@@ -591,8 +633,9 @@ public function show($select = array(), $attrib = null)
'selected' => (in_array($option['value'], $select, true) ||
in_array($option['text'], $select, true)) ? 1 : null);
- $this->content .= self::tag('option', $attr, Q($option['text']));
+ $this->content .= self::tag('option', $attr, self::quote($option['text']));
}
+
return parent::show();
}
}
@@ -803,4 +846,3 @@ public function remove_body()
}
}
-
View
@@ -40,7 +40,7 @@
}
// application constants
-define('RCMAIL_VERSION', '0.8-svn');
+define('RCMAIL_VERSION', '0.9-svn');
define('RCMAIL_CHARSET', 'UTF-8');
define('JS_OBJECT_NAME', 'rcmail');
define('RCMAIL_START', microtime(true));
@@ -53,11 +53,6 @@
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
}
-// make sure path_separator is defined
-if (!defined('PATH_SEPARATOR')) {
- define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
-}
-
// RC include folders MUST be included FIRST to avoid other
// possible not compatible libraries (i.e PEAR) to be included
// instead the ones provided by RC
@@ -80,59 +75,14 @@
@mb_regex_encoding(RCMAIL_CHARSET);
}
-/**
- * Use PHP5 autoload for dynamic class loading
- *
- * @todo Make Zend, PEAR etc play with this
- * @todo Make our classes conform to a more straight forward CS.
- */
-function rcube_autoload($classname)
-{
- $filename = preg_replace(
- array(
- '/MDB2_(.+)/',
- '/Mail_(.+)/',
- '/Net_(.+)/',
- '/Auth_(.+)/',
- '/^html_.+/',
- '/^utf8$/',
- ),
- array(
- 'MDB2/\\1',
- 'Mail/\\1',
- 'Net/\\1',
- 'Auth/\\1',
- 'html',
- 'utf8.class',
- ),
- $classname
- );
-
- if ($fp = @fopen("$filename.php", 'r', true)) {
- fclose($fp);
- include_once("$filename.php");
- return true;
- }
-
- return false;
-}
+// include global functions
+require_once INSTALL_PATH . 'program/include/rcube_shared.inc';
+// Register autoloader
spl_autoload_register('rcube_autoload');
-/**
- * Local callback function for PEAR errors
- */
-function rcube_pear_error($err)
-{
- error_log(sprintf("%s (%s): %s",
- $err->getMessage(),
- $err->getCode(),
- $err->getUserinfo()), 0);
-}
-
// set PEAR error handling (will also load the PEAR main class)
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
-// include global functions
+// backward compatybility (to be removed)
require_once INSTALL_PATH . 'program/include/main.inc';
-require_once INSTALL_PATH . 'program/include/rcube_shared.inc';
Oops, something went wrong.

0 comments on commit 0c25968

Please sign in to comment.