Location: PHPKode > scripts > Malware Finder > malware-finder/process.php
<?php
 
if (!isset($_REQUEST['query'])) 
    { 
        //Ask for query here :)      
        //echo "<p style=\"color:darkgray; font-family:arial\">Sorry. Please enter a search term.</p>"; 
        exit; 
    } 
 
    $query = isset($_REQUEST['query']) ? $_REQUEST['query'] : ''; 
 
 
    if (empty($query)) 
    { 
        echo "<p style=\"color:#575757; font-family:arial\">We are unable to process your request becuase you didn't enter a search term. Please try again.</p>"; 
        exit; 
    } 
 
 
    $filesFound = find_files('.'); 
 
    if (!$filesFound) 
    { 
        echo "<p style=\"color:#575757; font-family:arial\">No files contained the search, \"$query\". Please try another search.</p>"; 
    } 
 
 
    function find_files($seed) 
    { 
        if (!is_dir($seed)) return false; 
        $found = false; 
        $dirs = array($seed); 
 
        while (NULL !== ($dir = array_pop($dirs))) 
        { 
            if ($dh = opendir($dir)) 
            { 
                while (false !== ($file = readdir($dh))) 
                { 
                    if ($file == '.' || $file == '..') continue; 
                    $path = $dir . '/' . $file; 
                    if (is_dir($path)) 
                    { 
                        $dirs[] = $path; 
                    } 
                    else 
                    { 
                        if (preg_match('/^.*\.(php[\d]?|js|txt)$/i', $path)) 
                        { 
 
                            if (check_files($path)) 
                            {
                                $found = true;
                            }
                       } 
                    } 
                } 
                closedir($dh); 
            } 
        } 
        return $found; 
    } 
 
    function check_files($this_file) 
    { 
        $query = $_REQUEST['query']; 
 
        $str_to_find = $query; 
 
 
        if (($content = file_get_contents($this_file)) === false) 
        { 
            echo("<p style=\"color:#575757; font-family:arial\">Could not check $this_file</p>\n"); 
            return false; 
        } 
        else 
        { 
            if (stristr($content, $str_to_find)) 
            { 
                echo("<p style=\"color:#575757; font-family:arial\">$this_file -> contains \"$str_to_find\"</p>\n"); 
                return true; 
            } 
        } 
    } 

?>
Return current item: Malware Finder