// Parce que mcedit fait chier sinon
include("admin/func.php");
?>
home
include("connect.php");
if (empty($_GET['id']))
{
$result = mysql_query("SELECT id,date,section,titre,contenu FROM blog ORDER BY id DESC LIMIT 10");
while ($row = mysql_fetch_assoc($result))
{
$rquery = "SELECT count(id) FROM commentaires WHERE ref='".$row{'id'}."'";
$rresult = mysql_query($rquery) or die(mysql_error());
$arr = mysql_fetch_array($rresult); // $arr[0] contient le nbre de comm
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 "".$arr[0]." com.)";
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 "