Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/old_sites/epik/include/liens.php

(Deskargatu)
<?
if ($axx and $liens_id)
{
    $query = "UPDATE membres SET liens_id='$liens_id' WHERE pseudo='$nick'";
    mysql_query($query) or die(mysql_error());
}

?>

<div class="article">
<?

if ($chemin[2] !== "ajout") { $cat = $chemin[2]; }
else { $action  = $_POST['action'] or  $action = $chemin[2]; }
$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 ($action)
    { 
    if ($url and $description) 
    { echo "
    <h2>Merci de votre participation !</h2>
    <div class=\"element\">
    <h2>Nouvel element insere dans la cat&eacute;gorie: $categorie</h2>
    <div>    ";
    $query = "INSERT INTO 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>
    
    ";
    
    }
    elseif ($axx>=2) {
    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&eacute;e. La descriptions se doit d'etre br&egrave;ve, courte et pr&eacute;cise.
    La &quot;sous-categorie&quot; n'est qu'optionnelle.    </p>
    <form action=\"/site/liens/ajout\" method=\"post\">
    <dl>
    <dt>URL:</dt> <dd><input size=\"50\" type=\"text\" name=\"url\" value=\"http://\" /> </dd>
    <dt>Cat&eacute;gorie:</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 cat&eacute;gorie:</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>"; }
    else { echo "<h2>Ajout de liens</h2>
    <div class=\"element\">
    <h2>Veuillez vous identifier</h2>
    <div><p>Seuls les utilsateurs enregistres peuvent proposer de nouveaux liens</p></div>
    </div>";
    }
}
elseif ($cat)
{
echo "<h2>Liens $cat</h2>";
$ancienne_cat="";
$catnum=1;
$result = mysql_query("SELECT scategorie FROM lien WHERE categorie='$cat' ORDER BY scategorie ASC") or die("ERROR".mysql_error());
echo "<div>Categories: <ul>\n";
while($row = mysql_fetch_array($result))
{
    if ($ancienne_cat != $row[0]) { $ancienne_cat = $row[0];    echo "<li><a href=\"/site/liens/$cat/#a$catnum\" title=\"$row[0]\">$row[0]</a></li>\n"; $catnum++; }
}
echo "</ul></div>\n";

    

$ancienne_cat="";
$catnum=1;
$result = mysql_query("SELECT * FROM lien WHERE categorie='$cat' ORDER BY scategorie,id DESC ") or die("ERROR".mysql_error());
while($row = mysql_fetch_array($result))
{
    $row[1] = htmlentities($row[1]);
    $row[2] = htmlentities($row[2]);
    $row[3] = htmlentities($row[3]);
    $row[4] = htmlentities($row[4]);
    $row[5] = htmlentities($row[5]);    


    echo "    <div class=\"element\"> ";
    if ($ancienne_cat != "$row[2]") { $ancienne_cat = $row[2]; echo "<h2 id=\"a$catnum\">$row[2]</h2>\n"; $catnum++; }
    echo "
	<h3><a href=\"$row[3]\">$row[3]</a>
	";
	if ($row[5] == "Tres bon") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }
	elseif ($row[5] == "Bon") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }
	elseif ($row[5] == "Acceptable") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }	
	elseif ($row[5] == "Mauvais") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }		
	elseif ($row[5] == "Tres mauvais") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }			

	
	echo "</h3>
	<div>
	";
	$lignes = explode("\n",$row[4]);
	foreach($lignes  as  $key) { echo "<p>$key</p>\n"; }
	echo "</div>
	</div>
	";
}
}

else{
echo "<h2>Liens:</h2>";
echo "<div class=\"element\">
<h2>Veuillez choisir une cat&eacute;gorie</h2>
<div>
<p class=\"part\">Vous trouverez ici de nombreux liens class&eacute;s en cat&eacute;gories. Si un lien manque, n'h&eacute;sitez pas &agrave; nous <a href=\"/site/liens/ajout\">en faire part</a> 
pour enrichir ainsi notre base de don&eacute;es.</p>\n";
echo "<ul>\n";
$ancien = "";
$compteur=0;
$result = mysql_query("SELECT categorie FROM lien ORDER BY categorie ASC") or die("ERROR".mysql_error());
while($row = mysql_fetch_array($result))
{
    if ($compteur!=0 && $ancien != $row[0]) { echo " ($compteur)</li>\n"; }
    if ($ancien != $row[0]) {
	$compteur=1;
	$ancien = $row[0];
        echo "<li><a href=\"/site/liens/$row[0]\" title=\"$row[0]\">$row[0]</a>";
    }
    else { $compteur++; }
	
}
if ($compteur != 0) { echo " ($compteur)</li>\n"; }
echo "</ul>
</div>
</div>
";
$result = mysql_query("SELECT * FROM lien ORDER BY id DESC LIMIT 5") or die("ERROR".mysql_error());
    echo "    <div class=\"element\"><h2>5 derniers  liens</h2>";
while($row = mysql_fetch_array($result))
{
    $row[1] = htmlentities($row[1]);
    $row[2] = htmlentities($row[2]);
    $row[3] = htmlentities($row[3]);
    $row[4] = htmlentities($row[4]);
    $row[5] = htmlentities($row[5]);    



    
    echo "
	<h3>$row[2] <a href=\"$row[3]\">$row[3]</a>
	";
	if ($row[5] == "Tres bon") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }
	elseif ($row[5] == "Bon") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }
	elseif ($row[5] == "Acceptable") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }	
	elseif ($row[5] == "Mauvais") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" /><img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }		
	elseif ($row[5] == "Tres mauvais") { print "<img src=\"/images/etoile.png\" alt=\"Tres bon\" />\n"; }			

	
	echo "</h3>
	<div>
	";
	$lignes = explode("\n",$row[4]);
	foreach($lignes  as  $key) { echo "<p>$key</p>\n"; }
	echo "</div>
	";
}



}

?>
</div>