Vergleich inc/functions_search.php - 1.8.19 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 54Zeile 54
						$optionselected = '';
$selecteddone = "0";
}

						$optionselected = '';
$selecteddone = "0";
}

					if($forum['password'] != '')

					if(forum_password_validated($forum, true))

					{

					{

						if($mybb->cookies['forumpass'][$forum['fid']] === md5($mybb->user['uid'].$forum['password']))
{
$pwverified = 1;
}
else
{
$pwverified = 0;
}
}
if(empty($forum['password']) || $pwverified == 1)
{
eval("\$forumlistbits .= \"".$templates->get("search_forumlist_forum")."\";");

						eval("\$forumlistbits .= \"".$templates->get("search_forumlist_forum")."\";");












					}
if(!empty($pforumcache[$forum['fid']]))
{

					}
if(!empty($pforumcache[$forum['fid']]))
{

Zeile 77Zeile 66
				}
}
}

				}
}
}

	}

	}

	if($addselect)

	if($addselect)

	{
eval("\$forumlist = \"".$templates->get("search_forumlist")."\";");
}

	{
eval("\$forumlist = \"".$templates->get("search_forumlist")."\";");
}

	return $forumlist;
}

	return $forumlist;
}





/**
* Build a comma separated list of the forums this user cannot search
*

/**
* Build a comma separated list of the forums this user cannot search
*

Zeile 95Zeile 84
function get_unsearchable_forums($pid=0, $first=1)
{
global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;

function get_unsearchable_forums($pid=0, $first=1)
{
global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;





	$pid = (int)$pid;

if(!is_array($forum_cache))

	$pid = (int)$pid;

if(!is_array($forum_cache))

Zeile 103Zeile 92
		// Get Forums
$query = $db->simple_select("forums", "fid,parentlist,password,active", '', array('order_by' => 'pid, disporder'));
while($forum = $db->fetch_array($query))

		// Get Forums
$query = $db->simple_select("forums", "fid,parentlist,password,active", '', array('order_by' => 'pid, disporder'));
while($forum = $db->fetch_array($query))

		{

		{

			$forum_cache[$forum['fid']] = $forum;

			$forum_cache[$forum['fid']] = $forum;

		}

		}

	}
if(!is_array($permissioncache))
{

	}
if(!is_array($permissioncache))
{

Zeile 120Zeile 109
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

$pwverified = 1;
if($forum['password'] != '')
{
if(!isset($mybb->cookies['forumpass'][$forum['fid']]) || !my_hash_equals($mybb->cookies['forumpass'][$forum['fid']], md5($mybb->user['uid'].$forum['password'])))
{
$pwverified = 0;
}
}

		}











$parents = explode(",", $forum['parentlist']);
if(is_array($parents))


$parents = explode(",", $forum['parentlist']);
if(is_array($parents))

Zeile 143Zeile 123
			}
}


			}
}


		if($perms['canview'] != 1 || $perms['cansearch'] != 1 || $pwverified == 0 || $forum['active'] == 0)

		if($perms['canview'] != 1 || $perms['cansearch'] != 1 || !forum_password_validated($forum, true) || $forum['active'] == 0)

		{
if($unsearchableforums)
{

		{
if($unsearchableforums)
{

Zeile 168Zeile 148
	}

return $unsearchable;

	}

return $unsearchable;

 
}

/**
* Build query condition for threads/posts the user is allowed to see.
* Will return for example:
* - visible = 1 - for normal users
* - visible >= -1 - for admins & super mods
* - (visible = 1 OR (visible = ? AND fid IN ...)) - for forum moderators
*
* @param string $table_alias The alias of the table eg t to use t.visible instead of visible
* @return string the query condition
*/
function get_visible_where($table_alias = null)
{
global $db, $mybb;

$aliasdot = '';
if(!empty($table_alias))
{
$aliasdot = $table_alias.'.';
}

if($mybb->usergroup['issupermod'] == 1)
{
// Super moderators (and admins)
return "{$aliasdot}visible >= -1";
}
elseif(is_moderator())
{
// Normal moderators
$unapprove_forums = array();
$deleted_forums = array();
$unapproved_where = "({$aliasdot}visible = 1";

$moderated_fids = get_moderated_fids($mybb->user['uid']);

if($moderated_fids !== false)
{
foreach($moderated_fids as $fid)
{
if(!is_moderator($fid))
{
// Shouldn't occur.
continue;
}

// Use moderates this forum
$modperms = get_moderator_permissions($fid, $mybb->user['uid']);

if($modperms['canviewunapprove'] == 1)
{
$unapprove_forums[] = $fid;
}

if($modperms['canviewdeleted'] == 1)
{
$deleted_forums[] = $fid;
}
}

if(!empty($unapprove_forums))
{
$unapproved_where .= " OR ({$aliasdot}visible = 0 AND {$aliasdot}fid IN(".implode(',', $unapprove_forums)."))";
}
if(!empty($deleted_forums))
{
$unapproved_where .= " OR ({$aliasdot}visible = -1 AND {$aliasdot}fid IN(".implode(',', $deleted_forums)."))";
}
$unapproved_where .= ')';

return $unapproved_where;
}
}

// Normal users
if($mybb->user['uid'] > 0 && $mybb->settings['showownunapproved'] == 1)
{
return "({$aliasdot}visible = 1 OR ({$aliasdot}visible = 0 AND {$aliasdot}uid = {$mybb->user['uid']}))";
}
return "{$aliasdot}visible = 1";

}

/**

}

/**

Zeile 202Zeile 262
	$pass_fids = array();
foreach($fids as $fid)
{

	$pass_fids = array();
foreach($fids as $fid)
{

		if(empty($forum_cache[$fid]['password']))
{
continue;
}

if(md5($mybb->user['uid'].$forum_cache[$fid]['password']) !== $mybb->cookies['forumpass'][$fid])

		if(!forum_password_validated($forum_cache[$fid], true))






		{
$pass_fids[] = $fid;

		{
$pass_fids[] = $fid;

			$child_list = get_child_list($fid);
}

if(is_array($child_list))
{
$pass_fids = array_merge($pass_fids, $child_list);

			$pass_fids = array_merge($pass_fids, get_child_list($fid));






		}
}
return array_unique($pass_fids);

		}
}
return array_unique($pass_fids);

Zeile 229Zeile 279
 */
function clean_keywords($keywords)
{

 */
function clean_keywords($keywords)
{

	global $db;

	global $db, $lang;


$keywords = my_strtolower($keywords);
$keywords = $db->escape_string_like($keywords);


$keywords = my_strtolower($keywords);
$keywords = $db->escape_string_like($keywords);

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

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

 
		$keywords = " ".$keywords;

	}

if(my_strpos($keywords, "and") === 0)
{
$keywords = substr_replace($keywords, "", 0, 3);

	}

if(my_strpos($keywords, "and") === 0)
{
$keywords = substr_replace($keywords, "", 0, 3);

 
		$keywords = " ".$keywords;
}

if(!$keywords)
{
error($lang->error_nosearchterms);

	}

return $keywords;

	}

return $keywords;

Zeile 272Zeile 329
	// Separate braces for further processing
$keywords = preg_replace("#((\+|-|<|>|~)?\(|\))#s", " $1 ", $keywords);
$keywords = preg_replace("#\s+#s", " ", $keywords);

	// Separate braces for further processing
$keywords = preg_replace("#((\+|-|<|>|~)?\(|\))#s", " $1 ", $keywords);
$keywords = preg_replace("#\s+#s", " ", $keywords);

 

global $mybb;

$min_word_length = (int) $mybb->settings['minsearchword'];
if($min_word_length <= 0)
{
$min_word_length = 3;
}
$min_word_length -= 1;

$word_length_regex = '';
if($min_word_length > 1)
{
$word_length_regex = "{1,{$min_word_length}}";
}

// Replaces less than 3 characters
$keywords = preg_replace("/(\b.{$word_length_regex})(\s)|(\b.{$word_length_regex}$)/u", '$2', $keywords);
// Collapse multiple spaces
$keywords = preg_replace('/(\s)+/', '$1', $keywords);
$keywords = trim($keywords);


$words = array(array());



$words = array(array());


Zeile 296Zeile 374
				// Phrases do not need further processing
$words[$depth][] = "{$boolean[$depth]}\"{$phrase}\"";
$boolean[$depth] = $phrase_operator = '+';

				// Phrases do not need further processing
$words[$depth][] = "{$boolean[$depth]}\"{$phrase}\"";
$boolean[$depth] = $phrase_operator = '+';

			}

			}

			else
{
// Split words

			else
{
// Split words

Zeile 438Zeile 516
		$keywords = " {$keywords} ";

switch($db->type)

		$keywords = " {$keywords} ";

switch($db->type)

		{

		{

			case 'mysql':
case 'mysqli':
$sfield = 'subject';

			case 'mysql':
case 'mysqli':
$sfield = 'subject';

Zeile 449Zeile 527
				$mfield = 'LOWER(message)';
break;
}

				$mfield = 'LOWER(message)';
break;
}





		if(preg_match("#\s(and|or)\s#", $keywords))
{
$string = "AND";
if($search['subject'] == 1)

		if(preg_match("#\s(and|or)\s#", $keywords))
{
$string = "AND";
if($search['subject'] == 1)

			{

			{

				$string = "OR";
$subject_lookin = " AND (";
}


				$string = "OR";
$subject_lookin = " AND (";
}


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


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


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

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

Zeile 487Zeile 565
						}
// If this word is a search operator set the boolean
if($i % 2 && ($word == "and" || $word == "or"))

						}
// If this word is a search operator set the boolean
if($i % 2 && ($word == "and" || $word == "or"))

						{

						{

							if($i <= 1)
{
if($search['subject'] && $search['message'] && $subject_lookin == " AND (")

							if($i <= 1)
{
if($search['subject'] && $search['message'] && $subject_lookin == " AND (")

Zeile 535Zeile 613
				}
// In the middle of a quote (phrase)
else

				}
// In the middle of a quote (phrase)
else

				{

				{

					$phrase = str_replace(array("+", "-", "*"), '', trim($phrase));
if(my_strlen($phrase) < $mybb->settings['minsearchword'])

					$phrase = str_replace(array("+", "-", "*"), '', trim($phrase));
if(my_strlen($phrase) < $mybb->settings['minsearchword'])

					{

					{

						$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

						$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

					}

					}

					// Add phrase to search query
$subject_lookin .= " $boolean {$sfield} LIKE '%{$phrase}%'";
if($search['message'] == 1)

					// Add phrase to search query
$subject_lookin .= " $boolean {$sfield} LIKE '%{$phrase}%'";
if($search['message'] == 1)

Zeile 559Zeile 637
					$error = true;
}
elseif($search['subject'] && !$search['message'] && $subject_lookin == " AND (")

					$error = true;
}
elseif($search['subject'] && !$search['message'] && $subject_lookin == " AND (")

				{

				{

					// Just in a subject?

					// Just in a subject?

					$error = true;

					$error = true;

				}
elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (")

				}
elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (")

				{

				{

					// Just in a message?
$error = true;

					// Just in a message?
$error = true;

				}

				}


if($error == true)
{


if($error == true)
{

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

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

			}


			}


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

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

Zeile 653Zeile 731
	}

if(!is_array($search['folder']))

	}

if(!is_array($search['folder']))

	{
$search['folder'] = array($search['folder']);
}

	{
$search['folder'] = array($search['folder']);
}


if(!empty($search['folder']))
{


if(!empty($search['folder']))
{

Zeile 745Zeile 823
	{
$mybb->settings['minsearchword'] = 3;
}

	{
$mybb->settings['minsearchword'] = 3;
}





	$name_lookin = "";
$document_lookin = "";
$searchsql = "enabled='1'";

	$name_lookin = "";
$document_lookin = "";
$searchsql = "enabled='1'";

Zeile 814Zeile 892
								elseif($search['name'] && !$search['document'] && $name_lookin == " AND (")
{
// Just in a name?

								elseif($search['name'] && !$search['document'] && $name_lookin == " AND (")
{
// Just in a name?

									continue;
}

									continue;
}

								elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")
{
// Just in a document?
continue;
}

								elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")
{
// Just in a document?
continue;
}

							}

							}


$boolean = $word;


$boolean = $word;

						}

						}

						// Otherwise check the length of the word as it is a normal search term
else
{

						// Otherwise check the length of the word as it is a normal search term
else
{

Zeile 839Zeile 917
							if($search['name'] == 1)
{
$name_lookin .= " $boolean {$nfield} LIKE '%{$word}%'";

							if($search['name'] == 1)
{
$name_lookin .= " $boolean {$nfield} LIKE '%{$word}%'";

							}
if($search['document'] == 1)
{
$document_lookin .= " $boolean {$dfield} LIKE '%{$word}%'";
}
}
}
}
// In the middle of a quote (phrase)
else
{
$phrase = str_replace(array("+", "-", "*"), '', trim($phrase));

							}
if($search['document'] == 1)
{
$document_lookin .= " $boolean {$dfield} LIKE '%{$word}%'";
}
}
}
}
// In the middle of a quote (phrase)
else
{
$phrase = str_replace(array("+", "-", "*"), '', trim($phrase));

					if(my_strlen($phrase) < $mybb->settings['minsearchword'])
{
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);

					if(my_strlen($phrase) < $mybb->settings['minsearchword'])
{
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);

Zeile 874Zeile 952
				elseif($search['name'] && !$search['document'] && $name_lookin == " AND (")
{
// Just in a name?

				elseif($search['name'] && !$search['document'] && $name_lookin == " AND (")
{
// Just in a name?

					$error = true;
}

					$error = true;
}

				elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")
{
// Just in a document?

				elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")
{
// Just in a document?

Zeile 923Zeile 1001
				if($search['name'] == 1)
{
$searchsql .= " AND {$nfield} LIKE '%{$keywords}%'";

				if($search['name'] == 1)
{
$searchsql .= " AND {$nfield} LIKE '%{$keywords}%'";

				}


				}


				if($search['document'] == 1)
{
$searchsql .= " AND {$dfield} LIKE '%{$keywords}%'";

				if($search['document'] == 1)
{
$searchsql .= " AND {$dfield} LIKE '%{$keywords}%'";

Zeile 963Zeile 1041
	global $mybb, $db, $lang, $cache;

$keywords = clean_keywords($search['keywords']);

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

$keywords = clean_keywords($search['keywords']);

	if(!$keywords && !$search['author'])
{
error($lang->error_nosearchterms);
}

 

if($mybb->settings['minsearchword'] < 1)
{


if($mybb->settings['minsearchword'] < 1)
{

Zeile 1045Zeile 1119
							}
$boolean = 'AND';
}

							}
$boolean = 'AND';
}

					}
}

					}
}

				// In the middle of a quote (phrase)
else
{

				// In the middle of a quote (phrase)
else
{

Zeile 1089Zeile 1163
			if($search['postthread'] == 1)
{
$message_lookin = " AND {$pfield} LIKE '%{$keywords}%'";

			if($search['postthread'] == 1)
{
$message_lookin = " AND {$pfield} LIKE '%{$keywords}%'";

			}
}

			}
}

	}
$post_usersql = '';
$thread_usersql = '';

	}
$post_usersql = '';
$thread_usersql = '';

Zeile 1099Zeile 1173
		$userids = array();
$search['author'] = my_strtolower($search['author']);
if($search['matchusername'])

		$userids = array();
$search['author'] = my_strtolower($search['author']);
if($search['matchusername'])

		{

		{

			$user = get_user_by_username($search['author']);
if($user)

			$user = get_user_by_username($search['author']);
if($user)

			{

			{

				$userids[] = $user['uid'];
}
}

				$userids[] = $user['uid'];
}
}

Zeile 1113Zeile 1187
				case 'mysql':
case 'mysqli':
$field = 'username';

				case 'mysql':
case 'mysqli':
$field = 'username';

					break;

					break;

				default:
$field = 'LOWER(username)';
break;

				default:
$field = 'LOWER(username)';
break;

Zeile 1182Zeile 1256
		$thread_prefixcut .= " AND t.prefix='$threadprefix' ";
}
else

		$thread_prefixcut .= " AND t.prefix='$threadprefix' ";
}
else

	{

	{

		if(count($prefixlist) > 1)
{
$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")";

		if(count($prefixlist) > 1)
{
$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")";

Zeile 1228Zeile 1302
			if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;

			if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;

			}
}
}
if(!empty($onlyusfids))
{
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
}

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$permsql .= " AND t.fid NOT IN ($unsearchforums)";
}

			}
}
}
if(!empty($onlyusfids))
{
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
}

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$permsql .= " AND t.fid NOT IN ($unsearchforums)";
}

	$inactiveforums = get_inactive_forums();
if($inactiveforums)

	$inactiveforums = get_inactive_forums();
if($inactiveforums)

	{

	{

		$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}


		$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}


	$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";

	$visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = "";

	if(isset($search['visible']))
{
if($search['visible'] == 1)

	if(isset($search['visible']))
{
if($search['visible'] == 1)

Zeile 1261Zeile 1335
			}
}
elseif($search['visible'] == -1)

			}
}
elseif($search['visible'] == -1)

		{

		{

			$visiblesql = " AND t.visible = '-1'";

			$visiblesql = " AND t.visible = '-1'";


if($search['postthread'] == 1)
{


if($search['postthread'] == 1)
{

				$post_visiblesql = " AND p.visible = '-1'";
$plain_post_visiblesql = " AND visible = '-1'";

				$post_visiblesql = " AND p.visible = '-1'";
$plain_post_visiblesql = " AND visible = '-1'";

			}
}

			}
}

		else
{
$visiblesql = " AND t.visible == '0'";

		else
{
$visiblesql = " AND t.visible == '0'";

Zeile 1278Zeile 1352
			{
$post_visiblesql = " AND p.visible == '0'";
$plain_post_visiblesql = " AND visible == '0'";

			{
$post_visiblesql = " AND p.visible == '0'";
$plain_post_visiblesql = " AND visible == '0'";

			}
}
}





			}
}
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where_t = get_visible_where('t');
$unapproved_where_p = get_visible_where('p');


// Searching a specific thread?
$tidsql = '';
if(!empty($search['tid']))


// Searching a specific thread?
$tidsql = '';
if(!empty($search['tid']))

	{

	{

		$tidsql = " AND t.tid='".(int)$search['tid']."'";

		$tidsql = " AND t.tid='".(int)$search['tid']."'";

	}


	}


	$limitsql = '';
if((int)$mybb->settings['searchhardlimit'] > 0)
{

	$limitsql = '';
if((int)$mybb->settings['searchhardlimit'] > 0)
{

Zeile 1300Zeile 1378
	$posts = array();
$firstposts = array();
if($search['postthread'] == 1)

	$posts = array();
$firstposts = array();
if($search['postthread'] == 1)

	{

	{

		// No need to search subjects when looking for results within a specific thread
if(empty($search['tid']))
{
$query = $db->query("
SELECT t.tid, t.firstpost
FROM ".TABLE_PREFIX."threads t

		// No need to search subjects when looking for results within a specific thread
if(empty($search['tid']))
{
$query = $db->query("
SELECT t.tid, t.firstpost
FROM ".TABLE_PREFIX."threads t

				WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND t.closed NOT LIKE 'moved|%' {$subject_lookin}

				WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND ({$unapproved_where_t}) AND t.closed NOT LIKE 'moved|%' {$subject_lookin}

				{$limitsql}
");
while($thread = $db->fetch_array($query))

				{$limitsql}
");
while($thread = $db->fetch_array($query))

Zeile 1317Zeile 1395
				{
$posts[$thread['tid']] = $thread['firstpost'];
}

				{
$posts[$thread['tid']] = $thread['firstpost'];
}

			}
}

$query = $db->query("

			}
}

$query = $db->query("

			SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$visiblesql} {$post_visiblesql} AND t.closed NOT LIKE 'moved|%' {$message_lookin}

			WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$visiblesql} {$post_visiblesql} AND ({$unapproved_where_t}) AND ({$unapproved_where_p}) AND t.closed NOT LIKE 'moved|%' {$message_lookin}

			{$limitsql}
");
while($post = $db->fetch_array($query))

			{$limitsql}
");
while($post = $db->fetch_array($query))

Zeile 1393Zeile 1471
	global $mybb, $db, $lang;

$keywords = clean_keywords_ft($search['keywords']);

	global $mybb, $db, $lang;

$keywords = clean_keywords_ft($search['keywords']);

	if(!$keywords && !$search['author'])
{
error($lang->error_nosearchterms);
}

 




	// Attempt to determine minimum word length from MySQL for fulltext searches
$query = $db->query("SHOW VARIABLES LIKE 'ft_min_word_len';");
$min_length = $db->fetch_field($query, 'Value');
if(is_numeric($min_length))
{
$mybb->settings['minsearchword'] = $min_length;
}
// Otherwise, could not fetch - default back to MySQL fulltext default setting
else

	if($mybb->settings['minsearchword'] < 1)









	{
$mybb->settings['minsearchword'] = 4;
}


	{
$mybb->settings['minsearchword'] = 4;
}


 
	$message_lookin = $subject_lookin = '';

	if($keywords)
{
$keywords_exp = explode("\"", $keywords);

	if($keywords)
{
$keywords_exp = explode("\"", $keywords);

Zeile 1497Zeile 1564
			$thread_usersql = " AND t.uid IN (".$userids.")";
}
}

			$thread_usersql = " AND t.uid IN (".$userids.")";
}
}

	$datecut = '';

	$datecut = $thread_datecut = $post_datecut = '';

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

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

Zeile 1606Zeile 1673
		$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}


		$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}


	$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";

	$visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = "";

	if(isset($search['visible']))
{
if($search['visible'] == 1)

	if(isset($search['visible']))
{
if($search['visible'] == 1)

Zeile 1640Zeile 1707
			}
}
}

			}
}
}

 

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where_t = get_visible_where('t');
$unapproved_where_p = get_visible_where('p');


// Searching a specific thread?


// Searching a specific thread?

 
	$tidsql = '';

	if($search['tid'])
{
$tidsql = " AND t.tid='".(int)$search['tid']."'";

	if($search['tid'])
{
$tidsql = " AND t.tid='".(int)$search['tid']."'";

Zeile 1665Zeile 1737
			$query = $db->query("
SELECT t.tid, t.firstpost
FROM ".TABLE_PREFIX."threads t

			$query = $db->query("
SELECT t.tid, t.firstpost
FROM ".TABLE_PREFIX."threads t

				WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND t.closed NOT LIKE 'moved|%' {$subject_lookin}

				WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND ({$unapproved_where_t}) AND t.closed NOT LIKE 'moved|%' {$subject_lookin}

				{$limitsql}
");
while($thread = $db->fetch_array($query))

				{$limitsql}
");
while($thread = $db->fetch_array($query))

Zeile 1682Zeile 1754
			SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$post_visiblesql} {$visiblesql} AND t.closed NOT LIKE 'moved|%' {$message_lookin}

			WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$post_visiblesql} {$visiblesql} AND ({$unapproved_where_t}) AND {$unapproved_where_p} AND t.closed NOT LIKE 'moved|%' {$message_lookin}

			{$limitsql}
");
while($post = $db->fetch_array($query))

			{$limitsql}
");
while($post = $db->fetch_array($query))