Vergleich inc/functions_search.php - 1.8.24 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 279Zeile 279
 */
function clean_keywords($keywords)
{

 */
function clean_keywords($keywords)
{

	global $db;

	global $db, $lang;


$keywords = my_strtolower($keywords);
$keywords = $db->escape_string_like($keywords);


$keywords = my_strtolower($keywords);
$keywords = $db->escape_string_like($keywords);

Zeile 293Zeile 293
	if(my_strpos($keywords, "or") === 0)
{
$keywords = substr_replace($keywords, "", 0, 2);

	if(my_strpos($keywords, "or") === 0)
{
$keywords = substr_replace($keywords, "", 0, 2);

 
		$keywords = " ".$keywords;

	}

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

	}

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

 
		$keywords = " ".$keywords;
}

if(!$keywords)
{
error($lang->error_nosearchterms);

	}

return $keywords;

	}

return $keywords;

Zeile 343Zeile 350
	// Collapse multiple spaces
$keywords = preg_replace('/(\s)+/', '$1', $keywords);
$keywords = trim($keywords);

	// Collapse multiple spaces
$keywords = preg_replace('/(\s)+/', '$1', $keywords);
$keywords = trim($keywords);





	$words = array(array());

// Fulltext search syntax validation: http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

	$words = array(array());

// Fulltext search syntax validation: http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

Zeile 409Zeile 416
					elseif($word == "not")
{
$boolean[$depth] = "-";

					elseif($word == "not")
{
$boolean[$depth] = "-";

					}

					}

					// Closing braces
elseif($word == ")")
{

					// Closing braces
elseif($word == ")")
{

Zeile 474Zeile 481

$keywords = implode(' ', $words[0]);
return $keywords;


$keywords = implode(' ', $words[0]);
return $keywords;

}


}


/* Database engine specific search functions */

/**

/* Database engine specific search functions */

/**

Zeile 819Zeile 826

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


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

	$searchsql = "enabled='1'";

if($keywords)
{
switch($db->type)
{
case 'mysql':
case 'mysqli':

	$searchsql = "enabled='1'";

if($keywords)
{
switch($db->type)
{
case 'mysql':
case 'mysqli':

				$nfield = 'name';
$dfield = 'document';

				$nfield = 'name';
$dfield = 'document';

				break;

				break;

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

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

Zeile 845Zeile 852
			{
$string = "OR";
$name_lookin = " AND (";

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

			}

if($search['document'] == 1)
{

			}

if($search['document'] == 1)
{

				$document_lookin = " {$string} (";
}


				$document_lookin = " {$string} (";
}


Zeile 892Zeile 899
									// Just in a document?
continue;
}

									// Just in a document?
continue;
}

							}

							}


$boolean = $word;
}


$boolean = $word;
}

Zeile 958Zeile 965
					// There are no search keywords to look for
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']);
error($lang->error_minsearchlength);

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


$inquote = !$inquote;
}

Zeile 999Zeile 1006
				if($search['document'] == 1)
{
$searchsql .= " AND {$dfield} LIKE '%{$keywords}%'";

				if($search['document'] == 1)
{
$searchsql .= " AND {$dfield} LIKE '%{$keywords}%'";

				}
}
}

				}
}
}

	}

// Run the search

	}

// Run the search

Zeile 1345Zeile 1352
			{
$post_visiblesql = " AND p.visible == '0'";
$plain_post_visiblesql = " AND visible == '0'";

			{
$post_visiblesql = " AND p.visible == '0'";
$plain_post_visiblesql = " AND visible == '0'";

			}
}
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where_t = get_visible_where('t');
$unapproved_where_p = get_visible_where('p');


			}
}
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where_t = get_visible_where('t');
$unapproved_where_p = get_visible_where('p');


	// Searching a specific thread?
$tidsql = '';
if(!empty($search['tid']))
{
$tidsql = " AND t.tid='".(int)$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)


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

Zeile 1374Zeile 1381
	{
// No need to search subjects when looking for results within a specific thread
if(empty($search['tid']))

	{
// No need to search subjects when looking for results within a specific thread
if(empty($search['tid']))

		{

		{

			$query = $db->query("
SELECT t.tid, t.firstpost
FROM ".TABLE_PREFIX."threads t

			$query = $db->query("
SELECT t.tid, t.firstpost
FROM ".TABLE_PREFIX."threads t

Zeile 1396Zeile 1403
			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$visiblesql} {$post_visiblesql} AND ({$unapproved_where_t}) AND ({$unapproved_where_p}) AND t.closed NOT LIKE 'moved|%' {$message_lookin}

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$visiblesql} {$post_visiblesql} AND ({$unapproved_where_t}) AND ({$unapproved_where_p}) AND t.closed NOT LIKE 'moved|%' {$message_lookin}

			{$limitsql}

			{$limitsql}

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

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

Zeile 1440Zeile 1447
		{
$query = $db->simple_select("posts", "pid", "pid IN ($firstposts) {$plain_post_visiblesql} {$limitsql}");
while($post = $db->fetch_array($query))

		{
$query = $db->simple_select("posts", "pid", "pid IN ($firstposts) {$plain_post_visiblesql} {$limitsql}");
while($post = $db->fetch_array($query))

			{

			{

				$posts[$post['pid']] = $post['pid'];
}
$posts = implode(',', $posts);

				$posts[$post['pid']] = $post['pid'];
}
$posts = implode(',', $posts);

Zeile 1462Zeile 1469
function perform_search_mysql_ft($search)
{
global $mybb, $db, $lang;

function perform_search_mysql_ft($search)
{
global $mybb, $db, $lang;





	$keywords = clean_keywords_ft($search['keywords']);

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

	$keywords = clean_keywords_ft($search['keywords']);

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

Zeile 1470Zeile 1477
		$mybb->settings['minsearchword'] = 4;
}


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


 
	$message_lookin = $subject_lookin = '';

	if($keywords)
{
$keywords_exp = explode("\"", $keywords);

	if($keywords)
{
$keywords_exp = explode("\"", $keywords);

Zeile 1528Zeile 1536
		$userids = array();
$search['author'] = my_strtolower($search['author']);
if($search['matchusername'])

		$userids = array();
$search['author'] = my_strtolower($search['author']);
if($search['matchusername'])

		{

		{

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

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

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

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

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

		}

		}


if(count($userids) < 1)


if(count($userids) < 1)

		{
error($lang->error_nosearchresults);
}
else
{

		{
error($lang->error_nosearchresults);
}
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 = '';

	$datecut = $thread_datecut = $post_datecut = '';

	if($search['postdate'])
{
if($search['pddir'] == 0)

	if($search['postdate'])
{
if($search['pddir'] == 0)

		{

		{

			$datecut = "<=";

			$datecut = "<=";

		}

		}

		else
{
$datecut = ">=";

		else
{
$datecut = ">=";

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

	{

	{

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

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

		{

		{

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

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

Zeile 1595Zeile 1603
		{
$threadprefix = (int)$threadprefix;
$prefixlist[] = $threadprefix;

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

		}

		}

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

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

	{

	{

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

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

		{

		{

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

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

Zeile 1617Zeile 1625
		if(!is_array($search['forums']))
{
$search['forums'] = array((int)$search['forums']);

		if(!is_array($search['forums']))
{
$search['forums'] = array((int)$search['forums']);

		}

		}

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

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

Zeile 1639Zeile 1647
	}
$permsql = "";
$onlyusfids = array();

	}
$permsql = "";
$onlyusfids = array();





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

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

Zeile 1648Zeile 1656
		{
$onlyusfids[] = $fid;
}

		{
$onlyusfids[] = $fid;
}

	}

	}

	if(!empty($onlyusfids))

	if(!empty($onlyusfids))

	{

	{

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


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


Zeile 1661Zeile 1669
	}
$inactiveforums = get_inactive_forums();
if($inactiveforums)

	}
$inactiveforums = get_inactive_forums();
if($inactiveforums)

	{

	{

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


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


Zeile 1671Zeile 1679
		if($search['visible'] == 1)
{
$visiblesql = " AND t.visible = '1'";

		if($search['visible'] == 1)
{
$visiblesql = " AND t.visible = '1'";


if($search['postthread'] == 1)
{


if($search['postthread'] == 1)
{

				$post_visiblesql = " AND p.visible = '1'";
$plain_post_visiblesql = " AND visible = '1'";
}

				$post_visiblesql = " AND p.visible = '1'";
$plain_post_visiblesql = " AND visible = '1'";
}

Zeile 1681Zeile 1689
		elseif($search['visible'] == -1)
{
$visiblesql = " AND t.visible = '-1'";

		elseif($search['visible'] == -1)
{
$visiblesql = " AND t.visible = '-1'";


if($search['postthread'] == 1)
{


if($search['postthread'] == 1)
{

				$post_visiblesql = " AND p.visible = '-1'";
$plain_post_visiblesql = " AND visible = '-1'";

				$post_visiblesql = " AND p.visible = '-1'";
$plain_post_visiblesql = " AND visible = '-1'";

			}

			}

		}
else
{
$visiblesql = " AND t.visible != '1'";

		}
else
{
$visiblesql = " AND t.visible != '1'";





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

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

Zeile 1699Zeile 1707
			}
}
}

			}
}
}





	// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where_t = get_visible_where('t');
$unapproved_where_p = get_visible_where('p');

// Searching a specific thread?

	// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where_t = get_visible_where('t');
$unapproved_where_p = get_visible_where('p');

// Searching a specific thread?

 
	$tidsql = '';

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

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