// ==================== 配置区 ==================== $adminPwd = "newpass"; // 管理员登录密码 $groupList = [ '通用文件', '办公文档', '图片素材', '软件安装包' ]; $adminGroup = "其他资料"; // 仅管理员可见分组 // =============================================== session_start(); $isAdmin = !empty($_SESSION['is_admin']); // ========== PHP代理下载入口,解除下载限速 ========== if(isset($_GET['download']) && isset($_GET['group'])){ $downGroup = trim($_GET['group']); $downFile = basename($_GET['download']); // 安全过滤,防止目录穿越 if(!in_array($downGroup,$groupList) && !($isAdmin && $downGroup === $adminGroup)){ exit("无权下载"); } $realFile = "./uploads/{$downGroup}/{$downFile}"; if(!is_file($realFile)){ exit("文件不存在"); } $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $realFile); finfo_close($finfo); // 输出下载头,关闭PHP输出缓冲,全速输出 ob_end_clean(); header('Content‑Description: File Transfer'); header('Content‑Type: '.$mime); header('Content‑Disposition: attachment; filename="'.rawurlencode($downFile).'"'); header('Content‑Transfer‑Encoding: binary'); header('Content‑Length: '.filesize($realFile)); header('Cache‑Control: must‑revalidate, post‑check=0, pre‑check=0'); header('Pragma: no‑cache'); // 直接读取输出,无限速 readfile($realFile); exit; } // 管理员登录 if (isset($_POST['admin_login'])) { if (trim($_POST['admin_pwd']) === $adminPwd) { $_SESSION['is_admin'] = true; } header("Location: ?group=admin"); exit; } // 退出登录 if (isset($_GET['logout'])) { session_destroy(); header("Location: ./"); exit; } // 文件删除(仅管理员) if ($isAdmin && isset($_GET['del_file']) && isset($_GET['del_group'])) { $delGroup = trim($_GET['del_group']); $delFile = basename($_GET['del_file']); $filePath = "./uploads/" . $delGroup . "/" . $delFile; if (file_exists($filePath)) { unlink($filePath); } header("Location: ?group=" . urlencode($delGroup)); exit; } // 当前分组 $currentGroup = $_GET['group'] ?? $groupList[0]; $allGroups = $isAdmin ? array_merge($groupList, [$adminGroup]) : $groupList; if (!in_array($currentGroup, $allGroups)) { $currentGroup = $groupList[0]; } // 文件上传 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) { $uploadDir = './uploads/' . $currentGroup . '/'; if (!is_dir($uploadDir)) mkdir($uploadDir, 0777, true); $targetPath = $uploadDir . $_FILES['file']['name']; move_uploaded_file($_FILES['file']['tmp_name'], $targetPath); header("Location: ?group=" . urlencode($currentGroup)); exit; } ?> 文件下载系统
文件分组管理系统
返回网站
Warning: Undefined variable $groupList in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 155

Warning: foreach() argument must be of type array|object, null given in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 155

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 160

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 179

Warning: Undefined variable $currentGroup in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 184

Warning: Undefined variable $currentGroup in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 201

Warning: Undefined variable $currentGroup in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 201

Warning: Undefined variable $currentGroup in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 201

Warning: Undefined variable $currentGroup in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 201

Warning: Undefined variable $currentGroup in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 194

Warning: Undefined variable $isAdmin in /www/wwwroot/qhwcpx.com/xiazai/index.php on line 201
文件名称 上传时间 大小 下载
其他资料 2026-06-07 19:47 4.00 KB 下载
办公文档 2026-07-09 10:43 4.00 KB 下载
图片素材 2026-06-07 19:32 4.00 KB 下载
软件安装包 2026-08-12 10:26 4.00 KB 下载
通用文件 2026-06-07 18:43 4.00 KB 下载