Vergleich inc/functions_search.php - 1.6.0 - 1.6.2

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 238Zeile 238
	$keywords = preg_replace("#\s+#s", " ", $keywords);

// Search for "and" or "or" and remove if it's at the beginning

	$keywords = preg_replace("#\s+#s", " ", $keywords);

// Search for "and" or "or" and remove if it's at the beginning

 
	$keywords = trim($keywords);

	if(my_strpos($keywords, "or") === 0)
{
$keywords = substr_replace($keywords, "", 0, 2);

	if(my_strpos($keywords, "or") === 0)
{
$keywords = substr_replace($keywords, "", 0, 2);

Zeile 248Zeile 249
		$keywords = substr_replace($keywords, "", 0, 3);
}


		$keywords = substr_replace($keywords, "", 0, 3);
}


	return trim($keywords);

	return $keywords;

}

/**

}

/**

Zeile 289Zeile 290
					if(!is_array($split_words))
{
continue;

					if(!is_array($split_words))
{
continue;

					}

					}

					foreach($split_words as $word)
{
if(!$word)

					foreach($split_words as $word)
{
if(!$word)

Zeile 313Zeile 314
		foreach($split_words as $word)
{
if(!$word)

		foreach($split_words as $word)
{
if(!$word)

			{

			{

				continue;
}
$words[] = trim($word);

				continue;
}
$words[] = trim($word);

Zeile 334Zeile 335
		elseif($word == "not")
{
$boolean = "-";

		elseif($word == "not")
{
$boolean = "-";

		}

		}

		else
{
$keywords .= " ".$boolean.$word;

		else
{
$keywords .= " ".$boolean.$word;

Zeile 370Zeile 371
	
$subject_lookin = "";
$message_lookin = "";

	
$subject_lookin = "";
$message_lookin = "";

	$searchsql = "uid='{$mybb->user['uid']}'";

if($keywords)
{
// Complex search
$keywords = " {$keywords} ";
if(preg_match("# and|or #", $keywords))
{
$subject_lookin = " AND (";
$message_lookin = " AND (";










	$searchsql = "uid='{$mybb->user['uid']}'";

if($keywords)
{
// Complex search
$keywords = " {$keywords} ";
if(preg_match("# and|or #", $keywords))
{
$string = "AND";
if($search['subject'] == 1)
{
$string = "OR";
$subject_lookin = " AND (";
}

if($search['message'] == 1)
{
$message_lookin = " {$string} (";
}

			
// Expand the string by double quotes
$keywords_exp = explode("\"", $keywords);

			
// Expand the string by double quotes
$keywords_exp = explode("\"", $keywords);

Zeile 418Zeile 428
							}
// Add terms to search query
if($search['subject'] == 1)

							}
// Add terms to search query
if($search['subject'] == 1)

							{

							{

								$subject_lookin .= " $boolean LOWER(subject) LIKE '%{$word}%'";
}
if($search['message'] == 1)
{

								$subject_lookin .= " $boolean LOWER(subject) LIKE '%{$word}%'";
}
if($search['message'] == 1)
{

								$searchsql .= " $boolean LOWER(message) LIKE '%{$word}%'";

								$message_lookin .= " $boolean LOWER(message) LIKE '%{$word}%'";

							}
}
}

							}
}
}

Zeile 442Zeile 452
					if($search['message'] == 1)
{
$message_lookin .= " $boolean LOWER(message) LIKE '%{$phrase}%'";

					if($search['message'] == 1)
{
$message_lookin .= " $boolean LOWER(message) LIKE '%{$phrase}%'";

					}					
}

					}					
}

				$inquote = !$inquote;
}

				$inquote = !$inquote;
}

			$subject_lookin .= ")";
$message_lookin .= ")";











if($search['subject'] == 1)
{
$subject_lookin .= ")";
}

if($search['message'] == 1)
{
$message_lookin .= ")";
}


			$searchsql .= "{$subject_lookin} {$message_lookin}";
}
else

			$searchsql .= "{$subject_lookin} {$message_lookin}";
}
else

Zeile 576Zeile 594
 */
function perform_search_mysql($search)
{

 */
function perform_search_mysql($search)
{

	global $mybb, $db, $lang;

	global $mybb, $db, $lang, $cache;


$keywords = clean_keywords($search['keywords']);
if(!$keywords && !$search['author'])


$keywords = clean_keywords($search['keywords']);
if(!$keywords && !$search['author'])

Zeile 699Zeile 717
		if(count($userids) < 1)
{
error($lang->error_nosearchresults);

		if(count($userids) < 1)
{
error($lang->error_nosearchresults);

		}
else
{

		}
else
{

			$userids = implode(',', $userids);
$post_usersql = " AND p.uid IN (".$userids.")";
$thread_usersql = " AND t.uid IN (".$userids.")";

			$userids = implode(',', $userids);
$post_usersql = " AND p.uid IN (".$userids.")";
$thread_usersql = " AND t.uid IN (".$userids.")";

Zeile 709Zeile 727
	}
$datecut = '';
if($search['postdate'])

	}
$datecut = '';
if($search['postdate'])

	{

	{

		if($search['pddir'] == 0)

		if($search['pddir'] == 0)

		{

		{

			$datecut = "<=";
}
else
{
$datecut = ">=";

			$datecut = "<=";
}
else
{
$datecut = ">=";

		}

		}

		$now = TIME_NOW;
$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";

		$now = TIME_NOW;
$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";

Zeile 733Zeile 751
			$thread_replycut = " AND t.replies >= '".intval($search['numreplies'])."'";
}
else

			$thread_replycut = " AND t.replies >= '".intval($search['numreplies'])."'";
}
else

		{

		{

			$thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'";
}
}

			$thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'";
}
}

Zeile 758Zeile 776
		if($mybb->user['additionalgroups'])
{
$user_groups .= ",".$mybb->user['additionalgroups'];

		if($mybb->user['additionalgroups'])
{
$user_groups .= ",".$mybb->user['additionalgroups'];

 

// Setup some quick permissions for us
$fcache = $cache->read("forumpermissions");
$add_groups = explode(",", $mybb->user['additionalgroups']);

		}
foreach($search['forums'] as $forum)
{
$forum = intval($forum);
if(!$searchin[$forum])
{

		}
foreach($search['forums'] as $forum)
{
$forum = intval($forum);
if(!$searchin[$forum])
{

				switch($db->type)

				if(is_array($add_groups))

				{

				{

					case "pgsql":
$query = $db->query("
SELECT DISTINCT f.fid
FROM ".TABLE_PREFIX."forums f
LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups."))
WHERE (','||parentlist||',' LIKE ',%{$forum}%,') = true AND active!=0 AND (p.fid IS NULL OR p.cansearch=1)
");
break;
case "sqlite":
$query = $db->query("
SELECT DISTINCT f.fid
FROM ".TABLE_PREFIX."forums f
LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups."))
WHERE (','||parentlist||',' LIKE ',%{$forum}%,') > 0 AND active!=0 AND (p.fid = NULL OR p.cansearch=1)
");
break;
default:
$query = $db->query("
SELECT DISTINCT f.fid
FROM ".TABLE_PREFIX."forums f
LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups."))
WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!=0 AND (ISNULL(p.fid) OR p.cansearch=1)
");

					$can_search = 0;
foreach($add_groups as $add_group)
{
// Check to make sure that we have sufficient permissions to search this forum
if(!is_array($fcache[$forum][$add_group]) || $fcache[$forum][$add_group]['cansearch'] == 1 || $mybb->usergroup['cansearch'] == 1)
{
$can_search = 1;
}
}

if($can_search == 0)
{
// We can't search this forum...
continue;
}









				}

				}

 

switch($db->type)
{
case "pgsql":
$query = $db->simple_select("forums", "DISTINCT fid", "(','||parentlist||',' LIKE ',%{$forum}%,') = true AND active != 0");
break;
case "sqlite":
$query = $db->simple_select("forums", "DISTINCT fid", "(','||parentlist||',' LIKE ',%{$forum}%,') > 0 AND active != 0");
break;
default:
$query = $db->simple_select("forums", "DISTINCT fid", "INSTR(CONCAT(',',parentlist,','),',{$forum},') > 0 AND active != 0");
}


				while($sforum = $db->fetch_array($query))
{
$fidlist[] = $sforum['fid'];

				while($sforum = $db->fetch_array($query))
{
$fidlist[] = $sforum['fid'];