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