Changeset 5d66a4b in github
- Timestamp:
- Apr 19, 2012 3:42:19 AM (13 months ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo
- Children:
- 6c95b3e4
- Parents:
- 6a8b4c2
- Location:
- program/include
- Files:
-
- 4 edited
-
rcube.php (modified) (1 diff)
-
rcube_cache.php (modified) (2 diffs)
-
rcube_imap.php (modified) (1 diff)
-
rcube_shared.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube.php
r6a8b4c2 r5d66a4b 237 237 * @param string $name Cache identifier 238 238 * @param string $type Cache type ('db', 'apc' or 'memcache') 239 * @param int $ttl Expiration time for cache items in seconds239 * @param string $ttl Expiration time for cache items 240 240 * @param bool $packed Enables/disables data serialization 241 241 * -
program/include/rcube_cache.php
rbe98dfc2 r5d66a4b 60 60 * @param int $userid User identifier 61 61 * @param string $prefix Key name prefix 62 * @param int $ttl Expiration time of memcache/apc items in seconds (max.2592000)62 * @param string $ttl Expiration time of memcache/apc items 63 63 * @param bool $packed Enables/disabled data serialization. 64 64 * It's possible to disable data serialization if you're sure … … 83 83 } 84 84 85 // convert ttl string to seconds 86 $ttl = get_offset_sec($ttl); 87 if ($ttl > 2592000) $ttl = 2592000; 88 85 89 $this->userid = (int) $userid; 86 $this->ttl = (int)$ttl;90 $this->ttl = $ttl; 87 91 $this->packed = $packed; 88 92 $this->prefix = $prefix; -
program/include/rcube_imap.php
r6a8b4c2 r5d66a4b 3533 3533 $rcube = rcube::get_instance(); 3534 3534 $ttl = $rcube->config->get('message_cache_lifetime', '10d'); 3535 $ttl = get_offset_time($ttl) - time();3536 3537 3535 $this->cache = $rcube->get_cache('IMAP', $this->caching, $ttl); 3538 3536 } -
program/include/rcube_shared.inc
r6a8b4c2 r5d66a4b 147 147 148 148 /** 149 * Create a unix timestamp with a specified offset from now. 150 * 151 * @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days) 152 * @param int $factor Factor to multiply with the offset 153 * 154 * @return int Unix timestamp 155 */ 156 function get_offset_time($offset_str, $factor=1) 157 { 158 if (preg_match('/^([0-9]+)\s*([smhdw])/i', $offset_str, $regs)) { 159 $amount = (int)$regs[1]; 149 * Returns number of seconds for a specified offset string. 150 * 151 * @param string $str String representation of the offset (e.g. 20min, 5h, 2days, 1week) 152 * 153 * @return int Number of seconds 154 */ 155 function get_offset_sec($str) 156 { 157 if (preg_match('/^([0-9]+)\s*([smhdw])/i', $str, $regs)) { 158 $amount = (int) $regs[1]; 160 159 $unit = strtolower($regs[2]); 161 160 } 162 161 else { 163 $amount = (int) $offset_str;162 $amount = (int) $str; 164 163 $unit = 's'; 165 164 } 166 165 167 $ts = time();168 166 switch ($unit) { 169 167 case 'w': … … 175 173 case 'm': 176 174 $amount *= 60; 177 case 's': 178 $ts += $amount * $factor; 179 } 180 181 return $ts; 175 } 176 177 return $amount; 178 } 179 180 181 /** 182 * Create a unix timestamp with a specified offset from now. 183 * 184 * @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days) 185 * @param int $factor Factor to multiply with the offset 186 * 187 * @return int Unix timestamp 188 */ 189 function get_offset_time($offset_str, $factor=1) 190 { 191 return time() + get_offset_sec($offset_str) * $factor; 182 192 } 183 193
Note: See TracChangeset
for help on using the changeset viewer.
