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/rcube.php |   53 +++++++++++++++++------------------------------------
 1 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/program/include/rcube.php b/program/include/rcube.php
index 55dc4ee..1bfe93d 100644
--- a/program/include/rcube.php
+++ b/program/include/rcube.php
@@ -18,9 +18,6 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 
@@ -362,35 +359,6 @@
 
 
   /**
-   * 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))
-          $this->output->show_message($storage->get_error_code() == -1 ? 'storageerror' : 'sessionerror', 'error');
-      }
-      else {
-        $this->set_storage_prop();
-        return $storage->is_connected();
-      }
-    }
-
-    return false;
-  }
-
-  /**
    * Set storage parameters.
    * This must be done AFTER connecting to the server!
    */
@@ -476,7 +444,7 @@
             $this->session->set_keep_alive($keep_alive);
         }
 
-        $this->session->set_secret($this->config->get('des_key') . $_SERVER['HTTP_USER_AGENT']);
+        $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME']));
         $this->session->set_ip_check($this->config->get('ip_check'));
     }
 
@@ -631,7 +599,7 @@
         $this->texts = array_merge($this->texts, $messages);
 
       // include user language files
-      if ($lang != 'en' && is_dir(INSTALL_PATH . 'program/localization/' . $lang)) {
+      if ($lang != 'en' && $lang != 'en_US' && is_dir(INSTALL_PATH . 'program/localization/' . $lang)) {
         include_once(INSTALL_PATH . 'program/localization/' . $lang . '/labels.inc');
         include_once(INSTALL_PATH . 'program/localization/' . $lang . '/messages.inc');
 
@@ -1050,6 +1018,18 @@
      */
     public static function raise_error($arg = array(), $log = false, $terminate = false)
     {
+        // handle PHP exceptions
+        if (is_object($arg) && is_a($arg, 'Exception')) {
+            $err = array(
+                'type' => 'php',
+                'code' => $arg->getCode(),
+                'line' => $arg->getLine(),
+                'file' => $arg->getFile(),
+                'message' => $arg->getMessage(),
+            );
+            $arg = $err;
+        }
+
         // installer
         if (class_exists('rcube_install', false)) {
             $rci = rcube_install::get_instance();
@@ -1057,7 +1037,8 @@
             return;
         }
 
-        if ($log && $arg['type'] && $arg['message']) {
+        if (($log || $terminate) && $arg['type'] && $arg['message']) {
+            $arg['fatal'] = $terminate;
             self::log_bug($arg);
         }
 
@@ -1085,7 +1066,7 @@
         }
 
         // write error to local log file
-        if ($level & 1) {
+        if (($level & 1) || !empty($arg_arr['fatal'])) {
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $post_query = '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']);
             }

--
Gitblit v1.9.1