Vergleich inc/functions_search.php - 1.8.29 - 1.8.34

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 83Zeile 83
 */
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 $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;


$pid = (int)$pid;

if(!is_array($forum_cache))
{


$pid = (int)$pid;

if(!is_array($forum_cache))
{

		// Get Forums
$query = $db->simple_select("forums", "fid,parentlist,password,active", '', array('order_by' => 'pid, disporder'));
while($forum = $db->fetch_array($query))
{
$forum_cache[$forum['fid']] = $forum;
}

		cache_forums();






	}
if(!is_array($permissioncache))
{

	}
if(!is_array($permissioncache))
{

Zeile 105Zeile 100
		if($permissioncache[$forum['fid']])
{
$perms = $permissioncache[$forum['fid']];

		if($permissioncache[$forum['fid']])
{
$perms = $permissioncache[$forum['fid']];

		}

		}

		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

Zeile 119Zeile 114
				if($forum_cache[$parent]['active'] == 0)
{
$forum['active'] = 0;

				if($forum_cache[$parent]['active'] == 0)
{
$forum['active'] = 0;

				}
}

				}
}

		}

if($perms['canview'] != 1 || $perms['cansearch'] != 1 || !forum_password_validated($forum, true) || $forum['active'] == 0)

		}

if($perms['canview'] != 1 || $perms['cansearch'] != 1 || !forum_password_validated($forum, true) || $forum['active'] == 0)

Zeile 133Zeile 128
		}
}
$unsearchable = $unsearchableforums;

		}
}
$unsearchable = $unsearchableforums;





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

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





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

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

Zeile 145Zeile 140
	if($pass_protected_forums)
{
$unsearchable .= implode(",", $pass_protected_forums);

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

	}

	}


return $unsearchable;
}


return $unsearchable;
}

Zeile 219Zeile 214
			$unapproved_where .= ')';

return $unapproved_where;

			$unapproved_where .= ')';

return $unapproved_where;

		}
}


		}
}


	// Normal users
if($mybb->user['uid'] > 0 && $mybb->settings['showownunapproved'] == 1)
{

	// Normal users
if($mybb->user['uid'] > 0 && $mybb->settings['showownunapproved'] == 1)
{

Zeile 246Zeile 241
	}

if(!is_array($forum_cache))

	}

if(!is_array($forum_cache))

	{

	{

		$forum_cache = cache_forums();
if(!$forum_cache)
{

		$forum_cache = cache_forums();
if(!$forum_cache)
{

Zeile 297Zeile 292
	}

if(my_strpos($keywords, "and") === 0)

	}

if(my_strpos($keywords, "and") === 0)

	{

	{

		$keywords = substr_replace($keywords, "", 0, 3);
$keywords = " ".$keywords;
}


		$keywords = substr_replace($keywords, "", 0, 3);
$keywords = " ".$keywords;
}


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


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


	return $keywords;
}


	return $keywords;
}


Zeile 321Zeile 316
	if(!$keywords)
{
return false;

	if(!$keywords)
{
return false;

	}

	}

	$keywords = my_strtolower($keywords);
$keywords = str_replace("%", "\\%", $keywords);
$keywords = preg_replace("#\*{2,}#s", "*", $keywords);

	$keywords = my_strtolower($keywords);
$keywords = str_replace("%", "\\%", $keywords);
$keywords = preg_replace("#\*{2,}#s", "*", $keywords);

Zeile 370Zeile 365
				if($phrase_operator)
{
$boolean[$depth] = $phrase_operator;

				if($phrase_operator)
{
$boolean[$depth] = $phrase_operator;

				}

				}

				// Phrases do not need further processing
$words[$depth][] = "{$boolean[$depth]}\"{$phrase}\"";
$boolean[$depth] = $phrase_operator = '+';

				// Phrases do not need further processing
$words[$depth][] = "{$boolean[$depth]}\"{$phrase}\"";
$boolean[$depth] = $phrase_operator = '+';

Zeile 492Zeile 487
 * @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)

{
global $mybb, $db, $lang;

$keywords = clean_keywords($search['keywords']);
if(!$keywords && !$search['sender'])
{
error($lang->error_nosearchterms);
}

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

{
global $mybb, $db, $lang;

$keywords = clean_keywords($search['keywords']);
if(!$keywords && !$search['sender'])
{
error($lang->error_nosearchterms);
}

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

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


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


Zeile 655Zeile 650
				}

$inquote = !$inquote;

				}

$inquote = !$inquote;

			}

			}


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


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

Zeile 699Zeile 694
	}

if($search['sender'])

	}

if($search['sender'])

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

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

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

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

				$field = 'username';
break;
default:

				$field = 'username';
break;
default:

Zeile 746Zeile 741
		if($folderids)
{
$searchsql .= " AND folder IN (".$folderids.")";

		if($folderids)
{
$searchsql .= " AND folder IN (".$folderids.")";

		}
}


		}
}


	if($search['status'])
{
$searchsql .= " AND (";

	if($search['status'])
{
$searchsql .= " AND (";

Zeile 823Zeile 818
	{
$mybb->settings['minsearchword'] = 3;
}

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





	$name_lookin = "";
$document_lookin = "";
$searchsql = "enabled='1'";

	$name_lookin = "";
$document_lookin = "";
$searchsql = "enabled='1'";

Zeile 900Zeile 895
									continue;
}
}

									continue;
}
}


$boolean = $word;
}
// Otherwise check the length of the word as it is a normal search term
else
{
$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);
}


$boolean = $word;
}
// Otherwise check the length of the word as it is a normal search term
else
{
$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);
}

							// Add terms to search query
if($search['name'] == 1)
{

							// Add terms to search query
if($search['name'] == 1)
{

Zeile 1302Zeile 1297
			if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;

			if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;

			}
}
}
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)
{
$permsql .= " AND t.fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}


			}
}
}
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)
{
$permsql .= " AND t.fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}


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

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

Zeile 1371Zeile 1366
	if((int)$mybb->settings['searchhardlimit'] > 0)
{
$limitsql = "LIMIT ".(int)$mybb->settings['searchhardlimit'];

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

	}


	}


	// Searching both posts and thread titles
$threads = array();
$posts = array();

	// Searching both posts and thread titles
$threads = array();
$posts = array();

Zeile 1394Zeile 1389
				if($thread['firstpost'])
{
$posts[$thread['tid']] = $thread['firstpost'];

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

				}
}
}


				}
}
}


		$query = $db->query("
SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p

		$query = $db->query("
SELECT p.pid, p.tid
FROM ".TABLE_PREFIX."posts p

Zeile 1449Zeile 1444
			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 1525Zeile 1520
		{
$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);

		}

		}

		$message_lookin = "AND MATCH(message) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)";
$subject_lookin = "AND MATCH(subject) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)";
}

		$message_lookin = "AND MATCH(message) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)";
$subject_lookin = "AND MATCH(subject) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)";
}

Zeile 1539Zeile 1534
		{
$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

Zeile 1550Zeile 1545
			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 1627Zeile 1622
			$search['forums'] = array((int)$search['forums']);
}
foreach($search['forums'] as $forum)

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

		{

		{

			$forum = (int)$forum;
if($forum > 0)
{

			$forum = (int)$forum;
if($forum > 0)
{

Zeile 1652Zeile 1647
	$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)
{

	$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)
{

		if($forum_permissions['canonlyviewownthreads'] == 1)

		if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)

		{
$onlyusfids[] = $fid;
}

		{
$onlyusfids[] = $fid;
}

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

		if($search['visible'] == 1)
{
$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 1714Zeile 1709

// Searching a specific thread?
$tidsql = '';


// Searching a specific thread?
$tidsql = '';

	if($search['tid'])

	if(!empty($search['tid']))

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

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

	}

	}


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


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

	{

	{

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


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


Zeile 1732Zeile 1727
	if($search['postthread'] == 1)
{
// No need to search subjects when looking for results within a specific thread

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

		if(!$search['tid'])

		if(empty($search['tid']))

		{
$query = $db->query("
SELECT t.tid, t.firstpost

		{
$query = $db->query("
SELECT t.tid, t.firstpost