Vergleich search.php - 1.8.23 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 60Zeile 60
	$query = $db->simple_select("searchlog", "*", "sid='$sid'");
$search = $db->fetch_array($query);


	$query = $db->simple_select("searchlog", "*", "sid='$sid'");
$search = $db->fetch_array($query);


	if(!$search['sid'])

	if(!$search)

	{
error($lang->error_invalidsearch);
}

	{
error($lang->error_invalidsearch);
}

Zeile 104Zeile 104
			break;
case "lastpost":
default:

			break;
case "lastpost":
default:

			if($search['resulttype'] == "threads")

			if(isset($search['resulttype']) && $search['resulttype'] == "threads")

			{
$sortfield = "t.lastpost";
$sortby = "lastpost";

			{
$sortfield = "t.lastpost";
$sortby = "lastpost";

Zeile 115Zeile 115
				$sortby = "dateline";
}
break;

				$sortby = "dateline";
}
break;

	}

	}


if($order != "asc")


if($order != "asc")

	{

	{

		$order = "desc";
$oppsortnext = "asc";
$oppsort = $lang->asc;

		$order = "desc";
$oppsortnext = "asc";
$oppsort = $lang->asc;

Zeile 127Zeile 127
	{
$oppsortnext = "desc";
$oppsort = $lang->desc;

	{
$oppsortnext = "desc";
$oppsort = $lang->desc;

	}

	}


if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
{


if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
{

Zeile 152Zeile 152

// Work out if we have terms to highlight
$highlight = "";


// Work out if we have terms to highlight
$highlight = "";

	if($search['keywords'])

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

	{
if($mybb->seo_support == true)
{

	{
if($mybb->seo_support == true)
{

Zeile 175Zeile 175
	// Read some caches we will be using
$forumcache = $cache->read("forums");
$icon_cache = $cache->read("posticons");

	// Read some caches we will be using
$forumcache = $cache->read("forums");
$icon_cache = $cache->read("posticons");





	$threads = array();

if($mybb->user['uid'] == 0)

	$threads = array();

if($mybb->user['uid'] == 0)

	{
// Build a forum cache.
$query = $db->query("

	{
// Build a forum cache.
$query = $db->query("

			SELECT fid
FROM ".TABLE_PREFIX."forums
WHERE active != 0
ORDER BY pid, disporder
");


			SELECT fid
FROM ".TABLE_PREFIX."forums
WHERE active != 0
ORDER BY pid, disporder
");


		$forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);








		if(isset($mybb->cookies['mybb']['forumread']))
{
$forumsread = my_unserialize($mybb->cookies['mybb']['forumread'], false);
}
else
{
$forumsread = array();
}

	}
else
{

	}
else
{

Zeile 200Zeile 207
			WHERE f.active != 0
ORDER BY pid, disporder
");

			WHERE f.active != 0
ORDER BY pid, disporder
");

	}


	}


	while($forum = $db->fetch_array($query))
{
if($mybb->user['uid'] == 0)

	while($forum = $db->fetch_array($query))
{
if($mybb->user['uid'] == 0)

		{
if($forumsread[$forum['fid']])

		{
if(!empty($forumsread[$forum['fid']]))

			{
$forum['lastread'] = $forumsread[$forum['fid']];
}
}

			{
$forum['lastread'] = $forumsread[$forum['fid']];
}
}

		$readforums[$forum['fid']] = $forum['lastread'];










if(isset($forum['lastread']))
{
$readforums[$forum['fid']] = $forum['lastread'];
}
else
{
$readforums[$forum['fid']] = '';
}

	}
$fpermissions = forum_permissions();

// Inline Mod Column for moderators

	}
$fpermissions = forum_permissions();

// Inline Mod Column for moderators

	$inlinemodcol = $inlinecookie = '';

	$inlinemodcol = $inlinecookie = $inline_edit_js = '';

	$is_mod = $is_supermod = $show_inline_moderation = false;
if($mybb->usergroup['issupermod'])
{

	$is_mod = $is_supermod = $show_inline_moderation = false;
if($mybb->usergroup['issupermod'])
{

Zeile 231Zeile 246
	}

// Show search results as 'threads'

	}

// Show search results as 'threads'

	if($search['resulttype'] == "threads")

	if(isset($search['resulttype']) && $search['resulttype'] == "threads")

	{
$threadcount = 0;


	{
$threadcount = 0;


Zeile 298Zeile 313
		}
$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 369Zeile 384
		{
$mybb->settings['maxmultipagelinks'] = 5;
}

		{
$mybb->settings['maxmultipagelinks'] = 5;
}





		$results = '';

foreach($thread_cache as $thread)

		$results = '';

foreach($thread_cache as $thread)

Zeile 446Zeile 461
			}
else
{

			}
else
{

				$forum_read = $forumsread[$thread['fid']];








				if(isset($forumsread[$thread['fid']]))
{
$forum_read = $forumsread[$thread['fid']];
}
else
{
$forum_read = '';
}

			}

if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read)
{

			}

if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read)
{

				if($thread['lastread'])

				if(isset($thread['lastread']))

				{
$last_read = $thread['lastread'];
}

				{
$last_read = $thread['lastread'];
}

Zeile 486Zeile 508
			}

if($thread['replies'] >= $mybb->settings['hottopic'] || $thread['views'] >= $mybb->settings['hottopicviews'])

			}

if($thread['replies'] >= $mybb->settings['hottopic'] || $thread['views'] >= $mybb->settings['hottopicviews'])

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

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

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

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

Zeile 549Zeile 571
				$threadpages = '';
$morelink = '';
$thread['multipage'] = '';

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

			}

			}

			$lastpostdate = my_date('relative', $thread['lastpost']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$lastposteruid = $thread['lastposteruid'];
if(!$lastposteruid && !$thread['lastposter'])
{
$lastposter = htmlspecialchars_uni($lang->guest);

			$lastpostdate = my_date('relative', $thread['lastpost']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$lastposteruid = $thread['lastposteruid'];
if(!$lastposteruid && !$thread['lastposter'])
{
$lastposter = htmlspecialchars_uni($lang->guest);

			}
else

			}
else

			{
$lastposter = htmlspecialchars_uni($thread['lastposter']);

			{
$lastposter = htmlspecialchars_uni($thread['lastposter']);

			}

			}

			$thread_link = get_thread_link($thread['tid']);

// Don't link to guest's profiles (they have no profile).

			$thread_link = get_thread_link($thread['tid']);

// Don't link to guest's profiles (they have no profile).

Zeile 568Zeile 590
			{
$lastposterlink = $lastposter;
}

			{
$lastposterlink = $lastposter;
}

			else
{
$lastposterlink = build_profile_link($lastposter, $lastposteruid);
}


			else
{
$lastposterlink = build_profile_link($lastposter, $lastposteruid);
}


			$thread['replies'] = my_number_format($thread['replies']);
$thread['views'] = my_number_format($thread['views']);

			$thread['replies'] = my_number_format($thread['replies']);
$thread['views'] = my_number_format($thread['views']);





			$thread['forumlink'] = '';
if($forumcache[$thread['fid']])
{

			$thread['forumlink'] = '';
if($forumcache[$thread['fid']])
{

Zeile 588Zeile 610
			if(($thread['uid'] == $mybb->user['uid'] && $thread['closed'] != 1 && $mybb->user['uid'] != 0 && $fpermissions[$thread['fid']]['caneditposts'] == 1) || is_moderator($thread['fid'], "caneditposts"))
{
$inline_edit_class = "subject_editable";

			if(($thread['uid'] == $mybb->user['uid'] && $thread['closed'] != 1 && $mybb->user['uid'] != 0 && $fpermissions[$thread['fid']]['caneditposts'] == 1) || is_moderator($thread['fid'], "caneditposts"))
{
$inline_edit_class = "subject_editable";

			}
else
{

			}
else
{

				$inline_edit_class = "";
}


				$inline_edit_class = "";
}


Zeile 651Zeile 673
		{
$upper = $threadcount;
}

		{
$upper = $threadcount;
}

 

$selectall = '';
$inlinemod = '';


// Inline Thread Moderation Options
if($show_inline_moderation)


// Inline Thread Moderation Options
if($show_inline_moderation)

Zeile 698Zeile 723
	}
else // Displaying results as posts
{

	}
else // Displaying results as posts
{

		if(!$search['posts'])

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

		{
error($lang->error_nosearchresults);
}

		{
error($lang->error_nosearchresults);
}

Zeile 880Zeile 905
			$isnew = 0;
$donenew = 0;
$last_read = 0;

			$isnew = 0;
$donenew = 0;
$last_read = 0;

			$post['thread_lastread'] = $readthreads[$post['tid']];

 




			if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'])










			if(isset($readthreads[$post['tid']]))
{
$post['thread_lastread'] = $readthreads[$post['tid']];
}
else
{
$post['thread_lastread'] = '';
}

if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'])

			{
$forum_read = $readforums[$post['fid']];


			{
$forum_read = $readforums[$post['fid']];


Zeile 890Zeile 923
				if($forum_read == 0 || $forum_read < $read_cutoff)
{
$forum_read = $read_cutoff;

				if($forum_read == 0 || $forum_read < $read_cutoff)
{
$forum_read = $read_cutoff;

				}

				}

			}
else
{

			}
else
{

				$forum_read = $forumsread[$post['fid']];








				if(isset($forumsread[$post['fid']]))
{
$forum_read = $forumsread[$post['fid']];
}
else
{
$forum_read = '';
}

			}

if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $post['thread_lastpost'] > $forum_read)

			}

if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $post['thread_lastpost'] > $forum_read)

Zeile 940Zeile 980
			{
$folder .= "new";
$folder_label .= $lang->icon_new;

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

 
				$thread['newpostlink'] = get_thread_link($post['tid'], 0, "newpost");

				eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
$unreadpost = 1;
}

				eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
$unreadpost = 1;
}

Zeile 969Zeile 1010
				$post['forumlink_link'] = get_forum_link($post['fid']);
$post['forumlink_name'] = $forumcache[$post['fid']]['name'];
eval("\$post['forumlink'] = \"".$templates->get("search_results_posts_forumlink")."\";");

				$post['forumlink_link'] = get_forum_link($post['fid']);
$post['forumlink_name'] = $forumcache[$post['fid']]['name'];
eval("\$post['forumlink'] = \"".$templates->get("search_results_posts_forumlink")."\";");

			}

			}


if(!$post['subject'])
{


if(!$post['subject'])
{

Zeile 1035Zeile 1076
		if(!$results)
{
error($lang->error_nosearchresults);

		if(!$results)
{
error($lang->error_nosearchresults);

		}

		}

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

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

		{

		{

			$upper = $postcount;
}

			$upper = $postcount;
}







$selectall = '';
$inlinemod = '';


		// Inline Post Moderation Options
if($show_inline_moderation)
{
eval("\$inlinemodcol = \"".$templates->get("search_results_inlinemodcol")."\";");

		// Inline Post Moderation Options
if($show_inline_moderation)
{
eval("\$inlinemodcol = \"".$templates->get("search_results_inlinemodcol")."\";");





			// If user has moderation tools available, prepare the Select All feature
$num_results = $db->num_rows($query);
$lang->page_selected = $lang->sprintf($lang->page_selected, (int)$num_results);

			// If user has moderation tools available, prepare the Select All feature
$num_results = $db->num_rows($query);
$lang->page_selected = $lang->sprintf($lang->page_selected, (int)$num_results);

Zeile 1056Zeile 1100

$customthreadtools = $customposttools = '';
switch($db->type)


$customthreadtools = $customposttools = '';
switch($db->type)

			{

			{

				case "pgsql":
case "sqlite":
$query = $db->simple_select("modtools", "tid, name, type", "type='p' AND (','||forums||',' LIKE '%,-1,%' OR forums='')");

				case "pgsql":
case "sqlite":
$query = $db->simple_select("modtools", "tid, name, type", "type='p' AND (','||forums||',' LIKE '%,-1,%' OR forums='')");

Zeile 1120Zeile 1164
	}
if(!empty($onlyusfids))
{

	}
if(!empty($onlyusfids))
{

		$where_sql .= " AND 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" => '',
"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)";
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where = get_visible_where();
$where_sql .= " AND ({$unapproved_where})";

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

		$where_sql .= " AND fid NOT IN(".implode(',', $onlyusfids).")";


















































































	}

$options = array(

	}

$options = array(

		'order_by' => 'dateline',
'order_dir' => 'desc'
);

		'order_by' => 'dateline DESC, pid DESC',
);



// Do we have a hard search limit?
if($mybb->settings['searchhardlimit'] > 0)


// Do we have a hard search limit?
if($mybb->settings['searchhardlimit'] > 0)

Zeile 1220Zeile 1182
	$query = $db->simple_select("posts", "pid", "{$where_sql}", $options);
while($pid = $db->fetch_field($query, "pid"))
{

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

			$pids .= $comma.$pid;
$comma = ',';

		$pids .= $comma.$pid;
$comma = ',';

	}

$tids = '';

	}

$tids = '';

Zeile 1229Zeile 1191
	$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))
{

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

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

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

	}

$sid = md5(uniqid(microtime(), true));

	}

$sid = md5(uniqid(microtime(), true));

Zeile 1249Zeile 1211
	$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'] == "finduserthreads")

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

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


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


Zeile 1258Zeile 1220
	{
$where_sql .= " AND fid NOT IN ($unsearchforums)";
}

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

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

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where = get_visible_where();
$where_sql .= " AND ({$unapproved_where})";

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

































































































































































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

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where = get_visible_where();
$where_sql .= " AND ({$unapproved_where})";

$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 DESC, pid 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" => '',
"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'] == "finduserthreads")
{
$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)";
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where = get_visible_where();
$where_sql .= " AND ({$unapproved_where})";

$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 = ',';
}

$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" => '',
"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")
{

$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)";
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where = get_visible_where();
$where_sql .= " AND ({$unapproved_where})";

$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 = '';
$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))
{

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

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

	}

$sid = md5(uniqid(microtime(), true));

	}

$sid = md5(uniqid(microtime(), true));

Zeile 1306Zeile 1428
		"querycache" => $db->escape_string($where_sql),
"keywords" => ''
);

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

$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)";
}

// Moderators can view unapproved threads and deleted threads from forums they moderate
$unapproved_where = get_visible_where();
$where_sql .= " AND ({$unapproved_where})";

$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 = ',';
}

$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" => '',
"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 1396Zeile 1438
	if($mybb->get_input('days', MyBB::INPUT_INT) < 1)
{
$days = 1;

	if($mybb->get_input('days', MyBB::INPUT_INT) < 1)
{
$days = 1;

	}

	}

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

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





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

if($mybb->get_input('fid', MyBB::INPUT_INT))

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

if($mybb->get_input('fid', MyBB::INPUT_INT))

Zeile 1448Zeile 1490
		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))
{
$where_sql .= "AND ((fid IN(".implode(',', $onlyusfids).") AND uid='{$mybb->user['uid']}') OR fid NOT IN(".implode(',', $onlyusfids)."))";

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

Zeile 1460Zeile 1502
	$query = $db->simple_select("threads", "tid", $where_sql);
while($tid = $db->fetch_field($query, "tid"))
{

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

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

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

	}

$sid = md5(uniqid(microtime(), true));

	}

$sid = md5(uniqid(microtime(), true));

Zeile 1475Zeile 1517
		"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 1484Zeile 1526
elseif($mybb->input['action'] == "do_search")
{
$plugins->run_hooks("search_do_search_start");

elseif($mybb->input['action'] == "do_search")
{
$plugins->run_hooks("search_do_search_start");


// Check if search flood checking is enabled and user is not admin
if($mybb->settings['searchfloodtime'] > 0 && $mybb->usergroup['cancp'] != 1)
{
// Fetch the time this user last searched
if($mybb->user['uid'])
{
$conditions = "uid='{$mybb->user['uid']}'";
}
else
{
$conditions = "uid='0' AND ipaddress=".$db->escape_binary($session->packedip);
}
$timecut = TIME_NOW-$mybb->settings['searchfloodtime'];
$query = $db->simple_select("searchlog", "*", "$conditions AND dateline > '$timecut'", array('order_by' => "dateline", 'order_dir' => "DESC"));


// Check if search flood checking is enabled and user is not admin
if($mybb->settings['searchfloodtime'] > 0 && $mybb->usergroup['cancp'] != 1)
{
// Fetch the time this user last searched
if($mybb->user['uid'])
{
$conditions = "uid='{$mybb->user['uid']}'";
}
else
{
$conditions = "uid='0' AND ipaddress=".$db->escape_binary($session->packedip);
}
$timecut = TIME_NOW-$mybb->settings['searchfloodtime'];
$query = $db->simple_select("searchlog", "*", "$conditions AND dateline > '$timecut'", array('order_by' => "dateline", 'order_dir' => "DESC"));

		$last_search = $db->fetch_array($query);
// Users last search was within the flood time, show the error

		$last_search = $db->fetch_array($query);
// Users last search was within the flood time, show the error

		if($last_search['sid'])

		if(!empty($last_search['sid']))

		{
$remaining_time = $mybb->settings['searchfloodtime']-(TIME_NOW-$last_search['dateline']);
if($remaining_time == 1)

		{
$remaining_time = $mybb->settings['searchfloodtime']-(TIME_NOW-$last_search['dateline']);
if($remaining_time == 1)

			{

			{

				$lang->error_searchflooding = $lang->sprintf($lang->error_searchflooding_1, $mybb->settings['searchfloodtime']);
}
else

				$lang->error_searchflooding = $lang->sprintf($lang->error_searchflooding_1, $mybb->settings['searchfloodtime']);
}
else

Zeile 1514Zeile 1556
			}
error($lang->error_searchflooding);
}

			}
error($lang->error_searchflooding);
}

	}

	}

	if($mybb->get_input('showresults') == "threads")
{
$resulttype = "threads";

	if($mybb->get_input('showresults') == "threads")
{
$resulttype = "threads";

Zeile 1522Zeile 1564
	else
{
$resulttype = "posts";

	else
{
$resulttype = "posts";

	}











	}

if(isset($mybb->input['forums']) && is_array($mybb->input['forums']))
{
$forums = $mybb->get_input('forums', MyBB::INPUT_ARRAY);
}
else
{
$forums = array($mybb->get_input('forums'));
}


	$search_data = array(
"keywords" => $mybb->input['keywords'],
"author" => $mybb->get_input('author'),

	$search_data = array(
"keywords" => $mybb->input['keywords'],
"author" => $mybb->get_input('author'),

Zeile 1531Zeile 1582
		"matchusername" => $mybb->get_input('matchusername', MyBB::INPUT_INT),
"postdate" => $mybb->get_input('postdate', MyBB::INPUT_INT),
"pddir" => $mybb->get_input('pddir', MyBB::INPUT_INT),

		"matchusername" => $mybb->get_input('matchusername', MyBB::INPUT_INT),
"postdate" => $mybb->get_input('postdate', MyBB::INPUT_INT),
"pddir" => $mybb->get_input('pddir', MyBB::INPUT_INT),

		"forums" => $mybb->input['forums'],

		"forums" => $forums,

		"findthreadst" => $mybb->get_input('findthreadst', MyBB::INPUT_INT),
"numreplies" => $mybb->get_input('numreplies', MyBB::INPUT_INT),
"threadprefix" => $mybb->get_input('threadprefix', MyBB::INPUT_ARRAY)
);

		"findthreadst" => $mybb->get_input('findthreadst', MyBB::INPUT_INT),
"numreplies" => $mybb->get_input('numreplies', MyBB::INPUT_INT),
"threadprefix" => $mybb->get_input('threadprefix', MyBB::INPUT_ARRAY)
);





	if(is_moderator() && !empty($mybb->input['visible']))
{
$search_data['visible'] = $mybb->get_input('visible', MyBB::INPUT_INT);

	if(is_moderator() && !empty($mybb->input['visible']))
{
$search_data['visible'] = $mybb->get_input('visible', MyBB::INPUT_INT);

Zeile 1547Zeile 1598
		if($mybb->settings['searchtype'] == "fulltext" && $db->supports_fulltext_boolean("posts") && $db->is_fulltext("posts"))
{
$search_results = perform_search_mysql_ft($search_data);

		if($mybb->settings['searchtype'] == "fulltext" && $db->supports_fulltext_boolean("posts") && $db->is_fulltext("posts"))
{
$search_results = perform_search_mysql_ft($search_data);

		}

		}

		else
{
$search_results = perform_search_mysql($search_data);

		else
{
$search_results = perform_search_mysql($search_data);

Zeile 1594Zeile 1645
	if(!$thread || ($thread['visible'] != 1 && $ismod == false && ($thread['visible'] != -1 || $mybb->settings['soft_delete'] != 1 || !$mybb->user['uid'] || $mybb->user['uid'] != $thread['uid'])) || ($thread['visible'] > 1 && $ismod == true))
{
error($lang->error_invalidthread);

	if(!$thread || ($thread['visible'] != 1 && $ismod == false && ($thread['visible'] != -1 || $mybb->settings['soft_delete'] != 1 || !$mybb->user['uid'] || $mybb->user['uid'] != $thread['uid'])) || ($thread['visible'] > 1 && $ismod == true))
{
error($lang->error_invalidthread);

	}

	}


// Get forum info
$forum = get_forum($thread['fid']);


// Get forum info
$forum = get_forum($thread['fid']);

Zeile 1632Zeile 1683
		$query = $db->simple_select("searchlog", "*", "$conditions AND dateline > '$timecut'", array('order_by' => "dateline", 'order_dir' => "DESC"));
$last_search = $db->fetch_array($query);


		$query = $db->simple_select("searchlog", "*", "$conditions AND dateline > '$timecut'", array('order_by' => "dateline", 'order_dir' => "DESC"));
$last_search = $db->fetch_array($query);


		// We shouldn't show remaining time if time is 0 or under.
$remaining_time = $mybb->settings['searchfloodtime']-(TIME_NOW-$last_search['dateline']);
// Users last search was within the flood time, show the error.
if($last_search['sid'] && $remaining_time > 0)

		if($last_search)




		{

		{

			if($remaining_time == 1)
{
$lang->error_searchflooding = $lang->sprintf($lang->error_searchflooding_1, $mybb->settings['searchfloodtime']);
}
else

			// We shouldn't show remaining time if time is 0 or under.
$remaining_time = $mybb->settings['searchfloodtime']-(TIME_NOW-$last_search['dateline']);
// Users last search was within the flood time, show the error.
if($remaining_time > 0)


			{

			{

				$lang->error_searchflooding = $lang->sprintf($lang->error_searchflooding, $mybb->settings['searchfloodtime'], $remaining_time);









				if($remaining_time == 1)
{
$lang->error_searchflooding = $lang->sprintf($lang->error_searchflooding_1, $mybb->settings['searchfloodtime']);
}
else
{
$lang->error_searchflooding = $lang->sprintf($lang->error_searchflooding, $mybb->settings['searchfloodtime'], $remaining_time);
}
error($lang->error_searchflooding);

			}

			}

			error($lang->error_searchflooding);

 
		}
}


		}
}