Skip to content

Commit

Permalink
- Merge devel-framework branch, resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Apr 13, 2012
1 parent ce64332 commit 0c25968
Show file tree
Hide file tree
Showing 46 changed files with 5,335 additions and 4,411 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bin/msgexport.sh
Expand Up @@ -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}...");
Expand Down
27 changes: 14 additions & 13 deletions index.php
Expand Up @@ -2,7 +2,7 @@
/*
+-------------------------------------------------------------------------+
| Roundcube Webmail IMAP Client |
| Version 0.8-svn |
| Version 0.9-svn |
| |
| Copyright (C) 2005-2012, The Roundcube Dev Team |
| |
Expand Down Expand Up @@ -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();
Expand All @@ -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']);
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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'],
Expand All @@ -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;
}
Expand Down Expand Up @@ -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");
}
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions installer/index.php
Expand Up @@ -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();
Expand Down
16 changes: 3 additions & 13 deletions installer/utils.php
Expand Up @@ -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');
2 changes: 1 addition & 1 deletion program/include/clisetup.php
Expand Up @@ -55,7 +55,7 @@ function get_opt($aliases=array())
continue;

$args[$key] = preg_replace(array('/^["\']/', '/["\']$/'), '', $value);

if ($alias = $aliases[$key])
$args[$alias] = $args[$key];
}
Expand Down
66 changes: 54 additions & 12 deletions program/include/html.php
Expand Up @@ -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;
}

Expand All @@ -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
*
Expand All @@ -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
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -803,4 +846,3 @@ public function remove_body()
}

}

60 changes: 5 additions & 55 deletions program/include/iniset.php
Expand Up @@ -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));
Expand All @@ -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
Expand All @@ -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';

0 comments on commit 0c25968

Please sign in to comment.