Vergleich inc/functions_search.php - 1.8.11 - 1.8.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1184Zeile 1184

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

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

// 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 1262Zeile 1215

// Check group permissions if we can't view threads not started by us
if($group_permissions = forum_permissions())


// Check group permissions if we can't view threads not started by us
if($group_permissions = forum_permissions())

	{

	{

		foreach($group_permissions as $fid => $forum_permissions)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)

		foreach($group_permissions as $fid => $forum_permissions)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)

Zeile 1274Zeile 1227
	if(!empty($onlyusfids))
{
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";

	if(!empty($onlyusfids))
{
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";

	}

	}


$unsearchforums = get_unsearchable_forums();
if($unsearchforums)


$unsearchforums = get_unsearchable_forums();
if($unsearchforums)

Zeile 1285Zeile 1238
	if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";

	if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";

	}

	}


$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";
if(isset($search['visible']))


$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";
if(isset($search['visible']))

Zeile 1313Zeile 1266
		else
{
$visiblesql = " AND t.visible == '0'";

		else
{
$visiblesql = " AND t.visible == '0'";





			if($search['postthread'] == 1)
{
$post_visiblesql = " AND p.visible == '0'";

			if($search['postthread'] == 1)
{
$post_visiblesql = " AND p.visible == '0'";

Zeile 1325Zeile 1278
	// Searching a specific thread?
$tidsql = '';
if(!empty($search['tid']))

	// Searching a specific thread?
$tidsql = '';
if(!empty($search['tid']))

	{

	{

		$tidsql = " AND t.tid='".(int)$search['tid']."'";
}

$limitsql = '';
if((int)$mybb->settings['searchhardlimit'] > 0)

		$tidsql = " AND t.tid='".(int)$search['tid']."'";
}

$limitsql = '';
if((int)$mybb->settings['searchhardlimit'] > 0)

	{

	{

		$limitsql = "LIMIT ".(int)$mybb->settings['searchhardlimit'];
}


		$limitsql = "LIMIT ".(int)$mybb->settings['searchhardlimit'];
}


Zeile 1368Zeile 1321
			{$limitsql}
");
while($post = $db->fetch_array($query))

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

		{

		{

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

		{
error($lang->error_nosearchresults);
}
$threads = implode(',', $threads);

		{
error($lang->error_nosearchresults);
}
$threads = implode(',', $threads);

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

}

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

}

Zeile 1468Zeile 1421
						continue;
}
if(my_strlen($word) < $mybb->settings['minsearchword'])

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

					{

					{

						$all_too_short = true;
}
else

						$all_too_short = true;
}
else

Zeile 1484Zeile 1437
				if(my_strlen($phrase) < $mybb->settings['minsearchword'])
{
$all_too_short = true;

				if(my_strlen($phrase) < $mybb->settings['minsearchword'])
{
$all_too_short = true;

				}

				}

				else
{
$all_too_short = false;

				else
{
$all_too_short = false;

Zeile 1495Zeile 1448
		}
// 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 1512Zeile 1465
		{
$user = get_user_by_username($search['author']);
if($user)

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

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

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

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


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

Zeile 1537Zeile 1480
		}

if(count($userids) < 1)

		}

if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);
}
else

			error($lang->error_nosearchresults);
}
else

Zeile 1571Zeile 1514
		if((int)$search['findthreadst'] == 1)
{
$thread_replycut = " AND t.replies >= '".(int)$search['numreplies']."'";

		if((int)$search['findthreadst'] == 1)
{
$thread_replycut = " AND t.replies >= '".(int)$search['numreplies']."'";

		}

		}

		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')
{
foreach($search['threadprefix'] as $threadprefix)

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

		{

		{

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

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

Zeile 1603Zeile 1546
	$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)
{
$forum = (int)$forum;

		}
foreach($search['forums'] as $forum)
{
$forum = (int)$forum;

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

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





		}
}
$permsql = "";

		}
}
$permsql = "";