Файл: download.php
Строк: 15
<?php
require '__core/inc.php';
$p_id = $_GET['id'];
$result = $dbh->prepare("SELECT * FROM `projects` WHERE `p_id` = :p_id");
$result->bindValue(":p_id", $p_id, PDO::PARAM_INT);
$result->execute();
$project = $result->fetch(PDO::FETCH_ASSOC);
if (empty($project)) {
header("Location: /index.php");
exit;
}
$f_id = $_GET['file'];
$result = $dbh->prepare("SELECT * FROM `files` WHERE `f_id` = :f_id");
$result->bindValue(":f_id", $f_id, PDO::PARAM_INT);
$result->execute();
$file = $result->fetch(PDO::FETCH_ASSOC);
if (empty($file)) {
header("Location: /index.php");
exit;
}
$result = $dbh->prepare("UPDATE `files` SET `f_loads_count` = :count WHERE `f_id` = :f_id");
$result->bindValue(":count", ($file['f_loads_count'] + 1), PDO::PARAM_INT);
$result->bindValue(":f_id", $f_id, PDO::PARAM_INT);
$result->execute();
header ('Location: /files/' . $p_id . '/' . $file['f_path']);
exit;