Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: functions_search.php 5458 2011-05-01 21:12:31Z jammerx2 $
| * $Id$
|
*/
/**
| */
/**
|
Zeile 96 | Zeile 96 |
---|
function get_unsearchable_forums($pid="0", $first=1) { global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
|
function get_unsearchable_forums($pid="0", $first=1) { global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
|
|
|
$pid = intval($pid);
|
$pid = intval($pid);
|
|
|
if(!is_array($forum_cache))
|
if(!is_array($forum_cache))
|
{
| {
|
// Get Forums $query = $db->simple_select("forums", "fid,parentlist,password,active", '', array('order_by' => 'pid, disporder')); while($forum = $db->fetch_array($query))
| // Get Forums $query = $db->simple_select("forums", "fid,parentlist,password,active", '', array('order_by' => 'pid, disporder')); while($forum = $db->fetch_array($query))
|
Zeile 109 | Zeile 109 |
---|
} } if(!is_array($permissioncache))
|
} } if(!is_array($permissioncache))
|
{
| {
|
$permissioncache = forum_permissions(); } foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
|
$permissioncache = forum_permissions(); } foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
|
{
| {
|
$perms = $permissioncache[$forum['fid']]; } else
| $perms = $permissioncache[$forum['fid']]; } else
|
Zeile 151 | Zeile 151 |
---|
$unsearchableforums .= ","; } $unsearchableforums .= "'{$forum['fid']}'";
|
$unsearchableforums .= ","; } $unsearchableforums .= "'{$forum['fid']}'";
|
}
| }
|
} $unsearchable = $unsearchableforums;
|
} $unsearchable = $unsearchableforums;
|
|
|
// Get our unsearchable password protected forums $pass_protected_forums = get_password_protected_forums();
|
// Get our unsearchable password protected forums $pass_protected_forums = get_password_protected_forums();
|
|
|
if($unsearchable && $pass_protected_forums) { $unsearchable .= ","; }
|
if($unsearchable && $pass_protected_forums) { $unsearchable .= ","; }
|
|
|
if($pass_protected_forums) { $unsearchable .= implode(",", $pass_protected_forums); }
|
if($pass_protected_forums) { $unsearchable .= implode(",", $pass_protected_forums); }
|
|
|
return $unsearchable; }
/** * Build a array list of the forums this user cannot search due to password protection
|
return $unsearchable; }
/** * Build a array list of the forums this user cannot search due to password protection
|
*
| *
|
* @param int the fids to check (leave null to check all forums) * @return return a array list of password protected forums the user cannot search */ function get_password_protected_forums($fids=array()) { global $forum_cache, $mybb;
|
* @param int the fids to check (leave null to check all forums) * @return return a array list of password protected forums the user cannot search */ function get_password_protected_forums($fids=array()) { global $forum_cache, $mybb;
|
|
|
if(!is_array($fids)) { return false; }
|
if(!is_array($fids)) { return false; }
|
|
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache) { return false;
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache) { return false;
|
} }
| } }
|
if(empty($fids)) { $fids = array_keys($forum_cache); }
|
if(empty($fids)) { $fids = array_keys($forum_cache); }
|
|
|
$pass_fids = array(); foreach($fids as $fid) {
| $pass_fids = array(); foreach($fids as $fid) {
|
Zeile 207 | Zeile 207 |
---|
{ continue; }
|
{ continue; }
|
|
|
if(md5($mybb->user['uid'].$forum_cache[$fid]['password']) != $mybb->cookies['forumpass'][$fid]) { $pass_fids[] = $fid; $child_list = get_child_list($fid); }
|
if(md5($mybb->user['uid'].$forum_cache[$fid]['password']) != $mybb->cookies['forumpass'][$fid]) { $pass_fids[] = $fid; $child_list = get_child_list($fid); }
|
|
|
if(is_array($child_list)) { $pass_fids = array_merge($pass_fids, $child_list);
| if(is_array($child_list)) { $pass_fids = array_merge($pass_fids, $child_list);
|
Zeile 243 | Zeile 243 |
---|
{ $keywords = substr_replace($keywords, "", 0, 2); }
|
{ $keywords = substr_replace($keywords, "", 0, 2); }
|
|
|
if(my_strpos($keywords, "and") === 0) { $keywords = substr_replace($keywords, "", 0, 3);
|
if(my_strpos($keywords, "and") === 0) { $keywords = substr_replace($keywords, "", 0, 3);
|
}
return $keywords; }
| }
return $keywords; }
|
/** * Clean search keywords for fulltext searching, making them safe for querying *
| /** * Clean search keywords for fulltext searching, making them safe for querying *
|
Zeile 269 | Zeile 269 |
---|
$keywords = preg_replace("#\*{2,}#s", "*", $keywords); $keywords = preg_replace("#([\[\]\|\.\,:])#s", " ", $keywords); $keywords = preg_replace("#\s+#s", " ", $keywords);
|
$keywords = preg_replace("#\*{2,}#s", "*", $keywords); $keywords = preg_replace("#([\[\]\|\.\,:])#s", " ", $keywords); $keywords = preg_replace("#\s+#s", " ", $keywords);
|
|
|
$words = array();
|
$words = array();
|
|
|
if(my_strpos($keywords, "\"") !== false) { $inquote = false;
| if(my_strpos($keywords, "\"") !== false) { $inquote = false;
|
Zeile 281 | Zeile 281 |
---|
if($phrase != '') { if($inquote)
|
if($phrase != '') { if($inquote)
|
{
| {
|
$words[] = "\"".trim($phrase)."\""; } else
| $words[] = "\"".trim($phrase)."\""; } else
|
Zeile 368 | Zeile 368 |
---|
{ $mybb->settings['minsearchword'] = 3; }
|
{ $mybb->settings['minsearchword'] = 3; }
|
|
|
$subject_lookin = ""; $message_lookin = ""; $searchsql = "uid='{$mybb->user['uid']}'";
|
$subject_lookin = ""; $message_lookin = ""; $searchsql = "uid='{$mybb->user['uid']}'";
|
|
|
if($keywords) { // Complex search
| if($keywords) { // Complex search
|
Zeile 381 | Zeile 381 |
---|
{ $string = "AND"; if($search['subject'] == 1)
|
{ $string = "AND"; if($search['subject'] == 1)
|
{
| {
|
$string = "OR"; $subject_lookin = " AND (";
|
$string = "OR"; $subject_lookin = " AND (";
|
}
if($search['message'] == 1) { $message_lookin = " {$string} ("; } // Expand the string by double quotes $keywords_exp = explode("\"", $keywords); $inquote = false;
foreach($keywords_exp as $phrase) { // If we're not in a double quoted section if(!$inquote) { // Expand out based on search operators (and, or)
| }
if($search['message'] == 1) { $message_lookin = " {$string} ("; }
// Expand the string by double quotes $keywords_exp = explode("\"", $keywords); $inquote = false;
foreach($keywords_exp as $phrase) { // If we're not in a double quoted section if(!$inquote) { // Expand out based on search operators (and, or)
|
$matches = preg_split("#\s{1,}(and|or)\s{1,}#", $phrase, -1, PREG_SPLIT_DELIM_CAPTURE); $count_matches = count($matches);
|
$matches = preg_split("#\s{1,}(and|or)\s{1,}#", $phrase, -1, PREG_SPLIT_DELIM_CAPTURE); $count_matches = count($matches);
|
|
|
for($i=0; $i < $count_matches; ++$i) { $word = trim($matches[$i]); if(empty($word))
|
for($i=0; $i < $count_matches; ++$i) { $word = trim($matches[$i]); if(empty($word))
|
{
| {
|
continue; } // If this word is a search operator set the boolean
| continue; } // If this word is a search operator set the boolean
|
Zeile 419 | Zeile 419 |
---|
if($search['subject'] && $search['message'] && $subject_lookin == " AND (") { // We're looking for anything, check for a subject lookin
|
if($search['subject'] && $search['message'] && $subject_lookin == " AND (") { // We're looking for anything, check for a subject lookin
|
continue;
| continue;
|
} elseif($search['subject'] && !$search['message'] && $subject_lookin == " AND (")
|
} elseif($search['subject'] && !$search['message'] && $subject_lookin == " AND (")
|
{
| {
|
// Just in a subject?
|
// Just in a subject?
|
continue;
| continue;
|
} elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (") { // Just in a message?
|
} elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (") { // Just in a message?
|
continue;
| continue;
|
} }
| } }
|
Zeile 456 | Zeile 456 |
---|
} } }
|
} } }
|
}
| }
|
// In the middle of a quote (phrase) else {
| // In the middle of a quote (phrase) else {
|
Zeile 471 | Zeile 471 |
---|
if($search['message'] == 1) { $message_lookin .= " $boolean LOWER(message) LIKE '%{$phrase}%'";
|
if($search['message'] == 1) { $message_lookin .= " $boolean LOWER(message) LIKE '%{$phrase}%'";
|
}
| }
|
}
// Check to see if we have any search terms and not a malformed SQL string
| }
// Check to see if we have any search terms and not a malformed SQL string
|
Zeile 489 | Zeile 489 |
---|
elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (") { // Just in a message?
|
elseif(!$search['subject'] && $search['message'] && $message_lookin == " {$string} (") { // Just in a message?
|
$error = true;
| $error = true;
|
}
if($error == true)
| }
if($error == true)
|
Zeile 513 | Zeile 513 |
---|
}
$searchsql .= "{$subject_lookin} {$message_lookin}";
|
}
$searchsql .= "{$subject_lookin} {$message_lookin}";
|
}
| }
|
else { $keywords = str_replace("\"", '', trim($keywords));
| else { $keywords = str_replace("\"", '', trim($keywords));
|
Zeile 522 | Zeile 522 |
---|
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength); }
|
$lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength); }
|
|
|
// If we're looking in both, then find matches in either the subject or the message if($search['subject'] == 1 && $search['message'] == 1) {
| // If we're looking in both, then find matches in either the subject or the message if($search['subject'] == 1 && $search['message'] == 1) {
|
Zeile 534 | Zeile 534 |
---|
{ $searchsql .= " AND LOWER(subject) LIKE '%{$keywords}%'"; }
|
{ $searchsql .= " AND LOWER(subject) LIKE '%{$keywords}%'"; }
|
|
|
if($search['message'] == 1) { $searchsql .= " AND LOWER(message) LIKE '%{$keywords}%'";
| if($search['message'] == 1) { $searchsql .= " AND LOWER(message) LIKE '%{$keywords}%'";
|
Zeile 542 | Zeile 542 |
---|
} } }
|
} } }
|
|
|
if($search['sender']) { $userids = array(); $search['sender'] = my_strtolower($search['sender']);
|
if($search['sender']) { $userids = array(); $search['sender'] = my_strtolower($search['sender']);
|
|
|
$query = $db->simple_select("users", "uid", "LOWER(username) LIKE '%".$db->escape_string_like($db->escape_string($search['sender']))."%'");
|
$query = $db->simple_select("users", "uid", "LOWER(username) LIKE '%".$db->escape_string_like($db->escape_string($search['sender']))."%'");
|
while($user = $db->fetch_array($query)) { $userids[] = $user['uid']; } if(count($userids) < 1)
| while($user = $db->fetch_array($query)) { $userids[] = $user['uid']; }
if(count($userids) < 1)
|
{ error($lang->error_nosearchresults);
|
{ error($lang->error_nosearchresults);
|
}
| }
|
else { $userids = implode(',', $userids); $searchsql .= " AND fromid IN (".$userids.")"; }
|
else { $userids = implode(',', $userids); $searchsql .= " AND fromid IN (".$userids.")"; }
|
}
| }
|
if(!is_array($search['folder']))
|
if(!is_array($search['folder']))
|
{
| {
|
$search['folder'] = array($search['folder']); }
|
$search['folder'] = array($search['folder']); }
|
|
|
if(!empty($search['folder'])) { $folderids = array();
|
if(!empty($search['folder'])) { $folderids = array();
|
|
|
$search['folder'] = array_map("intval", $search['folder']);
|
$search['folder'] = array_map("intval", $search['folder']);
|
|
|
$folderids = implode(',', $search['folder']);
|
$folderids = implode(',', $search['folder']);
|
|
|
if($folderids) { $searchsql .= " AND folder IN (".$folderids.")";
| if($folderids) { $searchsql .= " AND folder IN (".$folderids.")";
|
Zeile 611 | Zeile 611 |
---|
$statussql = implode("OR", $statussql); $searchsql .= $statussql.")"; }
|
$statussql = implode("OR", $statussql); $searchsql .= $statussql.")"; }
|
|
|
// Run the search $pms = array(); $query = $db->simple_select("privatemessages", "pmid", $searchsql);
| // Run the search $pms = array(); $query = $db->simple_select("privatemessages", "pmid", $searchsql);
|
Zeile 619 | Zeile 619 |
---|
{ $pms[$pm['pmid']] = $pm['pmid']; }
|
{ $pms[$pm['pmid']] = $pm['pmid']; }
|
|
|
if(count($pms) < 1) { error($lang->error_nosearchresults); } $pms = implode(',', $pms);
|
if(count($pms) < 1) { error($lang->error_nosearchresults); } $pms = implode(',', $pms);
|
|
|
return array( "querycache" => $pms );
| return array( "querycache" => $pms );
|
Zeile 660 | Zeile 660 |
---|
{ $subject_lookin = " AND ("; $message_lookin = " AND (";
|
{ $subject_lookin = " AND ("; $message_lookin = " AND (";
|
|
|
// Expand the string by double quotes $keywords_exp = explode("\"", $keywords); $inquote = false;
| // Expand the string by double quotes $keywords_exp = explode("\"", $keywords); $inquote = false;
|
Zeile 673 | Zeile 673 |
---|
// Expand out based on search operators (and, or) $matches = preg_split("#\s{1,}(and|or)\s{1,}#", $phrase, -1, PREG_SPLIT_DELIM_CAPTURE); $count_matches = count($matches);
|
// Expand out based on search operators (and, or) $matches = preg_split("#\s{1,}(and|or)\s{1,}#", $phrase, -1, PREG_SPLIT_DELIM_CAPTURE); $count_matches = count($matches);
|
|
|
for($i=0; $i < $count_matches; ++$i) { $word = trim($matches[$i]);
| for($i=0; $i < $count_matches; ++$i) { $word = trim($matches[$i]);
|
Zeile 707 | Zeile 707 |
---|
{ $message_lookin .= " $boolean LOWER(p.message) LIKE '%{$word}%'"; }
|
{ $message_lookin .= " $boolean LOWER(p.message) LIKE '%{$word}%'"; }
|
} } }
| } } }
|
// In the middle of a quote (phrase) else {
| // In the middle of a quote (phrase) else {
|
Zeile 718 | Zeile 718 |
---|
{ $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
|
{ $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
|
}
| }
|
// Add phrase to search query $subject_lookin .= " $boolean LOWER(t.subject) LIKE '%{$phrase}%'"; if($search['postthread'] == 1) { $message_lookin .= " $boolean LOWER(p.message) LIKE '%{$phrase}%'";
|
// Add phrase to search query $subject_lookin .= " $boolean LOWER(t.subject) LIKE '%{$phrase}%'"; if($search['postthread'] == 1) { $message_lookin .= " $boolean LOWER(p.message) LIKE '%{$phrase}%'";
|
}
| }
|
}
if($subject_lookin == " AND (")
|
}
if($subject_lookin == " AND (")
|
{
| {
|
// There are no search keywords to look for $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
| // There are no search keywords to look for $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
|
Zeile 746 | Zeile 746 |
---|
{ $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
|
{ $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
|
}
| }
|
$subject_lookin = " AND LOWER(t.subject) LIKE '%{$keywords}%'"; if($search['postthread'] == 1) {
| $subject_lookin = " AND LOWER(t.subject) LIKE '%{$keywords}%'"; if($search['postthread'] == 1) {
|
Zeile 762 | Zeile 762 |
---|
if($search['matchusername']) { $query = $db->simple_select("users", "uid", "username='".$db->escape_string($search['author'])."'");
|
if($search['matchusername']) { $query = $db->simple_select("users", "uid", "username='".$db->escape_string($search['author'])."'");
|
} else {
| } else {
|
$search['author'] = my_strtolower($search['author']); $query = $db->simple_select("users", "uid", "LOWER(username) LIKE '%".$db->escape_string_like($db->escape_string($search['author']))."%'");
|
$search['author'] = my_strtolower($search['author']); $query = $db->simple_select("users", "uid", "LOWER(username) LIKE '%".$db->escape_string_like($db->escape_string($search['author']))."%'");
|
}
| }
|
while($user = $db->fetch_array($query))
|
while($user = $db->fetch_array($query))
|
{
| {
|
$userids[] = $user['uid'];
|
$userids[] = $user['uid'];
|
}
| }
|
if(count($userids) < 1)
|
if(count($userids) < 1)
|
{
| {
|
error($lang->error_nosearchresults); } else
| error($lang->error_nosearchresults); } else
|
Zeile 781 | Zeile 781 |
---|
$userids = implode(',', $userids); $post_usersql = " AND p.uid IN (".$userids.")"; $thread_usersql = " AND t.uid IN (".$userids.")";
|
$userids = implode(',', $userids); $post_usersql = " AND p.uid IN (".$userids.")"; $thread_usersql = " AND t.uid IN (".$userids.")";
|
} }
| } }
|
$datecut = ''; if($search['postdate']) { if($search['pddir'] == 0)
|
$datecut = ''; if($search['postdate']) { if($search['pddir'] == 0)
|
{
| {
|
$datecut = "<=";
|
$datecut = "<=";
|
}
| }
|
else { $datecut = ">=";
| else { $datecut = ">=";
|
Zeile 800 | Zeile 800 |
---|
$post_datecut = " AND p.dateline $datecut"; $thread_datecut = " AND t.dateline $datecut"; }
|
$post_datecut = " AND p.dateline $datecut"; $thread_datecut = " AND t.dateline $datecut"; }
|
|
|
$thread_replycut = ''; if($search['numreplies'] != '' && $search['findthreadst']) {
| $thread_replycut = ''; if($search['numreplies'] != '' && $search['findthreadst']) {
|
Zeile 813 | Zeile 813 |
---|
$thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'"; } }
|
$thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'"; } }
|
|
|
$thread_prefixcut = ''; if($search['threadprefix'] && $search['threadprefix'] != 'any') {
| $thread_prefixcut = ''; if($search['threadprefix'] && $search['threadprefix'] != 'any') {
|
Zeile 823 | Zeile 823 |
---|
$forumin = ''; $fidlist = array(); $searchin = array();
|
$forumin = ''; $fidlist = array(); $searchin = array();
|
if($search['forums'] != "all")
| if($search['forums'][0] != "all")
|
{ if(!is_array($search['forums'])) {
| { if(!is_array($search['forums'])) {
|
Zeile 857 | Zeile 857 |
---|
}
if($can_search == 0)
|
}
if($can_search == 0)
|
{
| {
|
// We can't search this forum... continue; }
| // We can't search this forum... continue; }
|
Zeile 874 | Zeile 874 |
---|
default: $query = $db->simple_select("forums", "DISTINCT fid", "INSTR(CONCAT(',',parentlist,','),',{$forum},') > 0 AND active != 0"); }
|
default: $query = $db->simple_select("forums", "DISTINCT fid", "INSTR(CONCAT(',',parentlist,','),',{$forum},') > 0 AND active != 0"); }
|
|
|
while($sforum = $db->fetch_array($query)) { $fidlist[] = $sforum['fid']; } }
|
while($sforum = $db->fetch_array($query)) { $fidlist[] = $sforum['fid']; } }
|
}
| }
|
if(count($fidlist) == 1)
|
if(count($fidlist) == 1)
|
{
| {
|
$forumin .= " AND t.fid='$forum' "; $searchin[$fid] = 1; } else
|
$forumin .= " AND t.fid='$forum' "; $searchin[$fid] = 1; } else
|
{
| {
|
if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(',', $fidlist).")";
|
if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(',', $fidlist).")";
|
}
| }
|
} }
|
} }
|
|
|
$permsql = ""; $onlyusfids = array();
|
$permsql = ""; $onlyusfids = array();
|
|
|
// Check group permissions if we can't view threads not started by us if($group_permissions = forum_permissions()) {
| // Check group permissions if we can't view threads not started by us if($group_permissions = forum_permissions()) {
|
Zeile 910 | Zeile 910 |
---|
} } if(!empty($onlyusfids))
|
} } if(!empty($onlyusfids))
|
{
| {
|
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
|
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
|
}
| }
|
$unsearchforums = get_unsearchable_forums(); if($unsearchforums)
|
$unsearchforums = get_unsearchable_forums(); if($unsearchforums)
|
{
| {
|
$permsql .= " AND t.fid NOT IN ($unsearchforums)"; } $inactiveforums = get_inactive_forums();
| $permsql .= " AND t.fid NOT IN ($unsearchforums)"; } $inactiveforums = get_inactive_forums();
|
Zeile 924 | Zeile 924 |
---|
{ $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
{ $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
|
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = ""; if(isset($search['visible'])) { if($search['visible'] == 1) { $visiblesql = " AND t.visible = '1'";
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = ""; if(isset($search['visible'])) { if($search['visible'] == 1) { $visiblesql = " AND t.visible = '1'";
|
if($search['postthread'] == 1) {
| if($search['postthread'] == 1) {
|
$post_visiblesql = " AND p.visible = '1'"; $plain_post_visiblesql = " AND visible = '1'"; }
| $post_visiblesql = " AND p.visible = '1'"; $plain_post_visiblesql = " AND visible = '1'"; }
|
Zeile 941 | Zeile 941 |
---|
else { $visiblesql = " AND t.visible != '1'";
|
else { $visiblesql = " AND t.visible != '1'";
|
|
|
if($search['postthread'] == 1) { $post_visiblesql = " AND p.visible != '1'"; $plain_post_visiblesql = " AND visible != '1'";
|
if($search['postthread'] == 1) { $post_visiblesql = " AND p.visible != '1'"; $plain_post_visiblesql = " AND visible != '1'";
|
} } }
| } } }
|
// Searching a specific thread? if($search['tid']) { $tidsql = " AND t.tid='".intval($search['tid'])."'"; }
|
// Searching a specific thread? if($search['tid']) { $tidsql = " AND t.tid='".intval($search['tid'])."'"; }
|
|
|
$limitsql = ''; if(intval($mybb->settings['searchhardlimit']) > 0) {
| $limitsql = ''; if(intval($mybb->settings['searchhardlimit']) > 0) {
|
Zeile 986 | Zeile 986 |
---|
} } }
|
} } }
|
|
|
$query = $db->query(" SELECT p.pid, p.tid FROM ".TABLE_PREFIX."posts p
| $query = $db->query(" SELECT p.pid, p.tid FROM ".TABLE_PREFIX."posts p
|
Zeile 999 | Zeile 999 |
---|
$posts[$post['pid']] = $post['pid']; $threads[$post['tid']] = $post['tid']; }
|
$posts[$post['pid']] = $post['pid']; $threads[$post['tid']] = $post['tid']; }
|
|
|
if(count($posts) < 1 && count($threads) < 1) { error($lang->error_nosearchresults);
| if(count($posts) < 1 && count($threads) < 1) { error($lang->error_nosearchresults);
|
Zeile 1143 | Zeile 1143 |
---|
$search['author'] = my_strtolower($search['author']); $query = $db->simple_select("users", "uid", "LOWER(username) LIKE '%".$db->escape_string_like($db->escape_string($search['author']))."%'"); }
|
$search['author'] = my_strtolower($search['author']); $query = $db->simple_select("users", "uid", "LOWER(username) LIKE '%".$db->escape_string_like($db->escape_string($search['author']))."%'"); }
|
|
|
while($user = $db->fetch_array($query)) { $userids[] = $user['uid']; }
|
while($user = $db->fetch_array($query)) { $userids[] = $user['uid']; }
|
|
|
if(count($userids) < 1) { error($lang->error_nosearchresults);
| if(count($userids) < 1) { error($lang->error_nosearchresults);
|
Zeile 1177 | Zeile 1177 |
---|
$post_datecut = " AND p.dateline $datecut"; $thread_datecut = " AND t.dateline $datecut"; }
|
$post_datecut = " AND p.dateline $datecut"; $thread_datecut = " AND t.dateline $datecut"; }
|
|
|
$thread_replycut = ''; if($search['numreplies'] != '' && $search['findthreadst']) { if(intval($search['findthreadst']) == 1)
|
$thread_replycut = ''; if($search['numreplies'] != '' && $search['findthreadst']) { if(intval($search['findthreadst']) == 1)
|
{
| {
|
$thread_replycut = " AND t.replies >= '".intval($search['numreplies'])."'"; } else
| $thread_replycut = " AND t.replies >= '".intval($search['numreplies'])."'"; } else
|
Zeile 1190 | Zeile 1190 |
---|
$thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'"; } }
|
$thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'"; } }
|
|
|
$thread_prefixcut = ''; if($search['threadprefix'] && $search['threadprefix'] != 'any') {
| $thread_prefixcut = ''; if($search['threadprefix'] && $search['threadprefix'] != 'any') {
|
Zeile 1200 | Zeile 1200 |
---|
$forumin = ''; $fidlist = array(); $searchin = array();
|
$forumin = ''; $fidlist = array(); $searchin = array();
|
if($search['forums'] != "all")
| if($search['forums'][0] != "all")
|
{ if(!is_array($search['forums'])) {
| { if(!is_array($search['forums'])) {
|
Zeile 1222 | Zeile 1222 |
---|
case "pgsql": case "sqlite": $query = $db->query("
|
case "pgsql": case "sqlite": $query = $db->query("
|
SELECT f.fid FROM ".TABLE_PREFIX."forums f
| SELECT f.fid FROM ".TABLE_PREFIX."forums f
|
LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups.")) WHERE INSTR(','||parentlist||',',',$forum,') > 0 AND active!=0 AND (ISNULL(p.fid) OR p.cansearch=1) "); break; default: $query = $db->query("
|
LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups.")) WHERE INSTR(','||parentlist||',',',$forum,') > 0 AND active!=0 AND (ISNULL(p.fid) OR p.cansearch=1) "); break; default: $query = $db->query("
|
SELECT f.fid FROM ".TABLE_PREFIX."forums f
| SELECT f.fid FROM ".TABLE_PREFIX."forums f
|
LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups.")) WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!=0 AND (ISNULL(p.fid) OR p.cansearch=1) ");
| LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid IN (".$user_groups.")) WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!=0 AND (ISNULL(p.fid) OR p.cansearch=1) ");
|
Zeile 1249 | Zeile 1249 |
---|
} else {
|
} else {
|
|
|
if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(',', $fidlist).")";
| if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(',', $fidlist).")";
|
Zeile 1258 | Zeile 1258 |
---|
} $permsql = ""; $onlyusfids = array();
|
} $permsql = ""; $onlyusfids = array();
|
|
|
// Check group permissions if we can't view threads not started by us $group_permissions = forum_permissions(); foreach($group_permissions as $fid => $forum_permissions)
| // Check group permissions if we can't view threads not started by us $group_permissions = forum_permissions(); foreach($group_permissions as $fid => $forum_permissions)
|
Zeile 1272 | Zeile 1272 |
---|
{ $permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))"; }
|
{ $permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))"; }
|
|
|
$unsearchforums = get_unsearchable_forums(); if($unsearchforums) {
| $unsearchforums = get_unsearchable_forums(); if($unsearchforums) {
|
Zeile 1283 | Zeile 1283 |
---|
{ $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
{ $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
|
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = ""; if(isset($search['visible'])) { if($search['visible'] == 1) { $visiblesql = " AND t.visible = '1'";
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = ""; if(isset($search['visible'])) { if($search['visible'] == 1) { $visiblesql = " AND t.visible = '1'";
|
|
|
if($search['postthread'] == 1) { $post_visiblesql = " AND p.visible = '1'";
| if($search['postthread'] == 1) { $post_visiblesql = " AND p.visible = '1'";
|
Zeile 1300 | Zeile 1300 |
---|
else { $visiblesql = " AND t.visible != '1'";
|
else { $visiblesql = " AND t.visible != '1'";
|
|
|
if($search['postthread'] == 1) { $post_visiblesql = " AND p.visible != '1'"; $plain_post_visiblesql = " AND visible != '1'"; } }
|
if($search['postthread'] == 1) { $post_visiblesql = " AND p.visible != '1'"; $plain_post_visiblesql = " AND visible != '1'"; } }
|
}
| }
|
// Searching a specific thread? if($search['tid']) { $tidsql = " AND t.tid='".intval($search['tid'])."'"; }
|
// Searching a specific thread? if($search['tid']) { $tidsql = " AND t.tid='".intval($search['tid'])."'"; }
|
|
|
$limitsql = ''; if(intval($mybb->settings['searchhardlimit']) > 0) {
| $limitsql = ''; if(intval($mybb->settings['searchhardlimit']) > 0) {
|