From e03c194656193400a6499f2a770cef69273294a6 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Fri, 15 Dec 2017 23:58:29 +0100 Subject: [PATCH] Compatibility with php 5.3 --- bl-kernel/helpers/cookie.class.php | 4 ++-- bl-kernel/helpers/date.class.php | 36 ++++++++++++++++-------------- bl-kernel/login.class.php | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/bl-kernel/helpers/cookie.class.php b/bl-kernel/helpers/cookie.class.php index 04f06d9b..45b7ef42 100644 --- a/bl-kernel/helpers/cookie.class.php +++ b/bl-kernel/helpers/cookie.class.php @@ -21,9 +21,9 @@ class Cookie { setcookie($key, $value, $expire); } - public static function isset($key) + public static function isEmpty($key) { - return isset($_COOKIE[$key]); + return empty($_COOKIE[$key]); } } \ No newline at end of file diff --git a/bl-kernel/helpers/date.class.php b/bl-kernel/helpers/date.class.php index 649bb8e7..3bbf0377 100644 --- a/bl-kernel/helpers/date.class.php +++ b/bl-kernel/helpers/date.class.php @@ -2,6 +2,21 @@ class Date { + // Returns string with the date translated + // Example: $date = 'Mon, 27th March' > 'Lun, 27th Marzo' + public static function translate($date) + { + global $Language; + + // If English default language don't translate + if ($Language->currentLanguage()=='en') { + return $date; + } + + $dates = $Language->getDates(); + return str_replace(array_keys($dates), array_values($dates), $date); + } + // Return current Unix timestamp, GMT+0 public static function unixTime() { @@ -14,7 +29,7 @@ class Date { $Date = new DateTime(); $output = $Date->format($format); - return Self::translate($output); + return self::translate($output); } public static function currentOffset($format, $offset) @@ -23,7 +38,7 @@ class Date { $Date->modify($offset); $output = $Date->format($format); - return Self::translate($output); + return self::translate($output); } // Format a local time/date according to locale settings. @@ -34,7 +49,7 @@ class Date { if ($Date!==false) { $output = $Date->format($outputFormat); - return Self::translate($output); + return self::translate($output); } return false; @@ -46,20 +61,7 @@ class Date { $Date->setTimezone(new DateTimeZone('UTC')); $output = $Date->format($outputFormat); - return Self::translate($output); - } - - public static function translate($date) - { - global $Language; - - // If English default language don't translate - if ($Language->currentLanguage()=='en') { - return $date; - } - - $dates = $Language->getDates(); - return str_replace(array_keys($dates), array_values($dates), $date); + return self::translate($output); } public static function timeago($time) diff --git a/bl-kernel/login.class.php b/bl-kernel/login.class.php index 89736914..afb80f94 100644 --- a/bl-kernel/login.class.php +++ b/bl-kernel/login.class.php @@ -118,7 +118,7 @@ class Login { // Check if the user has the cookies and the correct token public function verifyUserByRemember() { - if (!Cookie::isset(REMEMBER_COOKIE_USERNAME) || !Cookie::isset(REMEMBER_COOKIE_TOKEN)) { + if (Cookie::isEmpty(REMEMBER_COOKIE_USERNAME) || Cookie::isEmpty(REMEMBER_COOKIE_TOKEN)) { return false; }