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 .= '' . $text['core']['showComment'][9] . ' : ' . $valueText . '
';
if( $valueTextarea !== '') $content .= '' . $text['core']['showComment'][10] . ' : ' . $valueTextarea . '
';
// 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']) . ' :
' .
$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 .= '