Vergleich inc/functions_search.php - 1.4.5 - 1.4.16

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
<?php
/**
* MyBB 1.4

<?php
/**
* MyBB 1.4

 * Copyright � 2008 MyBB Group, All Rights Reserved

 * Copyright © 2008 MyBB Group, All Rights Reserved

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: functions_search.php 4304 2009-01-02 01:11:56Z chris $

 * $Id: functions_search.php 5379 2011-02-21 11:06:42Z Tomm $

 */

/**

 */

/**

Zeile 154Zeile 154
		}
}
$unsearchable = $unsearchableforums;

		}
}
$unsearchable = $unsearchableforums;

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

if($unsearchable && $pass_protected_forums)
{
$unsearchable .= ",";
}

if($pass_protected_forums)
{
$unsearchable .= implode(",", $pass_protected_forums);
}


	return $unsearchable;

	return $unsearchable;

}




















































}

/**
* 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
*/
function get_password_protected_forums($fids=array())
{
global $forum_cache, $mybb;

if(!is_array($fids))
{
return false;
}

if(!is_array($forum_cache))
{
$forum_cache = cache_forums();
if(!$forum_cache)
{
return false;
}
}

if(empty($fids))
{
$fids = array_keys($forum_cache);
}

$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])
{
$pass_fids[] = $fid;
$child_list = get_child_list($fid);
}

if(is_array($child_list))
{
$pass_fids = array_merge($pass_fids, $child_list);
}
}
return array_unique($pass_fids);
}


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


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

Zeile 171Zeile 236
	$keywords = str_replace("*", "%", $keywords);
$keywords = preg_replace("#([\[\]\|\.\,:'])#s", " ", $keywords);
$keywords = preg_replace("#\s+#s", " ", $keywords);

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

	return trim($keywords);














// Search for "and" or "or" and remove if it's at the beginning
$keywords = trim($keywords);
if(my_strpos($keywords, "or") !== false && my_strpos($keywords, "or") == 0)
{
$keywords = substr_replace($keywords, "", 0, 2);
}
if(my_strpos($keywords, "and") !== false && my_strpos($keywords, "and") == 0)
{
$keywords = substr_replace($keywords, "", 0, 3);
}

return $keywords;

}

/**

}

/**

Zeile 191Zeile 268
	$keywords = preg_replace("#\*{2,}#s", "*", $keywords);
$keywords = preg_replace("#([\[\]\|\.\,:])#s", " ", $keywords);
$keywords = preg_replace("#\s+#s", " ", $keywords);

	$keywords = preg_replace("#\*{2,}#s", "*", $keywords);
$keywords = preg_replace("#([\[\]\|\.\,:])#s", " ", $keywords);
$keywords = preg_replace("#\s+#s", " ", $keywords);





	
$words = array();


	if(my_strpos($keywords, "\"") !== false)
{
$inquote = false;

	if(my_strpos($keywords, "\"") !== false)
{
$inquote = false;

Zeile 201Zeile 280
			if($phrase != '')
{
if($inquote)

			if($phrase != '')
{
if($inquote)

				{

				{

					$words[] = "\"".trim($phrase)."\"";

					$words[] = "\"".trim($phrase)."\"";

				}
else
{

				}
else
{

					$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))
{

					$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))
{

Zeile 230Zeile 309
		if(!is_array($split_words))
{
continue;

		if(!is_array($split_words))
{
continue;

		}

		}

		foreach($split_words as $word)
{
if(!$word)

		foreach($split_words as $word)
{
if(!$word)

Zeile 249Zeile 328
			$boolean = '';
}
elseif($word == "and")

			$boolean = '';
}
elseif($word == "and")

		{

		{

			$boolean = "+";
}
elseif($word == "not")
{
$boolean = "-";

			$boolean = "+";
}
elseif($word == "not")
{
$boolean = "-";

		}

		}

		else
{
$keywords .= " ".$boolean.$word;

		else
{
$keywords .= " ".$boolean.$word;

Zeile 306Zeile 385
			{
// 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 358Zeile 437
						$message_lookin .= " $boolean LOWER(p.message) LIKE '%{$phrase}%'";
}
}

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

 
				
if($subject_lookin == " AND (")
{
// 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;
}
$subject_lookin .= ")";

				$inquote = !$inquote;
}
$subject_lookin .= ")";