Le $regs[3]/$regs[2]/$regs[1] à $regs[4]:$regs[5]:$regs[6]: [".$row['section']."] : ".$row{'titre'}." ("; print "".$arr[0]." com.)"; print "

"; $contenu = explode("\n",$row{'contenu'}); print "

"; foreach($contenu as $key) { print "$key
"; } print "

"; } } else { ereg("([0-9]{4})\/([0-9]{2})\/([0-9]{2})(\/([0-9]{1,5}))?.*",$_GET['id'],$regs); if (!empty($regs[5])) { $id = $regs[5]; } else { unset($id); } if ($id and !empty($_POST['titre']) and !empty($_POST['pseudo']) and !empty($_POST['contenu'])) { echo "Ajout de commentaire... "; $pseudo = htmlentities($_POST['pseudo']); $titre= htmlentities($_POST['titre']); $site = htmlentities($_POST['site']); $contenu = text2html($_POST['contenu']); $query = "INSERT INTO commentaires (ref,pseudo,site,titre,contenu) VALUES ('".$id."','".$pseudo."','".$site."','".$titre."','".$contenu."')"; mysql_query($query) or die(mysql_error()); echo "ok"; } if (! empty($regs[5])) { $query = "SELECT id,date,section,titre,contenu FROM blog WHERE id='".$regs[5]."' AND date LIKE '".$regs[1].$regs[2].$regs[3]."%' ORDER BY id DESC" ; } elseif (! empty($regs[3])) {$query = "SELECT id,date,section,titre,contenu FROM blog WHERE date LIKE '".$regs[1].$regs[2].$regs[3]."%' ORDER BY id DESC"; } elseif (ereg("^([0-9]{4})\/([0-9]{2})$",$_GET['id'],$regs)) { $query = "SELECT id,date,section,titre,contenu FROM blog WHERE date LIKE '".$regs[1].$regs[2]."%' ORDER BY id DESC" ; } else { $cat = htmlentities($_GET['id']); $query = "SELECT * FROM blog WHERE section LIKE '".$cat."' LIMIT 20"; } $result = mysql_query($query); if (mysql_num_rows($result) == 0) { die("Il n'y a aucun élément pour cette date. Utilisez le menu !"); } while ($row = mysql_fetch_assoc($result)) { $real_titre = $row{'titre'}; ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",$row{'date'},$regs); print "

Le $regs[3]/$regs[2]/$regs[1] à $regs[4]:$regs[5]:$regs[6]: [".$row['section']."] : ".$row{'titre'}.""; print "

"; $contenu = explode("\n",$row{'contenu'}); print "

"; foreach($contenu as $key) { print "$key
"; } print "

"; } if ($id) { $query = "SELECT * FROM commentaires WHERE ref='".$id."'"; $result = mysql_query($query); print "Commentaires"; if (mysql_num_rows($result) > 0) { print "
"; $i=1; while($row = mysql_fetch_assoc($result)) { $i++; $class= ($i % 2 ==0 ? "noir" : "gris"); print "
\n"; ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",$row{'date'},$regs); print "

".$row{'pseudo'}.", le $regs[3]/$regs[2]/$regs[1] à $regs[4]:$regs[5]:$regs[6]: ".$row{'titre'}."

"; $contenu = explode("\n",$row{'contenu'}); print "

"; foreach($contenu as $key) { print "$key
"; } print "

\n"; } print "
"; } else { print "

Pas de commentaires pour l'instant.

"; } if (empty($_POST['titre']) or empty($_POST['pseudo']) or empty($_POST['contenu'])) { if (!empty($_POST)) { echo "

Veuillez remplir les champs pseudo, titre et contenu.

"; } print "
Pseudo
Site Internet * facultatif
Titre
Message
"; } } } ?>