From c8ecdb8e7a2b9d043f6e7d95ffae9f3a938c6be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 15 Jan 2024 00:02:34 +0100 Subject: [PATCH] add function isDolValidTms --- htdocs/core/lib/functions.lib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c9fed272eaa..886a6473da1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -234,6 +234,25 @@ function isModEnabled($module) //return !empty($conf->$module->enabled); } +/** + * isDolValidTms check if a timestamp is valid. + * + * @param int|string|null $timestamp + * @return bool + */ +function isDolValidTms($timestamp) +{ + if ($timestamp == '') { + dol_syslog('Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER["PHP_SELF"], LOG_NOTICE); + return false; + } + if (is_null($timestamp) || !is_numeric($timestamp)) { + return false; + } + + return true; +} + /** * Return a DoliDB instance (database handler). *