Tfe

Ongi etorri tfe-ren webgunera...

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

(Deskargatu)
<?
if ($axx)
{
    $query = "SELECT MAX(id) FROM download";
    $result= mysql_query($query);
    while($row = mysql_fetch_array($result))
    {
	$article_id = $row[0];
    }
    $query = "UPDATE membres SET download_id = '$article_id' WHERE pseudo='$nick'";
    mysql_query($query) or die(mysql_error());
}





     $chemin[3] = preg_replace("/[^\w\-]/","",$chemin[3]); ?>
<div class="article">
<h2>Section t&eacute;l&eacute;chargement <? if ($chemin[3]) { echo "($chemin[3]"; if($chemin[4]) { echo "- $chemin[4]"; } echo ")"; } ?></h2>

<?


if (empty($chemin[2]))
{
    echo "    
    <div class=\"element\">
    <h2>Liste des Cat&eacute;gories disponibles</h2>
    <div>
    <p>Vous trouverez dans cette rubrique differents programmes disponibles que nous vous proposons de telecharger 
    via les site officiel.</p>
    ";
    if ($axx > 4) { echo "<p><span class=\"underline\">ADMIN:</span> <a href=\"/site/telechargement/new\">Ajouter un programme</a></p>"; }
    
    $ancien = "";
    $compteur = 0;
    
    $query = "SELECT categorie FROM download ORDER BY categorie ASC";
    $result = mysql_query($query) or die(mysql_error());
    $valeurs = array();
    echo "<ul>";
    while ($row = mysql_fetch_array($result))
    {
	if ($compteur != 0 && $ancien != $row[0]) 
	    { echo " ($compteur) </li>\n"; }
	if ($ancien != $row[0]) { $ancien = $row[0]; 
		$compteur=1;
	    	$nom = preg_replace("/-/"," ",$row[0]);	
		echo "<li><a href=\"/site/telechargement/view/$row[0]\" title=\"$row[0]\">$nom</a>";
	}	
	else { $compteur++; }



    }
    if ($compteur != 0 ) { echo " ($compteur)</li>\n"; }
    echo "
    
    </ul>
    </div>
    </div>
    ";

    echo "
    <div class=\"element\">
    <h2>Les 5 Derniers &eacute;l&eacute;ments</h2>
    ";
    $query = "SELECT * FROM download ORDER BY id DESC limit 5";
    $result = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($result) ==0)
    {
	echo "
	<h3>Erreur</h3>
	<div><p>Aucun element contenu dans cette categorie ($chemin[3])</p></div>
	<div>
	";
    }
    while ($row = mysql_fetch_array($result))
    {
    echo "
	  
	  <h3>$row[1] ($row[7]) <a href=\"$row[9]\" title=\"$row[1]\">Telecharger</a> ($row[6]) sur $row[8]</h3>
	  <div>
    ";
    $lignes = explode("\n",$row[5]);
    foreach($lignes as $key) { echo "<p>$key</p>\n"; }
    if ($axx > 8) { echo "<p><a href=\"/site/telechargement/edit/$row[0]\" title=\"Editer\">Editer cet &eacute;l&eacute;ment</a> / <a href=\"/test-new/site/telechargement/edit/$row[0]/suppr\" title=\"SUPPRIMER\">Supprimer</a></p>  "; }
    echo "  </div>\n";
    }
    echo "
    </div>
    ";

}
elseif($chemin[2] == "view" and !empty($chemin[3]))
{
    $chemin[3] = preg_replace("/[^\w\-\_\.\!]/","",$chemin[3]);
    if(empty($chemin[4]))
    {
    echo "
    <div class=\"element\">
    <h2>Liste des Sous Categories disponibles</h2>
    <div>
    <p>Vous trouverez dans cette rubrique differents programmes disponibles que nous vous proposons de telecharger 
    via les site officiel.</p>
    ";
    $compteur=0;
    $ancien="";
    $query = "SELECT scategorie FROM download WHERE categorie='$chemin[3]' ORDER BY scategorie ASC";
    $result = mysql_query($query) or die(mysql_error());
    $valeurs = array();
    echo "<ul>";
    while ($row = mysql_fetch_array($result))
    {
    	$nom = preg_replace("/-/"," ",$row[0]);
	if ($compteur != 0 && $ancien != $row[0]) 
	    { echo " ($compteur) </li>\n"; }
	if ($ancien != $row[0]) { $ancien = $row[0]; 
		$compteur=1;
	    	$nom = preg_replace("/-/"," ",$row[0]);	
	echo "<li><a href=\"/site/telechargement/view/$chemin[3]/$row[0]\" title=\"$row[0]\">$nom</a>\n";		
	}	
	else { $compteur++; }



    }
    if ($compteur != 0 ) { echo " ($compteur)</li>\n"; }    
    echo "</ul>
    </div>
    </div>
    ";
    }
    else {
    $chemin[4] = preg_replace("/[^\w\-\_\.\!]/","",$chemin[4]);    
    $query = "SELECT * FROM download WHERE categorie='$chemin[3]' and scategorie='$chemin[4]' ORDER BY nom ASC";
    $result = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($result) ==0)
    {
	echo "<div class=\"element\">
	<h2>Erreur</h2>
	<div><p>Aucun element contenu dans cette categorie ($chemin[3])</p></div>
	<div>
	";
    }
    while ($row = mysql_fetch_array($result))
    {
    echo "
	  <div class=\"element\">
	  <h2>$row[1] ($row[7])</h2>
	  <h3><a href=\"$row[9]\" title=\"$row[1]\">Telecharger</a> ($row[6]) sur $row[8]</h3>
	  <div>
    ";
    $lignes = explode("\n",$row[5]);
    foreach($lignes as $key) { echo "<p>$key</p>\n"; }
    if ($axx > 8) { echo "<p><a href=\"/site/telechargement/edit/$row[0]\" title=\"Editer\">Editer cet element</a> / <a href=\"/test-new/site/telechargement/edit/$row[0]/suppr\" title=\"SUPPRIMER\">Supprimer</a></p>  "; }
    echo "     </div></div>\n";
    }
    }
}
elseif($chemin[2] == "new" and $axx > 4)
{
$nom = $_POST['nom'];
$categorie = $_POST['categorie'];
$scategorie = $_POST['scategorie'];
if ($categorie == "autres") { $categorie = $_POST['categorie2']; }
if ($scategorie == "autres") { $scategorie = $_POST['scategorie2']; }
$description = $_POST['description'];
$taille = $_POST['taille'];
$softype = $_POST['softype'];
$site = $_POST['site'];
$download = $_POST['download'];

    if (!empty($nom) && !empty($categorie) && !empty($description) && !empty($taille) 
	&& !empty($softype) &&	!empty($site) && !empty($download))    

	{ 
	    $query ="INSERT INTO download (nom,categorie,scategorie,description,taille,softype,site,download)
		    VALUES ('".text2html($nom)."',
			    '".text2html($categorie)."',
			    '".text2html($scategorie)."',			    
			    '".text2html($description)."',			    
			    '".text2html($taille)."',
			    '".text2html($softype)."',	
			    '".$site."',
			    '".$download."')";
		mysql_query($query) or die(mysql_error()."<br>$query");	    
		echo "<p>AJOUTE AVEC SUCCES: categorie ".text2html($categorie)."</p>";
	}
	
    else {
	echo "
	<div class=\"element\">
	<h2>Nouveau programme</h2>
	<div>
	<form action=\"/site/telechargement/new\" method=\"post\">
	<dl>
	<dt>Nom: </dt> <dd><input type=\"text\" name=\"nom\" value=\"$nom\" /></dd>
	<dt>Categorie: </dt> 
	    	<dd>
		<select name=\"categorie\">
";
		
    $query = "SELECT DISTINCT categorie FROM download ORDER BY categorie ASC";
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result))
    {
	$row[0] = preg_replace("/-/"," ",$row[0]);
	echo "\t\t<option value=\"$row[0]\">$row[0]</option>\n";
    }
    echo "\t\t<option value=\"autres\">Autres, precisez ...</option></select>
		Si autre (sans accents): <input   type=\"text\" name=\"categorie2\" value=\"$categorie\" />
		
		</dd>	
	<dt>Sous Categorie: </dt> 
	    	<dd>
		<select name=\"scategorie\">
";
		
    $query = "SELECT DISTINCT scategorie FROM download ORDER BY categorie ASC";
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result))
    {
	$row[0] = preg_replace("/-/"," ",$row[0]);
	echo "\t\t<option value=\"$row[0]\">$row[0]</option>\n";
    }
    echo "\t\t<option value=\"autres\">Autres, precisez ...</option></select>
		Si autre (sans accents): <input   type=\"text\" name=\"scategorie2\" value=\"$categorie\" />
		</dd>	
	<dt>Description: </dt> <dd><textarea  rows=\"5\" cols=\"30\" name=\"description\">$description</textarea></dd>	
	<dt>Taille: </dt> <dd><input   type=\"text\" name=\"taille\" value=\"$taille\" /></dd>		
	<dt>License: </dt> <dd><input   type=\"text\" name=\"softype\" value=\"$softype\" /></dd>			
	<dt>Site: </dt> <dd><input   type=\"text\" name=\"site\" value=\"$site\" /></dd>			
	<dt>Download: </dt> <dd><input   type=\"text\" name=\"download\" value=\"$download\" /></dd>			
	<dt><input type=\"submit\" class=\"button\" value=\"OK\" /></dd>
	</dl>
        </form>
	</div>
	</div>
	";
    }
}



elseif($chemin[2] == "edit" and $axx > 8)
{
if ($chemin[4] == "suppr") { $action = "Supprimer"; } else {  $action = $_POST['action']; }
$chemin[3] = preg_replace("[^0-9]","",$chemin[3]);
$nom = $_POST['nom'];
$categorie = $_POST['categorie'];
if ($categorie == "autres") { $categorie = $_POST['categorie2']; }
$description = $_POST['description'];
$taille = $_POST['taille'];
$softype = $_POST['softype'];
$site = $_POST['site'];
$download = $_POST['download'];

    if ($action == "Supprimer")
    {
	$query = "DELETE FROM download WHERE id='$chemin[3]'";
	mysql_query($query) or die(mysql_error()."<br>$query");
	echo "<div class=\"element\"><h2>Suppression</h2><div><p>Suppression AVEC SUCCES</p></div></div>";	
    }
    
    
    else if (!empty($nom) && !empty($categorie) && !empty($description) && !empty($taille) 
	&& !empty($softype) &&	!empty($site) && !empty($download))    

	{ 
	    $query ="UPDATE download SET 
		    nom='".text2html($nom)."',
		    categorie='".text2html($categorie)."',
	            description='".text2html($description)."',			    
		    taille='".text2html($taille)."',
		    softype='".text2html($softype)."',	
		    site='".$site."',
		    download='".$download."'   WHERE id ='$chemin[3]'";
		mysql_query($query) or die(mysql_error()."<br>$query");	     
		echo "		<div class=\"element\"><h2>Modification</h2><div><p>Modifie AVEC SUCCES de ".$categorie."</p></div></div>";
	}
	
    else {

	echo "
	<div class=\"element\">
	<h2>Edition d'un programme (id $chemin[3])</h2>
	<div>
	<form action=\"/site/telechargement/edit/$chemin[3]\" method=\"post\">
	<dl>
	";
	$query = "SELECT * FROM download WHERE id='$chemin[3]'";
	$result = mysql_query($query) or die(mysql_error()."<br>$query");	
	$row = mysql_fetch_array($result);
	if (!isset($row[0])) { die; }
	
	echo "
	<dt>Nom: </dt> <dd><input type=\"text\" name=\"nom\" value=\"$row[1]\" /></dd>
	<dt>Categorie: </dt> 
	    	<dd>
		<select name=\"categorie\">
";
		
    $query = "SELECT DISTINCT categorie FROM download ORDER BY categorie ASC";
    $result2 = mysql_query($query) or die(mysql_error());
    while($val = mysql_fetch_array($result2))
    {
	$nom = preg_replace("/-/"," ",$val[0]);
	if ($row[2] ==  $val[0]) { echo "\t\t<option selected=\"selected\" value=\"$nom\">$nom</option>\n";
	}
	else {	echo "\t\t<option value=\"$nom\">$nom</option>\n"; }
    }
    echo "\t\t<option value=\"autres\">Autres, precisez ...</option>
    
    </select>
		Si autre: <input   type=\"text\" name=\"categorie2\" value=\"$categorie\" />
		
		</dd>	
	<dt>Description: </dt> <dd><textarea  rows=\"5\" cols=\"30\" name=\"description\">$row[5]</textarea></dd>	
	<dt>Taille: </dt> <dd><input   type=\"text\" name=\"taille\" value=\"$row[6]\" /></dd>		
	<dt>License: </dt> <dd><input   type=\"text\" name=\"softype\" value=\"$row[7]\" /></dd>			
	<dt>Site: </dt> <dd><input   type=\"text\" name=\"site\" value=\"$row[8]\" /></dd>			
	<dt>Download: </dt> <dd><input   type=\"text\" name=\"download\" value=\"$row[9]\" /></dd>			
	<dt><input type=\"submit\" class=\"button\" name=\"action\" value=\"Valider\" /></dd>
	<dt><input type=\"submit\" class=\"button\" name=\"action\" value=\"Supprimer\" /></dd>	
	</dl>
        </form>
	</div></div>
	";
    }
}





?>


</div>