-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
42 lines (37 loc) · 1.39 KB
/
index.php
File metadata and controls
42 lines (37 loc) · 1.39 KB
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
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<title>复古资源网</title>
<meta charset="UTF-8"> <!-- 添加字符编码声明 -->
</head>
<body>
<a href="https://modarchive.org/">复古mod音乐下载站</a>
<ol>
<?php
$directory = 'mod音乐收集'; // 实际目录路径
if (is_dir($directory)) {
$files = scandir($directory);
if ($files !== false) {
foreach ($files as $file) {
if ($file === '.' || $file === '..') continue;
$filePath = $directory . '/' . $file;
if (is_file($filePath)) {
// 处理中文路径编码:对路径中的每个部分单独编码
$encodedDir = implode('/', array_map('rawurlencode', explode('/', $directory)));
$encodedFile = rawurlencode($file);
$encodedPath = $encodedDir . '/' . $encodedFile;
// 创建带有下载链接的列表项
echo '<li><a href="' . htmlspecialchars($encodedPath) . '" download>'
. htmlspecialchars($file) . '</a></li>';
}
}
} else {
echo "<li>错误:无法读取目录内容</li>";
}
} else {
echo "<li>错误:目录不存在或不可访问</li>";
}
?>
</ol>
</body>
</html>