Old stuff/old_sites/epik/include/view.php
(Deskargatu)
<?
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 "
<div class=\"element\">";
$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 "
<h2>".$row["titre"]."</h2>
<h3><a href=\"/site/$page/$art_typ\">".$row["arttyp"]."</a>: le ".$row["datetime"]." par
<a href=\"".$site["site"]."\" title=\"Site web de ".$row["posteur"]."\">".$row["posteur"]."</a>
(<a href=\"http://epiknet.org/club/fiche.asp?nick=".$row["posteur"]."\" title=\"".$row["posteur"]."\">club</a>, <a href=\"mailto:".hex_encode($site["email"])."\">email</a>)
";
echo "
</h3>
<div>
";
affichage($row["article"],5,"/site/$page/".$row["id"]."-".normalise($row["titre"]));
echo " </div>";
$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 "<p class=\"com\"><a href=\"/site/$page/".$row["id"]."-".normalise(sans_accents(html_entity_decode($row["titre"])))."\">Aucun commentaire</a>";
}
elseif (mysql_num_rows($res)==1) {
print "<p class=\"com\"><a href=\"/site/$page/".$row["id"]."-".normalise(sans_accents(html_entity_decode($row["titre"])))."\">1 commentaire</a>";
}
else {
print "<p class=\"com\"><a href=\"/site/$page/".$row["id"]."-".normalise(html_entity_decode(sans_accents($row["titre"])))."\">".mysql_num_rows($res)." commentaires</a>";
}
if ($axx>5) { echo " :: <a href=\"/site/modif/$page/".$row["id"]."-".normalise($row["titre"])."/supprimer\">Suppr</a>/
<a href=\"/site/modif/$page/".$row["id"]."-".normalise($row["titre"])."/modifier\">modif</a>"; }
echo "</p>";
echo "</div>";
}
}
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 "
<div>
<h2>Archives (20 derniers elements)</h2>
<ul>" ;
while($row = mysql_fetch_array($result))
{
if ($i>4) {
echo "<li><a href=\"/site/$page/$row[0]-".normalise(sans_accents(html_entity_decode($row[1])))."\">$row[1]</a></li>";
}
$i++;
}
echo "</ul></div>";
}
}
}
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 "
<div class=\"element\">";
$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 "
<h2>".$row["titre"]."</h2>
<h3><a href=\"/site/$page/$art_typ\">".$row["arttyp"]."</a>: le ".$row["datetime"]." par <a href=\"http://epiknet.org/club/fiche.asp?nick=".$row["posteur"]."\" title=\"".$row["posteur"]."\">".$row["posteur"]."</a>
";
if ($site["site"]) { echo "(<a href=\"".$site["site"]."\" title=\"Site web de ".$row["posteur"]."\">Site</a>)"; }
echo "
</h3>
<div>
";
affichage($row["article"],5,"/site/$page/".$row["id"]."-".normalise($row["titre"]));
echo " </div>";
$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 "<p class=\"com\"><a href=\"/site/$page/".$row["id"]."-".normalise(sans_accents(html_entity_decode($row["titre"])))."\">Aucun commentaire</a>";
}
elseif (mysql_num_rows($res)==1) {
print "<p class=\"com\"><a href=\"/site/$page/".$row["id"]."-".normalise(sans_accents(html_entity_decode($row["titre"])))."\">1 commentaire</a>";
}
else {
print "<p class=\"com\"><a href=\"/site/$page/".$row["id"]."-".normalise(sans_accents(html_entity_decode($row["titre"])))."\">".mysql_num_rows($res)." commentaires</a>";
}
if ($axx>5) { echo " :: <a href=\"/site/modif/$page/".$row["id"]."-".normalise($row["titre"])."/supprimer\">Suppr</a>/
<a href=\"/site/modif/$page/".$row["id"]."-".normalise($row["titre"])."/modifier\">modif</a>"; }
echo "</p>";
echo "</div>";
}
}
}
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 " <div class=\"element\">
<h2>$row[4]</h2>
<h3><a href=\"/site/$page/$art_typ\">$row[3]</a>: le $row[1] par <a href=\"http://epiknet.org/club/fiche.asp?nick=$row[2]\" title=\"$row[2]\">$row[2]</a></h3>
<div> ";
affichage($row[5],0);
echo " </div> ";
if ($axx>3)
{
echo "<p class=\"com\"><a href=\"/site/modif/$page/$row[0]-".normalise($row[4])."/supprimer\">Suppr</a>/
<a href=\"/site/modif/$page/$row[0]-".normalise($row[4])."/modifier\">Modif</a></p>";
}
echo "</div>";
$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<div class=\"com\">
<h2>par <a href=\"http://epiknet.org/club/fiche.asp?nick=$row[2]\" title=\"fiche clien\">$row[2]</a>";
if ($axx >5) { echo " ($row[6]) "; }
if ($row[3] !== "email") { $row[3] = hex_encode($row[3]);echo ":: <a href=\"mailto:$row[3]\">mail</a>";}
$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 "</h2>\n<h3>le $row[4]</h3>
<div>";
affichage($row[5],0);
echo "</div>";
if ($axx>3 ) { echo "\n<p><a href=\"/site/modif/".$page."com/$row[0]/supprimer\">Supprimer</a></p>"; }
echo "\n</div>";
}
$var = ip_read($chemin[1]);
if ((empty($axx) or $axx < 3) && $var["$ip"]["visites"] > 5)
{ echo "<div class=\"element\"><h2>Commentaires epuises</h2>
<div><p>Vous avez deja poste 5 commentaires dans la journee !</p></div></div>";
}
else
{
print "<div class=\"element\">
<h2>Nouveau commentaire</h2>
<div>
";
aide();
echo "
<form action=\"/site/$page/$id\" method=\"post\">
";
if(isset($email))
{
echo "<p> <input type=\"text\" name=\"pseudocom\" value=\"".$nick."\" /></p>
<p> <input type=\"text\" name=\"email\" value=\"".$email."\" /> </p>";
}
else
{
echo " <p>Vous n'etes pas identifies</p>
<p><input type=\"text\" name=\"pseudocom\" value=\"nick\" onfocus=\"if (this.value == this.defaultValue) { this.value=''; }\" /></p>
<p> <input type=\"text\" name=\"email\" value=\"email\" onfocus=\"if (this.value == this.defaultValue) { this.value=''; }\"/> </p>";
}
echo "
<p> <textarea rows=\"15\" cols=\"60\" name=\"commentaire\" onfocus=\"if (this.value == this.defaultValue) { this.value=''; }\">commentaire</textarea></p>
<p> <input class=\"button\" type=\"submit\" value=\"Envoyer\" /></p>
</form>
</div>
</div>
";
}
}
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 "<div class=\"element\">
<h2>Ajout de commentaire</h2>
<div>
<p>Votre commentaire a correctement ete ajoute.</p>
<p>Pseudo: $pseudocom</p>
<p>Email: <a href=\"mailto:".hex_encode($email)."\">$email</a></p>
<p>Commentaire: </p>
<div>".text2html($commentaire)."</div>
<p>refID: $id</p>
<p>Date:$date</p>
</div>
</div>
<div class=\"element\">
<h2>Retour</h2>
<div>
<p><a href=\"/site/$page/$id\">Retourner voir l' article</a></p>
<p><a href=\"/site/$page\">Retourner a la section $page</a></p>
<p><a href=\"/site/accueil\">Retourner sur la page d' acceuil</a></p>
</div>
</div>";
}
else {
echo "<div class=\"element\">
<h2>Erreur !</h2>
<div><p>Erreur: veuillez entrer un pseudo, un email (ou laisser le champs sans modification), ainsi qu' un commentaire valide.</p>
</div>
</div>";
}
}
}
?>