Mein code...
<?
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" .
"Content-type: text/html" .
"charset=utf-8"
)
);
$context = stream_context_create($opts);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
<?
set_time_limit(2);
$path = "./";
$search = utf8_encode($_GET["search"]);
$highlight = "<DIV STYLE=\"background-color: darkblue; color: white; display: inline;\">".$search."</div>";
$dir=opendir($path);
while ($file = readdir ($dir))
if (!is_dir($datei))
{
if ($file != '.' && $file != '..')
{
if (eregi(".htm", $file)){
echo "<b>".$file."</b><br>";
$content = strip_tags(file_get_contents($file));
echo "<div STYLE=\"font-size: 10px;\">".$content."</div>";
echo "<br><br>";
$offset = 0;
$pos = 0;
$text_range = 100;
echo $search."<br>";
if(eregi($search,$content)) print "MATCH!<br><br>"; # Kontroll-Abfrage
do{
$pos = strpos($content,$search,$offset);
if ($pos !== false){
$text_s = $pos-$text_range;
$text_e = $text_range*2;
if ($text_s<0)$text_s=0;
echo "S:".$text_s;
echo "-E:".$text_e;
echo "<br>";
echo "<b>".str_replace($search,$highlight,substr($content,$text_s,$text_e))."</b>";
#$re[$file][] = str_replace($search,$highlight,$substr);
$offset = $pos+$text_e;
}
else print "<i>no match</i>";
echo "<br><br>";
} while($pos !== false);
echo "<hr>";
}
}
}
?>