Hi,

I'm having a great deal of a problem in making a new script that uses Mysql instead of a php webpage crawler script for a site search engine.

Example on:

Original Script: http://www.snsprops.com/searching.php

<?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=="all"){
$linkdir="";
$handle=opendir('.');

	}elseif($where=="bars"){
	$linkdir="bars/";
	chdir('./bars');
	$handle=opendir('.');

		}elseif($where=="clubs"){
		$linkdir="clubs/";
		chdir('./clubs');
		$handle=opendir('.');

			}elseif($where=="hotels"){
			$linkdir="hotels/";
			chdir('./hotels');
			$handle=opendir('.');

                              } else {
                            $dirtest="true";
                            $linkdir="";
                            $handle=opendir('.');
}

	print "<h4>The search was performed in: <b>&quot;$where&quot;</b> section.</h4>";

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_-]*.asp",$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=+1>$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=+1>$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=+1>$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=+1>$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 "</UL></FONT></TD></TR>";
	}

	}
}

if($command[0]==0){
	echo "<BR></TD></TR><TR><TD bgcolor=000000><CENTER><B><FONT SIZE=+1 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)";


?>

The reason that I need to change this search engine is because this script has no restrictions on the results it will give back.
(ie: search for "image" in Category "all", it will show everytime the word image is used "<image......" !!!)

I was able to find some good php & MySQL search engine using FULL-TEXT.
I understand how to Connect to MySQ, bring back the fields from the table etc....
But the problem that I am having is restricting the search into categories!!!

Does anyone have any ideas???

    Write a Reply...