This program can replace the contents of all files in the directory in batches or check and update Trojan files in batches. I hope this article will help you. the php batch replacement program instance code is as follows :? Php *************... this program can replace the contents of all files in the directory in batches or check and update Trojan files in batches. I hope this article will help you.
The php batch replacement program instance code is as follows:
Read () {if ($ v = ". "| $ v = ".. ") continue; $ file = $ d-> path. "/". $ v; if (is_dir ($ file) {echo"$ V
"; Hx_dirtree ($ file);} else {$ ext = substr (strrchr ($ v ,". "), 1); if (in_array ($ ext, $ arrext) {echo"
$ File "; $ body = file_get_contents ($ file); if ($ isreg = 1) {$ body2 = preg_replace ($ sstr, $ rpstr, $ body );} else {$ body2 = str_replace ($ sstr, $ rpstr, $ body);} if ($ body! = $ Body2 & $ body2! = '') {Tofile ($ file, $ body2); echo 'OK';} else {echo 'no';} echo'';}}$ D-> close ();} function hx_dealdir ($ dir) {global $ sstr, $ rpstr, $ isreg, $ arrext; if ($ dh = opendir ($ dir) {while (false! ==( $ File = readdir ($ dh) {if (filetype ($ dir. '/'. $ file) = 'file') {$ ext = substr (strrchr ($ file ,". "), 1); if (in_array ($ ext, $ arrext) {echo"
$ File "; $ body = file_get_contents ($ dir. '/'. $ file); if ($ isreg = 1) {$ body2 = preg_replace ($ sstr, $ rpstr, $ body);} else {$ body2 = str_replace ($ sstr, $ rpstr, $ body);} if ($ body! = $ Body2 & $ body2! = '') {Tofile ($ dir. '/'. $ file, $ body2); echo 'OK';} else {echo 'no';} echo'';}} Closedir ($ dh) ;}// write the function tofile ($ file_name, $ file_content) {if (is_file ($ file_name) in the file generation process )) {@ unlink ($ file_name);} $ handle = fopen ($ file_name, "w"); if (! Is_writable ($ file_name) {return false;} if (! Fwrite ($ handle, $ file_content) {return false;} fclose ($ handle); // Close the pointer return $ file_name ;}?>
Batch replace program | delete Trojans in batches _ www.itlearner.com
Bulk replacement program (UTF-8 edition)
This program can scan all the files in the specified directoryContent replacement. It can be used to delete Trojans in batches and to update some content on the page in batches.
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.