Vergleich inc/functions_search.php - 1.8.3 - 1.8.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 434Zeile 434
	{
// 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 455
			{
$string = "OR";
$subject_lookin = " AND (";

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

			}


			}


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

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

Zeile 468Zeile 482
						if(empty($word))
{
continue;

						if(empty($word))
{
continue;

						}

						}

						// If this word is a search operator set the boolean
if($i % 2 && ($word == "and" || $word == "or"))
{

						// If this word is a search operator set the boolean
if($i % 2 && ($word == "and" || $word == "or"))
{

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

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

									continue;

									continue;

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

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

Zeile 503Zeile 517
								$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 526Zeile 541
						error($lang->error_minsearchlength);
}
// Add phrase to search query

						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 601
			// 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 623
		$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))

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

		{

		{

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

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

		}

		}


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


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

		}

		}

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

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

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

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

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

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





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

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

Zeile 688Zeile 713

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
*

Zeile 711Zeile 736
	{
$mybb->settings['minsearchword'] = 3;
}

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





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

if($keywords)
{

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

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 829
							// 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 848
						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 907
			// 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 929Zeile 967
	$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))
{
$subject_lookin = " AND (";
$message_lookin = " AND (";

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





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

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

Zeile 945Zeile 996
			{
// If we're not in a double quoted section
if(!$inquote)

			{
// If we're not in a double quoted section
if(!$inquote)

				{

				{

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

Zeile 961Zeile 1012
						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 1029
								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 1048
						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 1076
				$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}%'";
}
}

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

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

Zeile 1040Zeile 1091
		$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))
{

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









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

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

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

Zeile 1078Zeile 1140
		$datecut .= "'$datelimit'";
$post_datecut = " AND p.dateline $datecut";
$thread_datecut = " AND t.dateline $datecut";

		$datecut .= "'$datelimit'";
$post_datecut = " AND p.dateline $datecut";
$thread_datecut = " AND t.dateline $datecut";

	}

	}


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


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

Zeile 1108Zeile 1170
		$thread_prefixcut .= " AND t.prefix='$threadprefix' ";
}
else

		$thread_prefixcut .= " AND t.prefix='$threadprefix' ";
}
else

	{

	{

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

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

Zeile 1201Zeile 1263
			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))
{

	}
if(!empty($onlyusfids))
{

Zeile 1443Zeile 1505
		$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'])."'");


			$user = get_user_by_username($search['author']);
$userids[] = $user['uid'];

		}
else
{

		}
else
{

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










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


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

		}

if(count($userids) < 1)

		}

if(count($userids) < 1)