Mercurial > defr > DualBlog
comparison comment.php @ 0:629389204276
Import initial
| author | Franck Deroche <webmaster@defr.org> |
|---|---|
| date | Sat, 20 Oct 2007 14:15:10 +0200 |
| parents | |
| children | 7dec52982000 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:629389204276 |
|---|---|
| 1 <?php | |
| 2 setlocale(LC_ALL, "fr_FR.utf8@euro"); | |
| 3 ini_set("display_errors", "off"); | |
| 4 include("classes.php"); | |
| 5 $id = $_GET['id']; | |
| 6 $Data = new DataAccess; | |
| 7 $Req = new Requete; | |
| 8 | |
| 9 $Auteur=$Req->get('Auteur'); | |
| 10 $Adresse=$Req->get('Adresse'); | |
| 11 $AdresseMail = $Req->get('AdresseMail'); | |
| 12 $Comment=$Req->get('Comment'); | |
| 13 $DateComment=gmdate("Y-m-d H:i:s", time() + 3600*2); | |
| 14 if(!is_null($Auteur) && $Auteur!='Votre Nom' && $Auteur != $Adresse && !empty($Comment)) { | |
| 15 // Prévention d'un "cassage" par ajout d'un commentaire incorrectement formaté | |
| 16 $ip = $_SERVER['REMOTE_ADDR']; | |
| 17 $Auteur = str_replace(array('<', '>'), array('<', '>'), $Auteur); | |
| 18 /*if(!DOMDocument::loadXML('<comment>' . $Comment . '</comment>')) | |
| 19 $Comment = '<![CDATA[' . str_replace(']]>', ']]>',$Comment) . ']]>';*/ | |
| 20 if(DOMDocument::loadXML('<comment>' . $Comment . '</comment>')) { | |
| 21 $Data->debugQuery(" | |
| 22 INSERT INTO Commentaires(MessId, Auteur, Adresse, AdresseMail, Comment, DateComment, ip) | |
| 23 VALUES({$id}, '{$Auteur}', '{$Adresse}', '{$AdresseMail}', '{$Comment}', '{$DateComment}', '{$ip}') | |
| 24 "); | |
| 25 $Data->Query("UPDATE Mess SET NbCommentaires=NbCommentaires+1 WHERE num_mess={$id}"); | |
| 26 mail('webmaster+blogcomment@defr.org', 'Nouveau commentaire sur de ' . $Auteur, $Auteur . " vient de mettre en ligne le commentaire suivant: \n" . wordwrap($Comment, 70)); | |
| 27 } | |
| 28 else { | |
| 29 $infos = 'Votre commentaire doit etre fait de XML valide pour apparaitre.'; | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 $Data->Query("SELECT * FROM Mess WHERE num_mess = {$id}"); | |
| 34 $row = $Data->GetRow(); | |
| 35 $mood = ''; | |
| 36 $Mess=$Data->utf8_ensure(str_replace("<P>","<p>",str_replace("</P>","</p>", $row['Message']))); | |
| 37 $dateFormatee = strftime("%A %d %B %Y, %Hh%M", strtotime($row['DatePost'])); | |
| 38 $Titre = $Data->utf8_ensure($row['Titre']); | |
| 39 $Titre_url = str_replace(" ", "_", strip_tags($Titre)); | |
| 40 $Titre_url = str_replace("-", "_", $Titre_url); | |
| 41 include("top.php"); | |
| 42 if(!empty($row['Emot'])) { | |
| 43 $mood = "<img src='/blog/mood/{$row['Emot']}.png' alt='Mood : {$row['Emot']}' class='mood' />"; | |
| 44 $row['Emot'] = " " . $row['Emot']; | |
| 45 } | |
| 46 echo(" | |
| 47 <div class='PostContent{$row['Emot']}'> | |
| 48 <h2>{$Titre} | <span class='Date'>{$dateFormatee}</span></h2> | |
| 49 {$mood} | |
| 50 {$Mess}<br /> | |
| 51 {$infos} | |
| 52 </div>"); | |
| 53 $Data->Query("SELECT * FROM Commentaires Where MessId={$id} ORDER BY num_comm"); | |
| 54 $defaultGravatar = urlencode("http://defr.org/Misc/NoGravatar.png"); | |
| 55 while(0 !== ($row = $Data->GetRow())) { | |
| 56 $dateFormatee = strftime(" à %Hh%M le <span class='Date'>%A %d %B %Y</span>", strtotime($row['DateComment'])); | |
| 57 $AdresseMail = $row['AdresseMail']; | |
| 58 $grav_id = md5($AdresseMail); | |
| 59 $Comment = nl2br($row['Comment']); | |
| 60 $Comment = str_replace(" & ", " & ", $Comment); | |
| 61 if($row['num_comm'] == 172) $Comment = str_replace("</sup>", "</del>", $Comment); | |
| 62 //if(stristr($Adresse, "@")) $Adresse = "mailto:" . $Adresse; | |
| 63 $betterHref = (stristr($row['Adresse'], 'http://') != false)?"href='{$row['Adresse']}'":''; | |
| 64 echo(" | |
| 65 <div class='PostContent'> | |
| 66 <div class='Infos'> | |
| 67 <img class='gravatar' src='http://www.gravatar.com/avatar.php?gravatar_id={$grav_id}&size=50&default=$defaultGravatar' alt='' /> | |
| 68 <a {$betterHref} name='c{$row['num_comm']}'>{$row['Auteur']}</a> {$dateFormatee} | |
| 69 </div> | |
| 70 <div class='Comment'>{$Comment}</div> | |
| 71 <br class='endComment' /> | |
| 72 </div>"); | |
| 73 } | |
| 74 echo(" | |
| 75 <div class='PostContent'> | |
| 76 <a href='/blog/'>Revenir au blog</a> | |
| 77 </div> | |
| 78 <div class='PostContent'> | |
| 79 <form method='post' action='#'> | |
| 80 <div id='FormCommentaire'> | |
| 81 Vous souhaitez ajouter un nouveau commentaire ? Faites donc, il vous suffit de remplir | |
| 82 le petit formulaire ci-dessous. | |
| 83 <input type='text' name='Auteur' value='Votre Nom' onfocus=\"if(this.value== this.getAttribute('value')) this.value='';\" /> | |
| 84 <input type='text' name='AdresseMail' value='Une adresse mail où vous joindre ? ( Non affichée publiquement )' onfocus=\"if(this.value == this.getAttribute('value')) this.value='';\"/> | |
| 85 <input type='text' name='Adresse' value='Un site web à vous ?' onfocus=\"if(this.value == this.getAttribute('value')) this.value='';\"/> | |
| 86 <textarea name='Comment' rows='10' cols='40' onfocus=\"if(this.value == 'Et z\'enfin, votre petit commentaire') this.value='';\">Et z'enfin, votre petit commentaire</textarea> | |
| 87 <input type='submit' value='Poster ce commentaire' /> | |
| 88 </div> | |
| 89 </form> | |
| 90 </div> | |
| 91 "); | |
| 92 include("foot.php"); | |
| 93 ?> |
