From 0344b168276f80189e2254c75a762aff5b517b6b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 22 May 2016 06:32:57 -0400 Subject: [PATCH] Fix priority icon(s) position --- program/lib/Roundcube/rcube_session_db.php | 42 +++++++++++++++++++++++++----------------- 1 files changed, 25 insertions(+), 17 deletions(-) diff --git a/program/lib/Roundcube/rcube_session_db.php b/program/lib/Roundcube/rcube_session_db.php index 93d5c2b..6b99699 100644 --- a/program/lib/Roundcube/rcube_session_db.php +++ b/program/lib/Roundcube/rcube_session_db.php @@ -1,6 +1,6 @@ <?php -/* +/** +-----------------------------------------------------------------------+ | This file is part of the Roundcube Webmail client | | Copyright (C) 2005-2014, The Roundcube Dev Team | @@ -33,10 +33,15 @@ private $db; private $table_name; - public function __construct() + /** + * @param Object $config + */ + public function __construct($config) { + parent::__construct($config); + // get db instance - $this->db = rcube::get_instance()->get_dbh(); + $this->db = rcube::get_instance()->get_dbh(); // session table name $this->table_name = $this->db->table_name('session', true); @@ -65,7 +70,6 @@ { return true; } - /** * Handler for session_destroy() @@ -104,7 +108,8 @@ return !empty($this->vars) ? (string) $this->vars : ''; } - return null; + + return ''; } /** @@ -116,16 +121,15 @@ */ public function write($key, $vars) { - $now = $this->db->now(); + $now = $this->db->now(); $this->db->query("INSERT INTO {$this->table_name}" - . " (`sess_id`, `vars`, `ip`, `created`, `changed`)" - . " VALUES (?, ?, ?, $now, $now)", - $key, base64_encode($vars), (string)$this->ip); + . " (`sess_id`, `vars`, `ip`, `created`, `changed`)" + . " VALUES (?, ?, ?, $now, $now)", + $key, base64_encode($vars), (string)$this->ip); return true; } - /** * update session data @@ -138,18 +142,19 @@ */ public function update($key, $newvars, $oldvars) { - $now = $this->db->now(); + $now = $this->db->now(); + $ts = microtime(true); // if new and old data are not the same, update data // else update expire timestamp only when certain conditions are met if ($newvars !== $oldvars) { $this->db->query("UPDATE {$this->table_name} " - . "SET `changed` = $now, `vars` = ? WHERE `sess_id` = ?", - base64_encode($newvars), $key); + . "SET `changed` = $now, `vars` = ? WHERE `sess_id` = ?", + base64_encode($newvars), $key); } else if ($ts - $this->changed + $this->time_diff > $this->lifetime / 2) { $this->db->query("UPDATE {$this->table_name} SET `changed` = $now" - . " WHERE `sess_id` = ?", $key); + . " WHERE `sess_id` = ?", $key); } return true; @@ -162,7 +167,10 @@ { // just clean all old sessions when this GC is called $this->db->query("DELETE FROM " . $this->db->table_name('session') - . " WHERE changed < " . $this->db->now(-$this->gc_enabled)); - } + . " WHERE changed < " . $this->db->now(-$this->gc_enabled)); -} \ No newline at end of file + $this->log("Session GC (DB): remove records < " + . date('Y-m-d H:i:s', time() - $this->gc_enabled) + . '; rows = ' . intval($this->db->affected_rows())); + } +} -- Gitblit v1.9.1