small-package/luci-app-nekobox/htdocs/nekobox/download.php

50 lines
1.6 KiB
PHP

<?php
$proxyDir = '/www/nekobox/proxy/';
$uploadDir = '/etc/neko/proxy_provider/';
$configDir = '/etc/neko/config/';
if (isset($_GET['file'])) {
$file = basename($_GET['file']);
$filePath = $proxyDir . $file;
if (file_exists($filePath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
exit;
}
$filePath = $uploadDir . $file;
if (file_exists($filePath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
exit;
}
$configPath = $configDir . $file;
if (file_exists($configPath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($configPath));
readfile($configPath);
exit;
}
echo '文件不存在!';
}