Old stuff/old_sites/newepik/include/forum.php
(Deskargatu)
<div class="article">
<div class="element">
<h2>Forum</h2>
<div class="forum">
<?
if (!$axx) { $axx=0; }
echo " <h3>Repertoire: /<a href=\"/site/forum\" title=\"Forums\">Forum</a>\n";
if (empty($chemin[2])) {
echo "</h3>
<p><a title=\"Recherche sur le forum\" href=\"/site/recherche/forum\">Rechercher sur tout le forum</a></p>
<dl>
";
$compteur=1;
$envoi = "SELECT ref,nom,description,categorie FROM description WHERE axx<=$axx ORDER by id ASC";
$resulta = mysql_query($envoi) or die(mysql_error()); #ref = nom et description des tables
while ($ref = mysql_fetch_assoc($resulta))
{
$compteur++;
if (fmod($compteur,2) ==0) { $style="foruma"; } else { $style="forumb"; }
$requete = "SELECT pseudo,date,topic_id,com_id from ".$ref["ref"]." ORDER BY id DESC LIMIT 1";
$resultat = mysql_query($requete) or die(mysql_error()."<br>$requete");
$dernier = mysql_fetch_assoc($resultat);
$dernier["date"] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$dernier["date"]);
$ref["ref"] = preg_replace("/^forum_(.*)/","$1",$ref["ref"]);
echo "<dt class=\"$style\"><a href=\"/site/forum/".$ref["ref"]."-1\" title=\"".$ref["nom"]."\">".$ref["nom"]."</a></dt><dd>".$ref["description"]."</dd>\n";
if (!empty($dernier["pseudo"]))
{
$lastpage = ceil($dernier["com_id"]/10);
echo "<dd><a href=\"/site/forum/".$ref["ref"]."/".$dernier["topic_id"]."-$lastpage#bas\" title=\"dernier message\">Dernier message</a>
le ".$dernier["date"]." par <a href=\"http://epiknet.org/club/fiche.asp?nick=".$dernier["pseudo"]."\" title=\"Description du pseudo\">".$dernier["pseudo"]."</a></dd> ";
}
}
echo "</dl>
";
}
else {
if (empty($chemin[3]))
{
list($table,$start) = split("-",$chemin[2]);
$envoi = "SELECT axx FROM description WHERE ref='forum_$table'";
$result_envoie=mysql_query($envoi);
if ($row=mysql_fetch_array($result_envoie)) { $need_axx = $row[0]; }
else { $need_axx = 100; }
if ($need_axx > $axx) { die("</h3><p>Vous n'avez pas acces a ce forum , fatal error</p>"); }
echo "/ <a href=\"/site/forum/$table-1\" title=\"Forum $table\">$table</a> \n";
$requete = "SELECT COUNT(DISTINCT topic_id) from forum_$table ";
$resultat = mysql_query($requete) or die("inexistant");
$pages = mysql_fetch_array($resultat);
$page = ceil($pages[0]/10);
if ($page == 1) { echo "( 1 page )"; }
else { echo "("; for($i=1;$i<=$page;$i++) { echo "<a href=\"/site/forum/$table-$i\" title=\"autre page\">$i</a> "; } echo " )";}
$start =($start-1)*10;
$chemin[2]=$table;
echo "</h3>
<p><a title=\"Recherche sur le forum\" href=\"/site/recherche/forum/$chemin[2]\">Rechercher sur cette section</a></p>
<p><a href=\"/site/forum/$chemin[2]/new\" title=\"Ajout\">Nouveau</a></p>";
$big=array();
$bignum = 0;
$query = "SELECT topic_id,nom,pseudo FROM forum_".$chemin[2]." WHERE com_id='1' ORDER BY id DESC LIMIT $start,10";
$result = mysql_query($query) or die("Not found?");
$compteur=1;
echo "<dl>\n";
while($row = mysql_fetch_assoc($result))
{
$big[$bignum] = array("nom"=> $row["nom"],
"topic_id"=>$row["topic_id"],
"pseudo"=>$row["pseudo"]);
$bignum++;
}
for ($i=0;$i<count($big);$i++)
{
$query = "SELECT MAX(date) FROM forum_".$chemin[2]." WHERE topic_id='".$big[$i]["topic_id"]."'";
$result = mysql_query($query) or die(mysql_error());
$element = mysql_fetch_array($result);
$big[$i]["date"] = preg_replace("/\d{2}(\d{2})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$1$2$3$4$5$6",$element[0]);
}
foreach($big as $key => $row) {
$a_nom[$key]=$row["nom"];
$a_topic_id[$key]=$row["topic_id"];
$a_pseudo[$key]=$row["pseudo"];
$a_date[$key]=$row["date"];
}
array_multisort($a_date, SORT_DESC,
$a_nom, SORT_DESC,
$a_topic_id, SORT_DESC,
$a_pseudo, SORT_DESC , $big);
foreach($big as $row)
{
$requete = "SELECT COUNT(*) from forum_$chemin[2] WHERE topic_id='".$row["topic_id"]."'";
$resultat = mysql_query($requete) or die(mysql_error());
$reponses = mysql_fetch_array($resultat);
$requete = "SELECT com_id,pseudo,date from forum_$chemin[2] WHERE topic_id='".$row["topic_id"]."' and com_id>1 ORDER BY com_id DESC LIMIT 1";
$resultat = mysql_query($requete) or die(mysql_error());
$dernier = mysql_fetch_assoc($resultat);
$compteur++;
if (fmod($compteur,2) ==0) { $style="foruma"; } else { $style="forumb"; }
echo "<dt class=\"$style\">
<a href=\"/site/forum/$chemin[2]/".$row["topic_id"]."-1-".normalise($row["nom"])."\" title=\"".$row["nom"]."\">".$row["nom"]."</a></dt>
<dd class=\"nick\">par <a href=\"http://epiknet.org/club/fiche.asp?nick=".$row["pseudo"]."\" title=\"Description du pseudo\">".$row["pseudo"]."</a>";
if ($axx > 5) { echo " (<a href=\"/site/forum/$chemin[2]/".$row["topic_id"]."/topicdel\" title=\"Supprimer\">Supprimer</a>)"; }
echo " </dd>
<dd class=\"reponses\">";
if (($reponses[0]-1)== 0) echo "pas de reponses";
elseif(($reponses[0]-1) == 1) { echo "1 reponse"; }
else { echo ($reponses[0]-1)." reponses"; }
$dernier["date"] = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$dernier["date"]);
echo " </dd>";
if (!empty($dernier["pseudo"])) {
$page = ceil($com_id/10)+1;
echo "<dd class=\"dernier\"><a href=\"/site/forum/$chemin[2]/".$row["topic_id"]."-$page"."\" title=\"Last msg\">Dernier message</a> le ".$dernier["date"]." par <a href=\"http://epiknet.org/club/fiche.asp?nick=".$dernier["pseudo"]."\" title=\"Description\">".$dernier["pseudo"]."</a>";
}
else { echo "<dd class=\"dernier\">n/a"; }
echo "\n";
echo " </dd> ";
}
echo "</dl>\n";
}
else
{
echo "/ <a href=\"/site/forum/$chemin[2]-1\" title=\"Forum $chemin[2]\">$chemin[2]</a> \n";
$chemin[2] = preg_replace("/[^a-zA-Z]/","",$chemin[2]);
$envoi = "SELECT axx FROM description WHERE ref='forum_$chemin[2]'";
$result_envoie=mysql_query($envoi);
if ($row=mysql_fetch_array($result_envoie)) { $need_axx = $row[0]; }
else { $need_axx = 100; }
if ($need_axx > $axx) { die("</h3><p>Vous n'avez pas acces a ce document</p>"); }
if ($chemin[3] == "new")
{
include(dirname(__FILE__)."/inc_forum/new.php");
}
else
{
$chemin[3] = preg_replace("/^(\d+)\-(\d+).*/","$1-$2",$chemin[3]);
if ($chemin[4]=="repondre") { include(dirname(__FILE__)."/inc_forum/repondre.php"); }
elseif ($chemin[4]=="topicdel") { include(dirname(__FILE__)."/inc_forum/topicdel.php"); }
else
{
if (!empty($chemin[4])) { include(dirname(__FILE__)."/inc_forum/edit.php"); }
else
{
list($table,$start) = split("-",$chemin[3]);
$requete = "SELECT COUNT(*) from forum_$chemin[2] WHERE topic_id='$table'";
$resultat = mysql_query($requete) or die(mysql_error());
$pages = mysql_fetch_array($resultat);
$page = ceil($pages[0]/10);
if ($page == 1) { echo "( 1 page )"; }
else { echo "("; for($i=1;$i<=$page;$i++) { echo "<a href=\"/site/forum/$chemin[2]/$table-$i\" title=\"Autre page\">$i</a> "; } echo " )";}
$start =($start-1)*10;
echo "</h3>\n
<p><a title=\"Recherche sur le forum\" href=\"/site/recherche/forum/$chemin[2]/$table\">Rechercher sur ce topic</a></p>
<div>";
$query = "SELECT com_id,nom,pseudo,date,contenu FROM forum_$chemin[2] WHERE topic_id='$table' ORDER BY id ASC LIMIT $start,10";
$result = mysql_query($query) or die("Erreur !");
$compteur=1;
while ($row = mysql_fetch_assoc($result))
{
$date = preg_replace("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/","$3/$2/$1 à $4:$5:$6",$row["date"]);
$compteur++;
if (fmod($compteur,2) ==0) { $style="foruma"; } else { $style="forumb"; }
# echo "<div id=\"id".$row["com_id"]."\" class=\"$style\"><dl><dt>".$row["nom"]." </dt>
# <dd>(<a href=\"/site/forum/$chemin[2]/$table-".($start+1)."/#id".$row["com_id"]."\" title=\"Element\">#</a>)par <a href=\"http://epiknet.org/club/fiche.asp?nick=".$row["pseudo"]."\" title=\"Description\">".$row["pseudo"]."</a> le ".$date."</dd></dl>
# <div>";
echo "<div id=\"id".$row["com_id"]."\" class=\"$style\"><dl><dt>".$row["nom"]." </dt>
<dd>(<a href=\"/site/forum/$chemin[2]/$table-".($page)."/#id".$row["com_id"]."\" title=\"Element\">#</a>)par <a href=\"http://epiknet.org/club/fiche.asp?nick=".$row["pseudo"]."\" title=\"Description\">".$row["pseudo"]."</a> le ".$date."</dd></dl>
<div>";
affichage($row["contenu"]);
if ($nick == $row["pseudo"] or $axx>5) { echo "<p><a href=\"/site/forum/$chemin[2]/$table/".$row["com_id"]."/Editer\" title=\"Editer\">Editer</a> :: <a href=\"/site/forum/$chemin[2]/$table/".$row["com_id"]."/Supprimer\" title=\"Supprimer\">Supprimer</a></p>"; }
echo "
</div></div>\n";
}
echo "<p><a href=\"/site/forum/$chemin[2]/$table/repondre\" title=\"repondre\">Repondre</a></p></div>\n";
}
}
}
}
}
?>
</div>
</div>
</div>