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 2180 2006-09-02 07:36:22Z chris $
| * $Id: search.php 3595 2008-01-09 00:10:57Z Tikitiki $
|
*/
| */
|
Zeile 40 | Zeile 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 50 | Zeile 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 77 | Zeile 84 |
---|
} break; case "forum":
|
} break; case "forum":
|
$sortfield = "t.fid"; break;
| $sortfield = "t.fid"; break;
|
case "starter": if($search['resulttype'] == "threads") {
| case "starter": if($search['resulttype'] == "threads") {
|
Zeile 93 | Zeile 100 |
---|
if($search['resulttype'] == "threads") { $sortfield = "t.lastpost";
|
if($search['resulttype'] == "threads") { $sortfield = "t.lastpost";
|
| $sortby = 'lastpost';
|
} else { $sortfield = "p.dateline";
|
} else { $sortfield = "p.dateline";
|
| $sortby = 'dateline';
|
} break; }
| } break; }
|
Zeile 104 | Zeile 113 |
---|
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 123 | Zeile 139 |
---|
$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") { $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'] != "") {
| if($search['querycache'] != "") {
|
$where_conditions = $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 160 | Zeile 184 |
---|
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 197 | Zeile 221 |
---|
{ $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 230 | Zeile 254 |
---|
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 = " ";
| else { $icon = " ";
|
Zeile 255 | Zeile 279 |
---|
$lastread = 0;
if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forumread)
|
$lastread = 0;
if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forumread)
|
{
| {
|
$cutoff = time()-$mybb->settings['threadreadcut']*60*60*24; if($thread['lastpost'] > $cutoff) {
| $cutoff = time()-$mybb->settings['threadreadcut']*60*60*24; if($thread['lastpost'] > $cutoff) {
|
Zeile 278 | Zeile 302 |
---|
$lastread = $readcookie; } elseif($forumread > $mybb->user['lastvisit'])
|
$lastread = $readcookie; } elseif($forumread > $mybb->user['lastvisit'])
|
{
| {
|
$lastread = $forumread; } else
| $lastread = $forumread; } else
|
Zeile 324 | Zeile 348 |
---|
{ $pagesstop = 4; eval("\$morelink = \"".$templates->get("forumdisplay_thread_multipage_more")."\";");
|
{ $pagesstop = 4; eval("\$morelink = \"".$templates->get("forumdisplay_thread_multipage_more")."\";");
|
}
| }
|
else { $pagesstop = $thread['pages'];
| else { $pagesstop = $thread['pages'];
|
Zeile 403 | Zeile 427 |
---|
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 595 | Zeile 620 |
---|
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),
| $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);
| ); $plugins->run_hooks("search_do_search_process"); $db->insert_query(TABLE_PREFIX."searchlog", $searcharray);
|
Zeile 626 | Zeile 651 |
---|
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),
| $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),
| "uid" => $mybb->user['uid'], "dateline" => time(), "ipaddress" => $db->escape_string($session->ipaddress),
|
Zeile 648 | Zeile 673 |
---|
"posts" => '', "searchtype" => "titles", "resulttype" => "posts",
|
"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 686 | Zeile 711 |
---|
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")
| redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults); } elseif($mybb->input['action'] == "getdaily")
|
Zeile 733 | Zeile 757 |
---|
{ $days = intval($mybb->input['days']); }
|
{ $days = intval($mybb->input['days']); }
|
$datecut = time()-(68400*$days);
| $datecut = time()-(86400*$days);
|
$where_sql = "t.lastpost >='".$datecut."'";
| $where_sql = "t.lastpost >='".$datecut."'";
|
Zeile 743 | Zeile 767 |
---|
} $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 790 | Zeile 814 |
---|
$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 814 | Zeile 847 |
---|
"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 848 | Zeile 883 |
---|
$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']; }
|