php 目录浏览

Posted 钢锅

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 目录浏览相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<title>我们的服务-软件下载</title>
<meta name="keywords" content="销售电脑,电脑维修服务,智能家居,物联网方案,智能无线,弱点施工">
<meta name="description" content="我们的服提供临江花园-碧水豪园-西环路-联庄一区电脑维修,弱点工程施工,智能家居-物联网方案,">
<meta name="author" content="杭州钢锅">
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />
<meta property="qc:admins" content="22007606776754676375" />
<style>
table{
    border-collapse:collapse;
  }
table,td{
border:2px solid #a8a8de;
  padding:5px 20px;
  }
img{
    width: 20px;
    height: 20px;
}
th{
  border:2px solid #8282db;
  font-size:1.1em;
  text-align:center;
  padding:5px 20px;

  background-color:#4C9ED9;
  color:#ffffff;
  }
a{
  text-transform:none;
  text-decoration:none;
  margin: 5px;
 }
h2,h5{
    display : inline
}
</style>
</head>
<?php
switch ($_SERVER["HTTP_HOST"]){ 
case "115.236.183.115:81": 
header("location:http://down.zhouein.com:81");
break; 
case "218.108.32.234": 
header("location:http://down2.zhouein.com/");
break;
case "218.108.32.234:81": 
header("location:http://down2.zhouein.com:81");
break;
}
  $dir = dirname(__FILE__);
  $open_dir = opendir($dir);

  echo "<center>";
  /* echo basename(dirname(__FILE__)); */
  echo "<h2>常用软件下载</h2><h5>for Windows</h5>\n\r";
  echo "<table>\n";
  echo "<tr><th>文件名</th><th>大小</th><th>添加日期</th></tr>\n\r";
    while ($file = readdir($open_dir)){
        if ($file!= "." && $file != ".."){
           if (pathinfo($file,PATHINFO_EXTENSION)=="zip"){
             echo "<tr>\n    <td align=‘left‘>\n        <img src=‘/image/winrar.png‘ title=‘WindownsZip压缩包‘>\n        <a href=‘down.php?down_id=" . $file . "‘ target=‘_blank‘ title=‘点击下载‘>" . $file . "</a>\n        </td>\n";
             if (filesize($file) < 1024){
                echo "    <td align=‘right‘>" .  round(filesize($file),2) . " Byte</td>\n";
                }
             elseif (filesize($file) < 1024*1024){
                echo "    <td align=‘right‘>" .  round(filesize($file)/1024,2) . " KB</td>\n";
                }
             elseif (filesize($file) < 1024*1024*1024){
                echo "    <td align=‘right‘>" .  round(filesize($file)/(1024*1024),2) . " MB</td>\n";
                }
                echo "    <td>" . date(‘Y-m-d H:i:s‘, filemtime($file)) . "</td>\n    </tr>\n";
                /* echo "<td>" . pathinfo($file,PATHINFO_EXTENSION) . "</td></tr>"; */
            }
           if (pathinfo($file,PATHINFO_EXTENSION)=="iso"){
             echo "<tr>\n    <td align=‘left‘>\n        <img src=‘/image/winrar.png‘ title=‘WindownsZip压缩包‘>\n        <a href=‘down.php?down_id=" . $file . "‘ target=‘_blank‘ title=‘点击下载‘>" . $file . "</a>\n        </td>\n";
             if (filesize($file) < 1024){
                echo "    <td align=‘right‘>" .  round(filesize($file),2) . " Byte</td>\n";
                }
             elseif (filesize($file) < 1024*1024){
                echo "    <td align=‘right‘>" .  round(filesize($file)/1024,2) . " KB</td>\n";
                }
             elseif (filesize($file) < 1024*1024*1024){
                echo "    <td align=‘right‘>" .  round(filesize($file)/(1024*1024),2) . " MB</td>\n";
                }
                echo "    <td>" . date(‘Y-m-d H:i:s‘, filemtime($file)) . "</td>\n    </tr>\n";
                /* echo "<td>" . pathinfo($file,PATHINFO_EXTENSION) . "</td></tr>"; */
            }
           if (pathinfo($file,PATHINFO_EXTENSION)=="exe"){
             echo "<tr>\n    <td align=‘left‘>\n        <img src=‘/image/winexe.png‘ title=‘Windows可执行程序‘>\n        <a href=‘down.php?down_id=" . $file . "‘ target=‘_blank‘ title=‘点击下载‘>" . $file . "</a>\n        </td>\n";
             if (filesize($file) < 1024){
                echo "    <td align=‘right‘>" .  round(filesize($file),2) . " Byte</td>\n";
                }
             elseif (filesize($file) < 1024*1024){
                echo "    <td align=‘right‘>" .  round(filesize($file)/1024,2) . " KB</td>\n";
                }
             elseif (filesize($file) < 1024*1024*1024){
                echo "    <td align=‘right‘>" .  round(filesize($file)/(1024*1024),2) . " MB</td>\n";
                }
                echo "    <td>" . date(‘Y-m-d H:i:s‘, filemtime($file)) . "</td>\n    </tr>\n";
                /* echo "<td>" . pathinfo($file,PATHINFO_EXTENSION) . "</td></tr>"; */
            } 
        }
    }
  echo "</table>\n";
$countfile = "tongji.txt";  
if(($fp=fopen("tongji.txt","r+"))==false)  
{  
    echo "打开文件失败!";  
}  
else  
{  
    $counter = fgets($fp,1024);  
    if(empty($_SESSION[‘temp‘]))  
    {  
        $counter++;  
        if(($fp=fopen("tongji.txt","w"))==false)  
            echo "打开文件失败!";  
        else  
            fputs($fp,$counter);  
        $_SESSION[‘temp‘]=1;   
    }  
    fclose($fp);  
} 
?>
<p><a href="">友情链接:</a><a href="http://www.wmdfw.com/">钢锅</a><a href="http://www.wmdfw.com/baidu.php">BaiDu.Com</a><a href="http://down.zhouein.com:81">电信线路</a> <a href="http://down2.zhouein.com/">华数线路</a></p>
<p>Copyright ?2001-<?php echo date("Y") ?> 钢锅 All Rights Reserved.访问量:<b style = ‘color:green;‘><?php echo $counter?></b>次</p>
</html>

 

以上是关于php 目录浏览的主要内容,如果未能解决你的问题,请参考以下文章

无法使用 ArrayObjectAdaptor 的 clear() 和 addAll() 刷新/更新浏览片段

php header在浏览器上打印完整的html代码

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

超级有用的9个PHP代码片段

PHP必用代码片段

PHP代码-psysh调试代码片段工具