AJOUTER FACILEMENT DES COMMENTAIRES À VOS PAGE PHP SANS SQL/DB

coockiesch Messages postés 2268 Date d'inscription mercredi 27 novembre 2002 Statut Membre Dernière intervention 13 septembre 2013 - 26 juil. 2006 à 07:24
Wanon Messages postés 2 Date d'inscription dimanche 16 août 2009 Statut Membre Dernière intervention 4 mai 2012 - 4 mai 2012 à 21:49
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/38785-ajouter-facilement-des-commentaires-a-vos-page-php-sans-sql-db

Wanon Messages postés 2 Date d'inscription dimanche 16 août 2009 Statut Membre Dernière intervention 4 mai 2012
4 mai 2012 à 21:49
Merci beaucoup !
ça fonctionne du tonnerre :D
MacGaliver Messages postés 146 Date d'inscription vendredi 28 mai 2010 Statut Membre Dernière intervention 21 juillet 2013 3
18 mars 2012 à 15:03
Réponse à la question de guillaume: le .htaccess:

###FILTRE CONTRE ROBOTS DES PIRATES ET ASPIRATEURS DE SITE WEB
RewriteEngine On
## EXCEPTION: TOUS LES ROBOTS MEMES ANONYMES OU BANNIS PEUVENT ACCEDER A CES FICHIERS
RewriteCond %{REQUEST_URI} !^robots.txt
##
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR] ## ANONYMES
RewriteCond %{HTTP_USER_AGENT} ^[bcdfghjklmnpqrstvwxz\ ]{8,}|^[0-9a-z]{15,}|^[0-9A-Za-z]{19,}|^[A-Za-z]{3,}\ [a-z]{4,}\ [a-z]{4,} [OR] ## CEUX QUI INVENTENT DES NOMS AU HASARD
RewriteCond %{HTTP_USER_AGENT} 2icommerce|@nonymouse|Accoona|ActiveTouristBot|adressendeutschland|ADSARobot|Advanced\ Email\ Extractor|agent|ah-ha|aipbot|aktuelles|Alexibot|Alligator|AllSubmitter|almaden|amzn_assoc|anarchie|anonymous|Apexoo|Aqua_Products|Art-Online|ASPSeek|ASSORT|asterias|ATHENS|AtHome|Atomz|attach|autoemailspider|autohttp|BackDoorBot|BackWeb|Badass|Baiduspider|Bandit|BatchFTP|bdfetch|BecomeBot|berts|big.brother|Bitacle|Biz360|Black.Hole|BlackWidow|bladder\ fusion|BlogPeople|blogsearchbot-martin|Blogshares\ Spiders|Blog\ Checker|Bloodhound|BlowFish|bmclient|Board\ Bot|Bookmark\ search\ tool|Boston\ Project|BotALot|BotRightHere|Bot\ mailto:craftbot@yahoo.com|BravoBrian\ SpiderEngine\ MarcoPolo|Bropwers|Browsezilla|BuiltBotTough|Bullseye|bumblebee|BunnySlippers|c-spider|capture|Cegbfeieh|CFNetwork|charlotte/|CheeseBot|CherryPicker|ChinaClaw|CICC|clipping|compatible\ \;|Convera|Copernic|CopyRightCheck|cosmos|Crescent|Crescent\ Internet|Custo|cyberalert|Cyberz|DataCha0s|Daum|Deweb|diagem|Digger|Digimarc [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} digout4uagent|DIIbot|DirectUpdate|disco|DISCoFinder|DittoSpyder|DnloadMage|Download|Downloader|Download\ Accelerator|Download\ Demon|Download\ Wonder|dragonfly|DreamPassport|Drip|DSurf|DSurf15a|DTS.Agent|DTS\ Agent|dumbot|DynaWeb|e-collector|EasyDL|EBrowse|eCatch|echo\ extense|ecollector|edgeio|efp@gmx\.net|EirGrabber|EmailCollector|EmailSiphon|EmailWolf|Email\ Extractor|Email\ Siphon|EmeraldShield|Enterprise_Search|EroCrawler|ESurf|Eval|Everest-Vulcan|Exabot|Express\ WebPictures|Extractor|ExtractorPro|EyeNetIE|FairAd|fastlwspider|FavOrg|Favorites\ Sweeper|fetch|FEZhead|FileHound|findlinks|Flaming\ AttackBot|flashget|FlickBot|fluffy|Foobot|Forex|Franklin\ Locator|FreshDownload|frontpage|FSurf|Gaisbot|GalaxyBot|Gamespy_Arcade|Generic|genieBot|GetBot|Getleft|GetRight|GetSmart|GetWeb!|GetWebPage|gigabaz|Girafabot|Go!Zilla|go-ahead-got-it|GOFORITBOT|GornKer|Grabber|GrabNet|Grafula|Green\ Research|grub-client|grub\ crawler|hanzoweb|Harvest|Hatena\ Antenna|heritrix|hhjhj@yahoo|hloader|HMView|holmes [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} HomePageSearch|HooWWWer|HouxouCrawler|HTTPConnect|httpdown|HTTPGet|HTTPRetriever|http\ generic|HTTrack|humanlinks|ia_archive|IBM_Planetwide|iCCrawler|ichiro|id-search|IDBot|iGetter|imagefetch|Image\ Stripper|Image\ Sucker|imds_monitor|IncyWincy|Industry\ Program|Indy\ Library|InetURL|InfoNaviRobot|informant|Ingelin|InstallShield\ DigitalWizard|InterGET|InternetLinkAgent|InternetSeer\.com|Internet\ Ninja|IPiumBot|Iria|IRLbot|Iron33|Irvine|ISSpider|IUPUI\ Research\ Bot|Jakarta\ Commons|JBH*Agent|JBH\ Agent|JennyBot|JetCar|JetCar|jeteye|jeteyebot|JoBo|JOC\ Web\ Spider|JustView|Kapere|Kenjin|Keyword\ Density|KRetrieve|ksoap|KWebGet|Lachesis|LapozzBot|larbin|LeechFTP|leipzig.de|LexiBot|lftp|LightningDownload|likse|Link*Sleuth|LinkextractorPro|Linkie|LinkScan|LINKS\ ARoMATIZED|linktiger|LinkWalker|lmcrawler|LNSpiderguy|LocalcomBot|looksmart|Mac\ Finder|Mag-Net|Magnet|Mail\ Sweeper|mark.blonin|MaSagool|Mass\ Downloader|Mata\ Hari|MCspider|MetaProducts\ Download\ Express [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} Microsoft\ Data|Microsoft\ Data\ Access|Microsoft\ URL|Microsoft\ URL\ Control|MIDown|MIDown\ tool|MIIxpc|minibot\(NaverRobot\)|Mirror|Missauga|Missigua|Missouri\ College\ Browse|Mister|Mister\ PiX|MJ12bot|mkdb|MMMtoCrawl\/UrlDispatcherLLL|moget|Monster|Moozilla|Moreoverbot|mothra/netscan|MovableType|Movable\ Type|Mozi!|Mozilla/22|Mozilla/3.0\ \(compatible\)|Mozilla/5.0\ \(compatible\;\ MSIE\ 5.0\)|MSIECrawler|MSIE_6.0|MSProxy|multithreaddb|Murzillo|MVAClient|MyFamilyBot|MyGetRight|nameprotect|NASA\ Search|nationaldirectory|Naver|Navroad|NearSite|NetAnts|netattache|NetCarta|NetMechanic|netprospector|NetResearchServer|NetSpider|NetZIP|NetZippy|NetZip\ Downloader|Net\ Vampire|NEWT|Nextopia|nicerspro|NimbleCrawler|ninja|noxtrumbot|NPBot|Nutch|Nutscrape/|Octopus|Offline\ Explorer|Offline\ Navigator|OK\ Mozilla|OmniExplorer|OpaL|OpaL|Openbot|Openfind|OpenTextSiteCrawler|Oracle\ Ultra\ Search|OrangeBot|PackRat|PageGrabber|PagmIEDownload|panscient|Papa\ Foto|Papa\ Foto|pavuk|pcBrowser|PerMan [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} PersonaPilot|PHP\ version|PingALink|PlantyNet_WebRobot|playstarmusic|Plucker|Pockey|Port\ Huron|Program\ Shareware|Progressive\ Download|ProPowerBot|prospector|ProWebWalker|Proxy|Prozilla|psbot|PSurf|psycheclone|puf|Pump|PushSite|PussyCat|PuxaRapido|PycURL|QRVA|QuepasaCreep|QueryN|Radiation|RealDownload|Reaper|Recorder|RedCarpet|RedKernel|ReGet|relevantnoise|replacer|RepoMonkey|RMA|Robozilla|Rover|RPT-HTTPClient|RTG30|Rufus|SAPO|SBIder|scooter|ScoutAbout|script|SearchExpress|searchhippo|searchpreview|searchterms|Second\ Street\ Research|Seekbot|Seeker|Serious|Shai|shelob|Shim-Crawler|SickleBot|sitecheck|SiteMapper|SiteSnagger|Slurpy\ Verifier|SlySearch|SlySearch|SmartDownload|sna-|snagger|So-net|sogou|sootle|SpaceBison|SpankBot|spanner|SpeedDownload|Spegla|Sphere|Sphider|SpiderBot|sproose|Sqworm|SQ\ Webscanner|Stamina|Stanford|Star\ Downloader|Stripper|studybot|sucker|SuperBot|SuperHTTP|Surfbot|SurfWalker|SurveyBot|suzuran|Szukacz|tAkeOut|TALWinHttpClient|tarspider|Teleport|Teleport\ Pro [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} Telesoft|Templeton|TestBED|TheNomad|The\ Intraformant|TightTwatBot|Titan|toCrawl/UrlDispatcher|TrackBack|TrueRobot|True_Robot|Turing|TurnitinBot|TV33_Mercator|Twisted\ PageGetter|UCmore|UdmSearch|UIowaCrawler|UMBC|UniversalFeedParser|URLGetFile|URLy\ Warning|URL\ Control|URL_Spider_Pro|UtilMind|Vacuum|vagabondo|vayala|visibilitygap|vobsub|VoidEYE|VoilaBot|voyager|vspider|W3CRobot|w3mir|Web\ Image\ Collector|Web2WAP|WebaltBot|WebAuto|webbandit|WebCapture|Webclipping|webcollage|webcollector|WebCopier|WebCopy|webcraft@bea|webdevil|webdownloader|Webdup|WebEMailExtrac.*|WebEnhancer|WebFetch|WebFilter|WebFountain|WebGo|WebHook|Webinator|WebLeacher|WEBMASTERS|WebmasterWorldForumBot|WebMiner|WebMirror|webmole|WebReaper|WebSauger|WEBsaver|Website|Website\ eXtractor|Website\ Quester|WebSnake|Webster|WebStripper|websucker|webvac|webwalk|webweasel|WebWhacker|WebZip|Web\ Data\ Extractor|Web\ Downloader|Web\ Image\ Collector|Web\ Sucker|web\.by\.mail|Wells\ Search|WEP\ Search\ 00 [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} WeRelateBot|whizbang|WhosTalking|Widow|Widows|Wildsoft\ Surfer|WinHttpRequest|WinHTTrack|WISEbot|WISEnutbot|WUMPUS|Wweb|WWW-Collector|WWWOFFLE|wwwster|Wysigot|x-Tractor|Xaldon|Xenu\'s|Xenus|XGET|Y!TunnelPro|YaDirectBot|YahooYSMcm|Yandex|Yeti|Zade|ZBot|zerxbot|Zeus|Zeus.*Webster|ZyBorg|^adwords|^Internet\ Explorer|^Mozilla$|^MSIE|^puf|^user|^User-Agent:\ |^User\ Agent:\ |^<sc|<\? [NC,OR] ## VRAIS ET FAUX ROBOTS NE RESPECTANT PAS LES REGLES
RewriteCond %{HTTP_USER_AGENT} ^curl|^Fetch\ API\ Request|GT\:\:WWW|^HTTP\:\:Lite|httplib|^Java/1.|^Java\ 1.|^LWP|libWeb|libwww|^PEAR|PECL\:\:HTTP|PHPCrawl|^Program\ Shareware|python|Rsync|Snoopy|^URI\:\:Fetch|WebDAV|^Wget [NC] ## BIBLIOTHEQUES / CLASSES HTTP DONT ON NE VEUT PAS. ATTENTION, CELA PEUT BLOQUER CERTAINES FONCTIONS DE VOTRE CMS. NE PAS TOUT EFFACER, MAIS CHERCHEZ LE NOM DE LA CLASSE HTTP CONCERNEE (DEMANDEZ AUX DEVELOPPEURS DE VOTRE CMS). CETTE LISTE BLOQUE 80% DES ROBOTS SPAMMEURS. IL FAUT LA CONSERVER.
RewriteRule (.*) - [F]
Guillaume170194 Messages postés 54 Date d'inscription dimanche 11 mai 2008 Statut Membre Dernière intervention 25 novembre 2021
15 juil. 2011 à 23:39
Est-il possible d'ajouter un système anti-bot ?
motoculteur Messages postés 1 Date d'inscription samedi 3 juillet 2010 Statut Membre Dernière intervention 3 juillet 2010
3 juil. 2010 à 06:37
Merci pour cette information
najiaB Messages postés 1 Date d'inscription lundi 26 avril 2010 Statut Membre Dernière intervention 27 avril 2010
27 avril 2010 à 13:05
comemment faire le code php de cet formulaire
<form action="" method="post">

Pseudo,

,

----

Sujet,
,

----
Commentaire,
<textarea name="comment" rows="10" cols="80"></textarea>
</form>


</html>
UnrealH Messages postés 3 Date d'inscription vendredi 12 septembre 2003 Statut Membre Dernière intervention 8 juillet 2009
24 févr. 2010 à 21:26
Vraiment top ton code !!! Merci beaucoup !!!

J'utilisais avant un site externe (gcomment.com) qui a apparemment fermé, ton code fait exactement la job que je recherche, dans prise de tête avec MySQL.... !

Thanks !!!
atoufa266 Messages postés 1 Date d'inscription mardi 13 juillet 2004 Statut Membre Dernière intervention 12 mai 2009
12 mai 2009 à 23:46
good
thomas0592 Messages postés 5 Date d'inscription mardi 18 décembre 2007 Statut Membre Dernière intervention 3 avril 2009
3 avril 2009 à 20:37
Salut,
Comment masquer les cookies affichés au dessus de l'affichage des commentaires.
Merci.
thomas0592 Messages postés 5 Date d'inscription mardi 18 décembre 2007 Statut Membre Dernière intervention 3 avril 2009
3 avril 2009 à 20:30
Salut,
Bon travail! Pour la simplification de l'installation, j'ai juste une question à vous poser comment fait-on pour personnaliser la page du commentaire en ajoutant une image background pour les commentaires sur "vos impressions".
Merci.
cs_haddaoui22 Messages postés 1 Date d'inscription mardi 17 mars 2009 Statut Membre Dernière intervention 17 mars 2009
17 mars 2009 à 17:07
<script type="text/javascript"><!--
google_ad_client = "pub-0502958480350610";
google_ad_host = "pub-1599271086004685";
/* 200x200, ?? ??????? 09/05/08 */
google_ad_slot = "8059958808";
google_ad_width = 200;
google_ad_height = 200;
//-->
</script>
<script
src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
nimp0rtequi Messages postés 1 Date d'inscription vendredi 29 février 2008 Statut Membre Dernière intervention 13 mars 2008
13 mars 2008 à 21:28
Bonjour,
Je suis encore moins que novice aussi, mais j'ai lu un peu de doc et me suis fait aider par un ami.
Donc j'ai renommé le gestion_commentaire_plus.inc en gestion_commentaire_plus.php pour plus de sécurité, d'après ce que j'ai lu plus haut.
J'ai aussi mis l'option
$debug = 0; //0=off / 1=on
à la place de
$debug = 1; //0=off / 1=on
pour éviter d'afficher des commentaires de débogage du script au milieu de ceux des visiteurs.
Globalement ça marche bien. Mais peut-être est-ce dù au CSS ou à la ligne concernant l'affichage dans un tableau HTML de 550 pixels : sur firefox sous windows, ça me change ma mise en page de départ.
Par contre avec firefox sous linux, ça apparait comme je veux
Un exemple :
http://thibault.aspe.free.fr/content/christian_rosset_10022008.php
un autre :
http://thibault.aspe.free.fr/content/chereeunschnell022008.php

Enfin, bravo, ce script tourne bien.
Et pour répondre au demandeur ci-dessus, il faut nommer la page sur laquelle on veut que le commentaire agisse en .php
et mettre dans le code de cette page :
<?php include (gestion_commentaires_plus.inc");?>
si le formulaire gestion_commentaires_plus.inc est bien dans le même répertoire que le fichier sur lequel on veut qu'il agisse.
Voilà ce que j'ai appris et appliqué hier soir.
comme quoi ce script est éfficace même avec les novices du php.
gregchris789 Messages postés 1 Date d'inscription lundi 4 décembre 2000 Statut Membre Dernière intervention 1 mars 2008
1 mars 2008 à 19:01
bonjour voila je suis novice lol petite question include("http://www.monsite/gestion_commentaires_plus.inc");
je dois le metres ou ? en php ou bien htlm je comprend pas
cs_pwepwe973 Messages postés 7 Date d'inscription samedi 23 décembre 2006 Statut Membre Dernière intervention 3 février 2008
29 déc. 2007 à 03:49
comment faire pour les pseudo frame le système de récupération de la page ne marche pas
MadOlivierMax Messages postés 11 Date d'inscription lundi 1 mars 2004 Statut Membre Dernière intervention 7 mars 2017
22 févr. 2007 à 11:44
Bonjour tout le monde,

Je suis aussi intérresser pour avoir les commentaires au début (et ne pas se taper tous les commentaires avant (même si c'est une logique !!!))
Donc je fais un up sur cette demande en attendant vos réponses je remercie Bouillou (particulièrement) pas Anthomicro et Vyper909 pour les précisions dans le code.
cs_JackNUMBER Messages postés 233 Date d'inscription jeudi 30 septembre 2004 Statut Membre Dernière intervention 26 juin 2011 5
5 janv. 2007 à 13:40
ha oui, désolé...
malalam Messages postés 10839 Date d'inscription lundi 24 février 2003 Statut Membre Dernière intervention 2 mars 2010 25
5 janv. 2007 à 12:53
Hello,

faites attention à l'orthographe quand même, un minimum...
"bonjour!
J'aurais aimé savoir s'il était possible de faire en sorte que les commentaires les plus récents s'affichent en haut.

Merci"
cs_JackNUMBER Messages postés 233 Date d'inscription jeudi 30 septembre 2004 Statut Membre Dernière intervention 26 juin 2011 5
5 janv. 2007 à 12:43
bonjour !
j'orai aimé savoir si il était possible de faaire en sorte que les commentaires les plus ressents s'affichent en haut

merci
cs_Bouillou2 Messages postés 11 Date d'inscription dimanche 28 mars 2004 Statut Membre Dernière intervention 31 juillet 2006
31 juil. 2006 à 15:43
Merci pour tous vos commentaires!

J'en prends bonne note et je réaliserai une version 1.1 dès que j'aurai un peu de temps.

A+,

Bouillou
Vyper909 Messages postés 24 Date d'inscription jeudi 27 mai 2004 Statut Membre Dernière intervention 8 janvier 2007
31 juil. 2006 à 15:39
Il est aussi important de ne PAS utiliser de fichiers ayant une extension de type ".inc" car la plupart des serveurs (Apache ou autres) ne connaissent pas cette extension et si un "hacker" réussit à connaitre les noms de fichiers "include" (ce qui n'est pas très difficile), il peut tenter de les faire exécuter par le serveur et comme il ne connait pas l'extension, il les affichera comme du texte. Pour un script de commentaires ce n'est pas vital, mais pour d'autres trucs (un fichier include qui comprendrait un nom d'utilisateur et mot de passe pour une base de données, par exemple), c'est la sécurité complète de ton site qui est en jeu.

Je nomme TOUS Mes fichiers includes avec l'extension ".php" à la fin, comme de vrais fichiers PHP. Donc si quelqu'un veut les exécuter, ca ne fonctionnera tout simplement pas.

Sinon je crois que la source est bien et je vais probablement m'en inspirer pour un petit "guestbook" sur mon site perso, un jour...
cs_Anthomicro Messages postés 9433 Date d'inscription mardi 9 octobre 2001 Statut Membre Dernière intervention 13 avril 2007 8
26 juil. 2006 à 22:45
Salut,

pense à vérifier que $commentaire = $_POST['commentaire']; existe car sinon tu auras une erreur d'undefined variable ;)

# $commentaire=eregi_replace("\r\n","
",$commentaire);
# $commentaire=eregi_replace("\\\'","'",$commentaire);

tu peux remplacer ça par un str_replace et puis un stripslashes() ;)

Sinon je trouve que l'idée est sympa et l'utilisation a l'air simple ;)

a +
coockiesch Messages postés 2268 Date d'inscription mercredi 27 novembre 2002 Statut Membre Dernière intervention 13 septembre 2013 4
26 juil. 2006 à 14:29
Salut!
Parce qu'on peut éventuellement, pour une variable non-initialisée, lui injecter une valeur depuis l'extérieur...

@++

R@f
kiki2sirom Messages postés 153 Date d'inscription mardi 17 août 2004 Statut Membre Dernière intervention 23 décembre 2010
26 juil. 2006 à 11:32
salut
il ne faut pas faire de count dans une boucle mais avant la boucle.
ligne 88 et 133 : for($i=0; $i < count($tableau_content); $i++)

à remplacer par :
$nb=count($tableau_content);
for($i=0; $i < $nb; $i++)

optimisation non négligeable si tu as beaucoup de commentaires

cdt

kiki
cs_Bouillou2 Messages postés 11 Date d'inscription dimanche 28 mars 2004 Statut Membre Dernière intervention 31 juillet 2006
26 juil. 2006 à 10:52
Salut,

Effectivement, cette sécurité n'est pas implémentée ce qui n'est pas très bien...

Du côté des variables globales, pourquoi cela pose un problème sécuritaire?

A+,

Bouillou
coockiesch Messages postés 2268 Date d'inscription mercredi 27 novembre 2002 Statut Membre Dernière intervention 13 septembre 2013 4
26 juil. 2006 à 07:24
Salut!
Tu devrais coder avec register_gloabsl à OFF: d'un point de vue sécurité c'est beaucoup mieux... :)

Autrement, tu devrais protéger les commentaires avec htmlentities, pas que qlqn s'amuse à rentrer du HTML ou JavaScript ;)

@++

R@f
Rejoignez-nous