Advertisement
Guest User

PHP Find string script

a guest
Jun 3rd, 2013
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <html><head><title>Find String</title></head><body>
  2. <?php
  3. // ini_set('max_execution_time', '0');
  4. // ini_set('set_time_limit', '0');
  5. find_files('.');
  6. function find_files($seed) {
  7.   if(! is_dir($seed)) return false;
  8.   $files = array();
  9.   $dirs = array($seed);
  10.   while(NULL !== ($dir = array_pop($dirs)))
  11.     {
  12.       if($dh = opendir($dir))
  13.         {
  14.           while( false !== ($file = readdir($dh)))
  15.             {
  16.               if($file == '.' || $file == '..') continue;
  17.               $path = $dir . '/' . $file;
  18.               if(is_dir($path)) {    $dirs[] = $path; }
  19.               else { if(preg_match('/^.*\.(php[\d]?|js|txt)$/i', $path)) { check_files($path); }}
  20.             }
  21.           closedir($dh);
  22.         }
  23.     }
  24. }
  25. function check_files($this_file) {
  26.    $str_to_find='base64_decode'; // the string(code/text) to search for
  27.    if(!($content = file_get_contents($this_file))) { echo("<p>Could not check $this_file</p>\n"); }
  28.    else { if(stristr($content, $str_to_find)) { echo("<p>$this_file -> contains $str_to_find</p>\n"); }}
  29.    unset($content);
  30. }
  31. ?>
  32. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement