332 lines
12 KiB
PHP
332 lines
12 KiB
PHP
<?php // Commentaires de page, fichier inclus dans showComment() ?>
|
|
|
|
<?php // Style lié au thème du site ?>
|
|
<style>.msgs > hr { --hr_color : <?=$this->getData(['theme', 'block', 'borderColor'])?>; }</style>
|
|
|
|
<?php
|
|
// Lexique
|
|
include('./core/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_core.php');
|
|
|
|
// Création du brouillon s'il n'existe pas
|
|
if( !isset($_SESSION['draftPage'])){
|
|
$_SESSION['draftPage'] = [];
|
|
$_SESSION['draftPage']['textarea'] = "";
|
|
$_SESSION['draftPage']['text'] = "";
|
|
}
|
|
|
|
// Traitement des boutons pagination
|
|
$commentNumPage = 'commentNumPage'. $this->getUrl(0);
|
|
if($this->isPost() && isset($_POST['commentPageFormNext' ])){
|
|
$_SESSION[$commentNumPage] = $_SESSION[$commentNumPage] + 1;
|
|
}
|
|
if($this->isPost() && isset($_POST['commentPageFormPrev' ])){
|
|
$_SESSION[$commentNumPage] = $_SESSION[$commentNumPage] - 1;
|
|
}
|
|
|
|
// Traitement de l'envoi du formualire
|
|
if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
|
|
|
|
|
// $notice concerne la détection d'erreurs
|
|
$notice = '';
|
|
$code = null !== $this->getInput('codeCaptcha') ? $this->getInput('codeCaptcha') : '';
|
|
// Captcha demandée
|
|
if( $this->getData(['config', 'social', 'comment', 'captcha']) ){
|
|
// option de détection de robot en premier cochée et $_SESSION['humanBot']==='human'
|
|
if( $_SESSION['humanBot']==='human' && $this->getData(['config', 'connect', 'captchaBot'])=== true ) {
|
|
// Présence des 5 cookies et checkbox cochée ?
|
|
$detectBot ='bot';
|
|
if ( isset ($_COOKIE['evtO']) && isset ($_COOKIE['evtV']) && isset ($_COOKIE['evtH'])
|
|
&& isset ($_COOKIE['evtS']) && isset ($_COOKIE['evtA']) && $this->getInput('commentPageFormHumanCheck', helper::FILTER_BOOLEAN) === true ) {
|
|
// Calcul des intervals de temps
|
|
$time2 = $_COOKIE['evtH'] - $_COOKIE['evtO']; // temps entre click checkbox et ouverture de la page
|
|
$time3 = $_COOKIE['evtV'] - $_COOKIE['evtH']; // temps entre validation formulaire et click checkbox
|
|
$time4 = $_COOKIE['evtS'] - $_COOKIE['evtA']; // temps passé sur la checkbox
|
|
if( $time2 >= 1000 && $time3 >=300 && $time4 >=300 ) $detectBot = 'human';
|
|
}
|
|
// Bot présumé
|
|
if( $detectBot === 'bot') $_SESSION['humanBot']='bot';
|
|
}
|
|
// $_SESSION['humanBot']==='bot' ou option 'Pas de Captcha pour un humain' non validée
|
|
elseif( md5($code) !== $_SESSION['captcha'] ) {
|
|
$notice = $text['core']['showComment'][1];
|
|
}
|
|
}
|
|
|
|
// Lecture des inputs
|
|
$valueText = $this->getInput('commentPageFormInput[0]', helper::FILTER_STRING_SHORT, true);
|
|
$valueTextarea = $this->getInput('commentPageFormInput[1]', helper::FILTER_STRING_LONG_NOSTRIP, true);
|
|
|
|
// Mise à jour du brouillon
|
|
$_SESSION['draftPage']['text'] = $valueText;
|
|
$_SESSION['draftPage']['textarea'] = $valueTextarea;
|
|
|
|
// Préparation du contenu des données ($data) et du mail
|
|
$data = [];
|
|
$content = '';
|
|
$file_name = '';
|
|
// Mail
|
|
if( $valueText !== '') $content .= '<strong>' . $text['core']['showComment'][9] . ' :</strong> ' . $valueText . '<br>';
|
|
if( $valueTextarea !== '') $content .= '<strong>' . $text['core']['showComment'][10] . ' :</strong> ' . $valueTextarea . '<br>';
|
|
// Données
|
|
$data[$text['core']['showComment'][9]] = $valueText;
|
|
$data[$text['core']['showComment'][10]] = $valueTextarea;
|
|
|
|
// Bot présumé, la page sera actualisée avec l'affichage du captcha complet
|
|
if( $detectBot === 'bot') $notice = $text['core']['showComment'][1];
|
|
|
|
// Si absence d'erreur
|
|
$sent = true;
|
|
if( $notice === ''){
|
|
// Crée les données, l'indice des messages est la date unix
|
|
$id = time();
|
|
$this->setData(['comment', $this->getUrl(0), 'data', $id , $data]);
|
|
// Ajout de la date en clair pour les données dans le json
|
|
if( $this->getData(['config', 'i18n', 'langAdmin']) === 'en' ){
|
|
$dateMessage = date('m/d/Y H:i', $id);
|
|
} else {
|
|
$dateMessage = date('d/m/Y H:i', $id);
|
|
}
|
|
$this->setData(['comment', $this->getUrl(0), 'data', $id , 'Date' , $dateMessage ]);
|
|
// Liste des utilisateurs
|
|
$userIdsFirstnames = helper::arrayCollumn($this->getData(['user']), 'firstname');
|
|
ksort($userIdsFirstnames);
|
|
$listUsers [] = '';
|
|
foreach($userIdsFirstnames as $userId => $userFirstname) {
|
|
$listUsers [] = $userId;
|
|
}
|
|
// Emission du mail
|
|
// Rechercher l'adresse en fonction du mail
|
|
$singleuser = $this->getData(['user', $listUsers[$this->getData(['config', 'social', 'comment', 'user'])], 'mail']);
|
|
$singlemail = $this->getData(['config', 'social', 'comment', 'mail']);
|
|
$group = $this->getData(['config', 'social', 'comment', 'group']);
|
|
// Verification si le mail peut être envoyé
|
|
if(
|
|
self::$inputNotices === [] && (
|
|
$group > 0 ||
|
|
$singleuser !== '' ||
|
|
$singlemail !== '' )
|
|
) {
|
|
// Utilisateurs dans le groupe
|
|
$to = [];
|
|
if ($group > 0){
|
|
foreach($this->getData(['user']) as $userId => $user) {
|
|
if($user['group'] >= $group) {
|
|
$to[] = $user['mail'];
|
|
}
|
|
}
|
|
}
|
|
// Utilisateur désigné
|
|
if (!empty($singleuser)) {
|
|
$to[] = $singleuser;
|
|
}
|
|
// Mail désigné
|
|
if (!empty($singlemail)) {
|
|
$to[] = $singlemail;
|
|
}
|
|
if($to) {
|
|
// Sujet du mail
|
|
$subject = $this->getData(['config', 'social', 'comment', 'subject']);
|
|
if($subject === '') {
|
|
$subject = $text['core']['showComment'][2];
|
|
}
|
|
// Envoi le mail
|
|
$sent = $this->sendMail(
|
|
$to,
|
|
$subject,
|
|
$text['core']['showComment'][3] . $this->getData(['page', $this->getUrl(0), 'title']) . ' :<br><br>' .
|
|
$content
|
|
);
|
|
}
|
|
}
|
|
// Redirection
|
|
$redirect = helper::baseUrl() . $this->getUrl(0);
|
|
if ( $this->getData(['module', $this->getUrl(0), 'config', 'pageId']) !== '') $redirect = helper::baseUrl() . $this->getData(['module', $this->getUrl(0), 'config', 'pageId']);
|
|
// Effacement des données provisoires
|
|
if( self::$inputNotices === [] ){
|
|
$_SESSION['draftPage'] = [];
|
|
$_SESSION['draftPage']['textarea'] = "";
|
|
$_SESSION['draftPage']['text'] = "";
|
|
} else {
|
|
$sent = false;
|
|
}
|
|
} else {
|
|
$sent = false;
|
|
}
|
|
|
|
// Notifications
|
|
if( $sent === true) {
|
|
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= $text['core']['showComment'][4];
|
|
$_SESSION['DELTA_NOTIFICATION_ERROR'] = '';
|
|
} else {
|
|
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= '';
|
|
$_SESSION['DELTA_NOTIFICATION_ERROR'] = $text['core']['showComment'][5];
|
|
}
|
|
$this->showNotification();
|
|
}
|
|
|
|
// Préparation de la liste paginée des commentaires // Initialisation de la pagination
|
|
$nbPage =0;
|
|
if ( !isset($_SESSION[$commentNumPage] )) $_SESSION[$commentNumPage] = 1;
|
|
$dataPage = $this->getData(['comment', $this->getUrl(0), 'data']);
|
|
if ( NULL !== $dataPage && is_array($dataPage) && $dataPage !== [] ) {
|
|
$nbPage = round(count( $dataPage) / self::ITEMSPAGE, 0, PHP_ROUND_HALF_UP);
|
|
if( $_SESSION[$commentNumPage] > $nbPage ) $_SESSION[$commentNumPage] = $nbPage;
|
|
if( $_SESSION[$commentNumPage] <= 0 ) $_SESSION[$commentNumPage] = 1;
|
|
$paramPage = $this->getUrl() .'/'. $_SESSION[$commentNumPage];
|
|
// Pagination
|
|
$pagination = helper::pagination($dataPage, $paramPage, self::ITEMSPAGE);
|
|
// Liste des pages
|
|
$pagesComment = $pagination['pages'];
|
|
// Inverse l'ordre du tableau
|
|
$dataIds = array_reverse(array_keys($dataPage));
|
|
$dataPage = array_reverse($dataPage);
|
|
// Données en fonction de la pagination et suppression des adresses e-mail
|
|
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
|
$content = '';
|
|
foreach($dataPage[$i] as $input => $value) {
|
|
if (!empty($value) && strpos($value, 'Д') === false) $content .= '<div class=\'clef\'>' . $input . '</div> : <div class=\'valeur\'>' . $value . '</div>';
|
|
}
|
|
$horizontalRule = '';
|
|
if( $i < $pagination['last'] - 1) : $horizontalRule = '<hr>';
|
|
else : $horizontalRule = '<br>';
|
|
endif;
|
|
$data[] = [
|
|
$content.$horizontalRule
|
|
];
|
|
}
|
|
}
|
|
|
|
// Partie affichage (View dans la structure classique)
|
|
// Adaptation de la langue dans tinymce pour la rédaction d'un message en fonction de la langue de la page, originale ou en traduction rédigée
|
|
$lang = $this->getData(['config', 'i18n', 'langBase']);
|
|
if ( !empty($_COOKIE["DELTA_I18N_SITE"])) {
|
|
if( $this->getInput('DELTA_I18N_SITE') !== 'base' ) $lang = $this->getInput('DELTA_I18N_SITE');
|
|
}
|
|
$lang_page = $lang;
|
|
switch ($lang) {
|
|
case 'en' :
|
|
$lang_page = 'en_GB';
|
|
break;
|
|
case 'pt' :
|
|
$lang_page = 'pt_PT';
|
|
break;
|
|
case 'sv' :
|
|
$lang_page = 'sv_SE';
|
|
break;
|
|
case 'fr' :
|
|
$lang_page = 'fr_FR';
|
|
break;
|
|
}
|
|
// Si la langue n'est pas supportée par Tinymce la langue d'administration est utilisée
|
|
if( ! file_exists( 'core/vendor/tinymce/langs/'.$lang_page.'.js' )){
|
|
$lang_page = $lang_admin;
|
|
}
|
|
echo '<script> var lang_admin = "'.$lang_page.'"; </script>';
|
|
// Vendor tinymce ?>
|
|
<script src="core/vendor/tinymce/tinymce.min.js"></script><script src="core/vendor/tinymce/init.js"></script>
|
|
|
|
<div class="row">
|
|
<div class="col4 offset4">
|
|
<?php echo template::button('buttonCommentShowForm', [
|
|
'value' => $text['core']['showComment'][0],
|
|
'ico' => 'pencil'
|
|
]); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="formCommentVisible" style="display: none;">
|
|
<?php // Formulaire
|
|
echo template::formOpenFile('commentPageFormForm'); ?>
|
|
<div class="humanBot">
|
|
<?php echo template::text('commentPageFormInput[0]', [
|
|
'id' => 'commentPageFormInput_0',
|
|
'label' => $text['core']['showComment'][9],
|
|
'value' => $_SESSION['draftPage']['text']
|
|
]);
|
|
echo template::textarea('commentPageFormInput[1]', [
|
|
'id' => 'commentPageFormInput_1',
|
|
'label' => $text['core']['showComment'][10],
|
|
'value' => $_SESSION['draftPage']['textarea'],
|
|
'class' => 'editorWysiwygComment',
|
|
'noDirty' => true
|
|
]); ?>
|
|
</div>
|
|
<?php if( $this->getData(['config', 'social', 'comment', 'captcha']) && ( $_SESSION['humanBot']==='bot') || $this->getData(['config', 'connect', 'captchaBot'])===false ): ?>
|
|
<div class="row">
|
|
<div class="col12 textAlignCenter">
|
|
<?php echo template::captcha('commentPageFormCaptcha', ''); ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if( $this->getData(['config', 'social', 'comment', 'captcha']) && $_SESSION['humanBot']==='human' && $this->getData(['config', 'connect', 'captchaBot']) ): ?>
|
|
<div class="row formCheckBlue">
|
|
<?php echo template::text('commentPageFormInputBlue', [
|
|
'label' => 'Input Blue',
|
|
'value' => ''
|
|
]); ?>
|
|
</div>
|
|
<br>
|
|
<div class="row formOuter">
|
|
<div class="formInner commentHumanCheck">
|
|
<?php echo template::checkbox('commentPageFormHumanCheck', true, $this->getData(['locale', 'captchaSimpleText']), [
|
|
'checked' => false,
|
|
'help' => $this->getData(['locale', 'captchaSimpleHelp'])
|
|
]); ?>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
<?php endif; ?>
|
|
<div class="row textAlignCenter">
|
|
<div class="formInner commentHumanBotClose">
|
|
<?php echo template::submit('commentPageFormSubmit', [
|
|
'value' => $this->getData(['config', 'social', 'comment', 'button']) ? $this->getData(['config', 'social', 'comment', 'button']) : $text['core']['showComment'][8],
|
|
'ico' => ''
|
|
]); ?>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
</div>
|
|
|
|
<?php
|
|
// Affichage des messages
|
|
echo '<div class="block msgs">';
|
|
if($data):
|
|
foreach( $data as $key1=>$value1){
|
|
if( is_array($value1)){
|
|
foreach( $value1 as $key2=>$value2){
|
|
echo $value2;
|
|
}
|
|
}
|
|
}
|
|
else:
|
|
echo template::speech('<div style=" text-align: center;">'.$text['core']['showComment'][6].'</div>' );
|
|
endif;
|
|
echo '</div>';
|
|
if($pagesComment && $nbPage > 1){ ?>
|
|
<div class="row" >
|
|
<?php if($_SESSION[$commentNumPage] > 1) { ?>
|
|
<div class="col1">
|
|
<?php echo template::submit('commentPageFormPrev', [
|
|
'class' => 'commentPageButtonPrevNext',
|
|
'value' => '',
|
|
'ico' =>'left'
|
|
]); ?>
|
|
</div>
|
|
<?php } ?>
|
|
<div class="col1" style="padding-top:20px;text-align:center;">
|
|
<?php echo template::label('',$text['core']['showComment'][11].$_SESSION[$commentNumPage].'/'.$nbPage,[]); ?>
|
|
</div>
|
|
<?php if($_SESSION[$commentNumPage] < $nbPage ) { ?>
|
|
<div class="col1">
|
|
<?php echo template::submit('commentPageFormNext', [
|
|
'class' => 'commentPageButtonPrevNext',
|
|
'value' => '',
|
|
'ico' =>'plus'
|
|
]); ?>
|
|
</div>
|
|
<?php } ?>
|
|
</div> <?php
|
|
}
|
|
echo template::formClose();
|
|
?>
|