chargement de la classe strftime à la demande + helper::dateUTF8 appliqué partout

This commit is contained in:
Fred Tempez 2022-10-09 10:50:28 +02:00
parent d4713f15cd
commit daa3d38695
6 changed files with 17 additions and 29 deletions

View File

@ -12,6 +12,5 @@ class autoload {
require_once 'core/class/phpmailer/SMTP.class.php'; require_once 'core/class/phpmailer/SMTP.class.php';
require_once 'core/class/jsondb/Dot.class.php'; require_once 'core/class/jsondb/Dot.class.php';
require_once 'core/class/jsondb/JsonDb.class.php'; require_once 'core/class/jsondb/JsonDb.class.php';
require_once 'core/class/strftime/php-8.1-strftime.class.php';
} }
} }

View File

@ -39,6 +39,7 @@ class helper
*/ */
public static function dateUTF8($format, $date) public static function dateUTF8($format, $date)
{ {
require_once 'core/class/strftime/php-8.1-strftime.class.php';
return mb_detect_encoding(\PHP81_BC\strftime($format, $date), 'UTF-8', true) return mb_detect_encoding(\PHP81_BC\strftime($format, $date), 'UTF-8', true)
? \PHP81_BC\strftime($format, $date) ? \PHP81_BC\strftime($format, $date)
: utf8_encode(\PHP81_BC\strftime($format, $date)); : utf8_encode(\PHP81_BC\strftime($format, $date));

View File

@ -1024,7 +1024,7 @@ class common
case 'gif': case 'gif':
$source_image = imagecreatefromgif($src); $source_image = imagecreatefromgif($src);
break; break;
case 'webp' : case 'webp':
$source_image = imagecreatefromwebp($src); $source_image = imagecreatefromwebp($src);
break; break;
} }
@ -1049,7 +1049,7 @@ class common
case 'image/gif': case 'image/gif':
return (imagegif($virtual_image, $dest)); return (imagegif($virtual_image, $dest));
break; break;
case 'webp' : case 'webp':
$source_image = imagecreatefromwebp($src); $source_image = imagecreatefromwebp($src);
break; break;
} }
@ -1260,7 +1260,7 @@ class common
) { ) {
$item .= '<form method="POST" action="' . helper::baseUrl(false) . '" id="cookieForm">'; $item .= '<form method="POST" action="' . helper::baseUrl(false) . '" id="cookieForm">';
} else { } else {
$item .= '<form method="POST" action="' . helper::baseUrl(true) . $this->getUrl(). '" id="cookieForm">'; $item .= '<form method="POST" action="' . helper::baseUrl(true) . $this->getUrl() . '" id="cookieForm">';
} }
$item .= '<br><br>'; $item .= '<br><br>';
$item .= '<input type="submit" id="cookieConsentConfirm" value="' . $this->getData(['locale', 'cookies', 'buttonValidLabel']) . '">'; $item .= '<input type="submit" id="cookieConsentConfirm" value="' . $this->getData(['locale', 'cookies', 'buttonValidLabel']) . '">';
@ -1283,7 +1283,7 @@ class common
{ {
echo '<section>'; echo '<section>';
// Récupérer la config de la page courante // Récupérer la config de la page courante
$blocks = is_null($this->getData(['page',$this->getUrl(0),'block'])) ? '12' : $this->getData(['page',$this->getUrl(0),'block']); $blocks = is_null($this->getData(['page', $this->getUrl(0), 'block'])) ? '12' : $this->getData(['page', $this->getUrl(0), 'block']);
$blocks = explode('-', $blocks); $blocks = explode('-', $blocks);
// Initialiser // Initialiser
$blockleft = ''; $blockleft = '';
@ -2126,10 +2126,9 @@ class common
// Sur une page sans module // Sur une page sans module
or $this->getData(['page', $this->getUrl(0), 'moduleId']) === '' or $this->getData(['page', $this->getUrl(0), 'moduleId']) === ''
// Sur une page avec un module invalide // Sur une page avec un module invalide
OR ( or (!is_null($this->getData(['page', $this->getUrl(2), 'moduleId'])) &&
!is_null($this->getData(['page', $this->getUrl(2), 'moduleId'])) &&
!class_exists($this->getData(['page', $this->getUrl(2), 'moduleId'])) !class_exists($this->getData(['page', $this->getUrl(2), 'moduleId']))
) )
// Sur une page d'accueil // Sur une page d'accueil
or $this->getUrl(0) === '' or $this->getUrl(0) === ''
) { ) {
@ -2783,9 +2782,7 @@ class core extends common
exit(); exit();
} }
// Journalisation // Journalisation
$dataLog = mb_detect_encoding(\PHP81_BC\strftime('%d/%m/%y', time()), 'UTF-8', true) $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time());
? \PHP81_BC\strftime('%d/%m/%y', time()) . ';' . \PHP81_BC\strftime('%R', time()) . ';'
: utf8_encode(\PHP81_BC\strftime('%d/%m/%y', time())) . ';' . utf8_encode(\PHP81_BC\strftime('%R', time())) . ';';
$dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';';
$dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';'; $dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';';
$dataLog .= $this->getUrl(); $dataLog .= $this->getUrl();
@ -2863,8 +2860,8 @@ class core extends common
$accessInfo['userName'] = ''; $accessInfo['userName'] = '';
$accessInfo['pageId'] = ''; $accessInfo['pageId'] = '';
foreach ($this->getData(['user']) as $userId => $userIds) { foreach ($this->getData(['user']) as $userId => $userIds) {
if (!is_null($this->getData(['user', $userId, 'accessUrl'])) ) { if (!is_null($this->getData(['user', $userId, 'accessUrl']))) {
$t = explode('/',$this->getData(['user', $userId, 'accessUrl'])); $t = explode('/', $this->getData(['user', $userId, 'accessUrl']));
} }
if ( if (
$this->getUser('id') && $this->getUser('id') &&
@ -2964,12 +2961,11 @@ class core extends common
$action = ''; $action = '';
$ignore = true; $ignore = true;
if (!is_null($this->getUrl(1))) { if (!is_null($this->getUrl(1))) {
foreach(explode('-', $this->getUrl(1)) as $actionPart) { foreach (explode('-', $this->getUrl(1)) as $actionPart) {
if($ignore) { if ($ignore) {
$action .= $actionPart; $action .= $actionPart;
$ignore = false; $ignore = false;
} } else {
else {
$action .= ucfirst($actionPart); $action .= ucfirst($actionPart);
} }
} }

View File

@ -696,9 +696,7 @@ class config extends common
$d = $this->getData(['blacklist']); $d = $this->getData(['blacklist']);
$data = ''; $data = '';
foreach ($d as $key => $item) { foreach ($d as $key => $item) {
$data .= mb_detect_encoding(\PHP81_BC\strftime('%d/%m/%y', $item['lastFail']), 'UTF-8', true) $data .= helper::dateUTF8('%Y %m %d', $item['lastFail']) . ' - ' . helper::dateUTF8('%H:%M', time());
? \PHP81_BC\strftime('%d/%m/%y', $item['lastFail']) . ';' . utf8_encode(\PHP81_BC\strftime('%R', $item['lastFail'])) . ';'
: utf8_encode(\PHP81_BC\strftime('%d/%m/%y', $item['lastFail'])) . ';' . utf8_encode(\PHP81_BC\strftime('%R', $item['lastFail'])) . ';';
$data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL; $data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL;
} }
file_put_contents($fileName, $data, FILE_APPEND); file_put_contents($fileName, $data, FILE_APPEND);

View File

@ -369,9 +369,7 @@ class plugin extends common
$store[$key]['category'], $store[$key]['category'],
'<a href="' . self::BASEURL_STORE . self::MODULE_STORE . $key . '" target="_blank" >' . $store[$key]['title'] . '</a>', '<a href="' . self::BASEURL_STORE . self::MODULE_STORE . $key . '" target="_blank" >' . $store[$key]['title'] . '</a>',
$store[$key]['version'], $store[$key]['version'],
mb_detect_encoding(\PHP81_BC\strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true) helper::dateUTF8('%d %B %Y', $store[$key]['versionDate']),
? \PHP81_BC\strftime('%d %B %Y', $store[$key]['versionDate'])
: utf8_encode(\PHP81_BC\strftime('%d %B %Y', $store[$key]['versionDate'])),
implode(', ', array_keys($pagesInfos, $key)), implode(', ', array_keys($pagesInfos, $key)),
template::button('moduleExport' . $key, [ template::button('moduleExport' . $key, [
'class' => $class, 'class' => $class,
@ -397,9 +395,7 @@ class plugin extends common
{ {
$store = json_decode(helper::getUrlContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true); $store = json_decode(helper::getUrlContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
self::$storeItem = $store[$this->getUrl(2)]; self::$storeItem = $store[$this->getUrl(2)];
self::$storeItem['fileDate'] = mb_detect_encoding(\PHP81_BC\strftime('%d %B %Y', self::$storeItem['fileDate']), 'UTF-8', true) self::$storeItem['fileDate'] = helper::dateUTF8('%d %B %Y', self::$storeItem['fileDate']);
? \PHP81_BC\strftime('%d %B %Y', self::$storeItem['fileDate'])
: utf8_encode(\PHP81_BC\strftime('%d %B %Y', self::$storeItem['fileDate']));
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Module ' . self::$storeItem['title']), 'title' => helper::translate('Module ' . self::$storeItem['title']),

View File

@ -495,9 +495,7 @@ class user extends common
} }
} }
// Journalisation // Journalisation
$dataLog = mb_detect_encoding(\PHP81_BC\strftime('%d/%m/%y', time()), 'UTF-8', true) $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time());
? \PHP81_BC\strftime('%d/%m/%y', time()) . ';' . \PHP81_BC\strftime('%R', time()) . ';'
: utf8_encode(\PHP81_BC\strftime('%d/%m/%y', time())) . ';' . utf8_encode(\PHP81_BC\strftime('%R', time())) . ';';
$dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';';
$dataLog .= empty($this->getInput('userLoginId')) ? ';' : $this->getInput('userLoginId', helper::FILTER_ID) . ';'; $dataLog .= empty($this->getInput('userLoginId')) ? ';' : $this->getInput('userLoginId', helper::FILTER_ID) . ';';
$dataLog .= $this->getUrl() . ';'; $dataLog .= $this->getUrl() . ';';