aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/dblayer/functions_mysql.inc.php5
-rw-r--r--include/dblayer/functions_pdo-sqlite.inc.php5
-rw-r--r--include/dblayer/functions_pgsql.inc.php5
-rw-r--r--include/dblayer/functions_sqlite.inc.php5
-rw-r--r--include/functions_session.inc.php2
5 files changed, 21 insertions, 1 deletions
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
index aa56e1f98..7eb659409 100644
--- a/include/dblayer/functions_mysql.inc.php
+++ b/include/dblayer/functions_mysql.inc.php
@@ -636,6 +636,11 @@ function pwg_db_get_weekday($date)
return 'WEEKDAY('.$date.')';
}
+function pwg_db_date_to_ts($date)
+{
+ return 'UNIX_TIMESTAMP('.$date.')';
+}
+
// my_error returns (or send to standard output) the message concerning the
// error occured for the last mysql query.
function my_error($header, $die)
diff --git a/include/dblayer/functions_pdo-sqlite.inc.php b/include/dblayer/functions_pdo-sqlite.inc.php
index ce02af55c..f50bcc1dc 100644
--- a/include/dblayer/functions_pdo-sqlite.inc.php
+++ b/include/dblayer/functions_pdo-sqlite.inc.php
@@ -550,6 +550,11 @@ function pwg_db_get_weekday($date)
return 'strftime(\'%w\',date('.$date.',\'-1 DAY\'))';
}
+function pwg_db_date_to_ts($date)
+{
+ return 'UNIX_TIMESTAMP('.$date.')';
+}
+
// my_error returns (or send to standard output) the message concerning the
// error occured for the last mysql query.
function my_error($header, $die)
diff --git a/include/dblayer/functions_pgsql.inc.php b/include/dblayer/functions_pgsql.inc.php
index 598a699f5..3766d7cc6 100644
--- a/include/dblayer/functions_pgsql.inc.php
+++ b/include/dblayer/functions_pgsql.inc.php
@@ -596,6 +596,11 @@ function pwg_db_get_weekday($date)
return 'EXTRACT(ISODOW FROM '.$date.')::INTEGER - 1';
}
+function pwg_db_date_to_ts($date)
+{
+ return 'EXTRACT(EPOCH FROM '.$date.')';
+}
+
// my_error returns (or send to standard output) the message concerning the
// error occured for the last pgsql query.
function my_error($header, $die)
diff --git a/include/dblayer/functions_sqlite.inc.php b/include/dblayer/functions_sqlite.inc.php
index 109f5f21d..c12116355 100644
--- a/include/dblayer/functions_sqlite.inc.php
+++ b/include/dblayer/functions_sqlite.inc.php
@@ -561,6 +561,11 @@ function pwg_db_get_weekday($date)
return 'strftime(\'%w\',date('.$date.',\'-1 DAY\'))';
}
+function pwg_db_date_to_ts($date)
+{
+ return 'UNIX_TIMESTAMP('.$date.')';
+}
+
// my_error returns (or send to standard output) the message concerning the
// error occured for the last mysql query.
function my_error($header, $die)
diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php
index 1c01f98ab..f8c3a4c58 100644
--- a/include/functions_session.inc.php
+++ b/include/functions_session.inc.php
@@ -175,7 +175,7 @@ function pwg_session_gc()
$query = '
DELETE
FROM '.SESSIONS_TABLE.'
- WHERE UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(expiration) > '
+ WHERE '.pwg_db_date_to_ts('NOW()').' - '.pwg_db_date_to_ts('expiration').' > '
.$conf['session_length'].'
;';
pwg_query($query);