موتور جستجو

yafatemeh

Member
:D سلام
بايد بگويم كه من در طراحي صفحات وب و HTML واردم ولي برنامه نويسي آنرا بيل مي رم...
من خيلي دوست دارم روي سايتم يك موتور جستجو بگذاردم كه بتوند كلمات فارسي را هم حتي ژيدا كنه...حالا البته كلمات انگليسي را هم پيدا كنه بسته...به هر حال اگر برنامه اي يا جايي يا ... مي شناسيد كه مي توند ما را ياري كند حتما به ما هم بگوييد...متشكرم :wink:
 

shahrokh_xp

Active Member
اگه اشتباه نكنم تو همين انجمن هاي مجيد آنلاين يه بحثي در اين مورد شده بود و به نتيجه خوبي هم ختم شده بود.من الآن يادم نيست چه برنامه اي بود و در ضمن آدرس اون بحث رو هم پيدا نكردم بدم ولي همان طور كه آقا مجيد گفتن اون برنامه هم مثل اينكه از هات سكريپت بود
:wink:
 

mahyar_nel

Active Member
مي توني اين رو search كني حتما پيدا مي كني

وقتي پيدا كردي به من بگو
 

saman_sweden

Active Member
yafatemeh گفت:
:D سلام
بايد بگويم كه من در طراحي صفحات وب و HTML واردم ولي برنامه نويسي آنرا بيل مي رم...
من خيلي دوست دارم روي سايتم يك موتور جستجو بگذاردم كه بتوند كلمات فارسي را هم حتي ژيدا كنه...حالا البته كلمات انگليسي را هم پيدا كنه بسته...به هر حال اگر برنامه اي يا جايي يا ... مي شناسيد كه مي توند ما را ياري كند حتما به ما هم بگوييد...متشكرم :wink:

اين بدردت ميخوره نمونه كد سايت http://www.eniro.se/ كه من يك زماني باشون كار ميكردم اما اون شركت هم بعدا از google استفاده كرد شما هم بهتره از search google استفاده كنيد

کد:
<?PHP
$intTimeBegan = time(); 
 unset($debug); 
  require("search.inc");?>
  
<HTML lang="en-us">
<?PHP

?>
<HEAD>
	<TITLE>
		Simple Web Search for "<?PHP print $words;?>"
	</TITLE>
	<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<META name="robots" content="index,nofollow">
	<META name="description" content="Simple Web Search!">
	<LINK href="<?php print $strStyleName ?>" rel="stylesheet" type="text/css" title="Simple Search Style">
</HEAD>
<BODY>
<h2>Simple Web Search</h2>
<div class="cool" style="text-align: center;">
	<form method="POST" action="<?php print $strSelf ?>">
		<table style="Width: 40%;" class="panel">
			<tr>
				<td style="Vertical-Align: Middle; Text-Align: Center;" colspan="2">Search for
					<input type="hidden" name="do" value="now">
					<input type="text" size="25" name="words" value="<?PHP print $words;?>">
					<?PHP 
if (isset ($strSearchSiteKey)) {
   $strSearchSiteIndex = $arySearchSiteIndices[chop($strSearchSiteKey)];
} else {
   reset ($arySearchSiteIndices);
   list( $dummy, $strSearchSiteIndex ) = each( $arySearchSiteIndices );
      if (count($arySearchSiteIndices) == 1) {
      $strSearchSiteKey = $dummy;
		}
}

// Print out available Site Indices to select field.
if (count($arySearchSiteIndices) > 1) {
   echo "<select name=\"strSearchSiteKey\">\n";
   reset ($arySearchSiteIndices);
   while (list($key,$val) = each( $arySearchSiteIndices ) ) {
      if ($strSearchSiteKey == $key) { echo "\t<option selected>".stripslashes($key)."\n"; }
      else {echo "\t<option>".stripslashes($key)."\n"; }
   }
   echo "</select>\n";
};

// Print out available Max Hits to select field.
if (count($aryMaxHits) > 1) {
   echo "<select name=\"intMaxHits\">\n";
   $m = 0;
   while($aryMaxHits[$m]) {
      if ($intMaxHits == $aryMaxHits[$m]) { echo "\t<option selected>$intMaxHits\n"; }
      else { echo "\t<option>$aryMaxHits[$m]\n"; }
      $m++ ;
   };
   echo "</select>\n";
} else { 
   $intMaxHits = $aryMaxHits[0];
};

// Make sure MaxHits is larger than returned results.
$intMaxHitsOffset = $intPageOffset + $intMaxHits;

?>
					<input type="submit" value="Find It!">
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<div style="Font-Size: 10pt; Font-Family: Verdana, Arial, Serif;">Ttest 
            from Saman</div>
				</td>
			</tr>
			<?PHP
// Determine if we want to use [t] limiting code.
if ($intUseLimits) {
?>
			<tr>
				<td>Limit Search:
				</td>
				<td style="Vertical-Align: Middle; Text-Align: Center;">
					<?PHP

	// Lump all of the [t] delimiters together in preparation for the commandline.
	// $strLimit is, also, used to determine if a box is checked.
	If (is_array($aryLimits)){$strLimit = implode($aryLimits, "");};

	// Print out Search delimiters to checkbox fields.
	reset ($arySearchDelimiter);
	while (list($key,$val) = each($arySearchDelimiter)) {
		echo "\t\t<INPUT type=\"checkbox\" name=\"aryLimits[]\" value=\"$val\"";
		if (strstr($strLimit,$val)){
			print " checked"; }
		echo ">$key\n";
	};

	// Setup Limit code
	if ($strLimit != ""){
		$strLimitLine = "-t $strLimit";
	} else {
		$strLimitLine = "";
	};
	print "</TD></TR>\n";
}; // EndIf intUseLimits

?>
		</table>
	</form>
</div>
<?PHP 
// Why waste time and resources if they haven't performed a search?
If($do != "now") {fncPrintFooter();}; 
?><h2 class="indexed">Searching for
<q lang="UTF-7">
<?PHP print "$words";?></q>:</h2>
<?PHP
/* Added DN: Adds last updated time of index November 17, 1999 */

print "<p class=\"updated\">Index of <em>" . ereg_replace("_", " ", stripslashes($strSearchSiteKey)) ."</em> last updated on " . date("D, M jS, Y H:i:s", filemtime($strSearchSiteIndex)) . "</p>";

/* Bug Fix JB: Parenthesis July 13, 1998
**
** $words = str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words))));
**
**
** Bug Fix JB: Fixes parenthesis fix  July 14, 1998
** $words = '"'.str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words).' '))).'"';
**
*/

$words = '"'.chop(str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words).' ')))).'"';


$strCommandLine = $strSearchEngine.escapeshellcmd(" -m $intMaxHitsOffset -f $strSearchSiteIndex $strLimitLine -w ").$words;

fncDebug("CommandLine", $strCommandLine, 1);

// Must find a better error message, possibly fix the HTML as well.
exec($strCommandLine, $aryResults, $return);

if( $return != 0 ) fncPrintFooter("<H3>Error performing search!</H3>\n<DL>\n\t<DT>Administrator\n\t\t<DD>Execution
of the command failed.  Please check the search.conf file.  Make sure there
are no special characters in the index array.</DL>");
	// Jump out to HTML and set the table...

/************************************/
$i=0;
while(substr($aryResults[$i],0,1) == "#" || substr($aryResults[$i],0,3) == "err" && $i < 50):
	$strResultsClean = $aryResults[$i];
	// Correct for offset caused by SWISH-E Comments.
	$intPageOffsetCorrect++;
	//Explodes the Comment into an array
	$aryComment = Explode(": ", strstr($strResultsClean, " "));
		fncDebug($aryComment[0], $aryComment[1], 2);
	
	    // Print number of results
		If (trim($aryComment[0]) == "Number of hits") {
			$intNumHits = trim($aryComment[1]);
   		    if ($intNumHits > 0) {
			if ($intNumHits >= $intMaxHits) {

				//Print 0 as 1
				If($intPageOffset == 0){$intPageOffsetOne = $intPageOffset + 1;}
				Else{$intPageOffsetOne = $intPageOffset;};

				// What is the result number of the last document
				If ($intNumHits > $intMaxHitsOffset){$intPageHitsThru = $intMaxHitsOffset;}
				Else {$intPageHitsThru = $intNumHits;};

				// At which results am I looking
				echo "Displaying $intPageOffsetOne through $intPageHitsThru of $intNumHits results.<BR>\n\n";
				print "<DL class=\"result\">\n";
			} else {
				// If in the off chance it is a small result, under MaxHits.
				print "$intNumHits results found.<BR>\n\n";
				print "<DL class=\"result\">\n";
			};
		};
	};
	    // Soundex Yes or ...
		If (trim($aryComment[0]) == "Soundex Applied") {
			if (trim($aryComment[1]) == "1"){
				print"<dl><dt>Note:<dd>Resulting matches are sound-alikes according to <a href=\"http://www.nara.gov/genealogy/coding.html\">US Census SoundEx codes</a>.</dl>";
			};
		};
		// Stemming yes or ...
		If (trim($aryComment[0]) == "Stemming Applied") {
			if (trim($aryComment[1]) == "1"){
				print"<dl><dt>Note:<dd>Resulting matches are based on stems of the words in your query. A search for 'testing' will return matches for 'testing', 'tested', 'test', etc.</dl>";
			};
		};
	// Set the strBaseURL if it isn't in the config already.
	If (trim($aryComment[0]) == "Pointer"  && !isset($strBaseURL)){
		$strBaseURL = trim($aryComment[1]);
		fncDebug("URL Pointer",$strBaseURL, 3);
	};
	fncDebug("strResultsClean", $strResultsClean, 3);
	
	//	Crappy No Results "err:" handling.  Will be fixed someday, maybe...
	if(substr($strResultsClean,0,3) == "err"){
		print "<H3>No match for your search!</H3>\n";
		print "<P>\n\t<STRONG>User:</STRONG> Please try adjusting the search criteria and/or changing the words.\n</P>";
	};
	
	$i++;
endwhile;
/******************************************/	
			
$i = $intPageOffset + $intPageOffsetCorrect;
while(substr($aryResults[$i],0,1) != "#" && substr($aryResults[$i],0,3) != "err" && $aryResults[$i] != "" && $aryResults[$i] != "." && $i <= $intPageOffset + $intPageOffsetCorrect + $intMaxHits):

	$strResultsClean = $aryResults[$i];
//	if (substr($strResultsClean,0,1) != "#" && substr($strResultsClean,0,3) != "err"){
//	if (!ereg("^#.*",$strResultsClean) && !ereg("^e.*",$strResultsClean) && $i >= $intPageOffset){

		//$strResultsClean String Format:
		// <RANK> <URL> "<TITLE>" <SIZE>
	
		// Array exploded on Double-Quote ("):
		// [RANK URL :0][TITLE:1][ SIZE:2] 
		/* Take note of evil whitespace in the array values,
		** which must be trimmed later.*/
		$aryResultLine = explode("\"", $strResultsClean);
		
		$j=0;
		while($aryResultLine[$j]):
			// Find the position, from begin, of the first space, then:
			// Rank is everything from begin to the first space trimming whitespace.
			$intResultRank = trim(substr($aryResultLine[0], 0, strpos($aryResultLine[0]," ")));
	
			/* URL everything following first space trimming whitespace.
			** Assuming file is under the DOCUMENT_ROOT directory somewhere.
			** If not, the file may not be found via HTTP...  However, 
			** if the indexer is configured correctly this is a 
			** waste of time.  Too easy of a mistake to ignore, though. */
	//			$strResultURL = trim(strstr($aryResultLine[0]," "));

			$strResultURL = ereg_replace($strSiteRootDir, "", trim(strstr($aryResultLine[0]," ")));


			// The rest is a piece of cake...
			if(trim($aryResultLine[1])){
				$strResultTitle = trim($aryResultLine[1]);
			}else {
				$strResultTitle = $strResultURL;
			};
			$intResultBytes = trim($aryResultLine[2]);
			
			// Attempt to grab data from each file
			if (count($aryMetaList) > 0) {
				unset($aryMetaTags);
				$strCurrentFile = $strSiteRootDir.$strResultURL ;
				if (file_exists($strCurrentFile) && $intGetFileData > 0) {
					// Get the META tags from the file
					$aryMetaTags = get_meta_tags($strCurrentFile);
					// Get the modification date stored in the file system
					$strResultModDate = gmdate("\M\o\d\i\f\i\e\d \a\\t H:i:s, \o\\n M d, Y \G\M\T", filemtime($strCurrentFile));
					// $aryMetaTags = get_meta_tags("/www/share/apache/htdocs/test/test.html");
				}
			}
			
			$j++;
		endwhile;

		print "\t<DT><A href=\"$strBaseURL$strResultURL\">$strResultTitle</A>\n";
		print "\t<DD>\n";
		fncDebug("Current File", $strCurrentFile, 4);
		reset ($aryMetaList);
		$p = 0;
		while($aryMetaList[$p]) {
			list ($strMetaName, $strLineHeading) = explode("|",$aryMetaList[$p]);
			if ($aryMetaTags["$strMetaName"]){print "\t\t$strLineHeading".$aryMetaTags["$strMetaName"]."<BR>\n";}
			$p++;
		};
		print "\t\t<SPAN style=\"Font-Size: 75%; Font-Weight:900;\">Score: $intResultRank, Size: $intResultBytes Bytes, $strResultModDate</SPAN><P>\n";
	$i++;
endwhile;

If ($intNumHits > 0) {print "</DL>\n";}

// Print out the Previous and Next buttons
If ($intNumHits > $intMaxHits) {
	print "<TABLE>\n<TR>\n";
	If ($intMaxHits < $intMaxHitsOffset){
		print "\t<TD>\n";
	    $intPrevVal = $intMaxHitsOffset - (2 * $intMaxHits);
		print "\t<FORM action=\"$strSelf\" method=\"POST\" name=\"frmPrev\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"do\" value=\"now\">\n";
/*
** Bug Fix JB: Parenthesis July 13, 1999
**		print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"". stripslashes($words) ."\">\n";
*/
		print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"".stripslashes(str_replace('"','',$words)) ."\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"strSearchSiteKey\" value=\"" . stripslashes($strSearchSiteKey) . "\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"intMaxHits\" value=\"$intMaxHits\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"intPageOffset\" value=\"$intPrevVal\">\n";
			// Print out Search delimiters to hidden fields.
			reset ($arySearchDelimiter);
			while (list($key,$val) = each($arySearchDelimiter)) {
				if (strstr($strLimit,$val)){print "\t\t<INPUT type=\"HIDDEN\" name=\"aryLimits[]\" value=\"$val\">\n";};
			};
		print "\t\t<INPUT type=\"SUBMIT\" name=\"prev$intMaxHits\" value=\"<< Previous $intMaxHits\">\n";
		print "\t</FORM>\n";
		print "\t</TD>\n";
	};

	If ($intNumHits > $intMaxHitsOffset){
	    if ( ( $intNumHits - $intPageHitsThru ) < $intMaxHits ) {
		    $intNextVal = ( $intNumHits - $intPageHitsThru );
		} else {
		    $intNextVal = $intMaxHits ;
		}
		print "\t<TD>\n";
		print "\t<FORM action=\"$strSelf\" method=\"POST\" name=\"frmNext\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"do\" value=\"now\">\n";

		print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"".stripslashes(str_replace('"','',$words)) ."\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"strSearchSiteKey\" value=\"" . stripslashes($strSearchSiteKey) . "\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"intMaxHits\" value=\"$intMaxHits\">\n";
		print "\t\t<INPUT type=\"HIDDEN\" name=\"intPageOffset\" value=\"$intMaxHitsOffset\">\n";
			// Print out Search delimiters to hidden fields.
			reset ($arySearchDelimiter);
			while (list($key,$val) = each($arySearchDelimiter)) {
				if (strstr($strLimit,$val)){print "\t\t<INPUT type=\"HIDDEN\" name=\"aryLimits[]\" value=\"$val\">\n";};
			};
		print "\t\t<INPUT type=\"SUBMIT\" name=\"next$intNextVal\" value=\"Next $intNextVal >>\">\n";
		print "\t</FORM>\n";
		print "\t</TD>\n";
	};
	print "\t</TR>\n</TABLE>\n";
};	
//Print the footer and exit
$intTimeComplete = time() - $intTimeBegan;
If ($intTimeComplete < 1){$intTimeComplete = "less than 1 second";}
Else {$intTimeComplete = $intTimeComplete." seconds";};
fncPrintFooter("<P>Search completed in $intTimeComplete.");
?>
 

totia1

Member
آقا saman اين كدهايي كه داديد براي پيدا كردن كلمه توي صفحه ويك سايت مناسبه ؟
سوال بعد اينكه چطوري بايد ازش استفاده كنم :oops:

سوال بعد اينكه search google بدرد من هم مي خوره يا نه :roll:
 

totia1

Member
saman
كد هايي را كه داديد توي يك فايل پي اچ پي سيو كردم وتوي روت سرورم گذاشتم :( ولي وقتي اجرا كردم اين خطا را داد ميدوني چرا :oops:
Fatal error: Failed opening required 'search.inc' (include_path='') in /home/www/saadabadpalace/test.php on line 4

اگر جواب مثبته لطفا راهنمايي كنيد :cry:
 

saman_sweden

Active Member
totia1 گفت:
saman
كد هايي را كه داديد توي يك فايل پي اچ پي سيو كردم وتوي روت سرورم گذاشتم :( ولي وقتي اجرا كردم اين خطا را داد ميدوني چرا :oops:
Fatal error: Failed opening required 'search.inc' (include_path='') in /home/www/saadabadpalace/test.php on line 4

اگر جواب مثبته لطفا راهنمايي كنيد :cry:
واقعيت من اينو سال 1998 تو تيمي برا شركتي كه اسم بردم نوشته بودم از اون تاريخ ببعد باش كار نكرده ام بايد يمقدار باتوحه به نوع سرورتان تغيير دهيد همون تو لاين 4 بايد مثلا آدرس سرور خودتان را بنويسيد كه حاي نقطه حين است
بيشتر از اين شرمنده ام
 

جدیدترین ارسال ها

بالا