You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.6 KiB
PHP

<?php
// error_reporting(0);
$suchkeys = array();
while (list($key,$varinhalt) = each($_POST)){
// echo "Key:".$key;
// echo " --- Inhalt:".$varinhalt."\n";
switch($key){
case 'suchestr':
$suchstr = $_POST[$key];
break;
case 'htmlverz':
$htmlverz = $_POST[$key];
break;
case 'keys':
$suchkeys = explode(':',$_POST[$key]);
break;
case 'html':
$suchhtml = explode(':',$_POST[$key]);
break;
default:
}
}
// echo 'suchstr='.$suchstr."\n";
// echo 'htmlverz='.$htmlverz."\n";
// echo 'suchstr='.$suchstr."\n";
// echo 'menuetxt='.$menuetxt[0]."\n";
// Alle gültgen Files durchsuchen
$sonderzeichen = array(':',';',',','=','<','>');
$erg = '';
$ergz = 0;
$lang = count($suchhtml)-1; // Letzter eintrag ist immer leer
for ($i=0;$i<$lang;$i++){
$file = $htmlverz.$suchhtml[$i].'.html';
// echo 'file='.$file."\n";
// if (file_exists($file) && !is_dir($file) && $suchhtml[$i] == 'testseite'){
if (file_exists($file) && !is_dir($file)){
if ($lfile = fopen($file, 'r')){
$content = fread($lfile,filesize($file));
// echo 'file='.$file." - found\n -> ".strpos($content,$suchstr)."\n";
// if ($suchhtml[$i] == 'testseite'){
// echo ":".strpos($content,$suchstr).":\n";
// echo ":".stripos($content,'bi').":\n";
// echo $content;
// }
fclose($lfile);
while(stripos($content,$suchstr) !== false && $ergz < 60){
$ergz++;
// Startposition des suchstr holen
$spos = stripos($content,$suchstr);
// echo 'spos='.$spos."\n";
// Startposition des Zeilenanker holen
// $zeile = strrpos($content,'<a name="szl',$spos)+9;
$zpos = strrpos(substr($content,0,$spos),'<a name="szl');
// echo 'zpos='.$zpos."\n";
//Anker setzten
if ($zpos === false){
$anker = 'top';
}else{
$zpos += 9;
$anker = substr($content,$zpos,strpos($content,'"',$zpos)-$zpos);
}
$postext = substr($content,stripos($content,$suchstr),30);
for ($k=0;$k<count($sonderzeichen);$k++){
if (strpos($postext,$sonderzeichen[$k]) !== false){
$postext = substr($postext,0,strpos($postext,$sonderzeichen[$k]));
}
}
// $postext = str_replace(array(':',';',',','=','<','>'),'',substr($content,stripos($content,$suchstr),30));
$erg .= $suchkeys[$i].'='.$suchkeys[$i].':'.$postext.','.$anker.'!!'.$suchstr.'??';
// echo substr($content,0,30)."\n";
$content = substr($content,0,$spos).substr($content,$spos+strlen($suchstr));
// echo substr($content,0,30);
// exit;
// $content = str_ireplace($suchstr,'',$content);
}
}
}
if ($ergz >= 60){
break;
}
}
echo $erg;
?>