PHP simulates server autoindex effect.

WBOY
Release: 2016-07-25 09:02:00
Original
769 people have browsed it
可以丢到后台 方便代码阅读什么的
  1. //文件浏览程序
  2. error_reporting(0);
  3. $pwd = empty($_GET['dir']) ? './' : $_GET['dir'];
  4. $pwd = realpath($pwd);
  5. if(is_file($pwd)) {
  6. highlight_file ($pwd);
  7. exit;
  8. }else
  9. $it = new FilesystemIterator($pwd);
  10. ?>
  11. pwd of <?php echo $pwd ?>
  12. pwd of


  13. <a href="?dir=<?php echo dirname($pwd)?>">../</a></li>
    <li><?php <li>foreach ($it as $file){ <li>	if($file->isDir()) {</li>
    <li>		$fileSize = '_';</li>
    <li>		$fileName = $file->getFilename() . '/';</li>
    <li>	} elseif($file->isFile()) {</li>
    <li>		$fileSize =  $file->getSize();</li>
    <li>		$fileName = $file->getFilename();</li>
    <li>	}</li>
    <li>	$date       = date('Y-m-d H:i',$file->getCTime());</li>
    <li>?><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)?></li>
    <li>
    <li><?php }?>

复制代码
PHP simulates server autoindex effect. PHP simulates server autoindex effect.


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!