Method for php simulation server to achieve autoindex effect, phpautoindex_PHP tutorial

WBOY
Release: 2016-07-13 10:04:20
Original
1513 people have browsed it

How to achieve autoindex effect by php simulation server, phpautoindex

This article describes the method of php simulation server to achieve autoindex effect. Share it with everyone for your reference. The specific implementation method is as follows:

1.PHP code is as follows:
Copy code The code is as follows: //File browsing program
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);
?>


pwd of <?php echo $pwd ?>



pwd of



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



2. The operation effect is shown in the figure below:

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/965562.htmlTechArticleHow to achieve the autoindex effect on the php simulation server, phpautoindex This article describes how to achieve the autoindex effect on the php simulation server. Share it with everyone for your reference. Specific implementation method...
Related labels:
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
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!