woocha Posted April 28, 2008 Share Posted April 28, 2008 Hi guys...I am not sure if this is possible, but I need a way to search through all of the files on my server. some piece of crap bug was spread to one of my severs and a bunch of the php and html files had an iframe attached to the bottom of them. I have downloaded all al;l infected files and altered all 150, but I seem to be missing one. So I want to do a sever wide search using php to find this one line bit of code and delete it. Does anyone know how to do this with php? Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/ Share on other sites More sharing options...
jonsjava Posted April 28, 2008 Share Posted April 28, 2008 windows or Linux server? Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528879 Share on other sites More sharing options...
woocha Posted April 28, 2008 Author Share Posted April 28, 2008 unix...without ssl Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528881 Share on other sites More sharing options...
woobarb Posted April 28, 2008 Share Posted April 28, 2008 Walk all the files, opening each one in turn and doing a preg_replace or substr_replace. Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528889 Share on other sites More sharing options...
woocha Posted April 28, 2008 Author Share Posted April 28, 2008 Walk all the files, opening each one in turn and doing a preg_replace or substr_replace. Ya, I could, but I was hoping for a much quick solution. There are literally 1000's of files on this ine server. Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528892 Share on other sites More sharing options...
jonsjava Posted April 28, 2008 Share Posted April 28, 2008 there isn't any faster solution. just fgrep "string_here" ./* -R from the base folder of the files. Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528894 Share on other sites More sharing options...
woocha Posted April 28, 2008 Author Share Posted April 28, 2008 there isn't any faster solution. just fgrep "string_here" ./* -R from the base folder of the files. I thought I need sheel access to use grep Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528898 Share on other sites More sharing options...
jonsjava Posted April 28, 2008 Share Posted April 28, 2008 <?php $command = shell_exec("fgrep 'string_here' /path/to/folder/* -R") print "<pre>".$command."</pre>"; Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528900 Share on other sites More sharing options...
woobarb Posted April 28, 2008 Share Posted April 28, 2008 Ya, I could, but I was hoping for a much quick solution. There are literally 1000's of files on this ine server. to change every text file on a server means you need to open, check and if required change and save, EVERY file... unless you know some better magic. And hey at least you don't have to do it by hand. And yes jonsjavas' variation would be faster, but you did specify with php... Link to comment https://forums.phpfreaks.com/topic/103249-use-php-to-search-through-entire-server-for-text-in-files/#findComment-528911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.