fritekst søgning uden DB
Mojn,Jeg har fundet et search script i php som jeg vil bruge på min hjemmeside. Scriptet skulle kunne søge i forskellige filtyper i undermapper mv., men jeg aner ikke hvordan jeg skal læse det... lidt assistance er velkommen. Det jeg skal vide er hvor jeg skal rette i scriptet så jeg får det til at søge i de rigtige undermapper, hvilke filtyper den kigger igennem.
<HTML><HEAD></HEAD><BODY BACKGROUND=background.gif>
<CENTER>
<BR>
<H1>Søge resultater</H1>
<HR>
<TABLE BORDER=0 width=95% spacing=0 CELLPADDING=0 CELLSPACING=0>
<TR><TD background=topbg.gif><BR></TD></TR>
<?Php
error_reporting(0);
$timex=time();
$timey=0;
$bgchange="FFFFFC";
$fchek=0;
$command[0]="0";
$dirtest="false";
#subfolder search options setup starts here
if($where=="index"){
$dirtest="true";
$linkdir="";
$handle=opendir('.');
} elseif($where=="php"){
$linkdir="phpapps/";
chdir('./phpapps');
$handle=opendir('.');
}elseif($where=="other"){
$linkdir="otherscripts/";
chdir('./otherscripts');
$handle=opendir('.');
}elseif($where=="news"){
$linkdir="news/";
chdir('./news');
$handle=opendir('.');
} else {
$dirtest="true";
$linkdir="/ts_ny/profil/";
$handle=opendir('.');
}
#thats it, nothing else should be changed do not edit below this line.
while (($file = readdir($handle))!==false){
if (eregi("[a-zA-Z0-p_-]*.html",$file) or eregi("[a-zA-Z0-p_-]*.htm",$file)or eregi("[a-zA-Z0-p_-]*.php",$file)or eregi("[a-zA-Z0-p_-]*.txt",$file)){
$fchek=$fchek+1;
$sizer=filesize($file);
$sizer=($sizer/1000);
$sizer=round($sizer,1);
$file=trim($file);
$file=chop($file);
$filed=file($file);
$fileold=$file;
$count = count($filed);
$i = $count;
$zt = 0;
$clt=0;
$found=0;
$stringer=0;
for($j=$zt;$j<$i;$j++){
$string=$filed[$j];
$stringer=$filed[$j];
$num = "regPLACE hold";
$string=strtolower($string);
$stringer=strtolower($stringer);
$whatdoreplace=strtolower($whatdoreplace);
$string = ereg_replace($whatdoreplace, $num, $string);
if($string!=$stringer){
$found=$found+1;
$abby=$found;
$show[$found]=$stringer;
}
}
$dircount=count($file);
echo "<FONT SIZE=-1>";
if($found>0){
$command[0]=($command[0]+10);
if(eregi("[a-zA-Z0-p_-]*.txt",$file)){
$fileold=$file;
$file="index.php";
if($dirtest=="true"){
$file=$fileold;
}
}
if($file=="index.html"){
if($bgchange=="EEEEEE"){
$bgchange="FFFFFF";
echo "</TD></TR><TR><TD BGCOLOR=$bgchange><BR><A HREF=\"$linkdir$file\" target=_new><FONT SIZE=+2>$file</A><BR>$data</FONT> Size: $sizer Kb<BR><BR>This file containes <B><FONT COLOR=RED>$found</FONT></B> instances of <B><FONT COLOR=RED>$whatdoreplace</FONT></B> (shown below) <BR><UL>";
} else {
$bgchange="EEEEEE";
echo "</TD></TR><TR><TD BGCOLOR=$bgchange><BR><A HREF=\"$linkdir$file\" target=_new><FONT SIZE=+2>$fileold</A> </FONT> Size: $sizer Kb<BR><BR>This file containes <B><FONT COLOR=RED>$found</FONT></B> instances of <B><FONT COLOR=RED>$whatdoreplace</FONT></B> (shown below) <BR><UL>";
}
} elseif($bgchange=="EEEEEE"){
$bgchange="FFFFFF";
echo "</TD></TR><TR><TD BGCOLOR=$bgchange><BR><A HREF=\"$linkdir$file\"><FONT SIZE=+2>$fileold</A></FONT> Size: $sizer Kb<BR><BR>This file containes <B><FONT COLOR=RED>$found</FONT></B> instances of <B><FONT COLOR=RED>$whatdoreplace</FONT></B> (shown below) <BR><UL>";
} else {
$bgchange="EEEEEE";
echo "</TD></TR><TR><TD BGCOLOR=$bgchange><BR><A HREF=\"$linkdir$file\"><FONT SIZE=+2>$fileold</A></FONT> Size: $sizer Kb<BR><BR>This file containes <B><FONT COLOR=RED>$found</FONT></B> instances of <B><FONT COLOR=RED>$whatdoreplace</FONT></B> (shown below) <BR><UL>";
}
$file=$fileold;
for($new=1;$new<=$found;$new++){
$show[$new]=strip_tags($show[$new]);
$show[$new] = ereg_replace($whatdoreplace,"<FONT COLOR=RED><B>$whatdoreplace</FONT></B>",$show[$new]);
echo "<FONT SIZE=-1>";
print "<LI>$show[$new]";
}
echo "</UL></FONT></TD></TR>";
}
}
}
if($command[0]==0){
echo "<BR></TD></TR><TR><TD bgcolor=000000><CENTER><B><FONT SIZE=+2 COLOR=RED>No Results Found!";
}
echo "<BR></TD></TR><TR><TD BGCOLOR=AAAAFF><CENTER><FONT SIZE=-1>There where $fchek total file(s) searched which took ";
$timey=time();
$timea=($timey-$timex);
echo " $timea total seconds(s)";
?>
<TD/></TD></TR></TABLE><BR><CENTER><IMG SRC=sas.gif><TABLE>
<BR><BR><BR><BR><BR><BR>
<TABLE WIDTH=300><TR><TD><FONT SIZE=-3 COLOR=BLUE>
In case your interested, this search engine was written entirely by me, using the PhP 4 Scripting Languarge. It uses nothing but itself, making it the easiest to setup and begin using for people who don't want to setup a database just to do searches. Every site I checked said that PhP search engines do not work. But I don't listen very well.
</TD></TR></TABLE>
</HTML>
