Vergleich inc/functions_search.php - 1.8.10 - 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($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 292Zeile 370
				if($phrase_operator)
{
$boolean[$depth] = $phrase_operator;

				if($phrase_operator)
{
$boolean[$depth] = $phrase_operator;

				}

				}

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

Zeile 302Zeile 380
				// 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 390
					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 351Zeile 429
					}
// Valid operators for opening braces
elseif($word == '+(' || $word == '-(' || $word == '<(' || $word == '>(' || $word == '~(' || $word == '(')

					}
// Valid operators for opening braces
elseif($word == '+(' || $word == '-(' || $word == '<(' || $word == '>(' || $word == '~(' || $word == '(')

					{

					{

						if(strlen($word) == 2)
{
$boolean[$depth] = substr($word, 0, 1);

						if(strlen($word) == 2)
{
$boolean[$depth] = substr($word, 0, 1);

Zeile 371Zeile 449
							case '<':
case '~':
$word = substr($word, 1);

							case '<':
case '~':
$word = substr($word, 1);

								break;

								break;

							default:
$operator = $boolean[$depth];
break;

							default:
$operator = $boolean[$depth];
break;

Zeile 430Zeile 508

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


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

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

if($keywords)
{

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

if($keywords)
{

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

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

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

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

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

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

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

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

Zeile 477Zeile 555
					// Expand out based on search operators (and, or)
$matches = preg_split("#\s{1,}(and|or)\s{1,}#", $phrase, -1, PREG_SPLIT_DELIM_CAPTURE);
$count_matches = count($matches);

					// Expand out based on search operators (and, or)
$matches = preg_split("#\s{1,}(and|or)\s{1,}#", $phrase, -1, PREG_SPLIT_DELIM_CAPTURE);
$count_matches = count($matches);





					for($i=0; $i < $count_matches; ++$i)
{
$word = trim($matches[$i]);

					for($i=0; $i < $count_matches; ++$i)
{
$word = trim($matches[$i]);

Zeile 549Zeile 627
						$message_lookin .= " $boolean {$mfield} LIKE '%{$phrase}%'";
}
$boolean = 'AND';

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

				}

				}


// Check to see if we have any search terms and not a malformed SQL string
$error = false;


// Check to see if we have any search terms and not a malformed SQL string
$error = false;

Zeile 621Zeile 699
	}

if($search['sender'])

	}

if($search['sender'])

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

switch($db->type)
{
case 'mysql':
case 'mysqli':

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

switch($db->type)
{
case 'mysql':
case 'mysqli':

				$field = 'username';
break;
default:

				$field = 'username';
break;
default:

Zeile 668Zeile 746
		if($folderids)
{
$searchsql .= " AND folder IN (".$folderids.")";

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

		}
}

		}
}


if($search['status'])
{


if($search['status'])
{

Zeile 698Zeile 776
		$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();
$query = $db->simple_select("privatemessages", "pmid", $searchsql);
while($pm = $db->fetch_array($query))


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

	{

	{

		$pms[$pm['pmid']] = $pm['pmid'];

		$pms[$pm['pmid']] = $pm['pmid'];

	}


	}


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

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

Zeile 717Zeile 802
		"querycache" => $pms
);
}

		"querycache" => $pms
);
}





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

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

Zeile 814Zeile 899
									// Just in a document?
continue;
}

									// Just in a document?
continue;
}

							}

$boolean = $word;
}
// Otherwise check the length of the word as it is a normal search term

							}

$boolean = $word;
}
// Otherwise check the length of the word as it is a normal search term

						else
{
$word = trim($word);

						else
{
$word = trim($word);

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

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

					$error = true;

					$error = true;

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

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

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

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

				}

				}


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


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

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

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

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

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

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

 

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


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

Zeile 993Zeile 1074
			$keywords_exp = explode("\"", $keywords);
$inquote = false;
$boolean = '';

			$keywords_exp = explode("\"", $keywords);
$inquote = false;
$boolean = '';





			foreach($keywords_exp as $phrase)
{
// If we're not in a double quoted section

			foreach($keywords_exp as $phrase)
{
// If we're not in a double quoted section

Zeile 1007Zeile 1088
					{
$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 1016Zeile 1097
							if($i <= 1 && $subject_lookin == " AND (")
{
continue;

							if($i <= 1 && $subject_lookin == " AND (")
{
continue;

							}


							}


							$boolean = $word;
}
// Otherwise check the length of the word as it is a normal search term

							$boolean = $word;
}
// Otherwise check the length of the word as it is a normal search term

Zeile 1042Zeile 1123
				}
// 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'])
{

Zeile 1056Zeile 1137
						$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 1066Zeile 1147
				}

$inquote = !$inquote;

				}

$inquote = !$inquote;

			}

			}

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

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

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

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

			}

			}

		}

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

		}

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

		}
else
{

		}
else
{

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

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

Zeile 1135Zeile 1216
		if($search['pddir'] == 0)
{
$datecut = "<=";

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

		}

		}

		else
{
$datecut = ">=";

		else
{
$datecut = ">=";

		}

		}

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

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

Zeile 1184Zeile 1265

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


		$fidlist = array_unique($fidlist);
if(count($fidlist) >= 1)

		{

		{

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

			$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
}









	}

	}





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


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


Zeile 1268Zeile 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)."))";

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

Zeile 1287Zeile 1321
		$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)
{
$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'";

Zeile 1303Zeile 1337
		elseif($search['visible'] == -1)
{
$visiblesql = " AND t.visible = '-1'";

		elseif($search['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 1318Zeile 1352
			{
$post_visiblesql = " AND p.visible == '0'";
$plain_post_visiblesql = " AND visible == '0'";

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

			}

			}

		}
}

		}
}

 

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


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


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

Zeile 1347Zeile 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))

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

Zeile 1364Zeile 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))

		{

		{

			$posts[$post['pid']] = $post['pid'];
$threads[$post['tid']] = $post['tid'];
}

			$posts[$post['pid']] = $post['pid'];
$threads[$post['tid']] = $post['tid'];
}

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

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

	global $mybb, $db, $lang;

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

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

 




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

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









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


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


 
	$message_lookin = $subject_lookin = '';

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

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

Zeile 1476Zeile 1503
						$all_too_short = false;
break;
}

						$all_too_short = false;
break;
}

				}
}

				}
}

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

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

Zeile 1518Zeile 1545
		}
else
{

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

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












while($user = $db->fetch_array($query))
{


while($user = $db->fetch_array($query))
{

Zeile 1537Zeile 1554
		}

if(count($userids) < 1)

		}

if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);
}
else

			error($lang->error_nosearchresults);
}
else

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

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

	$datecut = '';

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

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

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

Zeile 1586Zeile 1603
		{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;

		{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;

		}

		}

	}
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).")";

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

Zeile 1603Zeile 1620
	$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']))

	{
if(!is_array($search['forums']))

		{

		{

			$search['forums'] = array((int)$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]))
{
switch($db->type)
{
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))

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


















				{

				{

					$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 1674Zeile 1660
	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)
{

Zeile 1687Zeile 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 1721Zeile 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 1746Zeile 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 1763Zeile 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))