Vergleich search.php - 1.2.4 - 1.2.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html

 *

 *

 * $Id: search.php 2475 2006-12-01 04:58:21Z Tikitiki $

 * $Id: search.php 3478 2007-11-15 04:11:36Z Tikitiki $

 */



 */



Zeile 41Zeile 41

$now = time();



$now = time();


// Clear out searches older than a month

// Clear out searches older than a month 

if($rand == 3)
{
$timecut = time()-60*60*24*30;

if($rand == 3)
{
$timecut = time()-60*60*24*30;

Zeile 62Zeile 62
	$plugins->run_hooks("search_results_start");

// Decide on our sorting fields and sorting order.

	$plugins->run_hooks("search_results_start");

// Decide on our sorting fields and sorting order.

	$order = strtolower($mybb->input['order']);
$sortby = $mybb->input['sortby'];

	$order = strtolower(htmlspecialchars($mybb->input['order']));
$sortby = htmlspecialchars($mybb->input['sortby']);


switch($sortby)
{


switch($sortby)
{

Zeile 111Zeile 111
	if($order != "asc")
{
$order = "desc";

	if($order != "asc")
{
$order = "desc";

 
		$oppsortnext = "asc";
$oppsort = $lang->asc;
}
else
{
$oppsortnext = "desc";
$oppsort = $lang->desc;

	}

// Work out pagination, which page we're at, as well as the limits.
$perpage = $mybb->settings['threadsperpage'];
$page = intval($mybb->input['page']);
if($page > 0)

	}

// Work out pagination, which page we're at, as well as the limits.
$perpage = $mybb->settings['threadsperpage'];
$page = intval($mybb->input['page']);
if($page > 0)

	{

	{

		$start = ($page-1) * $perpage;
}
else

		$start = ($page-1) * $perpage;
}
else

Zeile 130Zeile 137
	$upper = $end;

$sorturl = "search.php?action=results&sid={$sid}";

	$upper = $end;

$sorturl = "search.php?action=results&sid={$sid}";

 
	
eval("\$orderarrow['$sortby'] = \"".$templates->get("forumdisplay_orderarrow")."\";");


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

$threads = array();


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

$threads = array();

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


// Show search results as 'threads'
if($search['resulttype'] == "threads")


// Show search results as 'threads'
if($search['resulttype'] == "threads")

Zeile 145Zeile 160
		if($search['querycache'] != "")
{
$where_conditions = $search['querycache'];

		if($search['querycache'] != "")
{
$where_conditions = $search['querycache'];

			$query = $db->simple_select(TABLE_PREFIX."threads t", "t.tid", $where_conditions. " AND t.visible>0 AND t.closed NOT LIKE 'moved|%'");

			$query = $db->simple_select(TABLE_PREFIX."threads t", "t.tid", $where_conditions. " AND t.visible>0 AND t.closed NOT LIKE 'moved|%' {$limitsql}");

			while($thread = $db->fetch_array($query))
{
$threads[$thread['tid']] = $thread['tid'];

			while($thread = $db->fetch_array($query))
{
$threads[$thread['tid']] = $thread['tid'];

Zeile 167Zeile 182
		else
{
$where_conditions = "t.tid IN (".$search['threads'].")";

		else
{
$where_conditions = "t.tid IN (".$search['threads'].")";

			$query = $db->simple_select(TABLE_PREFIX."threads t", "COUNT(t.tid) AS resultcount", $where_conditions. " AND t.visible>0 AND t.closed NOT LIKE 'moved|%'");

			$query = $db->simple_select(TABLE_PREFIX."threads t", "COUNT(t.tid) AS resultcount", $where_conditions. " AND t.visible>0 AND t.closed NOT LIKE 'moved|%' {$limitsql}");

			$count = $db->fetch_array($query);

if(!$count['resultcount'])

			$count = $db->fetch_array($query);

if(!$count['resultcount'])

Zeile 280Zeile 295
			if(!$lastread)
{
$readcookie = $threadread = my_get_array_cookie("threadread", $thread['tid']);

			if(!$lastread)
{
$readcookie = $threadread = my_get_array_cookie("threadread", $thread['tid']);

				if($readcookie > $forumread)
{
$lastread = $readcookie;
}
elseif($forumread > $mybb->user['lastvisit'])

				if($readcookie > $forumread)
{
$lastread = $readcookie;
}
elseif($forumread > $mybb->user['lastvisit'])

				{
$lastread = $forumread;

				{
$lastread = $forumread;

				}

				}

				else
{
$lastread = $mybb->user['lastvisit'];

				else
{
$lastread = $mybb->user['lastvisit'];

Zeile 295Zeile 310
			}

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

			}

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

			{

			{

				$folder .= "new";
$folder_label .= $lang->icon_new;
eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");

				$folder .= "new";
$folder_label .= $lang->icon_new;
eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");

Zeile 317Zeile 332
				$folder_label .= $lang->icon_lock;
}
$folder .= "folder";

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





			$thread['pages'] = 0;
$thread['multipage'] = '';
$threadpages = '';

			$thread['pages'] = 0;
$thread['multipage'] = '';
$threadpages = '';

Zeile 369Zeile 384
			if($forumcache[$thread['fid']])
{
$thread['forumlink'] = "<a href=\"".get_forum_link($thread['fid'])."\">".$forumcache[$thread['fid']]['name']."</a>";

			if($forumcache[$thread['fid']])
{
$thread['forumlink'] = "<a href=\"".get_forum_link($thread['fid'])."\">".$forumcache[$thread['fid']]['name']."</a>";

			}
else

			}
else

			{
$thread['forumlink'] = "";
}

			{
$thread['forumlink'] = "";
}

Zeile 410Zeile 425
			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
WHERE $where_conditions AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%'

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
WHERE $where_conditions AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%'

 
			{$limitsql}

		");
$count = $db->fetch_array($query);


		");
$count = $db->fetch_array($query);


Zeile 541Zeile 557
				$folder_label .= $lang->icon_hot;
}
if($thread['thread_closed'] == "yes")

				$folder_label .= $lang->icon_hot;
}
if($thread['thread_closed'] == "yes")

			{

			{

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

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

Zeile 602Zeile 618
elseif($mybb->input['action'] == "findguest")
{
$where_sql = "p.uid='0'";

elseif($mybb->input['action'] == "findguest")
{
$where_sql = "p.uid='0'";


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

$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => time(),
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"searchtype" => "titles",
"resulttype" => "posts",
"querycache" => $db->escape_string($where_sql),
);
$plugins->run_hooks("search_do_search_process");


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

$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => time(),
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"searchtype" => "titles",
"resulttype" => "posts",
"querycache" => $db->escape_string($where_sql),
);
$plugins->run_hooks("search_do_search_process");

	$db->insert_query(TABLE_PREFIX."searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "finduser")
{
$where_sql = "p.uid='".intval($mybb->input['uid'])."'";

	$db->insert_query(TABLE_PREFIX."searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "finduser")
{
$where_sql = "p.uid='".intval($mybb->input['uid'])."'";


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

$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],


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

$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],

		"dateline" => time(),
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"searchtype" => "titles",
"resulttype" => "posts",

		"dateline" => time(),
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"searchtype" => "titles",
"resulttype" => "posts",

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

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

}
elseif($mybb->input['action'] == "finduserthreads")
{

}
elseif($mybb->input['action'] == "finduserthreads")
{

Zeile 693Zeile 709
	redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "getnew")

	redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "getnew")

{


{	


	$where_sql = "t.lastpost >= '".$mybb->user['lastvisit']."'";

	$where_sql = "t.lastpost >= '".$mybb->user['lastvisit']."'";


if($mybb->input['fid'])
{
$where_sql .= " AND t.fid='".intval($mybb->input['fid'])."'";
}

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

$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => time(),
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"searchtype" => "titles",
"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),


if($mybb->input['fid'])
{
$where_sql .= " AND t.fid='".intval($mybb->input['fid'])."'";
}

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

$sid = md5(uniqid(microtime(), 1));
$searcharray = array(
"sid" => $db->escape_string($sid),
"uid" => $mybb->user['uid'],
"dateline" => time(),
"ipaddress" => $db->escape_string($session->ipaddress),
"threads" => '',
"posts" => '',
"searchtype" => "titles",
"resulttype" => "threads",
"querycache" => $db->escape_string($where_sql),

	);

$plugins->run_hooks("search_do_search_process");

	);

$plugins->run_hooks("search_do_search_process");

Zeile 787Zeile 802
	{
// Fetch the time this user last searched
if($mybb->user['uid'])

	{
// Fetch the time this user last searched
if($mybb->user['uid'])

		{

		{

			$conditions = "uid='{$mybb->user['uid']}'";

			$conditions = "uid='{$mybb->user['uid']}'";

		}

		}

		else

		else

		{

		{

			$conditions = "uid='0' AND ipaddress='".$db->escape_string($session->ipaddress)."'";
}
$timecut = time()-$mybb->settings['searchfloodtime'];
$query = $db->simple_select(TABLE_PREFIX."searchlog", "*", "$conditions AND dateline >= '$timecut'", array('order_by' => "dateline", 'order_dir' => "DESC"));
$last_search = $db->fetch_array($query);

			$conditions = "uid='0' AND ipaddress='".$db->escape_string($session->ipaddress)."'";
}
$timecut = time()-$mybb->settings['searchfloodtime'];
$query = $db->simple_select(TABLE_PREFIX."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
if($last_search['sid'])





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

		{

		{

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







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

			error($lang->error_searchflooding);
}
}

			error($lang->error_searchflooding);
}
}

Zeile 857Zeile 881

$db->insert_query(TABLE_PREFIX."searchlog", $searcharray);



$db->insert_query(TABLE_PREFIX."searchlog", $searcharray);


	if(strtolower($mybb->input['sortordr']) == "asc" || strtolower($mybb->input['sortordr'] == "desc"))

	if(strtolower($mybb->input['sortordr']) == "asc" || strtolower($mybb->input['sortordr']) == "desc")

	{
$sortorder = $mybb->input['sortordr'];
}

	{
$sortorder = $mybb->input['sortordr'];
}