Vergleich inc/functions_search.php - 1.8.5 - 1.8.8

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

	}

	}


if(my_strpos($keywords, "and") === 0)
{
$keywords = substr_replace($keywords, "", 0, 3);
}


if(my_strpos($keywords, "and") === 0)
{
$keywords = substr_replace($keywords, "", 0, 3);
}





	return $keywords;
}

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

	return $keywords;
}

/**
* 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 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 545Zeile 547
					if($search['message'] == 1)
{
$message_lookin .= " $boolean {$mfield} LIKE '%{$phrase}%'";

					if($search['message'] == 1)
{
$message_lookin .= " $boolean {$mfield} LIKE '%{$phrase}%'";

					}
$boolean = 'AND';
}

// Check to see if we have any search terms and not a malformed SQL string

					}
$boolean = 'AND';
}

// Check to see if we have any search terms and not a malformed SQL string

				$error = false;
if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{

				$error = false;
if($search['subject'] && $search['message'] && $subject_lookin == " AND (")
{

Zeile 583Zeile 585
			}

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

			}

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

			{

			{

				$message_lookin .= ")";
}


				$message_lookin .= ")";
}


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

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





		switch($db->type)

		switch($db->type)

		{

		{

			case 'mysql':
case 'mysqli':
$field = 'username';

			case 'mysql':
case 'mysqli':
$field = 'username';

Zeile 642Zeile 644
		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 681Zeile 683
			$statussql[] = " status='3' ";
}
if($search['status']['forwarded'])

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

		{

		{

			$statussql[] = " status='4' ";
}
if($search['status']['read'])

			$statussql[] = " status='4' ";
}
if($search['status']['read'])

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

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

	}


	}


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

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

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

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

	$pms = implode(',', $pms);

return array(

	$pms = implode(',', $pms);

return array(

Zeile 719Zeile 721
/**
* 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 749Zeile 751
			case 'mysqli':
$nfield = 'name';
$dfield = 'document';

			case 'mysqli':
$nfield = 'name';
$dfield = 'document';

				break;

				break;

			default:
$nfield = 'LOWER(name)';
$dfield = 'LOWER(document)';

			default:
$nfield = 'LOWER(name)';
$dfield = 'LOWER(document)';

Zeile 789Zeile 791
					{
$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 868Zeile 870
					$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 946Zeile 948
/**
* 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 1092Zeile 1094
		if($search['matchusername'])
{
$user = get_user_by_username($search['author']);

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

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




			if($user)
{
$userids[] = $user['uid'];
}

		}
else
{

		}
else
{

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

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

			{

			{

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

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

Zeile 1366Zeile 1371
		{
$posts[$post['pid']] = $post['pid'];
$threads[$post['tid']] = $post['tid'];

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

		}

		}


if(count($posts) < 1 && count($threads) < 1)
{


if(count($posts) < 1 && count($threads) < 1)
{

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

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

		{

		{

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

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

			{

			{

				$firstposts[$thread['tid']] = $thread['firstpost'];
}
}
if(count($threads) < 1)

				$firstposts[$thread['tid']] = $thread['firstpost'];
}
}
if(count($threads) < 1)

		{

		{

			error($lang->error_nosearchresults);
}


			error($lang->error_nosearchresults);
}


Zeile 1406Zeile 1411
			while($post = $db->fetch_array($query))
{
$posts[$post['pid']] = $post['pid'];

			while($post = $db->fetch_array($query))
{
$posts[$post['pid']] = $post['pid'];

			}

			}

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

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

Zeile 1420Zeile 1425
/**
* 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 1447Zeile 1452
	}

if($keywords)

	}

if($keywords)

	{

	{

		$keywords_exp = explode("\"", $keywords);
$inquote = false;
foreach($keywords_exp as $phrase)

		$keywords_exp = explode("\"", $keywords);
$inquote = false;
foreach($keywords_exp as $phrase)

Zeile 1487Zeile 1492
				}
}
$inquote = !$inquote;

				}
}
$inquote = !$inquote;

		}

		}

		// Show the minimum search term error only if all search terms are too short
if($all_too_short == true)

		// Show the minimum search term error only if all search terms are too short
if($all_too_short == true)

		{

		{

			$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);
}

			$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);
}

Zeile 1506Zeile 1511
		if($search['matchusername'])
{
$user = get_user_by_username($search['author']);

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

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




			if($user)
{
$userids[] = $user['uid'];
}

		}
else
{

		}
else
{