1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <?php session_start();
require_once("config/main.inc.php"); //Parametre generale du site.
require_once("config/db.inc.php"); // Parametre de connexion Base de donnée.
if(empty($_GET["action"])){header("Location:index.php");}
elseif(empty($_GET["requete_file"])){header("Location:index.php");}
if($_GET["action"] == "dl"){
$fichier = $_GET["requete_file"];
$chemin = PATH_PARTICULIER.'/'.$fichier;
if (file_exists($chemin))
{
header('Content-disposition: attachment; filename="' . $fichier . '"');
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. filesize($chemin));
header('Pragma: no-cache');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
readfile($chemin);
mysql_query('UPDATE `stats_users` SET `STATUT` = "DOWNLOAD" WHERE `stats_users`.`ID_USER` ="'.$_SESSION["ID"].'" AND FICHIER = "'.$fichier.'" LIMIT 1 ;')or die(mysql_error());
}
}
if($_GET["action"] == "del"){
$fichier = $_GET["requete_file"];
$chemin = PATH_PARTICULIER.'/'.$fichier;
mysql_query("UPDATE `BDD`.`stats_users` SET `SUPPRIMER` = 'oui' WHERE `stats_users`.`ID_USER` ='".$_SESSION["ID"]."' AND `FICHIER`='".$fichier."'")or die(mysql_error());
unlink($chemin);
header("Location:index.php");
}
?> |
Partager