if ($_POST['pseudocom']) { $pseudocom = $_POST['pseudocom']; }
if ($_POST['email']) { $email = $_POST['email']; }
if ($_POST['commentaire']) { $commentaire = $_POST['commentaire']; }
if (ereg("^[0-9]{1,5}",$chemin[2]))
{
$id = preg_replace("/^(\d+)(.*)?/","$1",$chemin[2]);
}
if(ereg("^[a-zA-Z\%0-9]{3,30}$",$chemin[2]) and !$id)
{
$section = $chemin[2];
}
if (!$min) { $min = 5; }
if (!$id and !$section)
{
$result = mysql_query("SELECT * FROM $page ORDER BY id DESC Limit 0,$min") or die("ERROR".mysql_error());
if (mysql_num_rows($result) != 0)
{
while($row = mysql_fetch_assoc($result))
{
unset($site);
$row["datetime"] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$row["datetime"]);
echo "
";
$req_site = "SELECT email,site FROM membres WHERE pseudo = '".$row["posteur"]."'";
$req_result = mysql_query($req_site) or die(mysql_error());
$site = mysql_fetch_assoc($req_result);
$art_typ = strtr($row["arttyp"], "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ", "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
echo "
".$row["titre"]."
";
affichage($row["article"],5,"/site/$page/".$row["id"]."-".normalise($row["titre"]));
echo "
";
$res = mysql_query("SELECT * FROM ".$page."com WHERE ".$page."id='".$row["id"]."' ORDER BY id ASC") or die("ERROR".mysql_error());
if ( mysql_num_rows($res)==0) {
print "
Aucun commentaire";
}
elseif (mysql_num_rows($res)==1) {
print "
1 commentaire";
}
else {
print "
".mysql_num_rows($res)." commentaires";
}
if ($axx>5) { echo " :: Suppr/
modif"; }
echo "
";
echo "
";
}
}
if (!$noaff)
{
$result = mysql_query("SELECT id,titre FROM $page ORDER BY id DESC LIMIT 25") or die("ERROR".mysql_error());
$i = 0;
if (mysql_num_rows($result) > 4)
{
echo "
Archives (20 derniers elements)
" ;
while($row = mysql_fetch_array($result))
{
if ($i>4) {
echo "- $row[1]
";
}
$i++;
}
echo "
";
}
}
}
elseif ($section)
{
if ($section == "hier") {
$date = mktime(0, 0, 0, date("n"), date("j") - 1, date("Y"));
$searchdate = date(Y,$date)."-".date(m,$date)."-".date(d,$date)." %:%:%";
$query = "SELECT * FROM $page WHERE 1 AND datetime LIKE '$searchdate' ORDER BY id DESC";
}
elseif ($section == "aujourdhui") {
$searchdate = date(Y)."-".date(m)."-".date(d)." %:%:%";
$query = "SELECT * FROM $page WHERE 1 AND datetime LIKE '$searchdate' ORDER BY id DESC";
}
elseif ($section == "mois") {
$searchdate = date(Y)."-".date(m)."-% %:%:%";
$query = "SELECT * FROM $page WHERE 1 AND datetime LIKE '$searchdate' ORDER BY id DESC";
}
else {
$query = "SELECT * FROM $page WHERE arttyp='$section' ORDER BY id DESC";
}
$result = mysql_query($query) or die("ERROR".mysql_error());
if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_assoc($result))
{
unset($site);
$row["datetime"] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$row["datetime"]);
echo "
";
$req_site = "SELECT site FROM membres WHERE pseudo = '".$row["posteur"]."'";
$req_result = mysql_query($req_site) or die(mysql_error());
$site = mysql_fetch_assoc($req_result);
$art_typ = sans_accents($row["arttyp"]);
echo "
".$row["titre"]."
";
affichage($row["article"],5,"/site/$page/".$row["id"]."-".normalise($row["titre"]));
echo "
";
$res = mysql_query("SELECT * FROM ".$page."com WHERE ".$page."id='".$row["id"]."' ORDER BY id ASC") or die("ERROR".mysql_error());
if ( mysql_num_rows($res)==0) {
print "
Aucun commentaire";
}
elseif (mysql_num_rows($res)==1) {
print "
1 commentaire";
}
else {
print "
".mysql_num_rows($res)." commentaires";
}
if ($axx>5) { echo " :: Suppr/
modif"; }
echo "
";
echo "
";
}
}
}
else {
if (!$pseudocom or !$commentaire)
{
$query = "SELECT * FROM $page WHERE id='$id'";
$result = mysql_query($query) or
die("ERROR".mysql_error());
$row = mysql_fetch_array($result);
$row[1] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$row[1]);
$art_typ = sans_accents($row["arttyp"]);
echo "
$row[4]
";
affichage($row[5],0);
echo "
";
if ($axx>3)
{
echo "
Suppr/
Modif
";
}
echo "
";
$result = mysql_query("SELECT * FROM ".$page."com WHERE ".$page."id='$id' ORDER BY id ASC") or die("ERROR".mysql_error());
while($row = mysql_fetch_array($result))
{
$row[4] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$row[4]);
print "\n\n
par $row[2]";
if ($axx >5) { echo " ($row[6]) "; }
if ($row[3] !== "email") { $row[3] = hex_encode($row[3]);echo ":: mail";}
$row[4] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$row[4]);
echo "
\n
le $row[4]
";
affichage($row[5],0);
echo "
";
if ($axx>3 ) { echo "\n
Supprimer
"; }
echo "\n
";
}
$var = ip_read($chemin[1]);
if ((empty($axx) or $axx < 3) && $var["$ip"]["visites"] > 5)
{ echo "Commentaires epuises
Vous avez deja poste 5 commentaires dans la journee !
";
}
else
{
print "
";
}
}
else
{
if($pseudocom != "nick" and ((strstr($email,'@') or $email=="email" or empty($email))) and $commentaire != "commentaire")
{
$var = ip_read($chemin[1]);
$var["$ip"]["visites"]++;
$var["$ip"]["pseudo"]=$nick;
ip_write($chemin[1],$var);
$date=date(Y)."-".date(m)."-".date(d)." ".date(H).":".date(i).":".date(s);
$query = "INSERT INTO ".$page."com (".$page."id,pseudocom,email,datetime,commentaire,ip) VALUES('$id','$pseudocom','$email','$date','".text2html($commentaire)."','$ip')";
mysql_query($query) or die("ERROR".mysql_error());
echo "
Ajout de commentaire
Votre commentaire a correctement ete ajoute.
Pseudo: $pseudocom
Email: $email
Commentaire:
".text2html($commentaire)."
refID: $id
Date:$date
";
}
else {
echo "
Erreur !
Erreur: veuillez entrer un pseudo, un email (ou laisser le champs sans modification), ainsi qu' un commentaire valide.
";
}
}
}
?>