php搜索文件程序分享
對于本地,我們可以利用windows自帶的查找去進行查找,但是對于線上的話,如查找ftp空間里面文件,本程序是很有用的。
php文件查找器源碼:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>php版文件查找(file search)</title> </head> <body> <form action="" method="post"> <p> 文件查找(注:區(qū)分大小寫)</p> <p>路徑:<input type="text" name="path" /></p> <p>查找:<input type="text" name="key" /></p> <p><input type="submit" name="sub" value=" 開 始 " /></p> </form> </body> </html> <?php /* * 注:區(qū)分大小寫 * by: http://www.daixiaorui.com */ if(!empty($_POST['path'])&&!empty($_POST['key'])){ echo "在路徑 ".$_POST['path']."/ 中查找 ".$_POST['key']." 的結果為:<hr/>"; $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 " <span><b> $dirName/$item </b></span><br />\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 " <span style='color:#297C79;'><b> $dirName </b></span><br />\n"; $GLOBALS['r_dir_num']++; } } }else{ die("沒有此路徑!"); } } delDirAndFile($_POST['path']); echo "<hr/>本次共搜索到".$file_num."個文件,文件夾".$dir_num."個<br/>"; echo "<hr/>符合結果的共".$r_file_num."個文件,文件夾".$r_dir_num."個<br/>"; } ?>
以上就是php文件查找器程序,可以搜索本地文件,便于操作,希望對大家的學習有所幫助。
相關文章
php rmdir使用遞歸函數(shù)刪除非空目錄實例詳解
我們大家都知道,php rmdir()函數(shù)用于刪除空目錄,但如果要刪除非空目錄,我們必須將非空目錄中的文件或子目錄刪除,本文章向大家介紹php如何使用遞歸函數(shù)刪除非空目錄,需要的朋友可以參考一下2016-10-10php echo, print, print_r, sprintf, var_dump, var_expor的使用區(qū)別
本篇文章是對php中echo, print, print_r, sprintf, var_dump, var_expor的使用區(qū)別進行了詳細的分析介紹,需要的朋友參考下2013-06-06php源碼分析之DZX1.5加密解密函數(shù)authcode用法
這篇文章主要介紹了php源碼分析之DZX1.5加密解密函數(shù)authcode用法,實例分析了DZX1.5中authcode函數(shù)加密與解密的使用技巧,需要的朋友可以參考下2015-06-06WordPres對前端頁面調(diào)試時的兩個PHP函數(shù)使用小技巧
這篇文章主要介紹了WordPres對前端頁面調(diào)試時的兩個PHP函數(shù)使用小技巧,分別是過濾Html內(nèi)嵌JavaScript與禁止瀏覽器緩存的方法,需要的朋友可以參考下2015-12-12CodeIgniter生成網(wǎng)站sitemap地圖的方法
用CodeIgniter只需要三步就可以生成網(wǎng)站sitemap地圖,方法很簡單,大家可以參考一下2013-11-11不用mod_rewrite直接用php實現(xiàn)偽靜態(tài)化頁面代碼
不用mod_rewrite直接用php代碼實現(xiàn)偽靜態(tài)效果,大家看后就會發(fā)現(xiàn)php真的很方便2008-10-10