tarun Posted April 22, 2007 Share Posted April 22, 2007 Well Heres What I Need To Do: Scan A Directory For Certain Types Of Files (php, txt, html) Any Ideas...? Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/48125-scanning-a-directory/ Share on other sites More sharing options...
tarun Posted April 22, 2007 Author Share Posted April 22, 2007 BuMp Link to comment https://forums.phpfreaks.com/topic/48125-scanning-a-directory/#findComment-235206 Share on other sites More sharing options...
AndyB Posted April 22, 2007 Share Posted April 22, 2007 http://ca.php.net/manual/en/function.glob.php Link to comment https://forums.phpfreaks.com/topic/48125-scanning-a-directory/#findComment-235222 Share on other sites More sharing options...
jchemie Posted April 22, 2007 Share Posted April 22, 2007 Hi Tarun... Here is a piece of code i had used earlier in one of my scripts function get_dir($path,$max_depth='',$l=0,$total=''){ global $conn; global $desireddir, $host, $mod; if(!is_dir($path))return; $path=substr($path,-1)!="/"?$path."/":$path; if(!$l){ $total=0; } if($max_depth==='' || ($max_depth>$l && is_int($max_depth))) $test_depth=true; else $test_depth=false; $pre=""; $c=$l; while($c--)$pre.=" "; $dir=opendir($path); while($f=readdir($dir)){ if($f=="."||$f=="..")continue; $file=$path.$f; $size=""; if(is_dir($file)) { $newdir = $desireddir . str_replace("upload", "", $file); ftp_mkdir($conn, $newdir); if(strpos(ftp_pwd($conn), "wp-content") || strpos($newdir, "wp-content")) { ftp_site($conn, 'CHMOD '.$mod.' '. $newdir); } } if((is_file($file)||!is_dir($file)) && (substr($file, strlen($file)-3) == "php"){ // DO WHAT YOU WANT TO WITH THE FILE.... } else $f.="/"; while(strlen($size)<16) $size=" ".$size; if(is_dir($file) && $test_depth) $total=get_dir($file,$max_depth,$l+1,$total); } if(!$l) return $total; } Link to comment https://forums.phpfreaks.com/topic/48125-scanning-a-directory/#findComment-235246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.