Vergleich inc/functions_search.php - 1.8.10 - 1.8.22

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
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 272Zeile 272
	// 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;

// Replaces less than 3 characters
$keywords = preg_replace("/(\b.{1,{$min_word_length}})(\s)|(\b.{1,{$min_word_length}}$)/", '$2', $keywords);
// Collapse multiple spaces
$keywords = preg_replace('/(\s)+/', '$1', $keywords);
$keywords = trim($keywords);


$words = array(array());



$words = array(array());


Zeile 582Zeile 597
			if($search['subject'] == 1)
{
$subject_lookin .= ")";

			if($search['subject'] == 1)
{
$subject_lookin .= ")";

			}

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

			}

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


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


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

Zeile 621Zeile 636
	}

if($search['sender'])

	}

if($search['sender'])

	{

	{

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


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


Zeile 681Zeile 696
		if($search['status']['replied'])
{
$statussql[] = " status='3' ";

		if($search['status']['replied'])
{
$statussql[] = " status='3' ";

		}

		}

		if($search['status']['forwarded'])

		if($search['status']['forwarded'])

		{

		{

			$statussql[] = " status='4' ";

			$statussql[] = " status='4' ";

		}

		}

		if($search['status']['read'])

		if($search['status']['read'])

		{

		{

			$statussql[] = " (status != '0' AND readtime > '0') ";

			$statussql[] = " (status != '0' AND readtime > '0') ";

		}

		}

		// Sent Folder
if(in_array(2, $search['folder']))
{

		// Sent Folder
if(in_array(2, $search['folder']))
{

Zeile 698Zeile 713
		$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 741Zeile 763

$name_lookin = "";
$document_lookin = "";


$name_lookin = "";
$document_lookin = "";

	$searchsql = "enabled='1'";

if($keywords)

	$searchsql = "enabled='1'";

if($keywords)

	{
switch($db->type)
{

	{
switch($db->type)
{

Zeile 779Zeile 801
			$inquote = false;

foreach($keywords_exp as $phrase)

			$inquote = false;

foreach($keywords_exp as $phrase)

			{

			{

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

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

Zeile 896Zeile 918
			}

$searchsql .= "{$name_lookin} {$document_lookin}";

			}

$searchsql .= "{$name_lookin} {$document_lookin}";

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

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

				error($lang->error_minsearchlength);
}


				error($lang->error_minsearchlength);
}


Zeile 956Zeile 978
	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 1026Zeile 1044
							$word = trim($word);
// Word is too short - show error message
if(my_strlen($word) < $mybb->settings['minsearchword'])

							$word = trim($word);
// Word is too short - show error message
if(my_strlen($word) < $mybb->settings['minsearchword'])

							{

							{

								$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 1066Zeile 1084
				}

$inquote = !$inquote;

				}

$inquote = !$inquote;

			}

			}

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

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

		}

		}

		else
{
$keywords = str_replace("\"", '', trim($keywords));

		else
{
$keywords = str_replace("\"", '', trim($keywords));

Zeile 1077Zeile 1095
			{
$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 {$tfield} LIKE '%{$keywords}%'";
if($search['postthread'] == 1)
{
$message_lookin = " AND {$pfield} LIKE '%{$keywords}%'";

			$subject_lookin = " AND {$tfield} LIKE '%{$keywords}%'";
if($search['postthread'] == 1)
{
$message_lookin = " AND {$pfield} LIKE '%{$keywords}%'";

			}
}

			}
}

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

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

Zeile 1095Zeile 1113
		{
$user = get_user_by_username($search['author']);
if($user)

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

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

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

		{
switch($db->type)

		{
switch($db->type)

			{

			{

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

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

					break;

					break;

				default:
$field = 'LOWER(username)';
break;

				default:
$field = 'LOWER(username)';
break;

Zeile 1115Zeile 1133
			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)
{

Zeile 1165Zeile 1183
	if($search['threadprefix'] && $search['threadprefix'][0] != 'any')
{
foreach($search['threadprefix'] as $threadprefix)

	if($search['threadprefix'] && $search['threadprefix'][0] != 'any')
{
foreach($search['threadprefix'] as $threadprefix)

		{

		{

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

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

		}

		}

	}
if(count($prefixlist) == 1)
{

	}
if(count($prefixlist) == 1)
{

Zeile 1181Zeile 1199
			$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")";
}
}

			$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")";
}
}





	$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)
{
$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 1433Zeile 1404
	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 1446Zeile 1413
		$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 1466Zeile 1433
					if(!$word)
{
continue;

					if(!$word)
{
continue;

					}

					}

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

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

					{

					{

						$all_too_short = true;

						$all_too_short = true;

					}

					}

					else
{
$all_too_short = false;

					else
{
$all_too_short = false;

Zeile 1486Zeile 1453
					$all_too_short = true;
}
else

					$all_too_short = true;
}
else

				{

				{

					$all_too_short = false;
break;
}

					$all_too_short = false;
break;
}

Zeile 1518Zeile 1485
		}
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))
{
$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.")";

		}

		}

	}
$datecut = '';
if($search['postdate'])

	}
$datecut = '';
if($search['postdate'])

Zeile 1557Zeile 1514
		else
{
$datecut = ">=";

		else
{
$datecut = ">=";

		}

		}

		$now = TIME_NOW;
$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";
$post_datecut = " AND p.dateline $datecut";
$thread_datecut = " AND t.dateline $datecut";

		$now = TIME_NOW;
$datelimit = $now-(86400 * $search['postdate']);
$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 1575Zeile 1532
		else
{
$thread_replycut = " AND t.replies <= '".(int)$search['numreplies']."'";

		else
{
$thread_replycut = " AND t.replies <= '".(int)$search['numreplies']."'";

		}
}


		}
}


	$thread_prefixcut = '';
$prefixlist = array();
if($search['threadprefix'] && $search['threadprefix'][0] != 'any')

	$thread_prefixcut = '';
$prefixlist = array();
if($search['threadprefix'] && $search['threadprefix'][0] != 'any')

Zeile 1587Zeile 1544
			$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;
}

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

	}

	}

	if(count($prefixlist) == 1)
{
$thread_prefixcut .= " AND t.prefix='$threadprefix' ";

	if(count($prefixlist) == 1)
{
$thread_prefixcut .= " AND t.prefix='$threadprefix' ";

Zeile 1597Zeile 1554
		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 = "";