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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
<?php error_reporting(0); $basedir = "/htdocs/File/download";/* 默认读取的根位置 */ if (!is_dir($basedir)) $basedir = dirname(__FILE__); $file_name = $_GET['downfile']; if (!empty($file_name)) { $file_dir = $basedir . "/" . $file_name; if (dirname(realpath($file_dir)) < $basedir) { echo "权限被拒绝!"; exit; } if (!file_exists($file_dir)) { echo "文件未找到!"; exit; } else { $file = fopen($file_dir, "r"); Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); Header("Accept-Length: " . filesize($file_dir)); Header("Content-Disposition: attachment; filename=" . $file_name); echo fread($file, filesize($file_dir)); fclose($file); exit; } } header("Content-type: text/html; charset=utf-8"); $requestDir = $_GET['dir']; if (empty($requestDir)) { $dir = $basedir; } else { $dir = $basedir . "/" . $requestDir; } $dir = realpath($dir); if ($dir < $basedir) $dir = $basedir; ?> <html> <head> <meta charset="utf-8"> <title>附件下载界面</title> <style type="text/css"> a:link {color: #FFF} /* 未访问时的状态 */ a:hover {color: #F00} /* 鼠标移动到链接上时的状态 */ a:active {color: #00F} /* 鼠标按下去时的状态 */ a:visited {color: #FFF} /* 已访问过的状态 */ body { font-family: "Courier New", "Verdana", "Tahoma"; font-size: 12px; } td { font-family: "Courier New", "Verdana", "Tahoma"; font-size: 16px; color: #FFF; /* 默认全网页文本颜色 */ } input { font-family: "Courier New", "Verdana", "Tahoma"; font-size: 12px; } .title { font-family: "Verdana", "Tahoma"; font-size: 32px; font-weight: bold; } </style> </head> <body style="background:#000 url(Picture.jpg); background-size:cover;"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td class="title"><a href="http://SNote.CN">山归山 - San Notes</a></td> <td align="right" valign="bottom"><font color="#F00"><?php echo "服务器系统: " . PHP_OS . "<br />";?>修 改: <b>ZhangZsky</b></font></td> </tr> </table> <hr style="border:1px dashed #888" width="100%" size="1" /> <table width="100%" border="0" cellpadding="3" cellspacing="1"> <tr> <td> <?php $predir = realpath($dir . "/../"); if ($predir > $basedir) $predir = str_replace($basedir . "/", "", $predir); if ($predir == $basedir) $predir = "."; if ($dir > $basedir) echo "<a href=\"?dir=" . $predir . "\">返回上级目录</a>"; if ($dir > $basedir) echo "<td>当前显示目录:<b>" . substr($dir, 45) . "</b></td>\n"; ?> </td> </tr> <?php $dirs = @opendir($dir); $count = 0; while ($file = @readdir($dirs)) { $b = "$dir/$file"; $a = @is_dir($b); if ($a == "1") { if ($file != ".." && $file != ".") { if ($count < 1) { $count++; echo "<tr>\n"; echo "<td><b>子目录</b></td>\n"; echo "</tr>\n"; } echo "<tr>\n"; echo "<td>◆ <a href=\"?dir=" . ($dir > $basedir ? str_replace($basedir . "/", '', $dir . "/") : '') . urlencode($file) . "\">$file</a></td>\n"; echo "</tr>\n"; } } } @closedir($dirs); ?> </table> <hr style="border:1px dashed #333" width="100%" size="1" /> <table width="100%" border="0" cellpadding="3" cellspacing="1"> <tr> <td><b>文件名称</b></td> <td><b>创建日期</b></td> <td><b>文件大小</b></td> <td><b>下载文件</b></td> </tr> <?php $dirs = @opendir($dir); while ($file = @readdir($dirs)) { $b = "$dir/$file"; $a = @is_dir($b); if ($a == "0") { $size = @filesize("$dir/$file"); $size = $size / 1048576; $size = @number_format($size, 3); $lastsave = @date("Y-n-d H:i", filectime("$dir/$file")); echo "<tr>\n<tr>\n<tr>\n"; echo "<td>◆ $file</td>\n"; echo "<td>$lastsave</td>\n"; echo "<td>$size MB</td>\n"; echo "<td><b><a href=\"?downfile=" . ($dir > $basedir ? str_replace($basedir . "/", '', $dir . "/") : '') . urlencode($file) . "\">$file</a></b></td>\n"; echo "</tr>\n</tr>\n"; } } @closedir($dirs); ?> </table> <hr style="border:1px dashed #888" width="100%" size="1" /> <center> <audio autoplay="autoplay" controls="controls" loop="loop" preload="auto" src="Music.mp3"></audio> <!-- <form action="SanGod.php" method="post" enctype="multipart/form-data"> <font color="#FFF"> <label for="file">文件名:</label> <input type="file" name="file" id="file"> <input type="submit" name="submit" value="上传"> </font> </form> --> </center> </body> </html> |
发表回复