Please tell me a Directory and the file type.


"; die; } $files = scandir($dir); if(empty($files[2])){ // without .(current Directory) and ..(last Directory) $thedir = explode("\\", $dir); if(sizeof($thedir) == 1 || empty($thedir[1]) ){ if(!preg_match("/[A-Za-z]/",$thedir[0])){ // $thedir[0] must be from a-z/A-Z/a-Z/A-z/.. print "

Invalid Directory

"; die; }else{ print "

The Directory '".$thedir[0]."' is empty or doesn't exists.


"; die; } }else{ print "

The Directory '".$thedir[count($thedir)-1]."' (in ".$thedir[0].") is empty or doesn't exists.


"; die; } } $cnt_files = 0; $the_files = array(); foreach($files as $file){ if(preg_match("/(.*).".$type."$/", $file)){ $the_files[$cnt_files] = $file; $cnt_files++; } } if($cnt_files === 0){ print "

In the Directory you told doesn\'t have files of your type


"; die; } print ""; for($i = 0; $i < $cnt_files; $i++){ print ""; $filed = fopen($dir."\\".$the_files[$i], "r"); while($blah = fgets($filed)){ if(preg_match("/\n/",$blah)){ $count_line[$the_files[$i]]++; $insgesamt++; } elseif(preg_match("/\r/",$blah)){ $count_line[$the_files[$i]]++; $insgesamt++; } elseif(preg_match("/\r\n/",$blah)){ $count_line[$the_files[$i]]++; $insgesamt++; } } fclose($filed); print ""; } print ""; print "
".$type."Lines

".$the_files[$i]."

".$count_line[$the_files[$i]]."

--------------------------------

--------

total lines:

".$insgesamt."

"; ?>