If ($ _ POST ['submit '] = 'start '){ $ Total = 0; // total number of files $ Dangerous = array (); // dangerous File $ Dangerous_content =$ _ POST ["sstr"]; $ Find_path = $ _ POST ["searchpath"]; $ Shortname = $ _ POST ["shortname"]; Echo""; Echo""; Echo""; Echo" "; Echo""; Echo""; $ Begin_time = date ("U "); // $ Dangerous_content = "xiaoliang, Root_GP, Root_CSS, c99sh_updateurl, c99sh_sourcesurl, 640684770 "; VisitFile ($ find_path, $ shortname ); $ End_time = date ("U "); Foreach ($ dangerous as $ d ){ Echo $ d ." "; } Echo "total number of files:". $ total. "dangerous files:". count ($ dangerous). "total time". ($ end_time-$ begin_time). "seconds "; Echo""; Echo""; // If (! Empty ($ dangerous )){ // Foreach ($ dangerous as $ dan ){ // Echo "[error]". $ dan ." "; //} //} Exit (); } Function visitFile ($ path, $ ext ){ Global $ total; Global $ dangerous_content; $ Fdir = dir ($ path ); // Echo "Handle:". $ d-> handle ." "; // Echo "Path:". $ fdir-> path ." "; Set_time_limit (24*60*60 ); While ($ entry = $ fdir-> read ())! = False ){ $ PathSub = $ path. "\". $ entry; If ($ entry! = '.' & $ Entry! = '..'){ If (is_dir ($ pathSub )){ VisitFile ($ pathSub, $ ext ); } Else { $ Exten = explode ('.', $ entry ); $ Exten = array_reverse ($ exten); // returns the reverse order of the preceding array. // Foreach () $ Shortnames = explode ('|', $ ext ); Foreach ($ shortnames as $ sn ){ If (! Empty ($ exten) & $ sn =$ exten [0]) { $ Total = $ total + 1; // Echo "Start analysis file:". $ path. "/". $ entry ." "; $ Content = file_get_contents ($ path. "/". $ entry); // High Performance $ Content = strtolower ($ content); // convert all to lowercase letters $ Dangerous_content = strtolower ($ dangerous_content); // convert all to lower case IsExists ($ dangerous_content, $ path. "/". $ entry, $ content); // This method is too memory-consuming. I hope some experts can solve this problem. } } // Sleep (1 ); } } } $ Fdir-> close (); } Function isExists ($ str, $ filename, $ content ){ Global $ dangerous; // Sleep (1 ); Set_time_limit (10 ); $ Arr = explode (',', $ str ); $ Signature = "signature :"; If (! Empty ($ arr )){ // $ Content = file_get_contents ($ filename); // This has good performance. $ Content = strtolower ($ content); // convert all to lowercase letters $ Error_count = 0; Foreach ($ arr as $ ){ If (trim ($ )! = ""){ If (strpos ($ content, $ )){ $ Error_count = $ error_count + 1; $ Signature. = $ .""; } } } If ($ error_count> 0 ){ // $ Dangerous [] = $ filename; $ Dangerous [] = "[error]". $ error_count. "". $ signature. "". $ filename; // Echo "[error]". $ error_count. "". $ signature. "". $ filename ." "; } Else { // Echo "[OK]". $ filename ." "; } } } ?> Batch query of Files Batch lookup programs This program can scan all the files in the specified directoryContent Search.
When the number of files is very large, this operation occupies server resources. Make sure that the script time-out period can be changed. Otherwise, the operation may fail. Cellspacing = "1" bgcolor = "#666666">
|