From bc92ca56ef6c51393d2782b7654eaa162dfc2e10 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 30 Jul 2012 07:20:56 -0400
Subject: [PATCH] Fixes after default->classic switch

---
 program/include/rcube.php |   52 ++++++++++++++--------------------------------------
 1 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/program/include/rcube.php b/program/include/rcube.php
index e9add8d..ab5879d 100644
--- a/program/include/rcube.php
+++ b/program/include/rcube.php
@@ -18,9 +18,6 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 
@@ -109,12 +106,14 @@
   /**
    * This implements the 'singleton' design pattern
    *
+   * @param integer Options to initialize with this instance. See rcube::INIT_WITH_* constants
    * @return rcube The one and only instance
    */
-  static function get_instance()
+  static function get_instance($mode = 0)
   {
     if (!self::$instance) {
       self::$instance = new rcube();
+      self::$instance->init($mode);
     }
 
     return self::$instance;
@@ -194,11 +193,17 @@
       $this->memcache = new Memcache;
       $this->mc_available = 0;
 
-      // add alll configured hosts to pool
+      // add all configured hosts to pool
       $pconnect = $this->config->get('memcache_pconnect', true);
       foreach ($this->config->get('memcache_hosts', array()) as $host) {
-        list($host, $port) = explode(':', $host);
-        if (!$port) $port = 11211;
+        if (substr($host, 0, 7) != 'unix://') {
+          list($host, $port) = explode(':', $host);
+          if (!$port) $port = 11211;
+        }
+        else {
+          $port = 0;
+        }
+
         $this->mc_available += intval($this->memcache->addServer($host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure')));
       }
 
@@ -243,8 +248,7 @@
    */
   public function get_cache($name, $type='db', $ttl=0, $packed=true)
   {
-    if (!isset($this->caches[$name])) {
-      $userid = $this->get_user_id();
+    if (!isset($this->caches[$name]) && ($userid = $this->get_user_id())) {
       $this->caches[$name] = new rcube_cache($type, $userid, $name, $ttl, $packed);
     }
 
@@ -362,35 +366,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!
    */
@@ -440,6 +415,7 @@
         ini_set('session.use_cookies', 1);
         ini_set('session.use_only_cookies', 1);
         ini_set('session.serialize_handler', 'php');
+        ini_set('session.cookie_httponly', 1);
 
         // use database for storing session data
         $this->session = new rcube_session($this->get_dbh(), $this->config);

--
Gitblit v1.9.1