Old stuff/old_sites/epik/include/proposition.php
(Deskargatu)
<div class="article">
<h2>Participation aux breves</h2>
<div class="element">
<?php
if (!isset($axx)) { die("NON AUTORISE"); }
$art = preg_replace("[^a-zA-Z]","",$chemin[2]);
if ($chemin[2] and $art !== "article" and $art !== "breves" and $art !== "lien" and $art !== "download") { die("Erreur d'element"); }
if ($axx and ($chemin[3] == "nouveau")) {
if ($chemin[2] == "lien")
{
$url = $_POST['url'];
$description = $_POST['description'];
$souscategorie = $_POST['souscategorie'];
if ($souscategorie == "autre") { $souscategorie = $_POST['souscategorie2']; }
$categorie = $_POST['categorie'];
if ($categorie == "autre") { $categorie = $_POST['categorie2']; }
$pertinence = $_POST['pertinence'];
if (!empty($url) and !empty($description) and !empty($categorie) and !empty($souscategorie))
{
echo "
<h2>Merci de votre participation !</h2>
<div class=\"element\">
<h2>Nouvel element insere dans la categorie: $categorie</h2>
<div> ";
$query = "INSERT INTO prop_lien (categorie,scategorie,url,description,pertinence) VALUES ('$categorie','$souscategorie','$url','$description','$pertinence')";
mysql_query($query) or die("Fatal: $query<br>".mysql_error());
echo "<p>$url correctement ajoute</p>
</div>
";
}
else {
echo "<h2>Ajout de liens</h2>
<div class=\"element\">
<h2>Veuillez remplir le formulaire:</h2>
<div>
<p>Verifiez avant tout que l'url que vous allez proposer n'est pas deja presente dans la base de donnée. La descriptions se doit d'etre brève, courte et précise.
La "sous-categorie" n'est qu'optionnelle. </p>
<form action=\"/site/proposition/lien/nouveau\" method=\"post\">
<dl>
<dt>URL:</dt> <dd><input size=\"50\" type=\"text\" name=\"url\" value=\"http://\" /> </dd>
<dt>Categorie:</dt><dd><select name=\"categorie\">
";
$result = mysql_query("SELECT DISTINCT categorie FROM lien ORDER BY categorie ASC") or die("ERROR".mysql_error());
while($row = mysql_fetch_array($result))
{
echo "\t\t<option value=\"$row[0]\">$row[0]</option>\n";
}
echo "
<option value=\"autre\">Autre (precisez)</option>
</select>
Si autre: <input type=\"text\" name=\"categorie2\" />
</dd>
<dt>Sous categorie:</dt> <dd>
<select name=\"souscategorie\">
";
$result = mysql_query("SELECT DISTINCT scategorie FROM lien ORDER BY categorie ASC") or die("ERROR".mysql_error());
while($row = mysql_fetch_array($result))
{
echo "\t\t<option value=\"$row[0]\">$row[0]</option>\n";
}
echo "
<option value=\"autre\">Autre (precisez)</option>
</select>
Si autre: <input type=\"text\" name=\"souscategorie2\" />
</dd>
<dt> Pertinence:</dt><dd>
<select name=\"pertinence\">
<option selected=\"selected\" value=\"Tres bon\">Tres bon</option>
<option value=\"Bon\">Bon</option>
<option value=\"Acceptable\">Acceptable</option>
<option value=\"Mauvais\">Mauvais</option>
<option value=\"Tres mauvais\">Tres mauvais</option>
</select>
</dd>
<dt>Description:</dt> <dd><textarea rows=\"2\" cols=\"50\" name=\"description\">Breve description</textarea></dd>
</dl>
<p><input class=\"button\" type=\"submit\" value=\"Valider\" /></p>
</form>
</div>
</div>";
}
}
elseif($chemin[2] == "download")
{
echo "PRopo de programmes";
}
elseif ($chemin[2] == "breves" or $chemin[2] == "article")
{
if($type=$_POST['type'] and $titre=$_POST['titre'] and $contenu=$_POST['contenu'] )
{
if ($type == "Autres") { $type= $_POST['type2'] or die("ERREUR type"); }
if (strcmp($contenu,"contenu")==0 or strcmp($titre,"Titre")==0) { echo "<h2>contenu et titre</h2><div><p>Veuillez entrer un vrai contenu ainsi qu'un vrai titre.</p></div>"; }
else{
$date=date(Y)."-".date(m)."-".date(d)." ".date(H).":".date(i).":".date(s);
$query = "INSERT INTO prop_$art (datetime,posteur,arttyp,titre,article) VALUES('$date','$nick','$type','".text2html($titre)."','".text2html($contenu)."')";
# echo "QUERY : $query";
mysql_query($query) or die("FATAL".mysql_error());
echo "
<h2>Votre $art a bien ete poste</h2>
<div>
<h3>$type: $titre</h3>
<div> $contenu
</div>
<p>Merci de ne pas cliquer sur precedent, et de suivre un des liens ci dessous.</p>
<ul>
<li><a href=\"/site/accueil\" title=\"Acceuil du site\">Acceuil</a></li>
<li><a href=\"/site/proposition/breves/nouveau\" title=\"Section proposition\">Poster une nouvelle breve</a></li>
<li><a href=\"/site/proposition/article/nouveau\" title=\"Section proposition\">Poster un nouveau article</a></li>
</ul>
</div>
";
}
}
else {
echo "<h2>Nouvel element: ".$_GET['art']."</h2>
<div>
";
aide();
echo "
<form action=\"/site/proposition/$art/nouveau\" method=\"post\">
<p><select name=\"type\">
";
$query = "SELECT DISTINCT(arttyp) FROM $art";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo "<option value=\"".$row["arttyp"]."\">".$row["arttyp"]."</option>\n";
}
echo "<option value=\"Autres\">Si autre... precisez</option>\n</select>\n\n";
echo " Si autre:
<input type=\"text\" name=\"type2\" value=\"Type\" /></p>
<p><input type=\"text\" name=\"titre\" value=\"Titre\" /></p>
<p><textarea rows=\"10\" cols=\"57\" name=\"contenu\">contenu</textarea></p>
<p><input class=\"button\" type=\"submit\" value=\"Valider\" /></p>
</div>
";
}
}
}
elseif($chemin[3] == "moderer")
{
if ($chemin[2] == "lien")
{
if (ereg("^[0-9]{1,5}$",$chemin[4]))
{
if ($chemin[5] == "supprimer") {
$query = "DELETE FROM prop_lien WHERE id='$chemin[4]'";
mysql_query($query) or die(mysql_error());
}
elseif($chemin[5] == "accepter") {
$query = "SELECT categorie,scategorie,url,description,pertinence FROM prop_lien WHERE id='$chemin[4]'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
$row["categorie"] = mysql_escape_string($row["categorie"]);
$row["scategorie"] = mysql_escape_string($row["scategorie"]);
$row["description"] = mysql_escape_string($row["description"]);
$row["url"] = mysql_escape_string($row["url"]);
$requete = "INSERT into lien (categorie,scategorie,url,description,pertinence) VALUES
('".$row["categorie"]."','".$row["scategorie"]."','".$row["url"]."','".$row["description"]."','".$row["pertinence"]."')";
mysql_query($requete) or die(mysql_error()."<br>$requete");
$requete = "DELETE from prop_lien WHERE id='$chemin[4]'";
mysql_query($requete) or die(mysql_error()."<br>$requete");
}
}
}
else {
$query = "SELECT id,categorie,scategorie,url,description,pertinence FROM prop_lien ORDER BY id ASC";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo "<div class=\"element\">
<h3>".$row["categorie"]."->".$row["scategorie"]." :: <a href=\"".$row["url"]."\" title=\"Proposition de lien\">".$row["url"]."</a> :: ".$row["pertinence"]."</h3>
<div>
";
echo "<p>".$row["description"]."</p>";
echo "</div>
<p><a href=\"/site/proposition/lien/moderer/".$row["id"]."/accepter\">Accepter</a> ::
<a href=\"/site/proposition/lien/moderer/".$row["id"]."/editer\">Editer</a> ::
<a href=\"/site/proposition/lien/moderer/".$row["id"]."/supprimer\">Supprimer</a>
</p>
</div>";
}
}
}
elseif ($chemin[2] == "breves" or $chemin[2] == "article")
{
if (ereg("^[0-9]{1,5}$",$chemin[4]))
{
echo "<h2>Moderation de la proposition $chemin[4]</h2>";
if ($chemin[5] == "supprimer") {
$query = "DELETE FROM prop_$art WHERE id='$chemin[4]'";
mysql_query($query) or die(mysql_error());
}
elseif($chemin[5] == "accepter") {
$query = "SELECT datetime,posteur,arttyp,titre,article FROM prop_$art WHERE id='$chemin[4]'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
$row["titre"] = mysql_escape_string($row["titre"]);
$row["arttyp"] = mysql_escape_string($row["arttyp"]);
$row["article"] = mysql_escape_string($row["article"]);
$var = ip_read($chemin[2]);
$var["$ip"]["visites"]++;
$var["$ip"]["pseudo"] = $row["posteur"];
ip_write($chemin[2],$var);
$requete = "INSERT into $art (datetime,posteur,arttyp,titre,article) VALUES
('".$row["datetime"]."','".$row["posteur"]."','".$row["arttyp"]."','".$row["titre"]."','".$row["article"]."')";
mysql_query($requete) or die(mysql_error()."<br>$requete");
$requete = "DELETE from prop_$art WHERE id='$chemin[4]'";
mysql_query($requete) or die(mysql_error()."<br>$requete");
}
}
elseif($chemin[5] == "editer") {
$chemin[4] = preg_replace("[^0-9]","",$chemin[4]);
if ($_POST['titre'] and $_POST['type'] and $_POST['contenu'] and $_POST['posteur'])
{
echo " <div class=\"element\">";
$query = "UPDATE prop_$art SET posteur='".$_POST['posteur']."',arttyp='".$_POST['type']."',titre='".$_POST['titre']."',
article='".$_POST['contenu']."' WHERE id='".$chemin[4]."'";
mysql_query($query) or die(mysql_error());
echo "<p>Changement Effectué</p>
<p><a href=\"/site/proposition/$art/moderer\" title=\"Page proposition\">Retour sur la modification des $art</a></p>
<p><a href=\"/site/proposition/\" title=\"Page proposition\">Retour sur la page des propositions</a></p>";
echo "</div> ";
}
else {
$query = "SELECT id,datetime,posteur,arttyp,titre,article FROM prop_$art ORDER BY id ASC";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo "
<div class=\"element\">
<form action=\"/site/proposition/$art/moderer/".$row["id"]."/editer\" method=\"post\">
<dl>
<dt>Titre</dt><dd><input type=\"text\" name=\"titre\" value=\"".$row["titre"]."\" /></dd>
<dt>Type</dt><dd><input type=\"text\" name=\"type\" value=\"".$row["arttyp"]."\" /></dd>
<dt>Posteur</dt><dd><input type=\"text\" name=\"posteur\" value=\"".$row["posteur"]."\" /></dd>
<dt>Contenu</dt><dd><textarea cols=\"50\" rows=\"15\" name=\"contenu\">".$row["article"]."</textarea></dd>
<dd><input type=\"submit\" value=\"Editer\" /></dd>
</dl>
</form>
</div>";
}
}
}
if ($chemin[5] == "accepter" or $chemin[5] == "supprimer") {
echo "<p><h3>element: $chemin[4]</h3><div><p>$chemin[4] avec succes </p>"; }
}
else {
$query = "SELECT id,datetime,posteur,arttyp,titre,article FROM prop_$art ORDER BY id ASC";
$result = mysql_query($query) or die(mysql_error()."<br>$query");
if (mysql_num_rows($result) == 0) { echo "<p>Aucun element</p>"; }
while($row = mysql_fetch_assoc($result))
{
echo "
<div class=\"element\">
<h2>".$row["titre"]."</h2>
<h3>par ".$row["posteur"]." le ".$row["datetime"]."</h3>
<div>
";
affichage($row["article"]);
echo "</div>
<p><a href=\"/site/proposition/$art/moderer/".$row["id"]."/accepter\">Accepter</a> ::
<a href=\"/site/proposition/$art/moderer/".$row["id"]."/editer\">Editer</a> ::
<a href=\"/site/proposition/$art/moderer/".$row["id"]."/supprimer\">Supprimer</a>
</p>
</div>";
}
}
}
}
else {
echo "<h2>Menu</h2>
<h3>Niveau d'accès: $axx</h3>
<div>
<p>Vous pouvez proposer des brèves soumises a modération. Nous ne somme pas trop exigents qu'en à
la qualité de la plume, il s'agit plus d'une modération sur le contenu même, et la pertinence.</p>
<ul>
<li><a href=\"/site/proposition/breves/nouveau\">Proposer une brève</a></li>
<li><a href=\"/site/proposition/article/nouveau\">Proposer un article</a></li>
<li><a href=\"/site/proposition/lien/nouveau\">Proposer un Lien</a></li>
";
if ($axx>8) {
echo "</ul>
<p>Administration:</p>
<ul>";
$query = "SELECT COUNT(id) FROM prop_breves";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<li><a href=\"/site/proposition/breves/moderer\">Moderer les brèves</a> ($row[0] en attente)</li>";
$query = "SELECT COUNT(id) FROM prop_article";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<li><a href=\"/site/proposition/article/moderer\">Moderer les articles</a> ($row[0] en attente)</li>";
$query = "SELECT COUNT(id) FROM prop_lien";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<li><a href=\"/site/proposition/lien/moderer\">Moderer les Liens</a> ($row[0] en attente)</li>"; }
echo "
</ul>
</div>
"; }
?>
</div>
</div>