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 ="