Vergleich search.php - 1.2.8 - 1.2.14

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

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

 * $Id: search.php 3163 2007-06-26 18:38:25Z CraKteR $

 * $Id: search.php 3887 2008-06-06 23:38:42Z 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 73Zeile 73
		case "views":
$sortfield = "t.views";
break;

		case "views":
$sortfield = "t.views";
break;

		case "dateline":

		case "subject":

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

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

				$sortfield = "t.dateline";

				$sortfield = "t.subject";

			}
else
{

			}
else
{

				$sortfield = "p.dateline";
}
break;

				$sortfield = "p.subject";
}
break;

		case "forum":
$sortfield = "t.fid";
break;

		case "forum":
$sortfield = "t.fid";
break;

Zeile 90Zeile 90
			if($search['resulttype'] == "threads")
{
$sortfield = "t.username";

			if($search['resulttype'] == "threads")
{
$sortfield = "t.username";

			}
else
{

			}
else
{

				$sortfield = "p.username";

				$sortfield = "p.username";

			}

			}

			break;

			break;

 
		case "lastpost":

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

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

			{

			{

				$sortfield = "t.lastpost";

				$sortfield = "t.lastpost";

			}
else
{


				$sortby = 'lastpost';
}
else
{

				$sortfield = "p.dateline";

				$sortfield = "p.dateline";

 
				$sortby = 'dateline';

			}
break;

			}
break;

	}

	}

	
if($order != "asc")

	
if($order != "asc")

	{

	{

		$order = "desc";

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

	}

// Work out pagination, which page we're at, as well as the limits.

Zeile 124Zeile 134
	{
$start = 0;
$page = 1;

	{
$start = 0;
$page = 1;

	}

	}

	$end = $start + $perpage;
$lower = $start+1;
$upper = $end;

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

	$end = $start + $perpage;
$lower = $start+1;
$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 163
		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 185
		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'])

			{

			{

				error($lang->error_nosearchresults);
}
$threadcount = $count['resultcount'];

				error($lang->error_nosearchresults);
}
$threadcount = $count['resultcount'];

Zeile 233Zeile 251

$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']);





			if($icon_cache[$thread['icon']])

			if($icon_cache[$thread['icon']])

			{

			{

				$posticon = $icon_cache[$thread['icon']];
$icon = "<img src=\"".$posticon['path']."\" alt=\"".$posticon['name']."\" />";

				$posticon = $icon_cache[$thread['icon']];
$icon = "<img src=\"".$posticon['path']."\" alt=\"".$posticon['name']."\" />";

			}

			}

			else
{
$icon = "&nbsp;";
}
if($thread['poll'])

			else
{
$icon = "&nbsp;";
}
if($thread['poll'])

			{

			{

				$prefix = $lang->poll_prefix;

				$prefix = $lang->poll_prefix;

			}

			}

				
// Determine the folder
$folder = '';

				
// Determine the folder
$folder = '';

Zeile 255Zeile 273
			{
$folder = "dot_";
$folder_label .= $lang->icon_dot;

			{
$folder = "dot_";
$folder_label .= $lang->icon_dot;

			}
$gotounread = '';
$isnew = 0;
$donenew = 0;
$lastread = 0;


			}
$gotounread = '';
$isnew = 0;
$donenew = 0;
$lastread = 0;


			if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forumread)
{
$cutoff = time()-$mybb->settings['threadreadcut']*60*60*24;

			if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forumread)
{
$cutoff = time()-$mybb->settings['threadreadcut']*60*60*24;

Zeile 410Zeile 428
			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 439Zeile 458
		{
$query = $db->simple_select(TABLE_PREFIX."threadsread", "tid, dateline", "uid='".$mybb->user['uid']."' AND tid IN(".$tids.")");
while($readthread = $db->fetch_array($query))

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

			{

			{

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

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

Zeile 461Zeile 480
			}
$post['profilelink'] = build_profile_link($post['username'], $post['uid']);
$post['subject'] = $parser->parse_badwords($post['subject']);

			}
$post['profilelink'] = build_profile_link($post['username'], $post['uid']);
$post['subject'] = $parser->parse_badwords($post['subject']);

			$post['subject'] = htmlspecialchars_uni($post['subject']);

 
			$post['thread_subject'] = $parser->parse_badwords($post['thread_subject']);
$post['thread_subject'] = htmlspecialchars_uni($post['thread_subject']);


			$post['thread_subject'] = $parser->parse_badwords($post['thread_subject']);
$post['thread_subject'] = htmlspecialchars_uni($post['thread_subject']);


Zeile 473Zeile 491
			else
{
$icon = "&nbsp;";

			else
{
$icon = "&nbsp;";

			}

			}


if($forumcache[$thread['fid']])
{


if($forumcache[$thread['fid']])
{

Zeile 495Zeile 513
			{
$cutoff = time()-$mybb->settings['threadreadcut']*60*60*24;
if($post['thread_lastpost'] > $cutoff)

			{
$cutoff = time()-$mybb->settings['threadreadcut']*60*60*24;
if($post['thread_lastpost'] > $cutoff)

				{

				{

					if($post['thread_lastread'])
{
$lastread = $post['thread_lastread'];

					if($post['thread_lastread'])
{
$lastread = $post['thread_lastread'];

Zeile 529Zeile 547
				$folder_label .= $lang->icon_new;
eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
$unreadpost = 1;

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

			}
else

			}
else

			{
$folder_label .= $lang->icon_no_new;
}

			{
$folder_label .= $lang->icon_no_new;
}

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

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





			$post['thread_replies'] = my_number_format($post['thread_replies']);
$post['thread_views'] = my_number_format($post['thread_views']);

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

			$post['thread_replies'] = my_number_format($post['thread_replies']);
$post['thread_views'] = my_number_format($post['thread_views']);

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

			}
else

			}
else

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

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

Zeile 565Zeile 583
			}
if(my_strlen($post['subject']) > 50)
{

			}
if(my_strlen($post['subject']) > 50)
{

				$post['subject'] = my_substr($post['subject'], 0, 50)."...";

				$post['subject'] = htmlspecialchars_uni(my_substr($post['subject'], 0, 50)."...");

			}
else
{

			}
else
{

				$post['subject'] = $post['subject'];

				$post['subject'] = htmlspecialchars_uni($post['subject']);

			}
if(my_strlen($post['message']) > 200)
{

			}
if(my_strlen($post['message']) > 200)
{

				$prev = htmlspecialchars_uni(my_substr($post['message'], 0, 200)."...");

				$post['message'] = htmlspecialchars_uni(my_substr($post['message'], 0, 200)."...");

			}
else
{

			}
else
{

				$prev = htmlspecialchars_uni($post['message']);

				$post['message'] = htmlspecialchars_uni($post['message']);

			}

			}

 
			$prev = $post['message'];


			$posted = my_date($mybb->settings['dateformat'], $post['dateline']).", ".my_date($mybb->settings['timeformat'], $post['dateline']);

$plugins->run_hooks("search_results_post");

			$posted = my_date($mybb->settings['dateformat'], $post['dateline']).", ".my_date($mybb->settings['timeformat'], $post['dateline']);

$plugins->run_hooks("search_results_post");

Zeile 593Zeile 613
		{
$upper = $postcount;
}

		{
$upper = $postcount;
}





		eval("\$searchresults = \"".$templates->get("search_results_posts")."\";");
$plugins->run_hooks("search_results_end");
output_page($searchresults);

		eval("\$searchresults = \"".$templates->get("search_results_posts")."\";");
$plugins->run_hooks("search_results_end");
output_page($searchresults);

	}

	}

}
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",


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

		"querycache" => $db->escape_string($where_sql),
);
$plugins->run_hooks("search_do_search_process");

Zeile 633Zeile 653
elseif($mybb->input['action'] == "finduser")
{
$where_sql = "p.uid='".intval($mybb->input['uid'])."'";

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(


$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(),

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

Zeile 655Zeile 675
		"posts" => '',
"searchtype" => "titles",
"resulttype" => "posts",

		"posts" => '',
"searchtype" => "titles",
"resulttype" => "posts",

		"querycache" => $db->escape_string($where_sql),
);
$plugins->run_hooks("search_do_search_process");

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

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

Zeile 667Zeile 687

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


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

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

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

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

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

Zeile 693Zeile 713
	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");
$db->insert_query(TABLE_PREFIX."searchlog", $searcharray);
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);

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

Zeile 735Zeile 754
	if($mybb->input['days'] < 1)
{
$days = 1;

	if($mybb->input['days'] < 1)
{
$days = 1;

	}
else

	}
else

	{
$days = intval($mybb->input['days']);
}
$datecut = time()-(86400*$days);

	{
$days = intval($mybb->input['days']);
}
$datecut = time()-(86400*$days);





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

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

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

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

	}

	}

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

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

Zeile 791Zeile 810
			$conditions = "uid='{$mybb->user['uid']}'";
}
else

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

		{

		{

			$conditions = "uid='0' AND ipaddress='".$db->escape_string($session->ipaddress)."'";
}
$timecut = time()-$mybb->settings['searchfloodtime'];

			$conditions = "uid='0' AND ipaddress='".$db->escape_string($session->ipaddress)."'";
}
$timecut = time()-$mybb->settings['searchfloodtime'];

Zeile 803Zeile 822
		// Users last search was within the flood time, show the error. 
if($last_search['sid'] && $remaining_time > 0)
{

		// Users last search was within the flood time, show the error. 
if($last_search['sid'] && $remaining_time > 0)
{

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