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