staticId().'.json'; if(!file_exists($commentsFile)) { touch($commentsFile); file_put_contents($commentsFile,'[]'); } # extraction des commentaires dans un tableau $comments = json_decode(file_get_contents($commentsFile), true); $num = count($comments); # format du message aprés soumission du formulaire $row ='

#com_message

'; # As t-on de nouveaux commentaires ? if(isset($_POST)){ # color boite message par défaut $color = 'orange'; $level='level-0'; if(isset($_POST['name']) AND isset($_POST['content'])) { if( $_POST['name'] =='' OR $_POST['content'] =='') { $_SESSION['msgcom'] = L_NEWCOMMENT_FIELDS_REQUIRED; } if(!empty($this->aConf['capcha']) AND (empty($_SESSION['capcha_token']) OR empty($_POST['capcha_token']) or ($_SESSION['capcha_token'] != $_POST['capcha_token']))) { $_SESSION['msgcom'] .= ' '. L_NEWCOMMENT_ERR_ANTISPAM; } else { # On vérifie que le capcha est correct if($this->plxMotor->aConf['capcha'] == 0 OR $_SESSION['capcha'] == sha1($_POST['rep'])) { if(isset($_POST['level'])) { $level = trim($_POST['level']) ; if($level == 'level-5' || $level =='level-max' ) {$level ='level-max';} else {$level++;} } $newcomment[] = array( 'num' => trim(strip_tags($_POST['num'])), 'date' => date('d-m-Y') , 'name' => trim(strip_tags($_POST['name'])) , 'mail' => trim(strip_tags($_POST['mail'])) , 'site' => trim(strip_tags($_POST['site'])), 'content' => trim(strip_tags($_POST['content'])), 'level' => trim(strip_tags($level)) ); $color = 'green'; $_SESSION['msgcom'] = L_COM_PUBLISHED; # est ce une reponse à un commentaire particulier? if(isset($_POST['index'])) { array_splice($comments, trim($_POST['index'])+1, 0, $newcomment); } else { array_push($comments,$newcomment[0]); } file_put_contents($commentsFile, json_encode($comments,true|JSON_PRETTY_PRINT) ); } else { $_SESSION['msgcom'] = L_NEWCOMMENT_ERR_ANTISPAM; } } } } if(count($comments)>0) { $tittleComment ="

".count($comments).' '. L_COMMENT ."

"; if(count($comments)>1) { $tittleComment ="

".count($comments).' '. L_COMMENTS ."

"; } echo $tittleComment ; # Style barre pagination commentaires echo ''; ############################# # extraction et maj variables ############################# # extraction de l'url $url = $this->plxMotor->urlRewrite('?static' . $this->staticId() . '/' . $this->plxMotor->aStats[str_pad($this->staticId(), 3, '0', STR_PAD_LEFT)]['url'] ); # generation du lien $link = $this->plxMotor->urlRewrite($url."/page"); // On calcule le nombre de pages total $nbr = count($comments); $pages = ceil( $nbr / $bypage); $position = 1; if($showLast==true) $position = $pages; # extraction du numéro de page dans l'URL $currentPage = preg_match('#\bpage(\d*)#',$_SERVER['REQUEST_URI'], $capture) ? intval($capture[1]) : $position; # indice de début, premier article à afficher $start = ($currentPage - 1) * $bypage; // Calcul du 1er commentaire de la page $premier = ($currentPage * $bypage) - $bypage; ; $pagecomments = array_slice($comments, $premier, $bypage); foreach($pagecomments as $com =>$val) { # On boucle sur les commentaires $index=array_search( $val['num'], array_column( $comments, 'num' ) ); echo '
#'.$val['num'].'  - '.$val['name'].' '. $this->getLang('SAID').':

'.$val['content'].'

'; if($this->plxMotor->aConf['allow_com']){ echo ''.$this->getLang('REPLY').''; } echo '
'; } ?> 1){ ?>

lang('WRITE_A_COMMENT') ?>

plxMotor->aConf['capcha']): ?>
plxMotor->plxCapcha = new plxCapcha(); # Création objet captcha $this->capchaQ(); ?>