Zeile 3 | Zeile 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 3887 2008-06-06 23:38:42Z Tikitiki $
|
*/
| */
|
Zeile 41 | Zeile 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 62 | Zeile 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 73 | Zeile 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";
| $sortfield = "p.subject";
|
} break; case "forum":
| } break; case "forum":
|
Zeile 96 | Zeile 96 |
---|
$sortfield = "p.username"; } break;
|
$sortfield = "p.username"; } break;
|
| case "lastpost":
|
default: if($search['resulttype'] == "threads") { $sortfield = "t.lastpost";
|
default: if($search['resulttype'] == "threads") { $sortfield = "t.lastpost";
|
}
| $sortby = 'lastpost'; }
|
else { $sortfield = "p.dateline";
|
else { $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 121 | Zeile 131 |
---|
$start = ($page-1) * $perpage; } else
|
$start = ($page-1) * $perpage; } else
|
{
| {
|
$start = 0; $page = 1; } $end = $start + $perpage; $lower = $start+1; $upper = $end;
|
$start = 0; $page = 1; } $end = $start + $perpage; $lower = $start+1; $upper = $end;
|
|
|
$sorturl = "search.php?action=results&sid={$sid}";
|
$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 145 | Zeile 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 167 | Zeile 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'])
|
Zeile 255 | Zeile 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) {
| if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forumread) {
|
Zeile 410 | Zeile 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 461 | Zeile 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 565 | Zeile 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 602 | Zeile 622 |
---|
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" => '',
| $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",
| "posts" => '', "searchtype" => "titles", "resulttype" => "posts",
|
Zeile 634 | Zeile 654 |
---|
{ $where_sql = "p.uid='".intval($mybb->input['uid'])."'";
|
{ $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)"; }
| $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),
| $sid = md5(uniqid(microtime(), 1)); $searcharray = array( "sid" => $db->escape_string($sid),
|
Zeile 693 | Zeile 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" => '',
| 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),
| "searchtype" => "titles", "resulttype" => "threads", "querycache" => $db->escape_string($where_sql),
|
Zeile 731 | Zeile 750 |
---|
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults); } elseif($mybb->input['action'] == "getdaily")
|
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults); } elseif($mybb->input['action'] == "getdaily")
|
{
| {
|
if($mybb->input['days'] < 1)
|
if($mybb->input['days'] < 1)
|
{
| {
|
$days = 1;
|
$days = 1;
|
}
| }
|
else { $days = intval($mybb->input['days']); } $datecut = time()-(86400*$days);
|
else { $days = intval($mybb->input['days']); } $datecut = time()-(86400*$days);
|
$where_sql = "t.lastpost >='".$datecut."'";
| $where_sql = "t.lastpost >='".$datecut."'";
|
if($mybb->input['fid'])
|
if($mybb->input['fid'])
|
{
| {
|
$where_sql .= " AND t.fid='".intval($mybb->input['fid'])."'"; }
| $where_sql .= " AND t.fid='".intval($mybb->input['fid'])."'"; }
|
Zeile 753 | Zeile 772 |
---|
if($unsearchforums) { $where_sql .= " AND t.fid NOT IN ($unsearchforums)";
|
if($unsearchforums) { $where_sql .= " AND t.fid NOT IN ($unsearchforums)";
|
}
| }
|
$inactiveforums = get_inactive_forums(); if($inactiveforums) {
| $inactiveforums = get_inactive_forums(); if($inactiveforums) {
|
Zeile 797 | Zeile 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 857 | Zeile 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']; }
|