PHP implements a remote file Finder _php instance that searches files by file name

Source: Internet
Author: User
For the local, we can take advantage of the Windows own find to find out, but for the online, such as the search FTP space inside the file, this program is very useful.

Use effect:

PHP file Finder Source:
Copy the Code code as follows:



PHP Version File Search





/*
* Note: Case sensitive
* By:http://www.php.net
*/
if (!empty ($_post[' path ')) &&!empty ($_post[' key ')) {
echo "in Path". $_post[' path ']. " /in Find ". $_post[' key ')." The result is:

";
$file _num = $dir _num = 0;
$r _file_num = $r _dir_num= 0;
$findFile = $_post[' key '];
function Deldirandfile ($dirName) {
if ($handle = @opendir ("$dirName")) {
while (false!== ($item = Readdir ($handle))) {
if ($item! = "." && $item! = "...") {
if (Is_dir ("$dirName/$item")) {
Deldirandfile ("$dirName/$item");
} else {
$GLOBALS [' File_num ']++;
if (Strstr ($item, $GLOBALS [' FindFile '])) {
echo " $dirName/$item
\ n ";
$GLOBALS [' R_file_num ']++;
}
}
}
}
Closedir ($handle);
$GLOBALS [' Dir_num ']++;
if (Strstr ($dirName, $GLOBALS [' FindFile '])) {
$loop = Explode ($GLOBALS [' FindFile '], $dirName);
$COUNTARR = count ($loop)-1;
if (Empty ($loop [$COUNTARR])) {
echo " $dirName
\ n ";
$GLOBALS [' R_dir_num ']++;
}
}
}else{
Die ("No This path! ");
}
}

Deldirandfile ($_post[' path ');
echo "

A total of ". $file _num." Files, folders ". $dir _num." A
";
echo " A total of ". $r _file_num." Files, folders ". $r _dir_num." A
";
}

?>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.