Vergleich search.php - 1.2.0 - 1.2.14

  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 2180 2006-09-02 07:36:22Z chris $

 * $Id: search.php 3887 2008-06-06 23:38:42Z Tikitiki $

 */



 */



Zeile 40Zeile 40
}

$now = time();

}

$now = time();

 

// Clear out searches older than a month
if($rand == 3)
{
$timecut = time()-60*60*24*30;
$db->delete_query(TABLE_PREFIX."searchlog", "dateline<='$timecut'");
}


if($mybb->input['action'] == "results")
{


if($mybb->input['action'] == "results")
{

Zeile 50Zeile 57
	if(!$search['sid'])
{
error($lang->error_invalidsearch);

	if(!$search['sid'])
{
error($lang->error_invalidsearch);

	}

$plugins->run_hooks("search_results_start");

	}

$plugins->run_hooks("search_results_start");


// Decide on our sorting fields and sorting order.


// 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 65Zeile 72
			break;
case "views":
$sortfield = "t.views";

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

			break;
case "dateline":
if($search['resulttype'] == "threads")
{
$sortfield = "t.dateline";

			break;
case "subject":
if($search['resulttype'] == "threads")
{
$sortfield = "t.subject";

			}
else
{

			}
else
{

				$sortfield = "p.dateline";

				$sortfield = "p.subject";

			}
break;
case "forum":

			}
break;
case "forum":

Zeile 89Zeile 96
				$sortfield = "p.username";
}
break;

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

 
		case "lastpost":

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

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

			{

			{

				$sortfield = "t.lastpost";

				$sortfield = "t.lastpost";

 
				$sortby = 'lastpost';

			}
else
{
$sortfield = "p.dateline";

			}
else
{
$sortfield = "p.dateline";

 
				$sortby = 'dateline';

			}
break;
}

			}
break;
}

Zeile 104Zeile 114
	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.

	}

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

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

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

	{

	{

		$start = 0;
$page = 1;
}

		$start = 0;
$page = 1;
}

Zeile 123Zeile 140
	$upper = $end;

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

	$upper = $end;

$sorturl = "search.php?action=results&amp;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")
{
$threadcount = 0;
// If we have saved WHERE conditions, execute them


// Show search results as 'threads'
if($search['resulttype'] == "threads")
{
$threadcount = 0;
// If we have saved WHERE conditions, execute them

		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|%'");

		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|%' {$limitsql}");

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

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

Zeile 160Zeile 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);

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





			if(!$count['resultcount'])
{
error($lang->error_nosearchresults);

			if(!$count['resultcount'])
{
error($lang->error_nosearchresults);

Zeile 197Zeile 222
		{
$query = $db->simple_select(TABLE_PREFIX."posts", "DISTINCT tid,uid", "uid='".$mybb->user['uid']."' AND tid IN(".$thread_ids.")");
while($post = $db->fetch_array($query))

		{
$query = $db->simple_select(TABLE_PREFIX."posts", "DISTINCT tid,uid", "uid='".$mybb->user['uid']."' AND tid IN(".$thread_ids.")");
while($post = $db->fetch_array($query))

			{

			{

				$thread_cache[$post['tid']]['dot_icon'] = 1;
}
}

				$thread_cache[$post['tid']]['dot_icon'] = 1;
}
}

Zeile 230Zeile 255
			if($icon_cache[$thread['icon']])
{
$posticon = $icon_cache[$thread['icon']];

			if($icon_cache[$thread['icon']])
{
$posticon = $icon_cache[$thread['icon']];

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

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

			else
{
$icon = "&nbsp;";

			else
{
$icon = "&nbsp;";

Zeile 403Zeile 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 415Zeile 441
		$tids = array();
$query = $db->query("
SELECT p.tid

		$tids = array();
$query = $db->query("
SELECT p.tid

			FROM ".TABLE_PREFIX."posts p

			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|%'
ORDER BY $sortfield $order

			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|%'
ORDER BY $sortfield $order

Zeile 454Zeile 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 462Zeile 487
			{
$posticon = $icon_cache[$post['icon']];
$icon = "<img src=\"".$posticon['path']."\" alt=\"".$posticon['name']."\" />";

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

			}
else

			}
else

			{
$icon = "&nbsp;";

			{
$icon = "&nbsp;";

			}

			}


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


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

			{

			{

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

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

			}

			}

			// Determine the folder
$folder = '';
$folder_label = '';

			// Determine the folder
$folder = '';
$folder_label = '';

Zeile 509Zeile 534
				elseif($forumread > $mybb->user['lastvisit'])
{
$lastread = $forumread;

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

				}

				}

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

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

Zeile 529Zeile 554
			}

if($post['thread_replies'] >= $mybb->settings['hottopic'] || $post['thread_views'] >= $mybb->settings['hottopicviews'])

			}

if($post['thread_replies'] >= $mybb->settings['hottopic'] || $post['thread_views'] >= $mybb->settings['hottopicviews'])

			{

			{

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

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

			}

			}

			if($thread['thread_closed'] == "yes")
{
$folder .= "lock";
$folder_label .= $lang->icon_lock;
}
$folder .= "folder";

			if($thread['thread_closed'] == "yes")
{
$folder .= "lock";
$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']);


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


Zeile 557Zeile 582
				$post['subject'] = $post['message'];
}
if(my_strlen($post['subject']) > 50)

				$post['subject'] = $post['message'];
}
if(my_strlen($post['subject']) > 50)

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

			{
$post['subject'] = htmlspecialchars_uni(my_substr($post['subject'], 0, 50)."...");
}
else
{
$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 596Zeile 623
{
$where_sql = "p.uid='0'";


{
$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),
);

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

	$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 626Zeile 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(
"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 686Zeile 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),
);

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


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);
}
elseif($mybb->input['action'] == "getdaily")
{
if($mybb->input['days'] < 1)

	redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}
elseif($mybb->input['action'] == "getdaily")
{
if($mybb->input['days'] < 1)

	{

	{

		$days = 1;
}
else
{
$days = intval($mybb->input['days']);

		$days = 1;
}
else
{
$days = intval($mybb->input['days']);

	}
$datecut = time()-(68400*$days);


	}
$datecut = time()-(86400*$days);


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

if($mybb->input['fid'])

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

if($mybb->input['fid'])

Zeile 743Zeile 769
	}

$unsearchforums = get_unsearchable_forums();

	}

$unsearchforums = get_unsearchable_forums();

	if($unsearchforums)
{

	if($unsearchforums)
{

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

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

Zeile 790Zeile 816
		$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);

		$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 814Zeile 849
		"matchusername" => $mybb->input['matchusername'],
"postdate" => $mybb->input['postdate'],
"pddir" => $mybb->input['pddir'],

		"matchusername" => $mybb->input['matchusername'],
"postdate" => $mybb->input['postdate'],
"pddir" => $mybb->input['pddir'],

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



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

	);

if($config['dbtype'] == "mysql" || $config['dbtype'] == "mysqli")

	);

if($config['dbtype'] == "mysql" || $config['dbtype'] == "mysqli")

Zeile 848Zeile 885

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