From 1ba096945f7f8c17c392d4e5229c77e73e0bc6c9 Mon Sep 17 00:00:00 2001 From: nikrou Date: Fri, 25 Jun 2010 19:43:44 +0000 Subject: Bug 1744 fixed : Incorrect use of timezone with SQLite Fixed anti-flood system. Need refactoring between each interval functions git-svn-id: http://piwigo.org/svn/trunk@6604 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/dblayer/functions_mysql.inc.php | 6 +++++- include/dblayer/functions_pdo-sqlite.inc.php | 5 +++++ include/dblayer/functions_pgsql.inc.php | 5 +++++ include/dblayer/functions_sqlite.inc.php | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) (limited to 'include/dblayer') diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php index 5e0c4dcd4..aa56e1f98 100644 --- a/include/dblayer/functions_mysql.inc.php +++ b/include/dblayer/functions_mysql.inc.php @@ -560,7 +560,6 @@ function boolean_to_string($var) * */ - function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE') { if ($date!='CURRENT_DATE') @@ -580,6 +579,11 @@ SELECT '.pwg_db_get_recent_period_expression($period); return $d; } +function pwg_db_get_flood_period_expression($seconds) +{ + return 'SUBDATE(now(), INTERVAL '.$seconds.' SECOND)'; +} + function pwg_db_get_hour($date) { return 'hour('.$date.')'; diff --git a/include/dblayer/functions_pdo-sqlite.inc.php b/include/dblayer/functions_pdo-sqlite.inc.php index ea47564f0..ce02af55c 100644 --- a/include/dblayer/functions_pdo-sqlite.inc.php +++ b/include/dblayer/functions_pdo-sqlite.inc.php @@ -499,6 +499,11 @@ function pwg_db_get_recent_period($period, $date='CURRENT_DATE') return $d; } +function pwg_db_get_flood_period_expression($seconds) +{ + return 'datetime(\'now\', \'localtime\', \''.-$seconds.' seconds\')'; +} + function pwg_db_get_hour($date) { return 'strftime(\'%H\', '.$date.')'; diff --git a/include/dblayer/functions_pgsql.inc.php b/include/dblayer/functions_pgsql.inc.php index a9f033fc3..598a699f5 100644 --- a/include/dblayer/functions_pgsql.inc.php +++ b/include/dblayer/functions_pgsql.inc.php @@ -546,6 +546,11 @@ function pwg_db_get_recent_period($period, $date='CURRENT_DATE') return $d; } +function pwg_db_get_flood_period_expression($seconds) +{ + return 'now() - \''.$seconds.' SECOND\'::interval'; +} + function pwg_db_get_hour($date) { return 'EXTRACT(HOUR FROM '.$date.')'; diff --git a/include/dblayer/functions_sqlite.inc.php b/include/dblayer/functions_sqlite.inc.php index 7e21e128c..109f5f21d 100644 --- a/include/dblayer/functions_sqlite.inc.php +++ b/include/dblayer/functions_sqlite.inc.php @@ -511,6 +511,11 @@ function pwg_db_get_recent_period($period, $date='CURRENT_DATE') return $d; } +function pwg_db_get_flood_period_expression($seconds) +{ + return 'datetime(\'now\', \'localtime\', \''.-$seconds.' seconds\')'; +} + function pwg_db_get_hour($date) { return 'strftime(\'%H\', '.$date.')'; -- cgit v1.2.3