diff --git a/README.md b/README.md index 351a51ea1..cec296060 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,9 @@ ### Recommended - * Apache 2.2 or newer on Linux with PHP 7.0 or newer - * MySQL 5.x or newer, or MariaDB + * Apache 2.4 or newer on Linux + * PHP 7.4 or newer + * MySQL 5.6 or newer, or MariaDB 10.3 or newer * A registered domain name * Access to a server control panel (such as cPanel) diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index 74eaf4d8c..05de1d5cc 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -371,7 +371,7 @@ class admin_log_ui extends e_admin_ui if(($action == "backdel") && isset($_POST['backdeltype'])) { // $old_date = intval($qs[1]); - $old_string = e_date::strftime("%d %B %Y", $old_date); + $old_string = strftime("%d %B %Y", $old_date); $qry = "dblog_datestamp < ".$old_date; // Same field for both logs switch($_POST['backdeltype']) diff --git a/e107_admin/banlist_export.php b/e107_admin/banlist_export.php index e1b66598d..bdaf00fdb 100644 --- a/e107_admin/banlist_export.php +++ b/e107_admin/banlist_export.php @@ -65,7 +65,7 @@ if (!empty($_POST['ban_types'])) } } -$filename = 'banlist_'.e_date::strftime("%Y%m%d_%H%M%S").'.csv'; +$filename = 'banlist_'.strftime("%Y%m%d_%H%M%S").'.csv'; if ($error_string = do_export($filename, $type_list, $format_array, $use_separator, $use_quote)) { @@ -98,7 +98,7 @@ function do_export($filename, $type_list='',$format_array=array(), $sep = ',', $ break; case 'banlist_datestamp' : case 'banlist_banexpires' : - if ($row[$f]) $line .= $spacer.$quot.e_date::strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot; + if ($row[$f]) $line .= $spacer.$quot.strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot; break; } $spacer = $sep; diff --git a/e107_admin/cron.php b/e107_admin/cron.php index 8b5461714..b59565856 100644 --- a/e107_admin/cron.php +++ b/e107_admin/cron.php @@ -542,9 +542,9 @@ class cron_admin_form_ui extends e_admin_form_ui $text .= "
"; $text .= ($day != '*') ? LAN_CRON_52 ." ". $day : LAN_CRON_40; // Day(s) $text .= "
"; - $text .= ($month != '*') ? LAN_CRON_53 ." ". e_date::strftime("%B", mktime(00, 00, 00, (int) $month, 1, 2000)) : LAN_CRON_41; // Month(s) + $text .= ($month != '*') ? LAN_CRON_53 ." ". strftime("%B", mktime(00, 00, 00, (int) $month, 1, 2000)) : LAN_CRON_41; // Month(s) $text .= "
"; - $text .= ($weekday != '*') ? LAN_CRON_54 ." ". e_date::strftime("%A", mktime(00, 00, 00, 5, (int) $weekday, 2000)) : LAN_CRON_42; // Weekday(s) + $text .= ($weekday != '*') ? LAN_CRON_54 ." ". strftime("%A", mktime(00, 00, 00, 5, (int) $weekday, 2000)) : LAN_CRON_42; // Weekday(s) return "".ADMIN_INFO_ICON." @@ -711,7 +711,7 @@ class cron_admin_form_ui extends e_admin_form_ui { $sel = (in_array($i, $month)) ? "selected='selected'" : ""; $diz = mktime(00, 00, 00, $i, 1, 2000); - $text .= "\n"; + $text .= "\n"; } $text .= " @@ -724,7 +724,7 @@ class cron_admin_form_ui extends e_admin_form_ui for ($i = 0; $i <= 6; $i++) { $sel = (in_array(strval($i), $weekday)) ? "selected='selected'" : ""; - $text .= "\n"; + $text .= "\n"; } $text .= " "; diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index d7b8f59c3..d79bd2443 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -787,26 +787,26 @@ $text .= " $def = strtotime('December 21, 2012 3:45pm'); $inputdate = array( // TODO add more formats - "%A, %d %B, %Y" => e_date::strftime("%A, %d %B, %Y",$def), - "%A, %d %b, %Y" => e_date::strftime("%A, %d %b, %Y",$def), - "%a, %d %B, %Y" => e_date::strftime("%a, %d %B, %Y",$def), - "%a, %d %b, %Y" => e_date::strftime("%a, %d %b, %Y",$def), + "%A, %d %B, %Y" => strftime("%A, %d %B, %Y",$def), + "%A, %d %b, %Y" => strftime("%A, %d %b, %Y",$def), + "%a, %d %B, %Y" => strftime("%a, %d %B, %Y",$def), + "%a, %d %b, %Y" => strftime("%a, %d %b, %Y",$def), - "%A, %B %d, %Y" => e_date::strftime("%A, %B %d, %Y",$def), - "%A, %b %d, %Y" => e_date::strftime("%A, %b %d, %Y",$def), - "%A, %b %d, %y" => e_date::strftime("%A, %b %d, %y",$def), + "%A, %B %d, %Y" => strftime("%A, %B %d, %Y",$def), + "%A, %b %d, %Y" => strftime("%A, %b %d, %Y",$def), + "%A, %b %d, %y" => strftime("%A, %b %d, %y",$def), - "%B %d, %Y" => e_date::strftime("%B %d, %Y",$def), - "%b %d, %Y" => e_date::strftime("%b %d, %Y",$def), - "%b %d, %y" => e_date::strftime("%b %d, %y",$def), + "%B %d, %Y" => strftime("%B %d, %Y",$def), + "%b %d, %Y" => strftime("%b %d, %Y",$def), + "%b %d, %y" => strftime("%b %d, %y",$def), - "%d %B, %Y" => e_date::strftime("%d %B, %Y",$def), - "%d %b, %Y" => e_date::strftime("%d %b, %Y",$def), - "%d %b, %y" => e_date::strftime("%d %b, %y",$def), + "%d %B, %Y" => strftime("%d %B, %Y",$def), + "%d %b, %Y" => strftime("%d %b, %Y",$def), + "%d %b, %y" => strftime("%d %b, %y",$def), - "%Y-%m-%d" => e_date::strftime("%Y-%m-%d",$def), - "%d-%m-%Y" => e_date::strftime("%d-%m-%Y",$def), - "%m/%d/%Y" => e_date::strftime("%m/%d/%Y",$def) + "%Y-%m-%d" => strftime("%Y-%m-%d",$def), + "%d-%m-%Y" => strftime("%d-%m-%Y",$def), + "%m/%d/%Y" => strftime("%m/%d/%Y",$def) ); @@ -815,19 +815,19 @@ $text .= " - $inputtime["%I:%M %p"] = e_date::strftime("%I:%M %p",$def); + $inputtime["%I:%M %p"] = strftime("%I:%M %p",$def); if(e107::getDate()->supported('P')) { - $inputtime["%I:%M %P"] = e_date::strftime("%I:%M %P",$def); + $inputtime["%I:%M %P"] = strftime("%I:%M %P",$def); } if(e107::getDate()->supported('l')) { - $inputtime["%l:%M %p"] = e_date::strftime("%l:%M %p",$def); - $inputtime["%l:%M %P"] = e_date::strftime("%l:%M %P",$def); + $inputtime["%l:%M %p"] = strftime("%l:%M %p",$def); + $inputtime["%l:%M %P"] = strftime("%l:%M %P",$def); } - $inputtime["%H:%M"] = e_date::strftime("%H:%M",$def); - $inputtime["%H:%M:%S"] = e_date::strftime("%H:%M:%S",$def); + $inputtime["%H:%M"] = strftime("%H:%M",$def); + $inputtime["%H:%M:%S"] = strftime("%H:%M:%S",$def); diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 4d81af63b..7d7084e2d 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1305,7 +1305,7 @@ class admin_shortcodes extends e_shortcode

' .FOOTLAN_19. '
- ' .e_date::strftime('%A %d %B %Y - %H:%M'). + ' .strftime('%A %d %B %Y - %H:%M'). '
'; return e107::getRender()->tablerender(FOOTLAN_13, $text, '', TRUE); diff --git a/e107_handlers/Shims/Internal/StrptimeTrait.php b/e107_handlers/Shims/Internal/StrptimeTrait.php index af66b1edf..099fb4baa 100644 --- a/e107_handlers/Shims/Internal/StrptimeTrait.php +++ b/e107_handlers/Shims/Internal/StrptimeTrait.php @@ -80,10 +80,10 @@ trait StrptimeTrait for ($i = 1; $i <= 12; $i++) { - $k = e_date::strftime('%B', mktime(0, 0, 0, $i)); + $k = strftime('%B', mktime(0, 0, 0, $i)); $fullmonth[$k] = $i; - $j = e_date::strftime('%b', mktime(0, 0, 0, $i)); + $j = strftime('%b', mktime(0, 0, 0, $i)); $abrevmonth[$j] = $i; } diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php index 9ba0cccfd..26d4c3297 100644 --- a/e107_handlers/cron_class.php +++ b/e107_handlers/cron_class.php @@ -391,7 +391,7 @@ class CronParser function getLastRan() { - return explode(",", e_date::strftime("%M,%H,%d,%m,%w,%Y", $this->lastRan)); //Get the values for now in a format we can use + return explode(",", strftime("%M,%H,%d,%m,%w,%Y", $this->lastRan)); //Get the values for now in a format we can use } function getLastRanUnix() @@ -505,7 +505,7 @@ class CronParser } //put the current time into an array - $t = e_date::strftime("%M,%H,%d,%m,%w,%Y", time()); + $t = strftime("%M,%H,%d,%m,%w,%Y", time()); $this->now = explode(",", $t); $this->year = $this->now[5]; diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php index e81b876ae..8ccd73c50 100644 --- a/e107_handlers/date_handler.php +++ b/e107_handlers/date_handler.php @@ -37,17 +37,17 @@ class e_date for ($i=1; $i < 8; $i++) { - $day = e_date::strftime('%A', mktime(1, 1, 1, 1, $i, 2012)); + $day = strftime('%A', mktime(1, 1, 1, 1, $i, 2012)); $dates['days'][] = $day; - $dates['daysShort'][] = e_date::strftime('%a', mktime(1, 1, 1, 1, $i, 2012)); + $dates['daysShort'][] = strftime('%a', mktime(1, 1, 1, 1, $i, 2012)); $dates['daysMin'][] = substr($day, 0, 2); } for ($i=1; $i < 13; $i++) { - $dates['months'][] = e_date::strftime('%B', mktime(1, 1, 1, $i, 2, 2013)); - $dates['monthsShort'][] = e_date::strftime('%h', mktime(1, 1, 1, $i, 2, 2013)); + $dates['months'][] = strftime('%B', mktime(1, 1, 1, $i, 2, 2013)); + $dates['monthsShort'][] = strftime('%h', mktime(1, 1, 1, $i, 2, 2013)); } @@ -88,7 +88,7 @@ class e_date $marray = array(); for ($i = 1; $i < 13; $i++) { - $marray[$i] = e_date::strftime($val, mktime(1, 1, 1, $i, 1, 2000)); + $marray[$i] = strftime($val, mktime(1, 1, 1, $i, 1, 2000)); } return $marray; @@ -102,15 +102,15 @@ class e_date switch ($type) { case 'day-shortest': // eg. 'Tu' - $days[] = substr(e_date::strftime('%a', mktime(1, 1, 1, 6, $i, 2014)), 0, 2); + $days[] = substr(strftime('%a', mktime(1, 1, 1, 6, $i, 2014)), 0, 2); break; case 'day-short': // eg. 'Tue' - $days[] = e_date::strftime('%a', mktime(1, 1, 1, 6, $i, 2014)); + $days[] = strftime('%a', mktime(1, 1, 1, 6, $i, 2014)); break; default: // eg. 'Tuesday' - $days[] = e_date::strftime('%A', mktime(1, 1, 1, 6, $i, 2014)); + $days[] = strftime('%A', mktime(1, 1, 1, 6, $i, 2014)); break; } } @@ -196,7 +196,7 @@ class e_date break; } - $dateString = e_date::strftime($mask, $datestamp); + $dateString = strftime($mask, $datestamp); if (!e107::getParser()->isUTF8($dateString)) { @@ -206,19 +206,6 @@ class e_date return $dateString; } - /** - * Alias of {@see eShims::strftime()} - * - * See {@see eShims::strftime()} for more information. - * - * @param string $format The old {@see strftime()} format string - * @param int|null $timestamp A Unix epoch timestamp. If null, defaults to the value of {@see time()}. - * @return string Datetime formatted according to the provided arguments - */ - public static function strftime($format, $timestamp = null) - { - return eShims::strftime($format, $timestamp); - } /** * @deprecated - for internal use only. @@ -801,8 +788,8 @@ class e_date trigger_error('' . __METHOD__ . ' is deprecated. Use eShims::strptime() instead', E_USER_DEPRECATED); // NO LAN $vals = eShims::strptime($str, $format); // PHP5 is more accurate than below. - $vals['tm_amon'] = e_date::strftime('%b', mktime(0, 0, 0, $vals['tm_mon'] + 1)); - $vals['tm_fmon'] = e_date::strftime('%B', mktime(0, 0, 0, $vals['tm_mon'] + 1)); + $vals['tm_amon'] = strftime('%b', mktime(0, 0, 0, $vals['tm_mon'] + 1)); + $vals['tm_fmon'] = strftime('%B', mktime(0, 0, 0, $vals['tm_mon'] + 1)); return $vals; } @@ -882,7 +869,7 @@ class e_date // Evaluate the formats whilst suppressing any errors. foreach($strftimeFormats as $format => $description) { - $strftimeValues[$format] = e_date::strftime("%{$format}"); + $strftimeValues[$format] = strftime("%{$format}"); } // Find the longest value. diff --git a/e107_handlers/iphandler_class.php b/e107_handlers/iphandler_class.php index e0beb5bef..a1e00bee9 100644 --- a/e107_handlers/iphandler_class.php +++ b/e107_handlers/iphandler_class.php @@ -1452,7 +1452,7 @@ class banlistManager private function dateFormat($date) { if ($date == 0) return '0'; - return e_date::strftime('%Y%m%d_%H%M%S',$date); + return strftime('%Y%m%d_%H%M%S',$date); } diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php index 071ad9a9d..435e59947 100644 --- a/e107_handlers/news_class.php +++ b/e107_handlers/news_class.php @@ -632,7 +632,7 @@ class e_news_item extends e_front_model $params = array($val); //value is always the first callback argument $params = array_merge($params, explode(',', $parm['arg'])); //should be done with date handler (awaiting for modifications) - return e_date::strftime(varset($parm['arg'], e107::getPref('shortdate')), $val); + return strftime(varset($parm['arg'], e107::getPref('shortdate')), $val); break; default: diff --git a/e107_handlers/php_compatibility_handler.php b/e107_handlers/php_compatibility_handler.php index b1d5ea1e9..f39becc4d 100644 --- a/e107_handlers/php_compatibility_handler.php +++ b/e107_handlers/php_compatibility_handler.php @@ -35,6 +35,15 @@ if (!function_exists('strptime')) } +if (!function_exists('strftime')) +{ + function strftime($format, $timestamp) + { + return eShims::strftime($format, $timestamp); + } +} + + // Fix for exim missing. if(!function_exists('exif_imagetype')) { diff --git a/e107_plugins/banner/banner.php b/e107_plugins/banner/banner.php index fdfc41153..1a57a832d 100644 --- a/e107_plugins/banner/banner.php +++ b/e107_plugins/banner/banner.php @@ -96,8 +96,8 @@ if (isset($_POST['clientsubmit'])) { while ($row = $sql->fetch()) { - $start_date = ($row['banner_startdate'] ? e_date::strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31); - $end_date = ($row['banner_enddate'] ? e_date::strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31); + $start_date = ($row['banner_startdate'] ? strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31); + $end_date = ($row['banner_enddate'] ? strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31); $scArray = array(); $scArray['BANNER_TABLE_CLICKPERCENTAGE'] = ($row['banner_clicks'] && $row['banner_impressions'] ? round(($row['banner_clicks'] / $row['banner_impressions']) * 100)."%" : "-"); diff --git a/e107_plugins/download/handlers/category_class.php b/e107_plugins/download/handlers/category_class.php index dcfba5d3a..638add31a 100644 --- a/e107_plugins/download/handlers/category_class.php +++ b/e107_plugins/download/handlers/category_class.php @@ -140,7 +140,7 @@ class downloadCategory { $text = "".$cat['download_category_id']."".$cat['download_category_parent'].""; $text .= $prefix.htmlspecialchars($cat['download_category_name']).$postfix."".$cat['d_size'].""; - $text .= "".$cat['d_count']."".$cat['d_requests']."".e_date::strftime('%H:%M %d-%m-%Y',$cat['d_last']).""; + $text .= "".$cat['d_count']."".$cat['d_requests']."".strftime('%H:%M %d-%m-%Y',$cat['d_last']).""; $text .= ""; return $text; } diff --git a/e107_plugins/list_new/list_class.php b/e107_plugins/list_new/list_class.php index 1e4ee513a..f3d2263e6 100644 --- a/e107_plugins/list_new/list_class.php +++ b/e107_plugins/list_new/list_class.php @@ -727,14 +727,14 @@ class listclass if($thisday == $current_day) { $datepreftoday = $this->list_pref[$this->mode."_datestyletoday"]; - return e_date::strftime($datepreftoday, $datestamp); + return strftime($datepreftoday, $datestamp); } } } //else use default date style $datepref = $this->list_pref[$this->mode."_datestyle"]; - return e_date::strftime($datepref, $datestamp); + return strftime($datepref, $datestamp); } /** diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 06e915b59..0559e0678 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -1889,10 +1889,10 @@ class news_front // render new date header if pref selected ... - $thispostday = e_date::strftime("%j", $news['news_datestamp']); + $thispostday = strftime("%j", $news['news_datestamp']); if ($newpostday != $thispostday && (isset($this->pref['news_newdateheader']) && $this->pref['news_newdateheader'])) { - echo "
".e_date::strftime("%A %d %B %Y", $news['news_datestamp'])."
"; + echo "
".strftime("%A %d %B %Y", $news['news_datestamp'])."
"; } $newpostday = $thispostday; $news['category_id'] = $news['news_category']; diff --git a/e107_tests/tests/unit/e107/Shims/Internal/e_dateAlternateTest.php b/e107_tests/tests/unit/e107/Shims/Internal/e_dateAlternateTest.php index 06618bfdd..8c43ab087 100644 --- a/e107_tests/tests/unit/e107/Shims/Internal/e_dateAlternateTest.php +++ b/e107_tests/tests/unit/e107/Shims/Internal/e_dateAlternateTest.php @@ -37,13 +37,13 @@ function defined($constant_name) * @param array|string|int $locales * @param string ...$rest * @return false|string - */ + *//* function setlocale($category, $locales, ...$rest) { if (e_dateAlternateTest::$alternate_locale) return 'nl_NL'; return \setlocale($category, $locales, ...$rest); -} +}*/ class e_dateAlternateTest extends \e_dateTest @@ -76,18 +76,23 @@ class e_dateAlternateTest extends \e_dateTest try { - + setlocale(LC_ALL,'nl_NL.utf8', 'nl'); $actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'long'); $expected = 'maandag 05 februari 2018 - 12:45:03'; $this->assertEquals($expected, $actual); - $actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'inputtime'); - $expected = '12:45 P.M.'; + setlocale(LC_ALL,'es_SP.utf8', 'es'); + + $actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'inputdate'); + $expected = 'lunes, 05 feb, 2018'; $this->assertEquals($expected, $actual); } finally { self::$alternate_locale = false; + setlocale(LC_ALL, 'en_GB.UTF-8', 'en_GB.utf8', 'en'); } + + } }