initial
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
include 'config.php';
|
||||
|
||||
if (isset($_GET['file'])) {
|
||||
$file = $_GET['file'];
|
||||
|
||||
// Get file details from the database
|
||||
$stmt = $main_db->prepare("SELECT * FROM archive_logs WHERE archive = ?");
|
||||
$stmt->bind_param("s", $file);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$fileDetails = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
|
||||
if ($fileDetails) {
|
||||
$filePath = 'uploads/' . $file;
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
// Increment download count
|
||||
$stmt = $main_db->prepare("UPDATE archive_logs SET downloads = downloads + 1 WHERE archive = ?");
|
||||
$stmt->bind_param("s", $file);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
// Serve the file for download
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.basename($filePath).'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($filePath));
|
||||
readfile($filePath);
|
||||
exit;
|
||||
} else {
|
||||
echo "File not found.";
|
||||
}
|
||||
} else {
|
||||
echo "Invalid file.";
|
||||
}
|
||||
} else {
|
||||
echo "No file specified.";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user