Localisation avec test de l'encodage

This commit is contained in:
Fred Tempez 2020-11-01 13:38:25 +01:00
parent 7783eb69ab
commit f863b69a4d
9 changed files with 45 additions and 18 deletions

View File

@ -1717,7 +1717,9 @@ class core extends common {
exit(); exit();
} }
// Journalisation // Journalisation
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; $dataLog = mb_detect_encoding(strftime('%d/%m/%y',time()), 'UTF-8', true)
? strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';'
: utf8_encode(strftime('%d/%m/%y',time())) . ';' . utf8_encode(strftime('%R',time())) . ';' ;
$dataLog .= helper::getIp() . ';'; $dataLog .= helper::getIp() . ';';
$dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';'; $dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';';
$dataLog .= $this->getUrl(); $dataLog .= $this->getUrl();

View File

@ -695,7 +695,9 @@ 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 .= strftime('%d/%m/%y',$item['lastFail']) . ';' . strftime('%R',$item['lastFail']) . ';' ; $data .= mb_detect_encoding(strftime('%d/%m/%y',$item['lastFail']), 'UTF-8', true)
? strftime('%d/%m/%y',$item['lastFail']) . ';' . utf8_encode(strftime('%R',$item['lastFail'])) . ';'
: utf8_encode(strftime('%d/%m/%y',$item['lastFail'])) . ';' . utf8_encode(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

@ -53,7 +53,7 @@ class user extends common {
$userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true); $userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true);
$userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true); $userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true);
$userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true); $userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true);
// Stockage des données // Stockage des données
$this->setData([ $this->setData([
'user', 'user',
@ -433,7 +433,9 @@ class user extends common {
$notification = 'Trop de tentatives, accès bloqué durant ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; $notification = 'Trop de tentatives, accès bloqué durant ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.';
} }
// Journalisation // Journalisation
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ; $dataLog = mb_detect_encoding(strftime('%d/%m/%y',time()), 'UTF-8', true)
? strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';'
: utf8_encode(strftime('%d/%m/%y',time())) . ';' . utf8_encode(strftime('%R',time())) . ';' ;
$dataLog .= helper::getIp() . ';'; $dataLog .= helper::getIp() . ';';
$dataLog .= $userId . ';' ; $dataLog .= $userId . ';' ;
$dataLog .= $this->getUrl() .';' ; $dataLog .= $this->getUrl() .';' ;

View File

@ -37,7 +37,6 @@ if(version_compare(PHP_VERSION, '5.6.0', '<')) {
date_default_timezone_set('Europe/Paris'); date_default_timezone_set('Europe/Paris');
setlocale (LC_ALL,'french','fr_Fr','fr_FR.utf8'); setlocale (LC_ALL,'french','fr_Fr','fr_FR.utf8');
/** /**
* Chargement des classes * Chargement des classes
*/ */

View File

@ -127,7 +127,9 @@ class blog extends common {
// Met en forme le tableau // Met en forme le tableau
$comment = $comments[$commentIds[$i]]; $comment = $comments[$commentIds[$i]];
self::$comments[] = [ self::$comments[] = [
strftime('%d %B %Y - %H:%M', $comment['createdOn']), mb_detect_encoding(strftime('%d %B %Y - %H:%M', $comment['createdOn']), 'UTF-8', true)
? strftime('%d %B %Y - %H:%M', $comment['createdOn'])
: utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn'])),
$comment['content'], $comment['content'],
$comment['userId'] ? $this->getData(['user', $comment['userId'], 'firstname']) . ' ' . $this->getData(['user', $comment['userId'], 'lastname']) : $comment['author'], $comment['userId'] ? $this->getData(['user', $comment['userId'], 'firstname']) . ' ' . $this->getData(['user', $comment['userId'], 'lastname']) : $comment['author'],
template::button('blogCommentDelete' . $commentIds[$i], [ template::button('blogCommentDelete' . $commentIds[$i], [
@ -188,12 +190,15 @@ class blog extends common {
// Articles en fonction de la pagination // Articles en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) { for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Met en forme le tableau // Met en forme le tableau
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])));
self::$articles[] = [ self::$articles[] = [
$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']), $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']),
// date('d/m/Y H:i', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])), $date .' à '. $heure,
strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))
.' à '.
strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])),
self::$states[$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'state'])], self::$states[$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'state'])],
template::button('blogConfigEdit' . $articleIds[$i], [ template::button('blogConfigEdit' . $articleIds[$i], [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleIds[$i] . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleIds[$i] . '/' . $_SESSION['csrf'],

View File

@ -3,8 +3,14 @@
<div class="col10"> <div class="col10">
<div class="blogDate"> <div class="blogDate">
<i class="far fa-calendar-alt"></i> <i class="far fa-calendar-alt"></i>
<?php echo strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])); ?> <?php $date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
à <?php echo strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])); ?> ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])));
$heure = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])));
echo $date . ' à ' . $heure;
?>
</div> </div>
</div> </div>
<?php if( <?php if(
@ -113,7 +119,10 @@
<?php else: ?> <?php else: ?>
<?php echo $comment['author']; ?> <?php echo $comment['author']; ?>
<?php endif; ?> <?php endif; ?>
le <?php echo strftime('%d %B %Y - %H:%M', $comment['createdOn']); ?> le <?php echo mb_detect_encoding(strftime('%d %B %Y - %H:%M', $comment['createdOn']), 'UTF-8', true)
? strftime('%d %B %Y - %H:%M', $comment['createdOn'])
: utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn']));
?>
</h4> </h4>
<?php echo $comment['content']; ?> <?php echo $comment['content']; ?>
</div> </div>

View File

@ -34,7 +34,9 @@
</div> </div>
<div class="blogDate"> <div class="blogDate">
<i class="far fa-calendar-alt"></i> <i class="far fa-calendar-alt"></i>
<?php echo strftime('%d %B %Y', $article['publishedOn']); ?> <?php echo mb_detect_encoding(strftime('%d %B %Y - %H:%M', $article['publishedOn']), 'UTF-8', true)
? strftime('%d %B %Y', $article['publishedOn'])
: utf8_encode(strftime('%d %B %Y', $article['publishedOn'])); ?>
</div> </div>
<p class="blogContent"> <p class="blogContent">
<?php echo helper::subword(strip_tags($article['content']), 0, 400); ?>... <?php echo helper::subword(strip_tags($article['content']), 0, 400); ?>...

View File

@ -89,11 +89,15 @@ class news extends common {
// News en fonction de la pagination // News en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) { for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Met en forme le tableau // Met en forme le tableau
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn'])));
self::$news[] = [ self::$news[] = [
$this->getData(['module', $this->getUrl(0), $newsIds[$i], 'title']), $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'title']),
strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn'])) $date .' à '. $heure,
.' à '.
strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $newsIds[$i], 'publishedOn'])),
self::$states[$this->getData(['module', $this->getUrl(0), $newsIds[$i], 'state'])], self::$states[$this->getData(['module', $this->getUrl(0), $newsIds[$i], 'state'])],
template::button('newsConfigEdit' . $newsIds[$i], [ template::button('newsConfigEdit' . $newsIds[$i], [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsIds[$i]. '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsIds[$i]. '/' . $_SESSION['csrf'],

View File

@ -10,7 +10,9 @@
</div> </div>
<div class="newsSignature"> <div class="newsSignature">
<i class="far fa-calendar-alt"></i> <i class="far fa-calendar-alt"></i>
<?php echo strftime('%d %B %Y', $news['publishedOn']); ?> <?php echo mb_detect_encoding(strftime('%d %B %Y', $news['publishedOn']), 'UTF-8', true)
? strftime('%d %B %Y', $news['publishedOn'])
: utf8_encode(strftime('%d %B %Y', $news['publishedOn'])); ?>
- <?php echo $this->getData(['user', $news['userId'], 'firstname']) . ' ' . $this->getData(['user', $news['userId'], 'lastname']); ?> - <?php echo $this->getData(['user', $news['userId'], 'firstname']) . ' ' . $this->getData(['user', $news['userId'], 'lastname']); ?>
</div> </div>
<div class="clearBoth"></div> <div class="clearBoth"></div>