Vergleich search.php - 1.8.15 - 1.8.22

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 90Zeile 90
			}
break;
case "forum":

			}
break;
case "forum":

			$sortfield = "t.fid";

			$sortfield = "f.name";

			break;
case "starter":
if($search['resulttype'] == "threads")

			break;
case "starter":
if($search['resulttype'] == "threads")

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

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

 
		}

$pages = ceil($threadcount / $perpage);
if($page > $pages)
{
$start = 0;
$page = 1;

		}

// Begin selecting matching threads, cache them.

		}

// Begin selecting matching threads, cache them.

Zeile 352Zeile 359
			SELECT t.*, u.username AS userusername
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)

			SELECT t.*, u.username AS userusername
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)

 
			LEFT JOIN ".TABLE_PREFIX."forums f ON (t.fid=f.fid)

			WHERE $where_conditions AND {$unapproved_where} {$permsql} AND t.closed NOT LIKE 'moved|%'
ORDER BY $sortfield $order
LIMIT $start, $perpage

			WHERE $where_conditions AND {$unapproved_where} {$permsql} AND t.closed NOT LIKE 'moved|%'
ORDER BY $sortfield $order
LIMIT $start, $perpage

Zeile 377Zeile 385

// Fetch dot icons if enabled
if($mybb->settings['dotfolders'] != 0 && $mybb->user['uid'] && $thread_cache)


// Fetch dot icons if enabled
if($mybb->settings['dotfolders'] != 0 && $mybb->user['uid'] && $thread_cache)

		{

		{

			$p_unapproved_where = str_replace('t.', '', $unapproved_where);
$query = $db->simple_select("posts", "DISTINCT tid,uid", "uid='{$mybb->user['uid']}' AND tid IN({$thread_ids}) AND {$p_unapproved_where}");
while($thread = $db->fetch_array($query))
{
$thread_cache[$thread['tid']]['dot_icon'] = 1;

			$p_unapproved_where = str_replace('t.', '', $unapproved_where);
$query = $db->simple_select("posts", "DISTINCT tid,uid", "uid='{$mybb->user['uid']}' AND tid IN({$thread_ids}) AND {$p_unapproved_where}");
while($thread = $db->fetch_array($query))
{
$thread_cache[$thread['tid']]['dot_icon'] = 1;

			}
}

			}
}


// Fetch the read threads.
if($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0)


// Fetch the read threads.
if($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0)

Zeile 393Zeile 401
			while($readthread = $db->fetch_array($query))
{
$thread_cache[$readthread['tid']]['lastread'] = $readthread['dateline'];

			while($readthread = $db->fetch_array($query))
{
$thread_cache[$readthread['tid']]['lastread'] = $readthread['dateline'];

			}
}


			}
}


		if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;
}


		if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;
}


		$results = '';


		$results = '';


		foreach($thread_cache as $thread)
{
$bgcolor = alt_trow();

		foreach($thread_cache as $thread)
{
$bgcolor = alt_trow();

Zeile 413Zeile 421
			if($thread['visible'] == 0)
{
$bgcolor = 'trow_shaded';

			if($thread['visible'] == 0)
{
$bgcolor = 'trow_shaded';

			}

			}

			elseif($thread['visible'] == -1)

			elseif($thread['visible'] == -1)

			{

			{

				$bgcolor = 'trow_shaded trow_deleted';

				$bgcolor = 'trow_shaded trow_deleted';

			}

			}


if($thread['userusername'])
{


if($thread['userusername'])
{

Zeile 425Zeile 433
			}
$thread['username'] = htmlspecialchars_uni($thread['username']);
$thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']);

			}
$thread['username'] = htmlspecialchars_uni($thread['username']);
$thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']);





			// If this thread has a prefix, insert a space between prefix and subject
if($thread['prefix'] != 0)
{
$thread['threadprefix'] .= ' ';

			// If this thread has a prefix, insert a space between prefix and subject
if($thread['prefix'] != 0)
{
$thread['threadprefix'] .= ' ';

			}


			}


			$thread['subject'] = $parser->parse_badwords($thread['subject']);
$thread['subject'] = htmlspecialchars_uni($thread['subject']);


			$thread['subject'] = $parser->parse_badwords($thread['subject']);
$thread['subject'] = htmlspecialchars_uni($thread['subject']);


Zeile 485Zeile 493
				if($thread['lastread'])
{
$last_read = $thread['lastread'];

				if($thread['lastread'])
{
$last_read = $thread['lastread'];

				}

				}

				else
{
$last_read = $read_cutoff;

				else
{
$last_read = $read_cutoff;

Zeile 494Zeile 502
			else
{
$last_read = my_get_array_cookie("threadread", $thread['tid']);

			else
{
$last_read = my_get_array_cookie("threadread", $thread['tid']);

			}


			}


			if($forum_read > $last_read)

			if($forum_read > $last_read)

			{

			{

				$last_read = $forum_read;
}

if($thread['lastpost'] > $last_read && $last_read)

				$last_read = $forum_read;
}

if($thread['lastpost'] > $last_read && $last_read)

			{

			{

				$folder .= "new";
$new_class = "subject_new";
$folder_label .= $lang->icon_new;

				$folder .= "new";
$new_class = "subject_new";
$folder_label .= $lang->icon_new;

Zeile 520Zeile 528
			{
$folder .= "hot";
$folder_label .= $lang->icon_hot;

			{
$folder .= "hot";
$folder_label .= $lang->icon_hot;

			}

			}

			if($thread['closed'] == 1)
{

			if($thread['closed'] == 1)
{

				$folder .= "lock";
$folder_label .= $lang->icon_lock;

				$folder .= "close";
$folder_label .= $lang->icon_close;

			}
$folder .= "folder";


			}
$folder .= "folder";


Zeile 574Zeile 582
					eval("\$threadpages .= \"".$templates->get("forumdisplay_thread_multipage_page")."\";");
}
eval("\$thread['multipage'] = \"".$templates->get("forumdisplay_thread_multipage")."\";");

					eval("\$threadpages .= \"".$templates->get("forumdisplay_thread_multipage_page")."\";");
}
eval("\$thread['multipage'] = \"".$templates->get("forumdisplay_thread_multipage")."\";");

			}
else
{

			}
else
{

				$threadpages = '';
$morelink = '';
$thread['multipage'] = '';

				$threadpages = '';
$morelink = '';
$thread['multipage'] = '';

Zeile 631Zeile 639
				if($thread['attachmentcount'] > 1)
{
$attachment_count = $lang->sprintf($lang->attachment_count_multiple, $thread['attachmentcount']);

				if($thread['attachmentcount'] > 1)
{
$attachment_count = $lang->sprintf($lang->attachment_count_multiple, $thread['attachmentcount']);

				}
else

				}
else

				{
$attachment_count = $lang->attachment_count;
}

				{
$attachment_count = $lang->attachment_count;
}

Zeile 640Zeile 648
				eval("\$attachment_count = \"".$templates->get("forumdisplay_thread_attachment_count")."\";");
}
else

				eval("\$attachment_count = \"".$templates->get("forumdisplay_thread_attachment_count")."\";");
}
else

			{

			{

				$attachment_count = '';
}


				$attachment_count = '';
}


Zeile 651Zeile 659
			if($is_supermod || is_moderator($thread['fid']))
{
if(isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|{$thread['tid']}|") !== false)

			if($is_supermod || is_moderator($thread['fid']))
{
if(isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|{$thread['tid']}|") !== false)

				{

				{

					$inlinecheck = "checked=\"checked\"";
++$inlinecount;
}

					$inlinecheck = "checked=\"checked\"";
++$inlinecount;
}

Zeile 659Zeile 667
				{
$inlinecheck = '';
}

				{
$inlinecheck = '';
}





				// If this user is allowed to use the inline moderation tools for at least one thread, include the necessary scripts
$show_inline_moderation = true;


				// If this user is allowed to use the inline moderation tools for at least one thread, include the necessary scripts
$show_inline_moderation = true;


Zeile 668Zeile 676
			elseif($is_mod)
{
eval("\$inline_mod_checkbox = \"".$templates->get("search_results_threads_nocheck")."\";");

			elseif($is_mod)
{
eval("\$inline_mod_checkbox = \"".$templates->get("search_results_threads_nocheck")."\";");

			}


			}


			$plugins->run_hooks("search_results_thread");
eval("\$results .= \"".$templates->get("search_results_threads_thread")."\";");

			$plugins->run_hooks("search_results_thread");
eval("\$results .= \"".$templates->get("search_results_threads_thread")."\";");

		}

		}

		if(!$results)

		if(!$results)

		{

		{

			error($lang->error_nosearchresults);

			error($lang->error_nosearchresults);

		}

		}

		$multipage = multipage($threadcount, $perpage, $page, "search.php?action=results&sid=$sid&sortby=$sortby&order=$order&uid=".$mybb->get_input('uid', MyBB::INPUT_INT));
if($upper > $threadcount)
{

		$multipage = multipage($threadcount, $perpage, $page, "search.php?action=results&sid=$sid&sortby=$sortby&order=$order&uid=".$mybb->get_input('uid', MyBB::INPUT_INT));
if($upper > $threadcount)
{

Zeile 687Zeile 695
		if($show_inline_moderation)
{
eval("\$inlinemodcol = \"".$templates->get("search_results_inlinemodcol")."\";");

		if($show_inline_moderation)
{
eval("\$inlinemodcol = \"".$templates->get("search_results_inlinemodcol")."\";");





			// If user has moderation tools available, prepare the Select All feature
$lang->page_selected = $lang->sprintf($lang->page_selected, count($thread_cache));
$lang->all_selected = $lang->sprintf($lang->all_selected, (int)$threadcount);

			// If user has moderation tools available, prepare the Select All feature
$lang->page_selected = $lang->sprintf($lang->page_selected, count($thread_cache));
$lang->all_selected = $lang->sprintf($lang->all_selected, (int)$threadcount);

Zeile 723Zeile 731
		}

$plugins->run_hooks("search_results_end");

		}

$plugins->run_hooks("search_results_end");





		eval("\$searchresults = \"".$templates->get("search_results_threads")."\";");
output_page($searchresults);
}

		eval("\$searchresults = \"".$templates->get("search_results_threads")."\";");
output_page($searchresults);
}

Zeile 777Zeile 785
		{
// Normal users
$unapproved_where = 'visible = 1';

		{
// Normal users
$unapproved_where = 'visible = 1';

		}

		}


$post_cache_options = array();
if((int)$mybb->settings['searchhardlimit'] > 0)
{
$post_cache_options['limit'] = (int)$mybb->settings['searchhardlimit'];


$post_cache_options = array();
if((int)$mybb->settings['searchhardlimit'] > 0)
{
$post_cache_options['limit'] = (int)$mybb->settings['searchhardlimit'];

		}


		}


		if(strpos($sortfield, 'p.') !== false)
{
$post_cache_options['order_by'] = str_replace('p.', '', $sortfield);

		if(strpos($sortfield, 'p.') !== false)
{
$post_cache_options['order_by'] = str_replace('p.', '', $sortfield);

Zeile 795Zeile 803
		$pids = array();
// Make sure the posts we're viewing we have permission to view.
$query = $db->simple_select("posts", "pid, tid", "pid IN(".$db->escape_string($search['posts']).") AND {$unapproved_where}", $post_cache_options);

		$pids = array();
// Make sure the posts we're viewing we have permission to view.
$query = $db->simple_select("posts", "pid, tid", "pid IN(".$db->escape_string($search['posts']).") AND {$unapproved_where}", $post_cache_options);

		while($post = $db->fetch_array($query))

		while($post = $db->fetch_array($query))

		{
$pids[$post['pid']] = $post['tid'];
$tids[$post['tid']][$post['pid']] = $post['pid'];

		{
$pids[$post['pid']] = $post['tid'];
$tids[$post['tid']][$post['pid']] = $post['pid'];

Zeile 830Zeile 838
			if($inactiveforums)
{
$permsql .= " OR fid IN ($inactiveforums)";

			if($inactiveforums)
{
$permsql .= " OR fid IN ($inactiveforums)";

			}


			}


			// Check the thread records as well. If we don't have permissions, remove them from the listing.
$query = $db->simple_select("threads", "tid", "tid IN(".$db->escape_string(implode(',', $pids)).") AND ({$unapproved_where}{$permsql} OR closed LIKE 'moved|%')");
while($thread = $db->fetch_array($query))

			// Check the thread records as well. If we don't have permissions, remove them from the listing.
$query = $db->simple_select("threads", "tid", "tid IN(".$db->escape_string(implode(',', $pids)).") AND ({$unapproved_where}{$permsql} OR closed LIKE 'moved|%')");
while($thread = $db->fetch_array($query))

Zeile 867Zeile 875
		{
$query = $db->simple_select("threadsread", "tid, dateline", "uid='".$mybb->user['uid']."' AND tid IN(".$db->escape_string($tids).")");
while($readthread = $db->fetch_array($query))

		{
$query = $db->simple_select("threadsread", "tid, dateline", "uid='".$mybb->user['uid']."' AND tid IN(".$db->escape_string($tids).")");
while($readthread = $db->fetch_array($query))

			{

			{

				$readthreads[$readthread['tid']] = $readthread['dateline'];

				$readthreads[$readthread['tid']] = $readthread['dateline'];

			}
}


			}
}


		$dot_icon = array();
if($mybb->settings['dotfolders'] != 0 && $mybb->user['uid'] != 0)
{

		$dot_icon = array();
if($mybb->settings['dotfolders'] != 0 && $mybb->user['uid'] != 0)
{

Zeile 880Zeile 888
			{
$dot_icon[$post['tid']] = true;
}

			{
$dot_icon[$post['tid']] = true;
}

		}


		}


		$results = '';

		$results = '';

 

$pages = ceil($postcount / $perpage);
if($page > $pages)
{
$start = 0;
$page = 1;
}


$query = $db->query("
SELECT p.*, u.username AS userusername, t.subject AS thread_subject, t.replies AS thread_replies, t.views AS thread_views, t.lastpost AS thread_lastpost, t.closed AS thread_closed, t.uid as thread_uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)


$query = $db->query("
SELECT p.*, u.username AS userusername, t.subject AS thread_subject, t.replies AS thread_replies, t.views AS thread_views, t.lastpost AS thread_lastpost, t.closed AS thread_closed, t.uid as thread_uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

 
			LEFT JOIN ".TABLE_PREFIX."forums f ON (t.fid=f.fid)

			WHERE p.pid IN (".$db->escape_string($search['posts']).")
ORDER BY $sortfield $order
LIMIT $start, $perpage

			WHERE p.pid IN (".$db->escape_string($search['posts']).")
ORDER BY $sortfield $order
LIMIT $start, $perpage

Zeile 903Zeile 919
			elseif($post['visible'] == -1)
{
$bgcolor = 'trow_shaded trow_deleted';

			elseif($post['visible'] == -1)
{
$bgcolor = 'trow_shaded trow_deleted';

			}

			}

			if($post['userusername'])
{
$post['username'] = $post['userusername'];

			if($post['userusername'])
{
$post['username'] = $post['userusername'];

Zeile 921Zeile 937
				$posticon['path'] = htmlspecialchars_uni($posticon['path']);
$posticon['name'] = htmlspecialchars_uni($posticon['name']);
eval("\$icon = \"".$templates->get("search_results_icon")."\";");

				$posticon['path'] = htmlspecialchars_uni($posticon['path']);
$posticon['name'] = htmlspecialchars_uni($posticon['name']);
eval("\$icon = \"".$templates->get("search_results_icon")."\";");

			}

			}

			else
{
$icon = " ";

			else
{
$icon = " ";

Zeile 1017Zeile 1033
			}
if($post['thread_closed'] == 1)
{

			}
if($post['thread_closed'] == 1)
{

				$folder .= "lock";
$folder_label .= $lang->icon_lock;

				$folder .= "close";
$folder_label .= $lang->icon_close;

			}
$folder .= "folder";


			}
$folder .= "folder";


Zeile 1214Zeile 1230
		"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => TIME_NOW,

		"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => TIME_NOW,

		"ipaddress" => $db->escape_binary($session->packedip),
"threads" => $db->escape_string($tids),
"posts" => $db->escape_string($pids),
"resulttype" => "posts",
"querycache" => '',
"keywords" => ''
);
$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "finduser")
{
$where_sql = "uid='".$mybb->get_input('uid', MyBB::INPUT_INT)."'";

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$where_sql .= " AND fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$where_sql .= " AND fid NOT IN ($inactiveforums)";
}

$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)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$where_sql .= "AND ((fid IN(".implode(',', $onlyusfids).") AND uid='{$mybb->user['uid']}') OR fid NOT IN(".implode(',', $onlyusfids)."))";
}

$options = array(
'order_by' => 'dateline',
'order_dir' => 'desc'
);

// Do we have a hard search limit?
if($mybb->settings['searchhardlimit'] > 0)
{
$options['limit'] = (int)$mybb->settings['searchhardlimit'];
}

$pids = '';
$comma = '';
$query = $db->simple_select("posts", "pid", "{$where_sql}", $options);
while($pid = $db->fetch_field($query, "pid"))
{
$pids .= $comma.$pid;
$comma = ',';
}

$tids = '';
$comma = '';
$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))
{
$tids .= $comma.$tid;
$comma = ',';
}

$sid = md5(uniqid(microtime(), true));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => TIME_NOW,
"ipaddress" => $db->escape_binary($session->packedip),
"threads" => $db->escape_string($tids),

		"ipaddress" => $db->escape_binary($session->packedip),
"threads" => $db->escape_string($tids),
"posts" => $db->escape_string($pids),
"resulttype" => "posts",
"querycache" => '',
"keywords" => ''
);
$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "finduser")
{
$where_sql = "uid='".$mybb->get_input('uid', MyBB::INPUT_INT)."'";

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$where_sql .= " AND fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$where_sql .= " AND fid NOT IN ($inactiveforums)";
}

$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)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$where_sql .= "AND ((fid IN(".implode(',', $onlyusfids).") AND uid='{$mybb->user['uid']}') OR fid NOT IN(".implode(',', $onlyusfids)."))";
}

$options = array(
'order_by' => 'dateline',
'order_dir' => 'desc'
);

// Do we have a hard search limit?
if($mybb->settings['searchhardlimit'] > 0)
{
$options['limit'] = (int)$mybb->settings['searchhardlimit'];
}

$pids = '';
$comma = '';
$query = $db->simple_select("posts", "pid", "{$where_sql}", $options);
while($pid = $db->fetch_field($query, "pid"))
{
$pids .= $comma.$pid;
$comma = ',';
}

$tids = '';
$comma = '';
$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))
{
$tids .= $comma.$tid;
$comma = ',';
}

$sid = md5(uniqid(microtime(), true));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => TIME_NOW,
"ipaddress" => $db->escape_binary($session->packedip),
"threads" => $db->escape_string($tids),

		"posts" => $db->escape_string($pids),
"resulttype" => "posts",
"querycache" => '',

		"posts" => $db->escape_string($pids),
"resulttype" => "posts",
"querycache" => '',

Zeile 1330Zeile 1346
		}
}
if(!empty($onlyusfids))

		}
}
if(!empty($onlyusfids))

	{

	{

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


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


Zeile 1350Zeile 1366
		"dateline" => TIME_NOW,
"ipaddress" => $db->escape_binary($session->packedip),
"threads" => $db->escape_string($tids),

		"dateline" => TIME_NOW,
"ipaddress" => $db->escape_binary($session->packedip),
"threads" => $db->escape_string($tids),

		"posts" => '',
"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),
"keywords" => ''
);
$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}

		"posts" => '',
"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),
"keywords" => ''
);
$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}

elseif($mybb->input['action'] == "getnew")

elseif($mybb->input['action'] == "getnew")

{

$where_sql = "lastpost >= '".(int)$mybb->user['lastvisit']."'";

if($mybb->get_input('fid', MyBB::INPUT_INT))
{
$where_sql .= " AND fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'";
}
else if($mybb->get_input('fids'))
{
$fids = explode(',', $mybb->get_input('fids'));
foreach($fids as $key => $fid)
{
$fids[$key] = (int)$fid;
}

if(!empty($fids))
{
$where_sql .= " AND fid IN (".implode(',', $fids).")";
}
}

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$where_sql .= " AND fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$where_sql .= " AND fid NOT IN ($inactiveforums)";
}

$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)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$where_sql .= "AND ((fid IN(".implode(',', $onlyusfids).") AND uid='{$mybb->user['uid']}') OR fid NOT IN(".implode(',', $onlyusfids)."))";
}

$tids = '';
$comma = '';
$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))

{

$where_sql = "lastpost >= '".(int)$mybb->user['lastvisit']."'";

if($mybb->get_input('fid', MyBB::INPUT_INT))
{
$where_sql .= " AND fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'";
}
else if($mybb->get_input('fids'))
{
$fids = explode(',', $mybb->get_input('fids'));
foreach($fids as $key => $fid)
{
$fids[$key] = (int)$fid;
}

if(!empty($fids))
{
$where_sql .= " AND fid IN (".implode(',', $fids).")";
}
}

$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$where_sql .= " AND fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$where_sql .= " AND fid NOT IN ($inactiveforums)";
}

$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)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$where_sql .= "AND ((fid IN(".implode(',', $onlyusfids).") AND uid='{$mybb->user['uid']}') OR fid NOT IN(".implode(',', $onlyusfids)."))";
}

$tids = '';
$comma = '';
$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))

	{
$tids .= $comma.$tid;
$comma = ',';

	{
$tids .= $comma.$tid;
$comma = ',';

Zeile 1430Zeile 1446
		"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),
"keywords" => ''

		"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),
"keywords" => ''

	);


	);


	$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);

	$plugins->run_hooks("search_do_search_process");
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);

Zeile 1447Zeile 1463
		$days = $mybb->get_input('days', MyBB::INPUT_INT);
}
$datecut = TIME_NOW-(86400*$days);

		$days = $mybb->get_input('days', MyBB::INPUT_INT);
}
$datecut = TIME_NOW-(86400*$days);


$where_sql = "lastpost >='".$datecut."'";



$where_sql = "lastpost >='".$datecut."'";


	if($mybb->get_input('fid', MyBB::INPUT_INT))
{
$where_sql .= " AND fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'";

	if($mybb->get_input('fid', MyBB::INPUT_INT))
{
$where_sql .= " AND fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'";

Zeile 1458Zeile 1474
	{
$fids = explode(',', $mybb->get_input('fids'));
foreach($fids as $key => $fid)

	{
$fids = explode(',', $mybb->get_input('fids'));
foreach($fids as $key => $fid)

		{

		{

			$fids[$key] = (int)$fid;
}

if(!empty($fids))
{
$where_sql .= " AND fid IN (".implode(',', $fids).")";

			$fids[$key] = (int)$fid;
}

if(!empty($fids))
{
$where_sql .= " AND fid IN (".implode(',', $fids).")";

		}
}


		}
}


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

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

	{

	{

		$where_sql .= " AND fid NOT IN ($unsearchforums)";

		$where_sql .= " AND fid NOT IN ($unsearchforums)";

	}

	}

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

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

Zeile 1485Zeile 1501
	// 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)

	{

	{

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

	if(!empty($onlyusfids))

	{

	{

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

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

	}

	}


$tids = '';
$comma = '';


$tids = '';
$comma = '';

Zeile 1504Zeile 1520
			$tids .= $comma.$tid;
$comma = ',';
}

			$tids .= $comma.$tid;
$comma = ',';
}

	



	$sid = md5(uniqid(microtime(), true));
$searcharray = array(
"sid" => $db->escape_string($sid),

	$sid = md5(uniqid(microtime(), true));
$searcharray = array(
"sid" => $db->escape_string($sid),

Zeile 1522Zeile 1538
	$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}

	$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}

elseif($mybb->input['action'] == "do_search" && $mybb->request_method == "post")

elseif($mybb->input['action'] == "do_search")

{
$plugins->run_hooks("search_do_search_start");


{
$plugins->run_hooks("search_do_search_start");