PHP檔案瀏覽功能

來源:互聯網
上載者:User

PHP檔案瀏覽功能,如下代碼:

 
  1. <html> 
  2. <head> 
  3. <title>檔案瀏覽</title> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
  5. <style type="text/css"> 
  6. <!-- 
  7. a:link {text-decoration: none;} 
  8. a:visited {text-decoration: none;} 
  9. a:hover {text-decoration: none;} 
  10. a:active {text-decoration: none;} 
  11. .style1 {font-size: 12px} 
  12. --> 
  13. </style></head> 
  14. <body><h3 align="center">檔案瀏覽 - www.cxybl.com</h3> 
  15.   <div align="center"> 
  16.     <table width="500" height="30" border="1" align="center"> 
  17.       <tr align="center" valign="middle" bgcolor="#A5F5BF" > 
  18.         <th width="100" height="25" align="center" valign="middle"><span class="style1">項目名</span></th> 
  19.         <th width="60" align="center" valign="middle"><span class="style1">大小</span></th> 
  20.         <th width="150" align="center" valign="middle"><span class="style1">建立日期</span></th> 
  21.         <th width="180" align="center" valign="middle"><span class="style1">最後修改時間</span></th> 
  22.       </tr> 
  23. <?php  
  24.     if(!isset($_GET[mulu])empty($_GET[mulu]))$dqml=getcwd();//獲得指令碼目錄 
  25.         else $dqml=$_GET[mulu]; 
  26.     chdir($dqml);//改變目前的目錄 
  27.         echo "目前的目錄:".getcwd()."<br>"; 
  28.     $ml = opendir($dqml);  //開啟目錄 
  29.     while ($hqml = readdir($ml)){ //迴圈讀取目錄中的目錄及檔案 
  30.     echo "<tr><td align='center' valign='middle'bgcolor='#A5F5BF'>"; 
  31.         if(is_dir($hqml)){  //判斷是目錄 
  32.            if($hqml=="."){ 
  33.               $mulu=getcwd();//顯示目前的目錄 
  34.        echo "<a href=$php_self?mulu=$mulu><span class='style1'>鎖定</span></a>"; } 
  35.            elseif($hqml==".."){ 
  36.               $mulu=getcwd()."\\.."; //上級目錄 
  37.               echo "<a href=$php_self?mulu=$mulu><span class='style1'>上級目錄</span></a>"; 
  38.            }else{ 
  39.               $mulu=getcwd()."\\$hqml";  //子目錄 
  40.               echo "<a href=$php_self?mulu=$mulu>$hqml</a>"; }  
  41.            }else{  
  42.            $ext=substr($hqml,strrpos($hqml,".")); 
  43.     if(strtoupper($ext)==".PHP"strtoupper($ext)==".TXT"){ 
  44.         $mulu=getcwd(); 
  45.         echo "<a href=./example25.php?mulu=$mulu&filename=$hqml&type=$ext>$hqml</a>";  
  46.         }else{ 
  47.         echo "$hqml"; }  } 
  48.     if(is_dir($hqml)) $file_size="目錄"; 
  49.         else $file_size=round(filesize($hqml)/1024)."k"; 
  50.            echo "<td align='center' valign='middle' bgcolor='#A5F5BF'>$file_size</td>"; 
  51.         $create_time=date("y-m-d h:i:sA",filectime($hqml)); 
  52.            echo "<td align='center' valign='middle' bgcolor='#A5F5BF'>$create_time</td>"; 
  53.         $update_time=date("y-m-d h:i:sA",filemtime($hqml)); 
  54.            echo "<td align='center' valign='middle' bgcolor='#A5F5BF'>$update_time</td>"; }   
  55.     closedir($ml); ?> 
  56.     </table> 
  57.   </div> 
  58. </body> 
  59. </html> 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.