Old stuff/old_sites/appo/oldblog_content.php
(Deskargatu)
<? // Parce que mcedit fait chier sinon
include("admin/func.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="alternate" type="application/rss+xml" title="Blog" href="http://blog.i-monde.org/rss.php" />
<title>home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
div.noir { background-color:#e5e5e5; padding:5px; margin:2px 5px;}
div.gris { background-color:#f5f5f5; padding:5px; margin:2px 5px;}
input,textarea { border:1px solid black; padding:0px 2px; background-color:#eee;}
input.button { border:1px outset black; }
a:link {
color: #666666;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #CCCCCC;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
color: #333333;
cursor: crosshair;
}
body {
margin-left: 15px;
margin-right: 15px;
margin-top: 10px;
cursor: crosshair;
}
.Style2 {color: #333333}
-->
</style>
</head>
<body>
<?
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 "
<p align=\"left\" class=\"Style2\"><strong>Le $regs[3]/$regs[2]/$regs[1] à $regs[4]:$regs[5]:$regs[6]</strong>:
[<a href=\"blog_content.php?id=".$row{'section'}."\">".$row['section']."</a>] : ".$row{'titre'}." (";
print "<a href=\"/blog_content.php?id=$regs[1]/$regs[2]/$regs[3]/".$row{'id'}."-".$row{'titre'}."\">".$arr[0]." com.</a>)";
print " </p>
";
$contenu = explode("\n",$row{'contenu'});
print "<p align\"left\" style=\"margin-bottom:15px\" class=\"Style2\">";
foreach($contenu as $key) { print "$key<br>"; }
print "</p>";
}
}
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 "
<p align=\"left\" class=\"Style2\"><strong>Le $regs[3]/$regs[2]/$regs[1] à $regs[4]:$regs[5]:$regs[6]</strong>:
[<a href=\"blog_content.php?id=".$row{'section'}."\">".$row['section']."</a>] : <a href=\"blog_content.php?id=".$regs[1]."/".$regs[2]."/".$regs[3]."/".$row{'id'}."\">".$row{'titre'}."</a>";
print " </p>
";
$contenu = explode("\n",$row{'contenu'});
print "<p align\"left\" class=\"Style2\">";
foreach($contenu as $key) { print "$key<br>"; }
print "</p>";
}
if ($id)
{
$query = "SELECT * FROM commentaires WHERE ref='".$id."'";
$result = mysql_query($query);
print "<strong>Commentaires</strong>";
if (mysql_num_rows($result) > 0)
{
print "<div>";
$i=1;
while($row = mysql_fetch_assoc($result))
{
$i++;
$class= ($i % 2 ==0 ? "noir" : "gris");
print "<div class=\"$class\">\n";
ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",$row{'date'},$regs);
print "
<p align=\"left\" class=\"Style2\"><strong><a href=\"".$row{'site'}."\">".$row{'pseudo'}."</a></strong>, le $regs[3]/$regs[2]/$regs[1] à $regs[4]:$regs[5]:$regs[6]:
".$row{'titre'}." </p>";
$contenu = explode("\n",$row{'contenu'});
print "<p align\"left\" class=\"Style2\">";
foreach($contenu as $key) { print "$key<br>"; }
print "</p></div>\n";
}
print "</div>";
}
else { print "<p>Pas de commentaires pour l'instant.</p>"; }
if (empty($_POST['titre']) or empty($_POST['pseudo']) or empty($_POST['contenu']))
{
if (!empty($_POST)) { echo "<p>Veuillez remplir les champs pseudo, titre et contenu.</p>"; }
print "
<form action=\"blog_content.php?id=".$_GET['id']."\" method=\"post\">
<dl>
<dt>Pseudo</dt><dd><input name=\"pseudo\" type=\"text\" value=\"".$_POST['pseudo']."\"></dd>
<dt>Site Internet <sup>*</sup> facultatif</dt><dd><input name=\"site\" type=\"text\" value=\"".$_POST['site']."\"></dd>
<dt>Titre</dt><dd><input name=\"titre\" type=\"text\" value=\"Re: ".$real_titre."\"></dd>
<dt>Message</dt><dd><textarea name=\"contenu\" rows=\"5\" cols=\"25\">".$_POST['contenu']."</textarea></dd>
<dt></dt><dd><input type=\"submit\" class=\"button\" value=\"Envoyer\"></dd>
</dl>
</form>
";
}
}
}
?>
</body>
</html>