Vergleich inc/functions_search.php - 1.8.2 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 11Zeile 11
/**
* Build a select box list of forums the current user has permission to search
*

/**
* Build a select box list of forums the current user has permission to search
*

 * @param int The parent forum ID to start at
* @param int The selected forum ID
* @param int Add select boxes at this call or not
* @param int The current depth

 * @param int $pid The parent forum ID to start at
* @param int $selitem The selected forum ID
* @param int $addselect Add select boxes at this call or not
* @param string $depth The current depth

 * @return string The forum select boxes
*/

 * @return string The forum select boxes
*/

function make_searchable_forums($pid="0", $selitem='', $addselect="1", $depth='')

function make_searchable_forums($pid=0, $selitem=0, $addselect=1, $depth='')

{
global $db, $pforumcache, $permissioncache, $mybb, $selecteddone, $forumlist, $forumlistbits, $theme, $templates, $lang, $forumpass;
$pid = (int)$pid;

{
global $db, $pforumcache, $permissioncache, $mybb, $selecteddone, $forumlist, $forumlistbits, $theme, $templates, $lang, $forumpass;
$pid = (int)$pid;

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)
{
eval("\$forumlist = \"".$templates->get("search_forumlist")."\";");

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

	}

	}

	return $forumlist;
}

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

	return $forumlist;
}

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

 * @param int The parent ID to build from
* @param int First rotation or not (leave at default)
* @return return a CSV list of forums the user cannot search

 * @param int $pid The parent ID to build from
* @param int $first First rotation or not (leave at default)
* @return string return a CSV list of forums the user cannot search

 */

 */

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))
{
$permissioncache = forum_permissions();

	}
if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();

	}

	}

	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

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

		else
{
$perms = $mybb->usergroup;

		}

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

 
		}

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

		}

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

			{

			{

				if($forum_cache[$parent]['active'] == 0)
{
$forum['active'] = 0;
}

				if($forum_cache[$parent]['active'] == 0)
{
$forum['active'] = 0;
}

			}
}

			}
}





		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 153Zeile 128
		}
}
$unsearchable = $unsearchableforums;

		}
}
$unsearchable = $unsearchableforums;





	// Get our unsearchable password protected forums
$pass_protected_forums = get_password_protected_forums();

if($unsearchable && $pass_protected_forums)

	// Get our unsearchable password protected forums
$pass_protected_forums = get_password_protected_forums();

if($unsearchable && $pass_protected_forums)

	{

	{

		$unsearchable .= ",";

		$unsearchable .= ",";

	}


	}


	if($pass_protected_forums)

	if($pass_protected_forums)

	{

	{

		$unsearchable .= implode(",", $pass_protected_forums);

		$unsearchable .= implode(",", $pass_protected_forums);

	}


	}


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

}

/**
* Build a array list of the forums this user cannot search due to password protection
*

}

/**
* Build a array list of the forums this user cannot search due to password protection
*

 * @param int the fids to check (leave null to check all forums)
* @return return a array list of password protected forums the user cannot search

 * @param array $fids the fids to check (leave blank to check all forums)
* @return array return a array list of password protected forums the user cannot search

 */
function get_password_protected_forums($fids=array())
{

 */
function get_password_protected_forums($fids=array())
{

Zeile 202Zeile 257
	$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 224Zeile 269
/**
* Clean search keywords and make them safe for querying
*

/**
* Clean search keywords and make them safe for querying
*

 * @param string The keywords to be cleaned

 * @param string $keywords The keywords to be cleaned

 * @return string The cleaned keywords
*/
function clean_keywords($keywords)
{

 * @return string The cleaned keywords
*/
function clean_keywords($keywords)
{

 
	global $db, $lang;


	$keywords = my_strtolower($keywords);

	$keywords = my_strtolower($keywords);

	$keywords = str_replace("%", "\\%", $keywords);

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

	$keywords = preg_replace("#\*{2,}#s", "*", $keywords);
$keywords = str_replace("*", "%", $keywords);

	$keywords = preg_replace("#\*{2,}#s", "*", $keywords);
$keywords = str_replace("*", "%", $keywords);

	$keywords = preg_replace("#([\[\]\|\.\,:'])#s", " ", $keywords);

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

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

 
	$keywords = str_replace('\\"', '"', $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);


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

 
		$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 254Zeile 308
/**
* Clean search keywords for fulltext searching, making them safe for querying
*

/**
* Clean search keywords for fulltext searching, making them safe for querying
*

 * @param string The keywords to be cleaned
* @return string The cleaned keywords

 * @param string $keywords The keywords to be cleaned
* @return string|bool The cleaned keywords or false on failure

 */
function clean_keywords_ft($keywords)
{

 */
function clean_keywords_ft($keywords)
{

Zeile 270Zeile 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 280Zeile 355
	// Brace depth
$depth = 0;
$phrase_operator = '+';

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

 
	$inquote = false;

	foreach($keywords as $phrase)
{
$phrase = trim($phrase);

	foreach($keywords as $phrase)
{
$phrase = trim($phrase);

Zeile 408Zeile 484
/**
* Perform a thread and post search under MySQL or MySQLi
*

/**
* Perform a thread and post search under MySQL or MySQLi
*

 * @param array Array of search data

 * @param array $search Array of search data

 * @return array Array of search data with results mixed in
*/
function privatemessage_perform_search_mysql($search)

 * @return array Array of search data with results mixed in
*/
function privatemessage_perform_search_mysql($search)

Zeile 434Zeile 510
	{
// Complex search
$keywords = " {$keywords} ";

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

 

switch($db->type)
{
case 'mysql':
case 'mysqli':
$sfield = 'subject';
$mfield = 'message';
break;
default:
$sfield = 'LOWER(subject)';
$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} (";
}

// 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 473Zeile 563
						if($i % 2 && ($word == "and" || $word == "or"))
{
if($i <= 1)

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

							{

							{

								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

Zeile 503Zeile 593
								$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
if($search['subject'] == 1)

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

							{
$subject_lookin .= " $boolean LOWER(subject) LIKE '%{$word}%'";

							{
$subject_lookin .= " $boolean {$sfield} LIKE '%{$word}%'";

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

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

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

								$message_lookin .= " $boolean {$mfield} LIKE '%{$word}%'";

							}
$boolean = 'AND';
}

							}
$boolean = 'AND';
}

Zeile 521Zeile 612
				{
$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);
}
// Add phrase to search query

						$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);
}
// Add phrase to search query

					$subject_lookin .= " $boolean LOWER(subject) LIKE '%{$phrase}%'";

					$subject_lookin .= " $boolean {$sfield} LIKE '%{$phrase}%'";

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

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

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

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

					}
$boolean = 'AND';
}

					}
$boolean = 'AND';
}

Zeile 586Zeile 677
			// If we're looking in both, then find matches in either the subject or the message
if($search['subject'] == 1 && $search['message'] == 1)
{

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

				$searchsql .= " AND (LOWER(subject) LIKE '%{$keywords}%' OR LOWER(message) LIKE '%{$keywords}%')";

				$searchsql .= " AND ({$sfield} LIKE '%{$keywords}%' OR {$mfield} LIKE '%{$keywords}%')";

			}
else
{
if($search['subject'] == 1)

			}
else
{
if($search['subject'] == 1)

				{
$searchsql .= " AND LOWER(subject) LIKE '%{$keywords}%'";
}


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


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

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

					$searchsql .= " AND LOWER(message) LIKE '%{$keywords}%'";

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

				}
}

				}
}

		}

		}

	}

if($search['sender'])

	}

if($search['sender'])

Zeile 608Zeile 699
		$userids = array();
$search['sender'] = my_strtolower($search['sender']);


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


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











		switch($db->type)
{
case 'mysql':
case 'mysqli':
$field = 'username';
break;
default:
$field = 'LOWER(username)';
break;
}
$query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'");

		while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];

		while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];

Zeile 638Zeile 739

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



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


		if($folderids)
{
$searchsql .= " AND folder IN (".$folderids.")";
}
}


		if($folderids)
{
$searchsql .= " AND folder IN (".$folderids.")";
}
}


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

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

Zeile 671Zeile 772
		$statussql = implode("OR", $statussql);
$searchsql .= $statussql.")";
}

		$statussql = implode("OR", $statussql);
$searchsql .= $statussql.")";
}

 

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


// Run the search
$pms = array();


// Run the search
$pms = array();

Zeile 694Zeile 802
/**
* Perform a help document search under MySQL or MySQLi
*

/**
* Perform a help document search under MySQL or MySQLi
*

 * @param array Array of search data

 * @param array $search Array of search data

 * @return array Array of search data with results mixed in
*/
function helpdocument_perform_search_mysql($search)

 * @return array Array of search data with results mixed in
*/
function helpdocument_perform_search_mysql($search)

Zeile 718Zeile 826

if($keywords)
{


if($keywords)
{

 
		switch($db->type)
{
case 'mysql':
case 'mysqli':
$nfield = 'name';
$dfield = 'document';
break;
default:
$nfield = 'LOWER(name)';
$dfield = 'LOWER(document)';
break;
}


		// Complex search
$keywords = " {$keywords} ";
if(preg_match("#\s(and|or)\s#", $keywords))

		// Complex search
$keywords = " {$keywords} ";
if(preg_match("#\s(and|or)\s#", $keywords))

Zeile 758Zeile 879
						if($i % 2 && ($word == "and" || $word == "or"))
{
if($i <= 1)

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

							{

							{

								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

Zeile 791Zeile 912
							// Add terms to search query
if($search['name'] == 1)
{

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

								$name_lookin .= " $boolean LOWER(name) LIKE '%{$word}%'";

								$name_lookin .= " $boolean {$nfield} LIKE '%{$word}%'";

							}
if($search['document'] == 1)
{

							}
if($search['document'] == 1)
{

								$document_lookin .= " $boolean LOWER(document) LIKE '%{$word}%'";

								$document_lookin .= " $boolean {$dfield} LIKE '%{$word}%'";

							}
}
}

							}
}
}

Zeile 810Zeile 931
						error($lang->error_minsearchlength);
}
// Add phrase to search query

						error($lang->error_minsearchlength);
}
// Add phrase to search query

					$name_lookin .= " $boolean LOWER(name) LIKE '%{$phrase}%'";

					$name_lookin .= " $boolean {$nfield} LIKE '%{$phrase}%'";

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

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

						$document_lookin .= " $boolean LOWER(document) LIKE '%{$phrase}%'";

						$document_lookin .= " $boolean {$dfield} LIKE '%{$phrase}%'";

					}
}


					}
}


Zeile 830Zeile 951
					$error = true;
}
elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (")

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

				{

				{

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

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

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

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

			}


			}


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

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

Zeile 864Zeile 985
			{
$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);

			}


			}


			// 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 (LOWER(name) LIKE '%{$keywords}%' OR LOWER(document) LIKE '%{$keywords}%')";

				$searchsql .= " AND ({$nfield} LIKE '%{$keywords}%' OR {$dfield} LIKE '%{$keywords}%')";

			}
else
{
if($search['name'] == 1)
{

			}
else
{
if($search['name'] == 1)
{

					$searchsql .= " AND LOWER(name) LIKE '%{$keywords}%'";

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

				}

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

				}

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

					$searchsql .= " AND LOWER(document) LIKE '%{$keywords}%'";

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

				}
}
}

				}
}
}

Zeile 892Zeile 1013
	while($help = $db->fetch_array($query))
{
$helpdocs[$help['hid']] = $help['hid'];

	while($help = $db->fetch_array($query))
{
$helpdocs[$help['hid']] = $help['hid'];

	}

	}


if(count($helpdocs) < 1)
{


if(count($helpdocs) < 1)
{

Zeile 908Zeile 1029
/**
* Perform a thread and post search under MySQL or MySQLi
*

/**
* Perform a thread and post search under MySQL or MySQLi
*

 * @param array Array of search data

 * @param array $search Array of search data

 * @return array Array of search data with results mixed in
*/
function perform_search_mysql($search)

 * @return array Array of search data with results mixed in
*/
function perform_search_mysql($search)

Zeile 916Zeile 1037
	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)

	{

	{

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

$subject_lookin = $message_lookin = '';
if($keywords)
{

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

$subject_lookin = $message_lookin = '';
if($keywords)
{

 
		switch($db->type)
{
case 'mysql':
case 'mysqli':
$tfield = 't.subject';
$pfield = 'p.message';
break;
default:
$tfield = 'LOWER(t.subject)';
$pfield = 'LOWER(p.message)';
break;
}


		// Complex search
$keywords = " {$keywords} ";
if(preg_match("#\s(and|or)\s#", $keywords))

		// Complex search
$keywords = " {$keywords} ";
if(preg_match("#\s(and|or)\s#", $keywords))

Zeile 978Zeile 1108
								error($lang->error_minsearchlength);
}
// Add terms to search query

								error($lang->error_minsearchlength);
}
// Add terms to search query

							$subject_lookin .= " $boolean LOWER(t.subject) LIKE '%{$word}%'";

							$subject_lookin .= " $boolean {$tfield} LIKE '%{$word}%'";

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

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

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

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

							}
$boolean = 'AND';
}

							}
$boolean = 'AND';
}

Zeile 997Zeile 1127
						error($lang->error_minsearchlength);
}
// Add phrase to search query

						error($lang->error_minsearchlength);
}
// Add phrase to search query

					$subject_lookin .= " $boolean LOWER(t.subject) LIKE '%{$phrase}%'";

					$subject_lookin .= " $boolean {$tfield} LIKE '%{$phrase}%'";

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

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

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

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

					}
$boolean = 'AND';
}

					}
$boolean = 'AND';
}

Zeile 1025Zeile 1155
				$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);
}

			$subject_lookin = " AND LOWER(t.subject) LIKE '%{$keywords}%'";

			$subject_lookin = " AND {$tfield} LIKE '%{$keywords}%'";

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

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

				$message_lookin = " AND LOWER(p.message) LIKE '%{$keywords}%'";

				$message_lookin = " AND {$pfield} LIKE '%{$keywords}%'";

			}
}
}

			}
}
}

Zeile 1040Zeile 1170
		$search['author'] = my_strtolower($search['author']);
if($search['matchusername'])
{

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

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

while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];
}
if(count($userids) < 1)
{
error($lang->error_nosearchresults);
}
else
{















			$user = get_user_by_username($search['author']);
if($user)
{
$userids[] = $user['uid'];
}
}
else
{
switch($db->type)
{
case 'mysql':
case 'mysqli':
$field = 'username';
break;
default:
$field = 'LOWER(username)';
break;
}
$query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['author'])."%'");
while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];
}
}

if(count($userids) < 1)
{
error($lang->error_nosearchresults);
}
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 1095Zeile 1239

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

	{
foreach($search['threadprefix'] as $threadprefix)
{

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

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

		}
}

		}
}


$forumin = '';
$fidlist = array();


$forumin = '';
$fidlist = array();

	$searchin = array();
if(!is_array($search['forums']) || $search['forums'][0] != "all")

	if(!empty($search['forums']) && (!is_array($search['forums']) || $search['forums'][0] != "all"))


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

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

		}
// Generate a comma separated list of all groups the user belongs to
$user_groups = $mybb->user['usergroup'];
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 = (int)$forum;

		}
foreach($search['forums'] as $forum)
{
$forum = (int)$forum;

			if(empty($searchin[$forum]))

			if($forum > 0)

			{

			{

				if(isset($add_groups) && is_array($add_groups))



				$fidlist[] = $forum;
$child_list = get_child_list($forum);
if(is_array($child_list))

				{

				{

					$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'];

					$fidlist = array_merge($fidlist, $child_list);
































				}

				}

			}
}
if(count($fidlist) == 1)
{
$forumin .= " AND t.fid='$forum' ";
$searchin[$forum] = 1;
}
else
{
if(count($fidlist) > 1)
{
$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
}
}
}

			}
}
$fidlist = array_unique($fidlist);
if(count($fidlist) >= 1)
{
$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
}
}









$permsql = "";
$onlyusfids = array();


$permsql = "";
$onlyusfids = array();

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

	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)


$unsearchforums = get_unsearchable_forums();
if($unsearchforums)

	{

	{

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

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

	}

	}

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


	$inactiveforums = get_inactive_forums();
if($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)
{
$visiblesql = " AND t.visible = '1'";

	if(isset($search['visible']))
{
if($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'";

			}
}

			}
}

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

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

		{

		{

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

			$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 1246Zeile 1343
		else
{
$visiblesql = " AND t.visible == '0'";

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


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


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

			{
$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']))
{
$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 = "LIMIT ".(int)$mybb->settings['searchhardlimit'];

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

	}


	}


	// Searching both posts and thread titles
$threads = array();
$posts = array();

	// Searching both posts and thread titles
$threads = array();
$posts = array();

Zeile 1280Zeile 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 1289Zeile 1390
				if($thread['firstpost'])
{
$posts[$thread['tid']] = $thread['firstpost'];

				if($thread['firstpost'])
{
$posts[$thread['tid']] = $thread['firstpost'];

				}
}
}

				}
}
}


$query = $db->query("
SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)


$query = $db->query("
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 1312Zeile 1413
		}
$threads = implode(',', $threads);
$posts = implode(',', $posts);

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


}


}

	// Searching only thread titles
else
{

	// Searching only thread titles
else
{

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

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

		}


		}


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

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

Zeile 1358Zeile 1459
/**
* Perform a thread and post search under MySQL or MySQLi using boolean fulltext capabilities
*

/**
* Perform a thread and post search under MySQL or MySQLi using boolean fulltext capabilities
*

 * @param array Array of search data

 * @param array $search Array of search data

 * @return array Array of search data with results mixed in
*/
function perform_search_mysql_ft($search)

 * @return array Array of search data with results mixed in
*/
function perform_search_mysql_ft($search)

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

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

	if($search['author'])

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

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

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

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

while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];





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

while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];
}

		}

if(count($userids) < 1)

		}

if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);
}
else

			error($lang->error_nosearchresults);
}
else

Zeile 1464Zeile 1558
			$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 = '';
if($search['postdate'])
{

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

		if($search['pddir'] == 0)
{
$datecut = "<=";
}
else

		if($search['pddir'] == 0)
{
$datecut = "<=";
}
else

		{

		{

			$datecut = ">=";
}
$now = TIME_NOW;

			$datecut = ">=";
}
$now = TIME_NOW;

Zeile 1485Zeile 1579
	}

$thread_replycut = '';

	}

$thread_replycut = '';

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

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

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

	{
if((int)$search['findthreadst'] == 1)
{
$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']."'";

Zeile 1499Zeile 1593

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

	{
foreach($search['threadprefix'] as $threadprefix)
{

Zeile 1522Zeile 1616
	$forumin = '';
$fidlist = array();
$searchin = array();

	$forumin = '';
$fidlist = array();
$searchin = array();

	if(!is_array($search['forums']) || $search['forums'][0] != "all")

	if(!empty($search['forums']) && (!is_array($search['forums']) || $search['forums'][0] != "all"))

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

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

		}
// Generate a comma separated list of all groups the user belongs to
$user_groups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])
{
$user_groups .= ",".$mybb->user['additionalgroups'];

 
		}
foreach($search['forums'] as $forum)
{
$forum = (int)$forum;

		}
foreach($search['forums'] as $forum)
{
$forum = (int)$forum;

			if(empty($searchin[$forum]))

			if($forum > 0)

			{

			{

				switch($db->type)



				$fidlist[] = $forum;
$child_list = get_child_list($forum);
if(is_array($child_list))

				{

				{

					case "pgsql":
case "sqlite":
$query = $db->query("
SELECT 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(','||parentlist||',',',$forum,') > 0 AND active!=0 AND ((p.fid) IS NULL OR p.cansearch=1)
");
break;
default:
$query = $db->query("
SELECT 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 ((p.fid) IS NULL OR p.cansearch=1)
");
}
while($sforum = $db->fetch_array($query))
{
$fidlist[] = $sforum['fid'];

					$fidlist = array_merge($fidlist, $child_list);




















				}

				}

			}
}
if(count($fidlist) == 1)
{
$forumin .= " AND t.fid='$forum' ";
$searchin[$forum] = 1;
}
else
{

if(count($fidlist) > 1)
{
$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
}
}
}

			}
}
$fidlist = array_unique($fidlist);
if(count($fidlist) >= 1)
{
$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
}
}









	$permsql = "";
$onlyusfids = array();

	$permsql = "";
$onlyusfids = array();





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

	}

	}

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

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

Zeile 1597Zeile 1660

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)


$unsearchforums = get_unsearchable_forums();
if($unsearchforums)

	{

	{

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

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

Zeile 1606Zeile 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 1639Zeile 1702
				$plain_post_visiblesql = " AND visible != '1'";
}
}

				$plain_post_visiblesql = " AND visible != '1'";
}
}

	}






	}

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

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

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

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

	{

	{

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


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


Zeile 1660Zeile 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 1682Zeile 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))