Hello,
I tried to create an index-search-engine (without mysql).
The indexer-script opens all files in the directories and adds the text (without HTML-code) to an index-file.
The search-script searches the index-file.
Now I have this problem: One directory contains 3.815 files (79 M😎. When indexing this directory and its subdirectories the script stops at file 2.800 (somtimes less, sometimes more) without an error message. To increase php-timeout and server-timeout doesnt help!
Does anyone know this problem?
Stefan
Here's the code:
foreach($verzeichnisse as $verz){
echo "<p>verz: $verz</p>";
get_dir($verz);
$index=kein_html($index);
$index_datei=$verz.".txt";
$fp=fopen($index_datei,"w");
fwrite ($fp,$index);
fclose($fp);
$index="";
}
function get_dir($verz)
{
$endungen=array("html","htm","php","phtml");
$treffer=0;
$pfad="../";
$dh=opendir($pfad.$verz);
while ($datei=readdir($dh)){
if (is_dir($pfad.$verz."/".$datei) && $datei!="." && $datei!=".."){
echo "<p><b>Verzeichnis:</b> ".$pfad.$verz."/".$datei;
get_dir($verz."/".$datei);
}else{
if (($datei!=".")&&($datei!="..")){
$dateiname=explode(".",$datei);
if (in_array($dateiname[1],$endungen)){
$filename = $pfad.$verz."/".$datei;
echo "<p>$filename</p>";
$fp = fopen($filename,'r');
$text=fread($fp,filesize($filename));
if(preg_match("%<title>(.*?)</title>%i",$text,$data)){
echo "<br>$i - $data[1]";
}
$text="\n".$filename."%%".$data[1]."%%".$text;
global $index;
$index=$index.$text;
$text="";
$titel="";
global $i;
$i++;
}
}
}
} //while
closedir($dh);
} // function()