From 2bbc3da52aee81e920e46778d68278bd31f7bb6b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 08 Aug 2012 02:44:46 -0400
Subject: [PATCH] - Check request tokens also in devel_mode

---
 program/include/rcube_shared.inc |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 30436b7..85f2784 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -17,9 +17,6 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 
@@ -41,7 +38,7 @@
 function in_array_nocase($needle, $haystack)
 {
     $needle = mb_strtolower($needle);
-    foreach ($haystack as $value) {
+    foreach ((array)$haystack as $value) {
         if ($needle === mb_strtolower($value)) {
             return true;
         }
@@ -146,25 +143,23 @@
 
 
 /**
- * Create a unix timestamp with a specified offset from now.
+ * Returns number of seconds for a specified offset string.
  *
- * @param string $offset_str  String representation of the offset (e.g. 20min, 5h, 2days)
- * @param int    $factor      Factor to multiply with the offset
+ * @param string $str  String representation of the offset (e.g. 20min, 5h, 2days, 1week)
  *
- * @return int Unix timestamp
+ * @return int Number of seconds
  */
-function get_offset_time($offset_str, $factor=1)
+function get_offset_sec($str)
 {
-    if (preg_match('/^([0-9]+)\s*([smhdw])/i', $offset_str, $regs)) {
-        $amount = (int)$regs[1];
+    if (preg_match('/^([0-9]+)\s*([smhdw])/i', $str, $regs)) {
+        $amount = (int) $regs[1];
         $unit   = strtolower($regs[2]);
     }
     else {
-        $amount = (int)$offset_str;
+        $amount = (int) $str;
         $unit   = 's';
     }
 
-    $ts = mktime();
     switch ($unit) {
     case 'w':
         $amount *= 7;
@@ -174,11 +169,23 @@
         $amount *= 60;
     case 'm':
         $amount *= 60;
-    case 's':
-        $ts += $amount * $factor;
     }
 
-    return $ts;
+    return $amount;
+}
+
+
+/**
+ * Create a unix timestamp with a specified offset from now.
+ *
+ * @param string $offset_str  String representation of the offset (e.g. 20min, 5h, 2days)
+ * @param int    $factor      Factor to multiply with the offset
+ *
+ * @return int Unix timestamp
+ */
+function get_offset_time($offset_str, $factor=1)
+{
+    return time() + get_offset_sec($offset_str) * $factor;
 }
 
 
@@ -400,7 +407,7 @@
             '/^utf8$/',
         ),
         array(
-            'MDB2/\\1',
+            'Mail/\\1',
             'Mail/\\1',
             'Net/\\1',
             'Auth/\\1',

--
Gitblit v1.9.1