From 194d80c326fe9c2c953dbbe815aa65eb1229b22f Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 22 Feb 2017 22:04:56 +0000 Subject: [PATCH] Bugfix for badly formatted date time string. --- include/dbm.php | 11 +++++++++++ include/socgraph.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/dbm.php b/include/dbm.php index 62ebb1af0..0e1241750 100644 --- a/include/dbm.php +++ b/include/dbm.php @@ -86,5 +86,16 @@ class dbm { public static function esc_array(&$arr, $add_quotation = false) { array_walk($arr, 'self::esc_array_callback', $add_quotation); } + + /** + * Checks Converts any date string into a SQL compatible date string + * + * @param string $date a date string in any format + * @return string SQL style date string + */ + public static function date($date) { + $timestamp = strtotime($date); + return date('Y-m-d H:i:s'); + } } ?> diff --git a/include/socgraph.php b/include/socgraph.php index 32c151c04..f0ce5875a 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -622,7 +622,7 @@ function poco_last_updated($profile, $force = false) { $last_updated = "0000-00-00 00:00:00"; q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'", - dbesc($last_updated), dbesc(datetime_convert()), dbesc(normalise_link($profile))); + dbesc(dbm::date($last_updated)), dbesc(datetime_convert()), dbesc(normalise_link($profile))); if (($gcontacts[0]["generation"] == 0)) q("UPDATE `gcontact` SET `generation` = 9 WHERE `nurl` = '%s'",