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

@ -2126,8 +2126,7 @@ 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
@ -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();
@ -2968,8 +2965,7 @@ class core extends common
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() . ';';