source: subversion/trunk/roundcubemail/program/include/rcube_sqlite.inc @ 5787

Last change on this file since 5787 was 5787, checked in by thomasb, 16 months ago

Changed license to GNU GPLv3+ with exceptions for skins and plugins

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
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-2010, The Roundcube Dev Team                       |
9 |                                                                       |
10 | Licensed under the GNU General Public License version 3 or            |
11 | any later version with exceptions for skins & plugins.                |
12 | See the README file for a full license statement.                     |
13 |                                                                       |
14 | PURPOSE:                                                              |
15 |   Provide callback functions for sqlite that will emulate             |
16 |   sone MySQL functions                                                |
17 |                                                                       |
18 +-----------------------------------------------------------------------+
19 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
20 +-----------------------------------------------------------------------+
21
22 $Id$
23
24*/
25
26/**
27 * Callback functions for sqlite database interface
28 *
29 * @package Database
30 */
31
32
33function rcube_sqlite_from_unixtime($timestamp)
34{
35    $timestamp = trim($timestamp);
36    if (!preg_match('/^[0-9]+$/is', $timestamp))
37        $ret = strtotime($timestamp);
38    else
39        $ret = $timestamp;
40   
41    $ret = date('Y-m-d H:i:s', $ret);
42    rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
43    return $ret;
44}
45
46
47function rcube_sqlite_unix_timestamp($timestamp='')
48{
49    $timestamp = trim($timestamp);
50    if (!$timestamp)
51        $ret = time();
52    else if (!preg_match('/^[0-9]+$/is', $timestamp))
53        $ret = strtotime($timestamp);
54    else
55        $ret = $timestamp;
56
57    rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
58    return $ret;
59}
60
61
62function rcube_sqlite_now()
63{
64    rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));
65    return date("Y-m-d H:i:s");
66}
67
68
69function rcube_sqlite_md5($str)
70{
71    return md5($str);
72}
73
74
75function rcube_sqlite_debug($str)
76{
77    //console($str);
78}
79
Note: See TracBrowser for help on using the repository browser.