All pastes #973789 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-06 09:25 UTC
rendered paste body
<?php
$dir = "./";
fwrite(STDOUT,"\nEnter string to search for: ");
$search = trim(fgets(STDIN)); 
fwrite(STDOUT,"\nSearching...\n\n");
if (is_dir($dir))
	{
	$dh = opendir($dir);
    if ($dh) {
		$counter = 0;
        while (($file = readdir($dh)) !== false) {
        if ($file==".."||$file==".") continue;
		//if (strpos($file,"ConsoleLog") === false) continue;
		
        $lines = file($file);
		foreach ($lines as $line_num => $line) {
			if (strpos($line,$search) !== false)
				{
				echo "$file | ".$line;
				$counter++;
				}
			}
		}
		fwrite(STDOUT,"\n".$counter." results found\n");
        closedir($dh);
    }
	else die("Couldn't open directory :(\n");
}
else die("Couldn't open directory :(\n");
?>