搜尋
首頁php教程PHP源码php 显示WEB目录下的所有目录及后缀为php,php3,htm,html的文件名

本程序可以显示WEB目录下的所有目录及后缀为php,php3,htm,html的文件名,并可以查看源文件,很适合作为编写php程序的工具。

<script>ec(2);</script>

第一个文件名为 phplist.inc

 代码如下 复制代码

global $htmlroot;
$htmlroot="/web/html"; //"/web/html"是apache的文档根目录,用户可以根据自己的配置修改
?>

第二个文件名为 codeshow.php

 代码如下 复制代码

highlight_file($filename); //高亮显示文件代码
?>

这个是主程序名为 phplist.php

 代码如下 复制代码

require ("phplist.inc");
if ($rootpath=="") {$rootpath=$htmlroot;}
function filelist($pathname){ //遍历所有的文件和目录,$pathnam为起始目录,$searchs为搜索关键字
global $htmlroot;
if (eregi("[/][.][.]$",$pathname)) {
$temp=split("[/]",$pathname);
$pathname="";
for ($tt=1;$tt $pathname=$pathname."/".$temp[$tt];
}
echo $pathname."
";
$handle=opendir($pathname); //打开目录
if (@chdir($pathname)) { //cd 进入目录,若无权限则不进入
$file = readdir($handle); //读出所有当前目录下的元素名,第一次读出为‘。’,指上层目录
while ($file = readdir($handle)) { //若有元素就进行以下处理
$fname=$pathname."/".$file; //将元素名与当前目录名结合组成完整的文件名,并赋值给$fname
if ((is_file($file)) and (ereg(".php[3]{0,1}$",$file) or ereg(".htm[l]{0,1}$",$file))) //判断是否为文件并且是否以.php和.php3结尾
{
$temppp=split($htmlroot,$fname);
echo "".$file."   ".filesize($file)."bytes      源文件
";
//findinfile($fname,$searchs); //调用findinfile函数
}
elseif (is_dir($fname)) { //判断是否为目录
linkres($fname);
//filelist($fname,$searchs);} //递归调用filelist函数
}
}
chdir(".."); //结束当前递归,返回上层
}
closedir($handle); //关闭当前目录读取
}
//
function linkres($filename){
$tpath=split("/web/html",$filename);
$turepath=$tpath[1];
ereg("[^\/~]{0,}$",$filename,$res);
//$ft=filetitle($filename);
//if ($ft=="") $ft="无标题";
echo "".$res[0]."  
";
}
//
filelist($rootpath);

?>

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)