From 866ae4e827ba992ae6d45ddf4587191a2b2159d7 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sun, 28 Jan 2024 14:27:09 -0500 Subject: [PATCH] Fixing #5648 - Time Zone issues with GMT/Etc+Fraction Fractional time offsets can cause huge webserver error-logs --- CHANGELOG | 1 + lib/functions.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 08e5910a61..3f70bea330 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -102,6 +102,7 @@ Cacti CHANGELOG 1.2.27 -issue#5622: Errors and deprecation warnings with PHP 8.3.0 -issue#5638: Add tooltip info about IPv6 address +-issue#5648: Fractional time offsets can cause huge webserver error-logs -issue#5649: Inapprorpiate use of PHP_OS in lib/ping.php on Windows Platform 1.2.26 diff --git a/lib/functions.php b/lib/functions.php index 1d23e4aa43..de348efbe1 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -8415,8 +8415,10 @@ function cacti_time_zone_set($gmt_offset) { $php_offset = $zone; ini_set('date.timezone', $zone); } else { - $php_offset = 'Etc/GMT' . ($hours > 0 ? '-':'+') . abs($hours); - ini_set('date.timezone', 'Etc/GMT' . ($hours > 0 ? '-':'+') . abs($hours)); + // Adding the rounding function as some timezones are Etc/GMT+5.5 which is + // not supported in PHP yet. + $php_offset = 'Etc/GMT' . ($hours > 0 ? '-':'+') . abs(round($hours)); + ini_set('date.timezone', 'Etc/GMT' . ($hours > 0 ? '-':'+') . abs(round($hours))); } $_SESSION[SESS_BROWSER_SYSTEM_TZ] = $sys_offset;