]> git.donarmstrong.com Git - roundcube.git/blob - program/include/rcube_sqlite.inc
Merge commit 'upstream/0.1'
[roundcube.git] / program / include / rcube_sqlite.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/include/rcube_sqlite.inc                                      |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Provide callback functions for sqlite that will emulate             |
13  |   sone MySQL functions                                                |
14  |                                                                       |
15  +-----------------------------------------------------------------------+
16  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
17  +-----------------------------------------------------------------------+
18
19  $Id: rcube_sqlite.inc 850 2007-10-03 00:13:32Z ihug $
20
21 */
22
23 /**
24  * Callback functions for sqlite database interface
25  *
26  * @package Database
27  */
28
29
30 function rcube_sqlite_from_unixtime($timestamp)
31   {
32   $timestamp = trim($timestamp);
33   if (!preg_match("/^[0-9]+$/is", $timestamp))
34     $ret = strtotime($timestamp);
35   else
36     $ret = $timestamp;
37     
38   $ret = date("Y-m-d H:i:s", $ret);
39   rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
40   return $ret;
41   }
42
43
44 function rcube_sqlite_unix_timestamp($timestamp="")
45   {
46   $timestamp = trim($timestamp);
47   if (!$timestamp)
48     $ret = time();
49   else if (!preg_match("/^[0-9]+$/is", $timestamp))
50     $ret = strtotime($timestamp);
51   else
52     $ret = $timestamp;
53
54   rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
55   return $ret;
56   }
57
58
59 function rcube_sqlite_now()
60   {
61   rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));
62   return date("Y-m-d H:i:s");
63   }
64
65
66 function rcube_sqlite_md5($str)
67   {
68   return md5($str);
69   }
70
71
72 function rcube_sqlite_debug($str)
73   {
74   //console($str);
75   }
76   
77 ?>