comparison comment.20060616.php @ 0:629389204276

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