- <?php
- //文件浏览程序
- error_reporting(0);
- $pwd = empty($_GET['dir']) ? './' : $_GET['dir'];
- $pwd = realpath($pwd);
- if(is_file($pwd)) {
- highlight_file ($pwd);
- exit;
- }else
- $it = new FilesystemIterator($pwd);
- ?>
- <html>
- <head>
- <title>pwd of <?php echo $pwd ?></title>
- </head>
- <body bgcolor="white">
- <h1>pwd of <?php echo $pwd ?></h1><hr>
- <pre><a href="?dir=<?php echo dirname($pwd)?>">../</a>
- <?php
- foreach ($it as $file){
- if($file->isDir()) {
- $fileSize = '_';
- $fileName = $file->getFilename() . '/';
- } elseif($file->isFile()) {
- $fileSize = $file->getSize();
- $fileName = $file->getFilename();
- }
- $date = date('Y-m-d H:i',$file->getCTime());
- ?><a href="?dir=<?php echo $file->getRealPath()?>"><?php echo $fileName ?></a><?php echo str_pad($date, 60-strlen($fileName),' ',STR_PAD_LEFT)?><?php echo str_pad($fileSize,30,' ',STR_PAD_LEFT)?>
- <?php }?></pre><hr>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/240720134795.html
来源: http://www.codesnippet.cn/detail/240720134795.html