Vergleich inc/functions_search.php - 1.8.20 - 1.8.38

  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 94Zeile 83
 */
function get_unsearchable_forums($pid=0, $first=1)
{

 */
function get_unsearchable_forums($pid=0, $first=1)
{

	global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;

	global $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;


$pid = (int)$pid;

if(!is_array($forum_cache))
{


$pid = (int)$pid;

if(!is_array($forum_cache))
{

		// 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;
}

		cache_forums();






	}
if(!is_array($permissioncache))
{

	}
if(!is_array($permissioncache))
{

Zeile 120Zeile 104
		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))

		{

		{

			foreach($parents as $parent)
{
if($forum_cache[$parent]['active'] == 0)

			foreach($parents as $parent)
{
if($forum_cache[$parent]['active'] == 0)

Zeile 143Zeile 118
			}
}


			}
}


		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 143
	}

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 197Zeile 252
	if(empty($fids))
{
$fids = array_keys($forum_cache);

	if(empty($fids))
{
$fids = array_keys($forum_cache);

	}


	}


	$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 274
 */
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 288
	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 324
	// 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 282Zeile 355
	// Brace depth
$depth = 0;
$phrase_operator = '+';

	// Brace depth
$depth = 0;
$phrase_operator = '+';

 
	$inquote = false;

	foreach($keywords as $phrase)
{
$phrase = trim($phrase);
if($phrase != '')
{
if($inquote)

	foreach($keywords as $phrase)
{
$phrase = trim($phrase);
if($phrase != '')
{
if($inquote)

			{

			{

				if($phrase_operator)

				if($phrase_operator)

				{

				{

					$boolean[$depth] = $phrase_operator;
}
// Phrases do not need further processing

					$boolean[$depth] = $phrase_operator;
}
// Phrases do not need further processing

Zeile 302Zeile 376
				// Split words
$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))

				// Split words
$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))

				{

				{

					continue;
}
if(!$inquote)

					continue;
}
if(!$inquote)

Zeile 312Zeile 386
					if($last_char == '+' || $last_char == '-' || $last_char == '<' || $last_char == '>' || $last_char == '~')
{
$phrase_operator = $last_char;

					if($last_char == '+' || $last_char == '-' || $last_char == '<' || $last_char == '>' || $last_char == '~')
{
$phrase_operator = $last_char;

					}

					}

				}
foreach($split_words as $word)
{

				}
foreach($split_words as $word)
{

Zeile 332Zeile 406
						}
}
elseif($word == "and")

						}
}
elseif($word == "and")

					{

					{

						$boolean[$depth] = "+";
}
elseif($word == "not")

						$boolean[$depth] = "+";
}
elseif($word == "not")

					{

					{

						$boolean[$depth] = "-";
}
// Closing braces

						$boolean[$depth] = "-";
}
// Closing braces

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

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

			}

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

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

			}

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

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

			$boolean = '';

foreach($keywords_exp as $phrase)

			$boolean = '';

foreach($keywords_exp as $phrase)

Zeile 482Zeile 556
					{
$word = trim($matches[$i]);
if(empty($word))

					{
$word = trim($matches[$i]);
if(empty($word))

						{

						{

							continue;
}
// If this word is a search operator set the boolean

							continue;
}
// If this word is a search operator set the boolean

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

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

								{

								{

									// We're looking for anything, check for a subject lookin

									// We're looking for anything, check for a subject lookin

									continue;
}

									continue;
}

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

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

Zeile 515Zeile 589
							$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);
}

Zeile 564Zeile 638
					$error = true;
}
elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (")

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

				{

				{

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

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

Zeile 575Zeile 649
					$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);
}





				$inquote = !$inquote;

				$inquote = !$inquote;

			}


			}


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

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

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

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

			}


			}


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

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

Zeile 637Zeile 711
		}
$query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'");
while($user = $db->fetch_array($query))

		}
$query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'");
while($user = $db->fetch_array($query))

		{

		{

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

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

		}

		}


if(count($userids) < 1)


if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);
}
else

			error($lang->error_nosearchresults);
}
else

Zeile 650Zeile 724
			$userids = implode(',', $userids);
$searchsql .= " AND fromid IN (".$userids.")";
}

			$userids = implode(',', $userids);
$searchsql .= " AND fromid IN (".$userids.")";
}

	}


	}


	if(!is_array($search['folder']))
{
$search['folder'] = array($search['folder']);

	if(!is_array($search['folder']))
{
$search['folder'] = array($search['folder']);

Zeile 661Zeile 735
	{
$folderids = array();


	{
$folderids = array();


		$search['folder'] = array_map("intval", $search['folder']);


		$search['folder'] = array_map("intval", $search['folder']);


		$folderids = implode(',', $search['folder']);

if($folderids)

		$folderids = implode(',', $search['folder']);

if($folderids)

Zeile 675Zeile 749
	{
$searchsql .= " AND (";
if($search['status']['new'])

	{
$searchsql .= " AND (";
if($search['status']['new'])

		{

		{

			$statussql[] = " status='0' ";

			$statussql[] = " status='0' ";

		}

		}

		if($search['status']['replied'])
{
$statussql[] = " status='3' ";
}
if($search['status']['forwarded'])

		if($search['status']['replied'])
{
$statussql[] = " status='3' ";
}
if($search['status']['forwarded'])

		{

		{

			$statussql[] = " status='4' ";

			$statussql[] = " status='4' ";

		}

		}

		if($search['status']['read'])
{
$statussql[] = " (status != '0' AND readtime > '0') ";

		if($search['status']['read'])
{
$statussql[] = " (status != '0' AND readtime > '0') ";

Zeile 705Zeile 779
		$limitsql = " LIMIT ".(int)$mybb->settings['searchhardlimit'];
}
$searchsql .= $limitsql;

		$limitsql = " LIMIT ".(int)$mybb->settings['searchhardlimit'];
}
$searchsql .= $limitsql;





	// Run the search
$pms = array();
$query = $db->simple_select("privatemessages", "pmid", $searchsql);

	// Run the search
$pms = array();
$query = $db->simple_select("privatemessages", "pmid", $searchsql);

Zeile 749Zeile 823
	$name_lookin = "";
$document_lookin = "";
$searchsql = "enabled='1'";

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





	if($keywords)
{
switch($db->type)

	if($keywords)
{
switch($db->type)

Zeile 839Zeile 913
							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(my_strlen($phrase) < $mybb->settings['minsearchword'])
{
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);
}
// Add phrase to search query

							}
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']);
error($lang->error_minsearchlength);
}
// Add phrase to search query

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

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

Zeile 869Zeile 943
				if($search['name'] && $search['document'] && $name_lookin == " AND (")
{
// We're looking for anything, check for a name lookin

				if($search['name'] && $search['document'] && $name_lookin == " AND (")
{
// We're looking for anything, check for a name lookin

					$error = true;

					$error = true;

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

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

				{

				{

					// Just in a name?
$error = true;
}

					// Just in a name?
$error = true;
}

Zeile 880Zeile 954
				{
// Just in a document?
$error = true;

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

				}


				}


				if($error == true)
{
// There are no search keywords to look for

				if($error == true)
{
// There are no search keywords to look for

Zeile 890Zeile 964
				}

$inquote = !$inquote;

				}

$inquote = !$inquote;

			}

			}


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


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

			{

			{

				$name_lookin .= ")";

				$name_lookin .= ")";

			}


			}


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

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

Zeile 905Zeile 979
			$searchsql .= "{$name_lookin} {$document_lookin}";
}
else

			$searchsql .= "{$name_lookin} {$document_lookin}";
}
else

		{

		{

			$keywords = str_replace("\"", '', trim($keywords));
if(my_strlen($keywords) < $mybb->settings['minsearchword'])
{
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

			$keywords = str_replace("\"", '', trim($keywords));
if(my_strlen($keywords) < $mybb->settings['minsearchword'])
{
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

			}


			}


			// If we're looking in both, then find matches in either the name or the document
if($search['name'] == 1 && $search['document'] == 1)

			// If we're looking in both, then find matches in either the name or the document
if($search['name'] == 1 && $search['document'] == 1)

			{

			{

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

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

				{

				{

					$searchsql .= " AND {$nfield} LIKE '%{$keywords}%'";
}


					$searchsql .= " AND {$nfield} LIKE '%{$keywords}%'";
}


Zeile 930Zeile 1004
					$searchsql .= " AND {$dfield} LIKE '%{$keywords}%'";
}
}

					$searchsql .= " AND {$dfield} LIKE '%{$keywords}%'";
}
}

		}

		}

	}

// Run the search

	}

// Run the search

Zeile 978Zeile 1052
			case 'mysqli':
$tfield = 't.subject';
$pfield = 'p.message';

			case 'mysqli':
$tfield = 't.subject';
$pfield = 'p.message';

				break;

				break;

			default:
$tfield = 'LOWER(t.subject)';
$pfield = 'LOWER(p.message)';

			default:
$tfield = 'LOWER(t.subject)';
$pfield = 'LOWER(p.message)';

Zeile 1051Zeile 1125
					{
$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 {$tfield} LIKE '%{$phrase}%'";
if($search['postthread'] == 1)

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

Zeile 1059Zeile 1133
						$message_lookin .= " $boolean {$pfield} LIKE '%{$phrase}%'";
}
$boolean = 'AND';

						$message_lookin .= " $boolean {$pfield} LIKE '%{$phrase}%'";
}
$boolean = 'AND';

				}

				}


if($subject_lookin == " AND (")
{


if($subject_lookin == " AND (")
{

Zeile 1072Zeile 1146
			}
$subject_lookin .= ")";
$message_lookin .= ")";

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

		}

		}

		else
{
$keywords = str_replace("\"", '', trim($keywords));

		else
{
$keywords = str_replace("\"", '', trim($keywords));

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

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

		{

		{

			$datecut = "<=";

			$datecut = "<=";

		}

		}

		else
{
$datecut = ">=";

		else
{
$datecut = ">=";

Zeile 1158Zeile 1232
			$thread_replycut = " AND t.replies >= '".(int)$search['numreplies']."'";
}
else

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

		{

		{

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

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

		}

		}

	}

$thread_prefixcut = '';
$prefixlist = array();

	}

$thread_prefixcut = '';
$prefixlist = array();

	if($search['threadprefix'] && $search['threadprefix'][0] != 'any')
{

	if(!empty($search['threadprefix']) && $search['threadprefix'][0] != 'any')
{

		foreach($search['threadprefix'] as $threadprefix)
{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;
}

		foreach($search['threadprefix'] as $threadprefix)
{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;
}

	}

	}

	if(count($prefixlist) == 1)

	if(count($prefixlist) == 1)

	{

	{

		$thread_prefixcut .= " AND t.prefix='$threadprefix' ";
}
else
{
if(count($prefixlist) > 1)

		$thread_prefixcut .= " AND t.prefix='$threadprefix' ";
}
else
{
if(count($prefixlist) > 1)

		{

		{

			$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")";
}
}

			$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")";
}
}

Zeile 1224Zeile 1298
			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)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}

$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";
if(isset($search['visible']))
{
if($search['visible'] == 1)
{
$visiblesql = " AND t.visible = '1'";

			}
}
}
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)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}

$visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = "";
if(isset($search['visible']))
{
if($search['visible'] == 1)
{
$visiblesql = " AND t.visible = '1'";


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


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

Zeile 1277Zeile 1351
			}
}
}

			}
}
}

 

// 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']))
{
$tidsql = " AND t.tid='".(int)$search['tid']."'";


// Searching a specific thread?
$tidsql = '';
if(!empty($search['tid']))
{
$tidsql = " AND t.tid='".(int)$search['tid']."'";

	}


	}


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

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

Zeile 1303Zeile 1381
			$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 1320Zeile 1398
			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}
{$limitsql}

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

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

Zeile 1357Zeile 1435
		if(count($threads) < 1)
{
error($lang->error_nosearchresults);

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

		}

		}


$threads = implode(',', $threads);
$firstposts = implode(',', $firstposts);


$threads = implode(',', $threads);
$firstposts = implode(',', $firstposts);

Zeile 1389Zeile 1467
	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 1456Zeile 1527
	}
$post_usersql = '';
$thread_usersql = '';

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

	if($search['author'])

	if(!empty($search['author']))

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

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

Zeile 1464Zeile 1535
		{
$user = get_user_by_username($search['author']);
if($user)

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

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

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

		else
{
$query = $db->simple_select("users", "uid", "username LIKE '%".$db->escape_string_like($search['author'])."%'");

		else
{
$query = $db->simple_select("users", "uid", "username LIKE '%".$db->escape_string_like($search['author'])."%'");

Zeile 1479Zeile 1550
		}

if(count($userids) < 1)

		}

if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);

			error($lang->error_nosearchresults);

		}

		}

		else
{
$userids = implode(',', $userids);

		else
{
$userids = implode(',', $userids);

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

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

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

	$datecut = $thread_datecut = $post_datecut = '';
if(!empty($search['postdate']))

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

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

Zeile 1508Zeile 1579
	}

$thread_replycut = '';

	}

$thread_replycut = '';

	if($search['numreplies'] != '' && $search['findthreadst'])

	if(!empty($search['numreplies']) && $search['findthreadst'])

	{
if((int)$search['findthreadst'] == 1)

	{
if((int)$search['findthreadst'] == 1)

		{

		{

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

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

		}

		}

		else

		else

		{

		{

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

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

		}

		}

	}

$thread_prefixcut = '';
$prefixlist = array();

	}

$thread_prefixcut = '';
$prefixlist = array();

	if($search['threadprefix'] && $search['threadprefix'][0] != 'any')

	if(!empty($search['threadprefix']) && $search['threadprefix'][0] != 'any')

	{
foreach($search['threadprefix'] as $threadprefix)
{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;

	{
foreach($search['threadprefix'] as $threadprefix)
{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;

		}
}

		}
}

	if(count($prefixlist) == 1)
{
$thread_prefixcut .= " AND t.prefix='$threadprefix' ";

	if(count($prefixlist) == 1)
{
$thread_prefixcut .= " AND t.prefix='$threadprefix' ";

Zeile 1576Zeile 1647
	// Check group permissions if we can't view threads not started by us
$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)

	// Check group permissions if we can't view threads not started by us
$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)

	{
if($forum_permissions['canonlyviewownthreads'] == 1)
{

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

			$onlyusfids[] = $fid;
}
}

			$onlyusfids[] = $fid;
}
}

Zeile 1598Zeile 1669
		$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 1632Zeile 1703
			}
}
}

			}
}
}

 

// 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?

	if($search['tid'])


	$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 1652Zeile 1728
	if($search['postthread'] == 1)
{
// No need to search subjects when looking for results within a specific thread

	if($search['postthread'] == 1)
{
// No need to search subjects when looking for results within a specific thread

		if(!$search['tid'])

		if(empty($search['tid']))

		{
$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 1750
			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))