Beispiel #1
0
 /**
  * Méthode qui crée un nouveau commentaire pour l'article $artId
  *
  * @param	artId	identifiant de l'article en question
  * @param	content	contenu du nouveau commentaire
  * @return	booléen
  * @author	Florent MONTHEL
  **/
 public function newCommentaire($artId, $content)
 {
     # On génère le contenu du commentaire
     $author = plxUtils::strCheck($this->aUsers[$_SESSION['user']]['name']);
     $contenu = strip_tags(trim($content), '<a>,<strong>');
     $date = time();
     $site = $this->racine;
     $ip = plxUtils::getIp();
     # On genere le nom du fichier selon l'existence ou non d'un fichier du meme nom
     $i = 0;
     do {
         # On boucle en testant l'existence du fichier (cas de plusieurs commentaires/sec pour un article)
         $i++;
         $filename = PLX_ROOT . $this->aConf['racine_commentaires'] . $artId . '.' . $date . '-' . $i . '.xml';
     } while (file_exists($filename));
     # On peut creer le commentaire
     if ($this->addCommentaire($filename, $author, 'admin', $ip, '', $site, $contenu)) {
         # Commentaire OK
         return true;
     } else {
         return false;
     }
 }
Beispiel #2
0
 /**
  * Méthode qui crée un nouveau commentaire pour l'article $artId
  *
  * @param	artId	identifiant de l'article en question
  * @param	content	tableau contenant les valeurs du nouveau commentaire
  * @return	string
  * @author	Florent MONTHEL, Stéphane F
  **/
 public function newCommentaire($artId, $content)
 {
     # Hook plugins
     if (eval($this->plxPlugins->callHook('plxMotorNewCommentaire'))) {
         return;
     }
     if (strtolower($_SERVER['REQUEST_METHOD']) != 'post' or !isset($_SESSION["capcha_token"]) or !isset($_POST['capcha_token']) or $_SESSION["capcha_token"] != $_POST['capcha_token']) {
         return L_NEWCOMMENT_ERR_ANTISPAM;
     }
     # On vérifie que le capcha est correct
     if ($this->aConf['capcha'] == 0 or $_SESSION['capcha'] == sha1($content['rep'])) {
         if (!empty($content['name']) and !empty($content['content'])) {
             # Les champs obligatoires sont remplis
             $comment = array();
             $comment['type'] = 'normal';
             $comment['author'] = plxUtils::strCheck(trim($content['name']));
             $comment['content'] = plxUtils::strCheck(trim($content['content']));
             # On vérifie le mail
             $comment['mail'] = plxUtils::checkMail(trim($content['mail'])) ? trim($content['mail']) : '';
             # On vérifie le site
             $comment['site'] = plxUtils::checkSite($content['site']) ? $content['site'] : '';
             # On récupère l'adresse IP du posteur
             $comment['ip'] = plxUtils::getIp();
             # index du commentaire
             $idx = $this->nextIdArtComment($idArt);
             # Commentaire parent en cas de réponse
             if (isset($content['parent']) and !empty($content['parent'])) {
                 $comment['parent'] = intval($content['parent']);
             } else {
                 $comment['parent'] = '';
             }
             # On génère le nom du fichier
             $time = time();
             if ($this->aConf['mod_com']) {
                 # On modère le commentaire => underscore
                 $comment['filename'] = '_' . $artId . '.' . $time . '-' . $idx . '.xml';
             } else {
                 # On publie le commentaire directement
                 $comment['filename'] = $artId . '.' . $time . '-' . $idx . '.xml';
             }
             # On peut créer le commentaire
             if ($this->addCommentaire($comment)) {
                 # Commentaire OK
                 if ($this->aConf['mod_com']) {
                     # En cours de modération
                     return 'mod';
                 } else {
                     # Commentaire publie directement, on retourne son identifiant
                     return 'c' . $artId . '-' . $idx;
                 }
             } else {
                 # Erreur lors de la création du commentaire
                 return L_NEWCOMMENT_ERR;
             }
         } else {
             # Erreur de remplissage des champs obligatoires
             return L_NEWCOMMENT_FIELDS_REQUIRED;
         }
     } else {
         # Erreur de vérification capcha
         return L_NEWCOMMENT_ERR_ANTISPAM;
     }
 }
 /**
  * Méthode qui crée un nouveau commentaire pour l'article $artId
  *
  * @param	artId	identifiant de l'article en question
  * @param	content	string contenu du nouveau commentaire
  * @return	booléen
  * @author	Florent MONTHEL, Stéphane F
  **/
 public function newCommentaire($artId, $content)
 {
     # On génère le contenu du commentaire
     $comment = array();
     $comment['author'] = plxUtils::strCheck($this->aUsers[$_SESSION['user']]['name']);
     $comment['content'] = strip_tags(trim($content['content']), '<a>,<strong>');
     $comment['site'] = $this->racine;
     $comment['ip'] = plxUtils::getIp();
     $comment['type'] = 'admin';
     $comment['mail'] = $this->aUsers[$_SESSION['user']]['email'];
     $comment['parent'] = $content['parent'];
     $idx = $this->nextIdArtComment($artId);
     $time = time();
     $comment['filename'] = $artId . '.' . $time . '-' . $idx . '.xml';
     # On peut créer le commentaire
     if ($this->addCommentaire($comment)) {
         # Commentaire OK
         return true;
     } else {
         return false;
     }
 }
Beispiel #4
0
 /**
  * Méthode qui crée un nouveau commentaire pour l'article $artId
  *
  * @param	artId	identifiant de l'article en question
  * @param	content	tableau contenant les valeurs du nouveau commentaire
  * @return	string
  * @author	Florent MONTHEL
  **/
 public function newCommentaire($artId, $content)
 {
     # On verifie que le capcha est correct, si besoin est
     if ($this->aConf['capcha'] == 0 or $content['rep2'] == md5($this->plxCapcha->gds . $content['rep'])) {
         if (!empty($content['name']) and !empty($content['content'])) {
             # Les champs obligatoires sont remplis
             $author = plxUtils::strCheck(trim($content['name']));
             $contenu = plxUtils::strCheck(trim($content['content']));
             $date = time();
             # On verifie le mail
             $mail = plxUtils::checkMail(trim($content['mail'])) ? trim($content['mail']) : '';
             # On verifie le site
             $site = plxUtils::checkSite(trim($content['site'])) ? trim($content['site']) : '';
             # On recupere l'adresse IP du posteur
             $ip = plxUtils::getIp();
             # On genere le nom du fichier selon l'existence ou non d'un fichier du meme nom
             $i = 0;
             do {
                 # On boucle en testant l'existence du fichier (cas de plusieurs commentaires/sec pour un article)
                 $i++;
                 if ($this->aConf['mod_com']) {
                     # On modere le commentaire => underscore
                     $filename = PLX_ROOT . $this->aConf['racine_commentaires'] . '_' . $artId . '.' . $date . '-' . $i . '.xml';
                 } else {
                     # On publie le commentaire directement
                     $filename = PLX_ROOT . $this->aConf['racine_commentaires'] . $artId . '.' . $date . '-' . $i . '.xml';
                 }
             } while (file_exists($filename));
             # On peut creer le commentaire
             if ($this->addCommentaire($filename, $author, 'normal', $ip, $mail, $site, $contenu)) {
                 # Commentaire OK
                 if ($this->aConf['mod_com']) {
                     # En cours de moderation
                     return 'mod';
                 } else {
                     # Commentaire publie directement, on retourne son identifiant
                     return 'c' . $date . '-' . $i;
                 }
             } else {
                 # Erreur lors de la création du commentaire
                 return 'Une erreur s\'est produite lors de la publication de ce commentaire';
             }
         } else {
             # Erreur de remplissage des champs obligatoires
             return 'Merci de remplir tous les champs obligatoires requis';
         }
     } else {
         # Erreur de verification capcha
         return 'La v&eacute;rification anti-spam a &eacute;chou&eacute;';
     }
 }