From 52877803f86c4f1b4e8a40b9a53b40586f653f2f Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 02 Jun 2012 10:59:01 -0400
Subject: [PATCH] Merge pull request #12 from mrhein/master
---
program/include/rcmail.php | 64 ++++++++++++++++++++++++++------
1 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 024fd3e..a10a2aa 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -19,9 +19,6 @@
| Author: Thomas Bruederli <roundcube@gmail.com> |
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
-
- $Id$
-
*/
@@ -325,7 +322,7 @@
$this->output->set_charset(RCMAIL_CHARSET);
// add some basic labels to client
- $this->output->add_label('loading', 'servererror');
+ $this->output->add_label('loading', 'servererror', 'requesttimedout');
return $this->output;
}
@@ -520,7 +517,7 @@
$_SESSION['storage_port'] = $port;
$_SESSION['storage_ssl'] = $ssl;
$_SESSION['password'] = $this->encrypt($pass);
- $_SESSION['login_time'] = mktime();
+ $_SESSION['login_time'] = time();
if (isset($_REQUEST['_timezone']) && $_REQUEST['_timezone'] != '_default_')
$_SESSION['timezone'] = floatval($_REQUEST['_timezone']);
@@ -549,15 +546,16 @@
if (is_array($default_host)) {
$post_host = rcube_utils::get_input_value('_host', rcube_utils::INPUT_POST);
+ $post_user = rcube_utils::get_input_value('_user', rcube_utils::INPUT_POST);
+
+ list($user, $domain) = explode('@', $post_user);
// direct match in default_host array
if ($default_host[$post_host] || in_array($post_host, array_values($default_host))) {
$host = $post_host;
}
-
// try to select host by mail domain
- list($user, $domain) = explode('@', rcube_utils::get_input_value('_user', rcube_utils::INPUT_POST));
- if (!empty($domain)) {
+ else if (!empty($domain)) {
foreach ($default_host as $storage_host => $mail_domains) {
if (is_array($mail_domains) && in_array_nocase($domain, $mail_domains)) {
$host = $storage_host;
@@ -1329,11 +1327,12 @@
$attrib = $hook['attribs'];
if ($type == 'select') {
+ $attrib['is_escaped'] = true;
$select = new html_select($attrib);
// add no-selection option
if ($attrib['noselection']) {
- $select->add($rcmail->gettext($attrib['noselection']), '');
+ $select->add(html::quote($rcmail->gettext($attrib['noselection'])), '');
}
$rcmail->render_folder_tree_select($a_mailboxes, $mbox_name, $attrib['maxlength'], $select, $attrib['realnames']);
@@ -1362,7 +1361,7 @@
*/
public function folder_selector($p = array())
{
- $p += array('maxlength' => 100, 'realnames' => false);
+ $p += array('maxlength' => 100, 'realnames' => false, 'is_escaped' => true);
$a_mailboxes = array();
$storage = $this->get_storage();
@@ -1388,7 +1387,7 @@
$select = new html_select($p);
if ($p['noselection']) {
- $select->add($p['noselection'], '');
+ $select->add(html::quote($p['noselection']), '');
}
$this->render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames'], 0, $p);
@@ -1579,7 +1578,7 @@
}
}
- $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']);
+ $select->add(str_repeat(' ', $nestLevel*4) . html::quote($foldername), $folder['id']);
if (!empty($folder['folders'])) {
$out .= $this->render_folder_tree_select($folder['folders'], $mbox_name, $maxlength,
@@ -2006,4 +2005,45 @@
{
rcube_utils::setcookie($name, $value, $exp);
}
+
+ public function imap_connect()
+ {
+ return $this->storage_connect();
+ }
+
+ public function imap_init()
+ {
+ return $this->storage_init();
+ }
+
+ /**
+ * Connect to the mail storage server with stored session data
+ *
+ * @return bool True on success, False on error
+ */
+ public function storage_connect()
+ {
+ $storage = $this->get_storage();
+
+ if ($_SESSION['storage_host'] && !$storage->is_connected()) {
+ $host = $_SESSION['storage_host'];
+ $user = $_SESSION['username'];
+ $port = $_SESSION['storage_port'];
+ $ssl = $_SESSION['storage_ssl'];
+ $pass = $this->decrypt($_SESSION['password']);
+
+ if (!$storage->connect($host, $user, $pass, $port, $ssl)) {
+ if (is_object($this->output)) {
+ $error = $storage->get_error_code() == -1 ? 'storageerror' : 'sessionerror';
+ $this->output->show_message($error, 'error');
+ }
+ }
+ else {
+ $this->set_storage_prop();
+ return $storage->is_connected();
+ }
+ }
+
+ return false;
+ }
}
--
Gitblit v1.9.1