1.SQL:
---------------------------------------------------------------------------------------
| 
---------------------------------------------------------------------------------------
ALTER TABLE 'word' CHANGE 'title' 'title' VARCHAR( 50 ) NOT NULL

(pGeШϥ ALTER TABLE 'eword' CHANGE 'title' 'title' VARCHAR( 50 ) NOT NULL )


2.sW]w
} http://www.A׾º}.com/admincp/options.php?do=addsetting&grouptitle=search
---------------------------------------------------------------------------------------
| ̧ǶJŮ
---------------------------------------------------------------------------------------
ܼƦW:searchposttable
]m:jﶵ
D:ҥPOSTjMҦ
yz:ҦNzLުAjMPOSTƪAĪGVBBؼҦTBs@ɥHָƮwϥζqAjƮw|yD`jtC<BR>`N!YܬjMҦAаȥʧRޥHŶ<BR>YאּؼҦAЭsإ߯ޡC
ﶵNX:yesno
q{(w]):0
ܶ 15


3.ק
}search.php
---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
	// #############################################################################
	// if query string is specified, check syntax and replace common syntax errors
	if ($query)
	{
	

| ᭱[W
---------------------------------------------------------------------------------------
		// 007pig
		$oriquery = $query;



---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
				if (verify_word_allowed($word))
				{
					// word is okay - add it to the list of NOT words to be queried
					$words['NOT']["$word"] = 'NOT';
					$queryWords["$word"] = &$words['NOT']["$word"];
				}

| N
---------------------------------------------------------------------------------------
				if (verify_word_allowed($word))
				{
					if ($vboptions['searchposttable']) {
						$words['NOT']["$word"] = 'NOT';
						$queryWords["$word"] = &$words['NOT']["$word"];
					} else {
						foreach (sp_str($word) as $word)
						{
							$words['NOT']["$word"] = 'NOT';
							$queryWords["$word"] = &$words['NOT']["$word"];
						}
					}
				}

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
					if (verify_word_allowed($orBit))
					{
						// word is okay - add it to the list of OR words for this clause
						$checkwords[] = $orBit;
					}

| N
---------------------------------------------------------------------------------------
					if (verify_word_allowed($orBit))
					{
						// word is okay - add it to the list of OR words for this clause
						// 007pig
						if ($vboptions['searchposttable']) {
							$checkwords[] = $orBit;
						} else {
							foreach (sp_str($orBit) as $orBit)
							{						
								$checkwords[] = $orBit;
							}
						}
					}
---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
		// #############################################################################
		// other words must be required (AND)


| ᭱[W
---------------------------------------------------------------------------------------

		// 007pig
		if (!$vboptions['searchposttable']) {
			$querysplit = implode(" ", sp_str($querysplit));
		}

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
	if ($phrasequery)
	{
		$words = array();
		$display['words'] = array(htmlspecialchars_uni('"' . $phrasequery . '"'));
		$display['common'] = array();
		$display['highlight'] = array(htmlspecialchars_uni($phrasequery));
		$query = '"' . $query . '"';
	}
	else
	{
		foreach ($words AS $wordtype => $searchwords)
		{
			switch($wordtype)
			{
				case 'AND':
					// do AND words
					foreach (array_keys($searchwords) AS $word)
					{
						$display['words'][] = $word;
					}
					break;
				case 'NOT':
					// do NOT words
					foreach (array_keys($searchwords) AS $word)
					{
						$display['words'][] = "</u></b>-<b><u>$word";
					}
					break;

				case 'OR':
					// do OR clauses
					foreach ($searchwords AS $orClause)
					{
						$or = array();
						foreach (array_keys($orClause) AS $orWord)
						{
							$or[] = $orWord;
						}
						$display['words'][] = implode('</u> OR <u>', $or);
					}
					break;

				default:
					// ignore COMMON words
			}
		}
	}
	

| N
---------------------------------------------------------------------------------------
	if ($phrasequery)
	{
		$words = array();
		$display['words'] = array(htmlspecialchars_uni('"' . $phrasequery . '"'));
		$display['common'] = array();
		$display['highlight'] = array(htmlspecialchars_uni($phrasequery));
		$query = '"' . $query . '"';
	}
	else
	{
		// 007pig
		$patterns[0] = "/\sOR\s/"; 
		$patterns[1] = "/\s-/"; 
		$patterns[2] = "/ /"; 
		$replacements[0] = "|||</u>OR<u>"; 
		$replacements[1] = "|||</u></b>-<b><u>"; 
		$replacements[2] = "|||"; 

		if($oriquery) $replacedwords = preg_replace($patterns, $replacements, sanitize_search_query($oriquery));
		$display['words'] = explode("|||", str_replace("</u>OR<u>", "</u> OR <u>", $replacedwords));
	}

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
				$getwords = $DB_site->query("
					SELECT wordid, title FROM " . TABLE_PREFIX . "word
					WHERE title LIKE('$queryword')
				");
				
				

| N
---------------------------------------------------------------------------------------

				if (!$vboptions['searchposttable']) {			
					$getwords = $DB_site->query("
						SELECT wordid, title FROM " . TABLE_PREFIX . "word
						WHERE title LIKE('$queryword')
					");
				}

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
				if ($DB_site->num_rows($getwords))
				

| N
---------------------------------------------------------------------------------------
				if ($vboptions['searchposttable'] || $DB_site->num_rows($getwords))


---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
					// found some results for current word
					$wordids = array();
					while ($getword = $DB_site->fetch_array($getwords))
					{
						$wordids[] = $getword['wordid'];
					}
					// query post ids for current word...
					// if $titleonly is specified, also get the value of postindex.intitle
					$postmatches = $DB_site->query("
						SELECT postid" . iif($titleonly, ', intitle') . iif($sortby == 'rank', ", score AS origscore,
							CASE intitle
								WHEN 1 THEN score + $vboptions[posttitlescore]
								WHEN 2 THEN score + $vboptions[posttitlescore] + $vboptions[threadtitlescore]
								ELSE score
							END AS score") . "
						FROM " . TABLE_PREFIX . "postindex
						WHERE wordid IN(" . implode(',', $wordids) . ")
					");
					

| N
---------------------------------------------------------------------------------------
					// query post ids for current word...
					// if $titleonly is specified, also get the value of postindex.intitle
					if (!$vboptions['searchposttable']) {				
						// found some results for current word
						$wordids = array();
						while ($getword = $DB_site->fetch_array($getwords))
						{
							$wordids[] = $getword['wordid'];
						}
						$postmatches = $DB_site->query("
							SELECT postid" . iif($titleonly, ', intitle') . iif($sortby == 'rank', ", score AS origscore,
								CASE intitle
									WHEN 1 THEN score + $vboptions[posttitlescore]
									WHEN 2 THEN score + $vboptions[posttitlescore] + $vboptions[threadtitlescore]
									ELSE score
								END AS score") . "
							FROM " . TABLE_PREFIX . "postindex
							WHERE wordid IN(" . implode(',', $wordids) . ")
						"); 
					} else {
						$postmatches = $DB_site->query("
						    SELECT postid
						    FROM " . TABLE_PREFIX . "post
						    WHERE title LIKE '%$word%'" . iif($titleonly == 0, " OR pagetext LIKE '%$word%'")
						);
					}

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
		// #############################################################################
		// get highlight words (part 2);
		foreach ($display['highlight'] AS $key => $word)
		{
			if (!isset($queryWords["$word"]))
			{
				unset($display['highlight']["$key"]);
			}
		}
		
		

| ᭱[W
---------------------------------------------------------------------------------------
		// #############################################################################
		// get highlight words (part3);
		if (!$vboptions['searchposttable'] && count($display['highlight']) % 2 == 0) 
		{
			if (!preg_match("/^[[:alpha:]]+$/", end($display['highlight']))) {
				$display['highlight']['temp'] = substr(end($display['highlight']), -2);
			}
		}

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------

					// check that word exists in the title
					if ($titleonly)

| N
---------------------------------------------------------------------------------------
					// check that word exists in the title
					if ($titleonly && !$vboptions['searchposttable'])

xsɮ!



}includes/functions_databuild.php
---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
// ###################### Start indexpost #######################
function build_post_index($postid, $foruminfo, $firstpost = -1, $post = false)
{
	global $vboptions;

	if ($vboptions['fulltextsearch'])
	{
		return;
	}

| N
---------------------------------------------------------------------------------------
// ###################### Start indexpost #######################
function build_post_index($postid, $foruminfo, $firstpost = -1, $post = false)
{
	global $vboptions;

	if ($vboptions['fulltextsearch'] || $vboptions['searchposttable'])
	{
		return;
	}


---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
			$words = fetch_postindex_text($threadinfo['title']);
			$allwords .= $words;
			$wordarray = explode(' ', $words);
			
			
| N
---------------------------------------------------------------------------------------
			$words = fetch_postindex_text($threadinfo['title']);
			// 007pig
			$wordarray = sp_str($words);
			$allwords .= implode(" ", $wordarray);
---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
		$words = fetch_postindex_text($post['title']);
		$allwords .= ' ' . $words;
		$wordarray = explode(' ', $words);
			
			
| N
---------------------------------------------------------------------------------------
		$words = fetch_postindex_text($post['title']);
		// 007pig
		$wordarray = sp_str($words);
		$allwords .= implode(" ", $wordarray);

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
		$words = fetch_postindex_text($post['pagetext']);
		$allwords .= ' ' . $words;
		$wordarray = explode(' ', $words);
			
			
| N
---------------------------------------------------------------------------------------
		$words = fetch_postindex_text($post['pagetext']);
		// 007pig
		$wordarray = sp_str($words);
		$allwords .= implode(" ", $wordarray);

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
	$text = strip_tags($text); // clean out HTML as it's probably not going to be indexed well anyway
			
			
| N
---------------------------------------------------------------------------------------
	//$text = strip_tags($text); // clean out HTML as it's probably not going to be indexed well anyway

---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
// ###################### Start unindexpost #######################
function delete_post_index($postid, $title = '', $pagetext = '')
{
	global $DB_site, $vboptions;

	if ($vboptions['fulltextsearch'])
	{
		return;
	}
			
			
| N
---------------------------------------------------------------------------------------
// ###################### Start unindexpost #######################
function delete_post_index($postid, $title = '', $pagetext = '')
{
	global $DB_site, $vboptions;

	if ($vboptions['fulltextsearch'] || $vboptions['searchposttable'])
	{
		return;
	}

xsɮ!



}includes/functions.php
---------------------------------------------------------------------------------------
| bɮץ
---------------------------------------------------------------------------------------
/*======================================================================*\
|| ####################################################################
|| # *
|| # CVS: $RCSfile: functions.php,v $ - $Revision: 1.944 $
|| ####################################################################
\*======================================================================*/
?>

e


| W[
---------------------------------------------------------------------------------------
// ###################### Gyk(bigram) #######################
// 007pig
function sp_str($str)
{
	// pGuOrAh^
	if (strlen($str) <= 3) {
		$ahz[] = $str;
		return $ahz;
	}
	
	$ahz = array();
	$search = array(",", "/", "\\", ".", ";", ":", "\"", "!", "~", "`", "^", "(", ")", "?", "-", "\t", "\n", "'", "<", ">", "\r", "\r\n", "$", "&", "%", "#", "@", "+", "=", "{", "}", "[", "]", "G", "^", "]", "D", "C", "A", "I", "F", "u", "v", "y", "z", "e", "f", "B", "X", "@", "m", "n", "", "K", "i", "j",);
	$str = str_replace($search," ",$str);
	$strarr = explode(" ", $str);

	foreach ($strarr as $str) 
	{
		if (preg_match("/^[[:alpha:]]+$/", $str)) {
			array_push($ahz, $str);
		} else {
			$n = strlen($str);
			$m = 0;
			$j = 0;
			$en = '';
			for($i=0;$i<$n;$i++)
			{
				if(ord($str[$i]) > 128)
				{	
					$hz[$m] = $str[$i].$str[$i+1];
					if($m > 0)
					{
						array_push($ahz, $hz[$m-1].$hz[$m]);
						$j++;
					}
					$m++;
					$i++;
					if (!empty($en)) {
						array_push($ahz, $en);
						$en='';
					}
				} 
				else 
				{
					$en .= $str[$i];
				}

			}

			$a_e = preg_split("/[\s,]+/",$en);
			$n_e = count($a_e);
			for($u = 0;$u < $n_e;$u++)
			{
				if(strlen($a_e[$u]) < 4 || strlen($a_e[$u]) > 50)
					continue;
				array_push($ahz, strtolower($a_e[$u]));
				$n_a++;
			}
			$en='';
		}
	}
	
	return $ahz;
}


xsɮ!

}includes/functions_showthread.php
---------------------------------------------------------------------------------------
| jM
---------------------------------------------------------------------------------------
// ###################### Start process_highlight_postbit #######################
function process_highlight_postbit($text, $words, $prepend)
{
	$text = str_replace('\"', '"', $text);
	foreach ($words AS $replaceword)
	{
		$text = preg_replace('#(?<=[\s"\]>()]|^)(' . $replaceword . ')(([.,:;-?!()\s"<\[]|$))#siU', '<span class="highlight">\\1</span>\\2', $text);
		//$text = preg_replace('#(?<=[^\w=])(' . $replaceword . ')(?=[^\w=])#siU', '<span class="highlight">\\1</span>', $text);
	}

	return "$prepend$text";
}
			
			
| N
---------------------------------------------------------------------------------------
// ###################### Start process_highlight_postbit #######################
function process_highlight_postbit($text, $words, $prepend)
{
	$text = str_replace('\"', '"', $text);
	foreach ($words AS $replaceword)
	{
		$text = str_replace($replaceword,  '<span class="highlight">'. $replaceword .'</span>', $text);
	}

	return "$prepend$text";
}



3./M
YzƮwwg峹AШ޲zO->ޤJ & @->spƾ->طjޡG
IuIo̲MšvMůޡAMIuطjޡvsطjޡC

쪩ɯŻ
pGzgw˹Lj 2.x AЦb^媩oXӤ󪺰¦WsקA 2.x קL search.php M functions_databuild.phpCíקfunctions.phpMfunctions_showthread.phpCMMůޡC