Carte
Chat Box
jpb.yo
nicolas.yo
nicolas.yup
nicolas.https://two-dev.nicodev.fr/stats/s
nicolas.le désabonnement a la lnl ne marc

Anciens Articles
Activité du Site

Pages vues depuis 05/06/2021 : 1 536 479

  • Nb. de membres 6
  • Nb. d'articles 9
  • Nb. de forums 2
  • Nb. de sujets 6
  • Nb. de critiques 1

Top 10  Statistiques

Un Bloc ...




Offcanvas right




...

Index du forum »»  Demo »» modif commentaire article

Modérateur(s)user

Poster une réponse dans le sujet

A propos des messages publiés :
Les utilisateurs anonymes peuvent poster de nouveaux sujets et des réponses dans ce forum.

 

Aperçu des sujets :

nicolas nicolas
Posté : 09-09-2023 14:10
regarde : // modif php8

modules/comments/article.php


<?php
/************************************************************************/
/* DUNE by NPDS */
/* =========================== */
/* */
/* Based on PhpNuke 4.x source code */
/* */
/* This version name NPDS Copyright (c) 2001-2020 by Philippe Brunier */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (!function_exists("Mysql_Connexion"))
!include! ("mainfile.php");

settype($sid, "integer");
settype($archive, "integer");

if (!isset($sid) && !isset($tid))
header ("Location: index.php");

// modif php 8
if (!isset($archive))
$archive=0;

if (!$archive)
$xtab=news_aff("libre","WHERE sid='$sid'",1,1);
else
$xtab=news_aff("archive","WHERE sid='$sid'",1,1);

list($sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant, $notes) = $xtab[0];
if (!$aid)
header ("Location: index.php");

sql_query("UPDATE ".$NPDS_Prefix."stories SET counter=counter+1 WHERE sid='$sid'");

!include! ("header.php");

// !include! cache manager
global $SuperCache;
if ($SuperCache) {
$cache_obj = new cacheManager();
$cache_obj->startCachingPage();
}
else
$cache_obj = new SuperCacheEmpty();

if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
$title = aff_langue(stripslashes($title));
$hometext = aff_code(aff_langue(stripslashes($hometext)));
$bodytext = aff_code(aff_langue(stripslashes($bodytext)));
$notes = aff_code(aff_langue(stripslashes($notes)));

if ($notes!= '') $notes='<div class="note blockquote">'.translate("Note").' : '.$notes.'</div>';

if ($bodytext == '')
$bodytext = meta_lang($hometext.'<br />'.$notes);
else
$bodytext = meta_lang($hometext.'<br />'.$bodytext.'<br />'.$notes);

if ($informant == '') $informant = $anonymous;

getTopics($sid);

if ($catid != 0) {
$resultx = sql_query("SELECT title FROM ".$NPDS_Prefix."stories_cat WHERE catid='$catid'");
list($title1) = sql_fetch_row($resultx);
$title = '<a href="index.php?op=newindex&amp;catid='.$catid.'"><span>'.aff_langue($title1).'</span></a> : '.$title;
}

$boxtitle=translate("Liens relatifs");
$boxstuff='
<ul>';

$result=sql_query("SELECT name, url FROM ".$NPDS_Prefix."related WHERE tid='$topic'");
while(list($name, $url) = sql_fetch_row($result)) {
$boxstuff .= '
<li><a href="'.$url.'" target="new"><span>'.$name.'</span></a></li>';
}

$boxstuff .= '
</ul>
<ul>
<li><a href="search.php?topic='.$topic.'" >'.translate("En savoir plus à propos de").' '.aff_langue($topictext).'</a></li>
<li><a href="search.php?member='.$informant.'" >'.translate("Article de").' '.$informant.'</a></li>
</ul>
<div class="">'.translate("L'article le plus lu à propos de").'&nbsp;&nbsp;'.aff_langue($topictext).' :</div>';

$xtab=news_aff("big_story","WHERE topic=$topic",0,1);
list($topstory, $ttitle) = $xtab[0];
$boxstuff .= '
<ul>
<li><a href="article.php?sid='.$topstory.'" >'.aff_langue($ttitle).'</a></li>
</ul>
<div class="">'.translate("Les dernières nouvelles à propos de").' '.aff_langue($topictext).' :</div>';

if (!$archive)
//if ($archive === 0)
$xtab=news_aff("libre","WHERE topic=$topic AND archive='0' ORDER BY sid DESC LIMIT 0,5",0,5);
else
$xtab=news_aff("archive","WHERE topic=$topic AND archive='1' ORDER BY sid DESC LIMIT 0,5",0,5);

$story_limit=0;
$boxstuff .='
<ul>';

while (($story_limit<5) and ($story_limit<sizeof($xtab))) {
list($sid1,$catid1,$aid1,$title1) = $xtab[$story_limit];
$story_limit++;
$title1=aff_langue(addslashes($title1));
$boxstuff.='
<li><a href="article.php?sid='.$sid1.'&amp;archive='.$archive.'" >'.aff_langue(stripslashes($title1)).'</a></li>';
}

$boxstuff .='
</ul>
<p align="center">
<a href="print.php?sid='.$sid.'&amp;archive='.$archive.'" ><i class="fa fa-print fa-lg me-1" title="'.translate("Page spéciale pour impression").'" data-bs-toggle="tooltip"></i></a>
<a href="friend.php?op=FriendSend&amp;sid='.$sid.'&amp;archive='.$archive.'"><i class="fa fa-lg fa-at" title="'.translate("Envoyer cet article à un ami").'" data-bs-toggle="tooltip"></i></a>
</p>';

if (!$archive) {
$previous_tab=news_aff("libre","WHERE sid<'$sid' ORDER BY sid DESC ",0,1);
$next_tab=news_aff("libre","WHERE sid>'$sid' ORDER BY sid ASC ",0,1);
} else {
_d('f');
$previous_tab=news_aff("archive","WHERE sid<'$sid' ORDER BY sid DESC",0,1);
$next_tab=news_aff("archive","WHERE sid>'$sid' ORDER BY sid ASC ",0,1);
}

if (array_key_exists(0,$previous_tab))
list($previous_sid) = $previous_tab[0];
else
$previous_sid=0;

if (array_key_exists(0,$next_tab))
list($next_sid) = $next_tab[0];
else
$next_sid=0;

themearticle($aid, $informant, $time, $title, $bodytext, $topic, $topicname, $topicimage, $topictext, $sid, $previous_sid, $next_sid, $archive);

// theme sans le système de commentaire en meta-mot !
if (!function_exists("Caff_pub")) {
if (file_exists("modules/comments/article.conf.php")) {
!include! ("modules/comments/article.conf.php");
!include! ("modules/comments/comments.php");
}
}
}

if ($SuperCache)
$cache_obj->endCachingPage();

!include! ("footer.php");
?&gt;


modules/comments/article.conf.php


&lt;?php
/************************************************************************/
/* DUNE by NPDS */
/* =========================== */
/* */
/* NPDS Copyright (c) 2002-2019 by Philippe Brunier */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
// Don't remove this line !
global $C_start;

// $file_name : racine du nom de ce fichier (article, pollBoth, ...)
$file_name='article';

// $forum : permet d'allouer un numéro de forum pour chaque 'type de commentaires' (article, sondage, ...) - le numéro de forum doit impérativement être NEGATIF
$forum=-1;

// $topic : permet d'allouer un numéro UNIQUE pour chaque publication sur laquelle un commentaire peut être réalisé (article numéro X, sondage numéro Y, ...)

// modif php 8
//settype($sid,'integer');
//if ($sid!='') $topic=$sid;
if (isset($sid)) $topic=$sid;

// $url_ret : URL de retour lorsque la soumission du commentaire est OK
global $archive;
//settype($archive,'integer');
$url_ret="article.php?sid=$topic&archive=$archive";

// $formulaire : Formulaire SFORM si vous souhaitez avoir une grille de saisie en lieu et place de l'interface standard de saisie - sinon ""
$formulaire='';

// $comments_per_page : Nombre de commentaire sur chaque page
$comments_per_page=2;

// Mise à jour de champ d'une table externe à la table des commentaires
// $req_add = opération à effectuer lorsque je rajoute un commentaire
// $req_del = opération à effectuer lorsque je cache un commentaire
// $req_raz = opération à effectuer lorsque je supprime tous les commentaires
$comments_req_add="stories SET comments=comments+1 WHERE sid='$topic'";
$comments_req_del="stories SET comments=comments-1 WHERE sid='$topic'";
$comments_req_raz="stories SET comments=0 WHERE sid='$topic'";
?&gt;


modules/comments/comments.php


&lt;?php
/************************************************************************/
/* DUNE by NPDS */
/* =========================== */
/* */
/* Based on PhpNuke 4.x source code */
/* Based on Parts of phpBB */
/* */
/* NPDS Copyright (c) 2002-2021 by Philippe Brunier */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (!function_exists("Mysql_Connexion"))
die();
!include!_once('functions.php');
!include!_once('auth.php');

settype($forum,'integer');
settype($short_user,'integer');

if ($forum>=0) die();

// gestion des params du 'forum' : type, accès, modérateur ...
$forum_name = 'comments';
$forum_type=0;
$allow_to_post=false;

if ($anonpost)
$forum_access=0;
else
$forum_access=1;

if (($moderate==1) and $admin)
$Mmod=true;
elseif ($moderate==2) {
$userX=base_64_decode($user);
$userdata=explode(':', $userX);
$result=sql_query("SELECT level FROM ".$NPDS_Prefix."users_status WHERE uid='".$userdata[0]."'");
list($level)=sql_fetch_row($result);
if ($level>=2)
$Mmod=true;
} else
$Mmod=false;


function Caff_pub($topic, $file_name, $archive) {
global $language;
$tmp='<a href="modules.php?ModPath=comments&amp;ModStart=reply&amp;topic='.$topic.'&amp;file_name='.$file_name.'&amp;archive='.$archive.'" class="btn btn-primary btn-sm" role="button">'.translate("Commentaire").'</a>';
return ($tmp);
}

if ($forum_access==0)
$allow_to_post=true;
else
if ($user)
$allow_to_post=true;

global $anonymous;

//settype($archive,'integer');

// modif php 8
if (!isset($archive))
$archive=0;

if ($allow_to_post)
echo '<nav class="text-end my-2">'.Caff_pub($topic,$file_name, $archive).'</nav>';

// Pagination

//settype($C_start,'integer');
// modif php 8
if (!isset($C_start))
$C_start=0;

settype($comments_per_page,'integer');

$result=sql_query ("SELECT COUNT(*) AS total FROM ".$NPDS_Prefix."posts WHERE forum_id='$forum' AND topic_id='$topic' AND post_aff='1'");
list($total)=sql_fetch_row($result);

$nbPages = ceil($total/$comments_per_page);
$current = 1;

if ($C_start >= 1)
$current=$C_start/$comments_per_page;
else if ($C_start < 1)
$current=0;
else
$current = $nbPages;

if($total>=1) {
echo '
<div class="d-flex mt-4 justify-content-between flex-wrap">
<nav id="co-pagihaute">
<ul class="pagination pagination-sm d-flex flex-wrap justify-content-end">
<li class="page-item">
<a class="page-link" href="#co-pagibasse"><i class="fa fa-angle-double-down" title="'.translate("Bas de page").'" data-bs-toggle="tooltip"></i></a>
</li>
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="'.translate("Commentaire(s)").'">'.$total.' '.translate("Commentaire(s)").'</a>
</li>
<li class="page-item disabled">
<a class="page-link"href="#" aria-label="'.translate("pages").'">'.$nbPages.' '.translate("pages").'</a>
</li>
</ul>
</nav>';

if ($total > $comments_per_page)
echo paginate(rawurldecode($url_ret).'&amp;C_start=', '', $nbPages, $current, 2, $comments_per_page, $C_start);
echo '
</div>';
}

if ($Mmod) $post_aff=' '; else $post_aff=" AND post_aff='1' ";

$sql = "SELECT * FROM ".$NPDS_Prefix."posts WHERE forum_id='$forum' AND topic_id='$topic'".$post_aff."ORDER BY post_id LIMIT $C_start, $comments_per_page";

if (!$result = sql_query($sql)) forumerror('0001');

$mycount = sql_num_rows($result);
$myrow = sql_fetch_assoc($result);
$count = 0;

if ($mycount) {
if ($ibid=theme_image("forum/icons/posticon.gif")) {$imgtmpPI=$ibid;} else {$imgtmpPI="images/forum/icons/posticon.gif";}

do {
$posterdata = get_userdata_from_id($myrow['poster_id']);
if($myrow['poster_id'] !== '0') {
$posts = $posterdata['posts'];
$socialnetworks=array(); $posterdata_extend=array(); $res_id=array(); $my_rs='';

if (!$short_user) {
$posterdata_extend = get_userdata_extend_from_id($myrow['poster_id']);

!include!('modules/reseaux-sociaux/reseaux-sociaux.conf.php');
if($user or autorisation(-127)) {

if (array_key_exists('M2', $posterdata_extend)) {

if ($posterdata_extend['M2']!='') {
$socialnetworks= explode(';',$posterdata_extend['M2']);

foreach ($socialnetworks as $socialnetwork) {
$res_id[] = explode('|',$socialnetwork);
}

sort($res_id);
sort($rs);

foreach ($rs as $v1) {
foreach($res_id as $y1) {
$k = array_search( $y1[0],$v1);

if (false !== $k) {
$my_rs.='<a class="me-2" href="'.$v1[1].$y1[1].'" target="_blank"><i class="fab fa-'.$v1[2].' fa-lg fa-fw mb-2"></i></a>';
break;
}
}
}
}
}
}
}

!include!('modules/geoloc/geoloc.conf');
settype($ch_lat,'string');

$useroutils = '';
if($user or autorisation(-127)) {
if ($posterdata['uid']!= 1 and $posterdata['uid']!='')
$useroutils .= '<a class="list-group-item text-primary text-center text-md-start" href="user.php?op=userinfo&amp;uname='.$posterdata['uname'].'" target="_blank" title="'.translate("Profil").'" data-bs-toggle="tooltip"><i class="fa fa-user fa-2x align-middle"></i><span class="ms-3 d-none d-md-inline">'.translate("Profil").'</span></a>';

if ($posterdata['uid']!= 1 and $posterdata['uid']!='')
$useroutils .= '<a class="list-group-item text-primary text-center text-md-start" href="powerpack.php?op=instant_message&amp;to_userid='.$posterdata["uname"].'" title="'.translate("Envoyer un message interne").'" data-bs-toggle="tooltip"><i class="far fa-envelope fa-2x align-middle"></i><span class="ms-3 d-none d-md-inline">'.translate("Message").'</span></a>';

if ($posterdata['femail']!='')
$useroutils .= '<a class="list-group-item text-primary text-center text-md-start" href="mailto:'.anti_spam($posterdata['femail'],1).'" target="_blank" title="'.translate("Email").'" data-bs-toggle="tooltip"><i class="fa fa-at fa-2x align-middle"></i><span class="ms-3 d-none d-md-inline">'.translate("Email").'</span></a>';

if ($myrow['poster_id']!=1 and array_key_exists($ch_lat, $posterdata_extend)) {
if ($posterdata_extend[$ch_lat] !='')
$useroutils .= '<a class="list-group-item list-group-item-action text-primary text-center text-md-start" href="modules.php?ModPath=geoloc&amp;ModStart=geoloc&amp;op='.$posterdata['uname'].'" title="'.translate("Localisation").'" ><i class="fas fa-map-marker-alt fa-2x align-middle"></i><span class="ms-3 d-none d-md-inline">'.translate("Localisation").'</span></a>';
}
}

if ($posterdata['url']!='')
$useroutils .= '<a class="list-group-item text-primary text-center text-md-start" href="'.$posterdata['url'].'" target="_blank" title="'.translate("Visiter ce site web").'" data-bs-toggle="tooltip"><i class="fas fa-external-link-alt fa-2x align-middle"></i><span class="ms-3 d-none d-md-inline">'.translate("Visiter ce site web").'</span></a>';

if ($posterdata['mns'])
$useroutils .= '<a class="list-group-item text-primary text-center text-md-start" href="minisite.php?op='.$posterdata['uname'].'" target="_blank" target="_blank" title="'.translate("Visitez le minisite").'" data-bs-toggle="tooltip"><i class="fa fa-desktop fa-2x align-middle"></i><span class="ms-3 d-none d-md-inline">'.translate("Visitez le minisite").'</span></a>';
}

echo '
<div class="row">
<a name="'.$forum.$topic.$myrow['post_id'].'"></a>';

if (($count+2)==$mycount) echo '<a name="lastpost"></a>';
echo '
<div class="col-12 mb-3">
<div class="card">
<div class="card-header">';

global $smilies;
if ($smilies) {
if($myrow['poster_id'] !== '0') {
if ($posterdata['user_avatar'] != '') {
if (stristr($posterdata['user_avatar'],"users_private"))
$imgtmp=$posterdata['user_avatar'];
else
$imgtmp = $ibid=theme_image("forum/avatar/".$posterdata['user_avatar']) ?
$ibid :
"images/forum/avatar/".$posterdata['user_avatar'];
}
echo '
<a style="position:absolute; top:1rem;" tabindex="0" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-html="true" data-bs-title="'.$posterdata['uname'].'" data-bs-content=\'<div class="my-2 border rounded p-2">'.member_qualif($posterdata['uname'], $posts,$posterdata['rang']).'</div><div class="list-group mb-3 text-center">'.$useroutils.'</div><div class="mx-auto text-center" style="max-width:170px;">'.$my_rs.'</div>\'><img class=" btn-outline-primary img-thumbnail img-fluid n-ava" src="'.$imgtmp.'" alt="'.$posterdata['uname'].'" loading="lazy" /></a>
<span style="position:absolute; left:6em;" class="text-muted"><strong>'.$posterdata['uname'].'</strong></span>';
} else
echo '
<a style="position:absolute; top:1rem;" title="'.$anonymous.'" data-bs-toggle="tooltip"><img class=" btn-outline-primary img-thumbnail img-fluid n-ava" src="images/forum/avatar/blank.gif" alt="'.$anonymous.'" loading="lazy" /></a>
<span style="position:absolute; left:6em;" class="text-muted"><strong>'.$anonymous.'</strong></span>';
} else
echo $myrow['poster_id'] !== '0' ?
'<span style="position:absolute; left:6em;" class="text-muted"><strong>'.$posterdata['uname'].'</strong></span>' :
'<span class="text-muted"><strong>'.$anonymous.'</strong></span>';

$imgtmp = $ibid=theme_image("forum/subject/00.png") ? $ibid : 'images/forum/subject/00.png';
echo '
<span class="float-end"><img class="n-smil" src="'.$imgtmp.'" alt="" /></span>
</div>';
$message=stripslashes($myrow['post_text']);
$date_post=convertdateTOtimestamp($myrow['post_time']);
echo '
<div class="card-body">
<div class="card-text pt-3">';
if ($allow_bbcode) {
$message = smilie($message);
$message = aff_video_yt($message);
}

if(array_key_exists('user_sig', $posterdata))
$message=str_replace("
", '<div class="n-signature">'.nl2br($posterdata['user_sig']).'</div>', $message);
echo '
<div class="card-text fo-post-mes">
'.nl2br($message).'
</div>
</div>
</div>
<div class="card-footer">
<div class="row">
<div class=" col-sm-6 text-muted small">'.post_convertdate($date_post).'</div>
<div class=" col-sm-6 text-end">';

if ($allow_to_post)
echo '<a class="me-3" href="modules.php?ModPath=comments&amp;ModStart=reply&amp;topic='.$topic.'&amp;file_name='.$file_name.'&amp;archive='.$archive.'" title="'.translate("Commentaire").'" data-bs-toggle="tooltip"><i class="far fa-comment fa-lg"></i></a>';

if ($allow_to_post and $posterdata['uid']!='') {
if ($formulaire=='')
echo '<a class="me-3" href="modules.php?ModPath=comments&amp;ModStart=reply&amp;topic='.$topic.'&amp;file_name='.$file_name.'&amp;post='.$myrow['post_id'].'&amp;citation=1&amp;archive='.$archive.'" title="'.translate("Citation").'" data-bs-toggle="tooltip" ><i class="fa fa-lg fa-quote-left"></i></a>';
}

if ($Mmod) {
echo '<a class="me-3" href="modules.php?ModPath=comments&amp;ModStart=admin&amp;mode=viewip&amp;topic='.$topic.'&amp;post='.$myrow['post_id'].'&amp;file_name='.$file_name.'&amp;archive='.$archive.'" title="IP" data-bs-toggle="tooltip"><i class="fa fa-lg fa-laptop"></i></a>';
if (!$myrow['post_aff'])
echo '<a class="me-3" href="modules.php?ModPath=comments&amp;ModStart=admin&amp;mode=aff&amp;topic='.$topic.'&amp;post='.$myrow['post_id'].'&amp;ordre=1&amp;file_name='.$file_name.'&amp;archive='.$archive.'" title="'.translate("Afficher ce commentaire").'" data-bs-toggle="tooltip" data-bs-placement="left"><i class="fa fa-lg fa-eye text-danger"></i></a>';
else
echo '<a class="me-3" href="modules.php?ModPath=comments&amp;ModStart=admin&amp;mode=aff&amp;topic='.$topic.'&amp;post='.$myrow['post_id'].'&amp;ordre=0&amp;file_name='.$file_name.'&amp;archive='.$archive.'" title="'.translate("Masquer ce commentaire").'" data-bs-toggle="tooltip" data-bs-placement="left"><i class="fa fa-lg fa-eye-slash"></i></a>';
}

echo '
</div>
</div>
</div>
</div>
</div>
</div>';
$count++;
} while($myrow = sql_fetch_assoc($result));
unset ($tmp_imp); // not sure we need ?

echo '
<div class="d-flex my-2 justify-content-between flex-wrap">
<nav id="co-pagibasse">
<ul class="pagination pagination-sm d-flex flex-wrap justify-content-end">
<li class="page-item">
<a class="page-link" href="#co-pagihaute"><i class="fa fa-angle-double-up" title="'.translate("Haut de page").'" data-bs-toggle="tooltip"></i></a>
</li>
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="'.translate("Commentaire(s)").'">'.$total.' '.translate("Commentaire(s)").'</a>
</li>
<li class="page-item disabled">
<a class="page-link"href="#" aria-label="'.translate("pages").'">'.$nbPages.' '.translate("pages").'</a>
</li>
</ul>
</nav>';

if ($total > $comments_per_page)
echo paginate(rawurldecode($url_ret).'&amp;C_start=', '', $nbPages, $current, 2, $comments_per_page, $C_start);
echo '
</div>';

if ($allow_to_post)
echo '
<nav class="text-end mb-2">'.Caff_pub($topic,$file_name, $archive).'</nav>';
echo '
<blockquote class="blockquote my-3">'.translate("Les commentaires sont la propriété de leurs auteurs. Nous ne sommes pas responsables de leur contenu.").'</blockquote>';

if ($Mmod)
echo '
<nav class="text-center">
<ul class="pagination pagination-sm">
<li class="page-item disabled">
<a class="page-link" href="#"><i class="fa fa-cogs fa-lg"></i>&nbsp;'.translate("Outils administrateur").'</a>
</li>
<li class="page-item">
<a class="page-link text-danger" href="modules.php?ModPath=comments&amp;ModStart=admin&amp;mode=del&amp;topic='.$topic.'&amp;file_name='.$file_name.'&amp;archive='.$archive.' " title="'.translate("Effacer les commentaires.").'" data-bs-toggle="tooltip"><i class="fa fa-times fa-lg" ></i></a>
</li>
</ul>
</nav>';
}
?&gt;


moduless/comments/reply.php


&lt;?php
/************************************************************************/
/* DUNE by NPDS */
/* =========================== */
/* */
/* Based on PhpNuke 4.x source code */
/* Based on Parts of phpBB */
/* */
/* NPDS Copyright (c) 2002-2021 by Philippe Brunier */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (!function_exists("Mysql_Connexion"))
die();

!include!('functions.php');
!include!('auth.php');

var_dump($file_name);

filtre_module($file_name);
if (file_exists("modules/comments/$file_name.conf.php"))
!include! ("modules/comments/$file_name.conf.php");
else
die();

// modif php 8
//settype($cancel,'string');
settype($url_ret,'string');

// modif php 8
//if ($cancel)
if (isset($cancel))
header("Location: $url_ret");

settype($forum,'integer');
if ($forum>=0)
die();

// gestion des params du 'forum' : type, accès, modérateur ...
$forum_name = 'comments';
$forum_type=0;
$allow_to_post=false;
if ($anonpost) $forum_access=0;
else $forum_access=1;
global $user;
if ($moderate==1 and isset($admin))
$Mmod=true;
elseif ($moderate==2) {
$userX=base_64_decode($user);
$userdata=explode(':', $userX);
$result=sql_query("SELECT level FROM ".$NPDS_Prefix."users_status WHERE uid='".$userdata[0]."'");
list($level)=sql_fetch_row($result);
if ($level>=2)
$Mmod=true;
else
$Mmod=false;
} else
$Mmod=false;
// gestion des params du 'forum' : type, accès, modérateur ...

if (isset($submitS)) {
$stop=0;
if ($message=='') $stop=1;
if (!$user) {
if ($forum_access==0) {
$userdata = array('uid' => 1);
!include!('header.php');
} else {
if (($username=='') or ($password==''))
forumerror('0027');
else {
$result = sql_query("SELECT pass FROM ".$NPDS_Prefix."users WHERE uname='$username'");
list($pass) = sql_fetch_row($result);
if (!$system)
$passwd=crypt($password,$pass);
else
$passwd=$password;
if ((strcmp($passwd,$pass)==0) and ($pass != '')) {
$userdata = get_userdata($username);
!include!('header.php');
} else
forumerror('0028');
}
}
} else {
$userX = base_64_decode($user);
$userdata = explode(':', $userX);
$userdata = get_userdata($userdata[1]);
!include!("header.php");
}

// Either valid user/pass, or valid session. continue with post.
if ($stop != 1) {
$poster_ip = getip();
if ($dns_verif)
$hostname=@gethostbyaddr($poster_ip);
else
$hostname=$poster_ip;

// anti flood
anti_flood ($Mmod, $anti_flood, $poster_ip, $userdata, $gmt);
//anti_spambot
if (isset($asb_question) and isset($asb_reponse)) {
if (!R_spambot($asb_question, $asb_reponse, $message)) {
Ecr_Log('security', "Forum Anti-Spam : forum=".$forum." / topic=".$topic, '');
redirect_!url(!"$url_ret");
die();
}
}

if ($formulaire!='')
!include! ("modules/comments/comments_extender.php");

if ($allow_html == 0 || isset($html)) $message = htmlspecialchars($message,ENT_COMPAT|ENT_HTML401,cur_charset);
if (isset($sig) && $userdata['uid'] != 1) $message .= '
';
$message=af_cod($message);
$message = smile($message);
$message = make_clickable($message);
$message = removeHack($message);
$image_subject='';
$message = addslashes(dataimagetofile!url(!$message,'modules/upload/upload/co'));
$time = date("Y-m-d H:i:s",time()+((integer)$gmt*3600));
$sql = "INSERT INTO ".$NPDS_Prefix."posts (post_idH, topic_id, image, forum_id, poster_id, post_text, post_time, poster_ip, poster_dns) VALUES ('0', '$topic', '$image_subject', '$forum', '".$userdata['uid']."', '$message', '$time', '$poster_ip', '$hostname')";
if (!$result = sql_query($sql))
forumerror('0020');
else
$IdPost=sql_last_id();

$sql = "UPDATE ".$NPDS_Prefix."users_status SET posts=posts+1 WHERE (uid = '".$userdata['uid']."')";
$result = sql_query($sql);
if (!$result)
forumerror('0029');

// ordre de mise à jour d'un champ externe ?
if ($comments_req_add!='')
sql_query("UPDATE ".$NPDS_Prefix.$comments_req_add);

redirect_!url(!"$url_ret");
} else {
echo '
<h2><i class="far fa-comment text-muted fa-lg me-2"></i>'.translate("Commentaire").'</h2>
<hr />
<div class="alert alert-danger" >'.translate("Vous devez taper un message à poster.").'</div>
<p><a href="!javascript!:history.go(-1)" class="btn btn-primary">'.translate("Retour en arrière").'</a></p>';
}
} else {
!include!('header.php');
if ($allow_bbcode==1)
!include!("lib/formhelp.java.php");
echo '
<h2><i class="far fa-comment text-muted fa-lg me-2"></i>'.translate("Commentaire").'</h2>
<hr />';
if ($formulaire=='')
echo '
<form action="modules.php" method="post" name="coolsus">';
echo '<div class="mb-3 ">';
$allow_to_reply=false;
if ($forum_access==0)
$allow_to_reply=true;
else
if (isset($user))
$allow_to_reply=true;
if ($allow_to_reply) {
if (isset($submitP)) {
$time=date(translate("dateinternal"),time()+((integer)$gmt*3600));
if(isset($user)){
$userY = base_64_decode($user);
$userdata = explode(':', $userY);
$userdata = get_userdata($userdata[1]);
} else {
$userdata = array('uid' => 1);
$userdata = get_userdata($userdata['uid']);
}
$theposterdata = get_userdata_from_id($userdata['uid']);
$messageP=$message;
$messageP=af_cod($messageP);
echo '
<h4>'.translate("Prévisualiser").'</h4>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">';
if ($smilies) {
if ($theposterdata['user_avatar'] != '') {
if (stristr($theposterdata['user_avatar'],"users_private"))
$imgtmp=$theposterdata['user_avatar'];
else {
if ($ibid=theme_image("forum/avatar/".$theposterdata['user_avatar'])) $imgtmp=$ibid; else $imgtmp="images/forum/avatar/".$theposterdata['user_avatar'];
}
echo '
<a style="position:absolute; top:1rem;" tabindex="0" data-bs-toggle="popover" data-bs-html="true" data-bs-title="'.$theposterdata['uname'].'" data-bs-content=\''.member_qualif($theposterdata['uname'], $theposterdata['posts'],$theposterdata['rang']).'\'><img class=" btn-secondary img-thumbnail img-fluid n-ava" src="'.$imgtmp.'" alt="'.$theposterdata['uname'].'" /></a>';
}
}
echo'
&nbsp;<span style="position:absolute; left:6rem;" class="text-muted"><strong>'.$theposterdata['uname'].'</strong></span>
</div>
<div class="card-body">
<span class="text-muted float-end small" style="margin-top:-1rem;">'.translate("Commentaires postés : ").$time.'</span>
<div id="post_preview" class="card-text pt-3">';
$messageP=stripslashes($messageP);
if (($forum_type=='6') or ($forum_type=='5'))
highlight_string(stripslashes($messageP));
else {
if ($allow_bbcode) $messageP=smilie($messageP);
if ($allow_sig == 1 and isset($sig))
$messageP .= '<div class="n-signature">'.nl2br($theposterdata['user_sig']).'</div>';
echo $messageP.'
</div>';
}
echo '
</div>
</div>
</div>
</div>';
}
else
$message='';

if ($formulaire!='') {
echo'<div class="col" id ="debug">';
!include! ("modules/comments/comments_extender.php");
echo'</div></div>';
} else {
if ($allow_bbcode)
$xJava = 'name="message" onselect="storeCaret(this);" !onclick!="storeCaret(this);" !onkey!up="storeCaret(this);" !onfocus!="storeForm(this)"';

if (isset($citation) && !isset($submitP)) {
$sql = "SELECT p.post_text, p.post_time, u.uname FROM ".$NPDS_Prefix."posts p, ".$NPDS_Prefix."users u WHERE post_id='$post' AND ((p.poster_id = u.uid) XOR (p.poster_id=0))";
if ($r = sql_query($sql)) {
$m = sql_fetch_assoc($r);
$text = $m['post_text'];
$text = smile($text);
$text = str_replace('<br />', "\n", $text);
$text = stripslashes($text);
$text=desaf_cod($text);
if ($m['post_time']!='' && $m['uname']!='')
$reply = '<div class="blockquote">'.translate("Citation").' : <strong>'.$m['uname'].'</strong>'."\n".$text.'</div>';
else
$reply = $text."\n";
} else
$reply = translate("Erreur de connexion à la base de données")."\n";
}
if (!isset($reply)) $reply=$message;

echo '
</div>
<div class="mb-3 row">
<label class="form-label" for="message">'.translate("Message").'</label>
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<div class="float-start">';
putitems('ta_comment');
echo '
</div>';
if ($allow_html == 1)
echo '
<span class="text-success float-end mt-2" title="HTML '.translate("Activé").'" data-bs-toggle="tooltip"><i class="fa fa-code fa-lg"></i></span>'.HTML_Add();
else
echo '
<span class="text-danger float-end mt-2" title="HTML '.translate("Désactivé").'" data-bs-toggle="tooltip"><i class="fa fa-code fa-lg"></i></span>';
echo '
</div>
<div class="card-body">
<textarea id="ta_comment" class="form-control" '.$xJava.' name="message" rows="12">'.stripslashes($reply).'</textarea>
</div>
<div class="card-footer p-0">
<span class="d-block">
<button class="btn btn-link" type="submit" value="'.translate("Prévisualiser").'" name="submitP" title="'.translate("Prévisualiser").'" data-bs-toggle="tooltip" ><i class="fa fa-eye fa-lg"></i></button>
</span>
</div>
</div>
</div>
</div>
<div class="mb-3 row">
<label class="form-label">'.translate("Options").'</label>';
if ($allow_html==1) {
if (isset($html)) $sethtml = 'checked="checked"'; else $sethtml = '';
echo '
<div class="col-sm-12 my-2">
<div class="checkbox">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="html" name="html" '.$sethtml.' />
<label class="form-check-label" for="html">'.translate("Désactiver le html pour cet envoi").'</label>
</div>
</div>';
}
if ($user) {
if ($allow_sig == 1||isset($sig)) {
$asig = sql_query("SELECT attachsig FROM ".$NPDS_Prefix."users_status WHERE uid='$cookie[0]'");
list($attachsig) = sql_fetch_row($asig);
if ($attachsig == 1 or isset($sig)) $s = 'checked="checked"'; else $s='';
echo '
<div class="checkbox my-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="sig" name="sig" '.$s.' />
<label class="form-check-label" for="sig"> '.translate("Afficher la signature").'</label>
</div>
<span class="help-block"><small>'.translate("Cela peut être retiré ou ajouté dans vos paramètres personnels").'</small></span>
</div>';
}
}
echo '</div>
</div>';

echo Q_spambot();
echo '
<div class="mb-3 row">
<div class="col-sm-12">
<input type="hidden" name="ModPath" value="comments" />
<input type="hidden" name="ModStart" value="reply" />
<input type="hidden" name="topic" value="'.$topic.'" />
<input type="hidden" name="file_name" value="'.$file_name.'" />
<input type="hidden" name="archive" value="'.$archive.'" />
<input class="btn btn-primary" type="submit" name="submitS" value="'.translate("Valider").'" />
<input class="btn btn-danger" type="submit" name="cancel" value="'.translate("Annuler la contribution").'" />
</div>
</div>';
}
}
else
echo '
<div class="alert alert-danger">'.translate("Vous n'êtes pas autorisé à participer à ce forum").'</div>';

if ($formulaire=='')
echo '
</form>';
if ($allow_to_reply) {
if ($Mmod)
$post_aff='';
else
$post_aff=" AND post_aff='1' ";
$sql = "SELECT * FROM ".$NPDS_Prefix."posts WHERE topic_id='$topic'".$post_aff." AND forum_id='$forum' ORDER BY post_id DESC LIMIT 0,10";
$result = sql_query($sql);
if (sql_num_rows($result)) {
echo translate("Aperçu des sujets :");

while($myrow = sql_fetch_assoc($result)) {

$posterdata = get_userdata_from_id($myrow['poster_id']);
if ($posterdata['uname']!=$anonymous)
echo "<a href=\"powerpack.php?op=instant_message&amp;to_userid=".$posterdata['uname']."\" class=\"noir\">".$posterdata['uname']."</a>";
else
echo $posterdata['uname'];
echo '<br />';
$posts = $posterdata['posts'];
echo member_qualif($posterdata['uname'], $posts, $posterdata['rang']);
echo '<br /><br />';
if ($smilies) {
if ($posterdata['user_avatar'] != '') {
if (stristr($posterdata['user_avatar'],"users_private")) {
$imgtmp=$posterdata['user_avatar'];
} else {
if ($ibid=theme_image("forum/avatar/".$posterdata['user_avatar'])) {$imgtmp=$ibid;} else {$imgtmp="images/forum/avatar/".$posterdata['user_avatar'];}
}
echo '<div class="avatar_cadre"><img src="'.$imgtmp.'" alt="'.$posterdata['uname'].'" border="0" /></div>';
}
}

echo "&nbsp;".translate("Posté : ").convertdate($myrow['post_time']);
echo '<hr /> ';
$message = stripslashes($myrow['post_text']);
if ($allow_bbcode) {
$message = smilie($message);
}
// <a href in the message
if (stristr($message,'<a href')) {
$message=preg_replace('#_blank(")#i','_blank\1 class=\1 \1',$message);
}
$message = str_replace('
', '<br /><br />' . nl2br($posterdata['user_sig']), $message);
echo $message.'<br />';
}
}
}
}
!include!('footer.php');
?&gt;