0 && in_array(strtolower($ext), $allowed_ftypes) ) || count($allowed_ftypes) == 0 ) {
// Grab file contents
$contents = file_get_contents($file);
// Decide whether to include based on entire file or found in HTML restriction
if ( !$ef ) {
$contents = strip_tags($contents);
}
$contents = preg_replace('|[\s]+|', ' ', $contents);
//
if ( ( $pos = strpos($contents, $_POST['searchString']) ) !== false ) {
$snippet = substr($contents, max(($pos-200), 0), 400);
// Add link to result set
$allowed_results[] = array(
'link' => "{$file}",
'snip' => htmlspecialchars($snippet),
'lmod' => date('Y-m-d H:i A', filemtime($file)),
'size' => round(filesize($file)/1024, 1),
);
}
}
}
// Finish Timer
$finish_time = microtime(true);
// Display Results
echo "Searching for {$safe_searchString} - ".count($allowed_results)." result".(count($allowed_results)==1?'':'s').' in '.round($finish_time-$start_time, 2).' seconds.
';
foreach ( $allowed_results AS $v ) {
echo <<
{$v['link']}
{$v['snip']}
Modification Time: {$v['lmod']} Size: {$v['size']} kb's
HTML;
}
}