本程序可以显示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); |
?>
Statement
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055612 fails to install in Windows 10?
4 weeks agoByDDD
Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
3 weeks agoByDDD
Nordhold: Fusion System, Explained
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools
