Vergleich inc/functions_search.php - 1.8.20 - 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 436Zeile 514
	{
// Complex search
$keywords = " {$keywords} ";

	{
// Complex search
$keywords = " {$keywords} ";





		switch($db->type)

		switch($db->type)

		{

		{

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

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

				break;

				break;

			default:
$sfield = 'LOWER(subject)';
$mfield = 'LOWER(message)';
break;
}

			default:
$sfield = 'LOWER(subject)';
$mfield = 'LOWER(message)';
break;
}





		if(preg_match("#\s(and|or)\s#", $keywords))
{
$string = "AND";

		if(preg_match("#\s(and|or)\s#", $keywords))
{
$string = "AND";

Zeile 457Zeile 535
			{
$string = "OR";
$subject_lookin = " AND (";

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

			}

if($search['message'] == 1)

			}

if($search['message'] == 1)

			{
$message_lookin = " {$string} (";
}

			{
$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 484Zeile 562
						if(empty($word))
{
continue;

						if(empty($word))
{
continue;

						}

						}

						// 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"))
{

Zeile 493Zeile 571
								if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{
// We're looking for anything, check for a subject lookin

								if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{
// We're looking for anything, check for a subject lookin

									continue;

									continue;

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

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

								{

								{

									// Just in a subject?

									// Just in a subject?

									continue;
}

									continue;
}

								elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (")
{
// Just in a message?

								elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (")
{
// Just in a message?

Zeile 508Zeile 586
							}

$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 522Zeile 600

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


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

							{

							{

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

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

Zeile 531Zeile 609
							}
$boolean = 'AND';
}

							}
$boolean = 'AND';
}

					}
}

					}
}

				// 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 556Zeile 634
				if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{
// We're looking for anything, check for a subject lookin

				if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{
// We're looking for anything, check for a subject lookin

					$error = true;

					$error = true;

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

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

Zeile 653Zeile 731
	}

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

	}

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

	{

	{

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


		$search['folder'] = array($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)

							}
if($search['document'] == 1)
{
$document_lookin .= " $boolean {$dfield} LIKE '%{$word}%'";
}
}
}
}
// In the middle of a quote (phrase)

				else
{
$phrase = str_replace(array("+", "-", "*"), '', trim($phrase));

				else
{
$phrase = str_replace(array("+", "-", "*"), '', trim($phrase));

Zeile 872Zeile 950
					$error = true;
}
elseif($search['name'] && !$search['document'] && $name_lookin == " AND (")

					$error = true;
}
elseif($search['name'] && !$search['document'] && $name_lookin == " AND (")

				{

				{

					// Just in a name?

					// Just in a name?

					$error = true;

					$error = true;

				}
elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")

				}
elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")

				{

				{

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

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

				}

				}


if($error == true)
{


if($error == true)
{

Zeile 895Zeile 973
			if($search['name'] == 1)
{
$name_lookin .= ")";

			if($search['name'] == 1)
{
$name_lookin .= ")";

			}


			}


			if($search['document'] == 1)
{
$document_lookin .= ")";

			if($search['document'] == 1)
{
$document_lookin .= ")";

Zeile 944Zeile 1022
	if(count($helpdocs) < 1)
{
error($lang->error_nosearchresults);

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

	}

	}

	$helpdocs = implode(',', $helpdocs);

return array(

	$helpdocs = implode(',', $helpdocs);

return array(

Zeile 1017Zeile 1095
						if($i % 2 && ($word == "and" || $word == "or"))
{
if($i <= 1 && $subject_lookin == " AND (")

						if($i % 2 && ($word == "and" || $word == "or"))
{
if($i <= 1 && $subject_lookin == " AND (")

							{

							{

								continue;
}


								continue;
}


Zeile 1029Zeile 1107
							$word = trim($word);
// Word is too short - show error message
if(my_strlen($word) < $mybb->settings['minsearchword'])

							$word = trim($word);
// Word is too short - show error message
if(my_strlen($word) < $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 terms to search query
$subject_lookin .= " $boolean {$tfield} LIKE '%{$word}%'";
if($search['postthread'] == 1)

							// Add terms to search query
$subject_lookin .= " $boolean {$tfield} LIKE '%{$word}%'";
if($search['postthread'] == 1)

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

							}
$boolean = 'AND';
}

					}

					}

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

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

Zeile 1085Zeile 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 1095Zeile 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 1109Zeile 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 1178Zeile 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 1224Zeile 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 1259Zeile 1337
		elseif($search['visible'] == -1)
{
$visiblesql = " AND t.visible = '-1'";

		elseif($search['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'";





			if($search['postthread'] == 1)
{
$post_visiblesql = " AND p.visible == '0'";

			if($search['postthread'] == 1)
{
$post_visiblesql = " AND p.visible == '0'";

Zeile 1277Zeile 1355
			}
}
}

			}
}
}

 

// 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 = '';


// Searching a specific thread?
$tidsql = '';

Zeile 1303Zeile 1385
			$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))
{
$threads[$thread['tid']] = $thread['tid'];
if($thread['firstpost'])

				{$limitsql}
");
while($thread = $db->fetch_array($query))
{
$threads[$thread['tid']] = $thread['tid'];
if($thread['firstpost'])

				{

				{

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

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

Zeile 1320Zeile 1402
			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 1335Zeile 1417
		}
$threads = implode(',', $threads);
$posts = implode(',', $posts);

		}
$threads = implode(',', $threads);
$posts = implode(',', $posts);





	}
// Searching only thread titles
else

	}
// Searching only thread titles
else

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

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

	global $mybb, $db, $lang;

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

	
// 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 1438Zeile 1513
					$all_too_short = true;
}
else

					$all_too_short = true;
}
else

				{

				{

					$all_too_short = false;
break;
}

					$all_too_short = false;
break;
}

Zeile 1487Zeile 1562
			$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.")";

		}

		}

	}

	}

	$datecut = '';

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

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

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

Zeile 1598Zeile 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 1609Zeile 1684
			{
$post_visiblesql = " AND p.visible = '1'";
$plain_post_visiblesql = " AND visible = '1'";

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

			}

			}

		}
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'";

Zeile 1624Zeile 1699
		else
{
$visiblesql = " AND t.visible != '1'";

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





			if($search['postthread'] == 1)
{
$post_visiblesql = " AND p.visible != '1'";

			if($search['postthread'] == 1)
{
$post_visiblesql = " AND p.visible != '1'";

Zeile 1632Zeile 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 1657Zeile 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 1674Zeile 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))