欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php模擬服務(wù)器實現(xiàn)autoindex效果的方法

 更新時間:2015年03月10日 12:31:06   作者:小囧  
這篇文章主要介紹了php模擬服務(wù)器實現(xiàn)autoindex效果的方法,實例分析了php操作URL及傳遞參數(shù)的技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了php模擬服務(wù)器實現(xiàn)autoindex效果的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

1.PHP代碼如下:

復(fù)制代碼 代碼如下:
<?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>

2. 運行效果如下圖所示:

希望本文所述對大家的php程序設(shè)計有所幫助。

相關(guān)文章

最新評論