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/jsondb/Dot.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)
{
require_once 'core/class/strftime/php-8.1-strftime.class.php';
return mb_detect_encoding(\PHP81_BC\strftime($format, $date), 'UTF-8', true)
? \PHP81_BC\strftime($format, $date)
: utf8_encode(\PHP81_BC\strftime($format, $date));

View File

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

View File

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

View File

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

View File

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