Vergleich inc/functions_search.php - 1.8.1 - 1.8.20

  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 56Zeile 56
					}
if($forum['password'] != '')
{

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

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

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

						{
$pwverified = 1;
}

						{
$pwverified = 1;
}

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

/**
* 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 $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;


Zeile 125Zeile 125
		$pwverified = 1;
if($forum['password'] != '')
{

		$pwverified = 1;
if($forum['password'] != '')
{

			if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$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;
}

			{
$pwverified = 0;
}

Zeile 173Zeile 173
/**
* 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 207Zeile 207
			continue;
}


			continue;
}


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

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

		{
$pass_fids[] = $fid;
$child_list = get_child_list($fid);

		{
$pass_fids[] = $fid;
$child_list = get_child_list($fid);

Zeile 224Zeile 224
/**
* 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;


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


// Search for "and" or "or" and remove if it's at the beginning
$keywords = trim($keywords);

Zeile 254Zeile 256
/**
* 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 288Zeile 290
			if($inquote)
{
if($phrase_operator)

			if($inquote)
{
if($phrase_operator)

				{

				{

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

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

Zeile 327Zeile 329
								$last = substr($last, 1);
}
$words[$depth][] = $last;

								$last = substr($last, 1);
}
$words[$depth][] = $last;

						}

						}

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

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

Zeile 345Zeile 347
						{
$words[$depth-1][] = $boolean[$depth-1].'('.implode(' ', $words[$depth]).')';
--$depth;

						{
$words[$depth-1][] = $boolean[$depth-1].'('.implode(' ', $words[$depth]).')';
--$depth;

						}
}

						}
}

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

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

Zeile 385Zeile 387
						}
$words[$depth][] = $word;
$boolean[$depth] = '+';

						}
$words[$depth][] = $word;
$boolean[$depth] = '+';

					}

					}

				}
}
}

				}
}
}

Zeile 408Zeile 410
/**
* 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 436
	{
// 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(preg_match("#\s(and|or)\s#", $keywords))
{
$string = "AND";

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

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

			}

			}


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


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

Zeile 503Zeile 519
								$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 518Zeile 535
				}
// In the middle of a quote (phrase)
else

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

				{

				{

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

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

					{

					{

						$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);
}
// 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 539Zeile 556
				if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{
// We're looking for anything, check for a subject lookin

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

					$error = true;

					$error = true;

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

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

				{

				{

					// Just in a subject?

					// Just in a subject?

					$error = true;

					$error = true;

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

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

				}

				}


if($error == true)
{
// There are no search keywords to look for
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);


if($error == true)
{
// There are no search keywords to look for
$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 .= ")";

			}


			}


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

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

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

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

		}
else
{

		}
else
{

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

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

Zeile 586Zeile 603
			// 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}%'";

				}
}
}

				}
}
}

Zeile 608Zeile 625
		$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'];
}

if(count($userids) < 1)

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

if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);
}
else

			error($lang->error_nosearchresults);
}
else

Zeile 623Zeile 650
			$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 633Zeile 660
	if(!empty($search['folder']))
{
$folderids = array();

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





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

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

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

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

Zeile 671Zeile 698
		$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 678Zeile 712
	while($pm = $db->fetch_array($query))
{
$pms[$pm['pmid']] = $pm['pmid'];

	while($pm = $db->fetch_array($query))
{
$pms[$pm['pmid']] = $pm['pmid'];

	}


	}


	if(count($pms) < 1)
{
error($lang->error_nosearchresults);
}
$pms = implode(',', $pms);

	if(count($pms) < 1)
{
error($lang->error_nosearchresults);
}
$pms = implode(',', $pms);





	return array(
"querycache" => $pms

	return array(
"querycache" => $pms

	);
}

/**

	);
}

/**

 * 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 703Zeile 737

$keywords = clean_keywords($search['keywords']);
if(!$keywords && !$search['sender'])


$keywords = clean_keywords($search['keywords']);
if(!$keywords && !$search['sender'])

	{

	{

		error($lang->error_nosearchterms);

		error($lang->error_nosearchterms);

	}


	}


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

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

Zeile 718Zeile 752

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 791Zeile 838
							// 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 857
						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 869Zeile 916
			// 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 908Zeile 955
/**
* 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 963
	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 929Zeile 972
	$subject_lookin = $message_lookin = '';
if($keywords)
{

	$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 961Zeile 1017
						if($i % 2 && ($word == "and" || $word == "or"))
{
if($i <= 1 && $subject_lookin == " AND (")

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

							{

							{

								continue;
}


								continue;
}


Zeile 978Zeile 1034
								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';
}

					}

					}

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

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

Zeile 997Zeile 1053
						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 1010Zeile 1066
					// There are no search keywords to look for
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

					// There are no search keywords to look for
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

				}

				}


$inquote = !$inquote;
}


$inquote = !$inquote;
}

Zeile 1025Zeile 1081
				$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 1039Zeile 1095
		$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'];
}
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.")";

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

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

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

		}
else
{

		}
else
{

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

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

Zeile 1117Zeile 1187

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

		}
foreach($search['forums'] as $forum)

		{

		{

			$forum = (int)$forum;

			$forum = (int)$forum;

			if(empty($searchin[$forum]))
{
if(isset($add_groups) && is_array($add_groups))
{
$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))

			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

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





		{

		{

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

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




		}
}


		}
}


Zeile 1358Zeile 1381
/**
* 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 1389
	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');

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

Zeile 1379Zeile 1398
		$mybb->settings['minsearchword'] = $min_length;
}
// Otherwise, could not fetch - default back to MySQL fulltext default setting

		$mybb->settings['minsearchword'] = $min_length;
}
// Otherwise, could not fetch - default back to MySQL fulltext default setting

	else
{

	else
{

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


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


Zeile 1419Zeile 1438
					$all_too_short = true;
}
else

					$all_too_short = true;
}
else

				{

				{

					$all_too_short = false;
break;
}

					$all_too_short = false;
break;
}

Zeile 1438Zeile 1457
	$post_usersql = '';
$thread_usersql = '';
if($search['author'])

	$post_usersql = '';
$thread_usersql = '';
if($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)
{
error($lang->error_nosearchresults);

		}

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

		}
else

		}
else

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

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

Zeile 1516Zeile 1539
		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();
$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)

		}
foreach($search['forums'] as $forum)







		{
$forum = (int)$forum;

		{
$forum = (int)$forum;

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

			if($forum > 0)

			{

			{

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

				$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


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

		{

		{


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

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





		}
}
$permsql = "";

		}
}
$permsql = "";