Zeile 54 | Zeile 54 |
---|
$optionselected = ''; $selecteddone = "0"; }
|
$optionselected = ''; $selecteddone = "0"; }
|
if($forum['password'] != '') { if($mybb->cookies['forumpass'][$forum['fid']] === md5($mybb->user['uid'].$forum['password'])) { $pwverified = 1; } else { $pwverified = 0; } } if(empty($forum['password']) || $pwverified == 1)
| if(forum_password_validated($forum, true))
|
{ eval("\$forumlistbits .= \"".$templates->get("search_forumlist_forum")."\";"); }
| { eval("\$forumlistbits .= \"".$templates->get("search_forumlist_forum")."\";"); }
|
Zeile 114 | Zeile 103 |
---|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
|
{
| {
|
$perms = $permissioncache[$forum['fid']];
|
$perms = $permissioncache[$forum['fid']];
|
}
| }
|
else
|
else
|
{
| {
|
$perms = $mybb->usergroup;
|
$perms = $mybb->usergroup;
|
}
$pwverified = 1; if($forum['password'] != '') { if(!isset($mybb->cookies['forumpass'][$forum['fid']]) || !my_hash_equals($mybb->cookies['forumpass'][$forum['fid']], md5($mybb->user['uid'].$forum['password']))) { $pwverified = 0; }
| |
}
$parents = explode(",", $forum['parentlist']);
| }
$parents = explode(",", $forum['parentlist']);
|
Zeile 143 | Zeile 123 |
---|
} }
|
} }
|
if($perms['canview'] != 1 || $perms['cansearch'] != 1 || $pwverified == 0 || $forum['active'] == 0)
| if($perms['canview'] != 1 || $perms['cansearch'] != 1 || !forum_password_validated($forum, true) || $forum['active'] == 0)
|
{ if($unsearchableforums) {
| { if($unsearchableforums) {
|
Zeile 168 | Zeile 148 |
---|
}
return $unsearchable;
|
}
return $unsearchable;
|
| }
/** * Build query condition for threads/posts the user is allowed to see. * Will return for example: * - visible = 1 - for normal users * - visible >= -1 - for admins & super mods * - (visible = 1 OR (visible = ? AND fid IN ...)) - for forum moderators * * @param string $table_alias The alias of the table eg t to use t.visible instead of visible * @return string the query condition */ function get_visible_where($table_alias = null) { global $db, $mybb;
$aliasdot = ''; if(!empty($table_alias)) { $aliasdot = $table_alias.'.'; }
if($mybb->usergroup['issupermod'] == 1) { // Super moderators (and admins) return "{$aliasdot}visible >= -1"; } elseif(is_moderator()) { // Normal moderators $unapprove_forums = array(); $deleted_forums = array(); $unapproved_where = "({$aliasdot}visible = 1"; $moderated_fids = get_moderated_fids($mybb->user['uid']);
if($moderated_fids !== false) { foreach($moderated_fids as $fid) { if(!is_moderator($fid)) { // Shouldn't occur. continue; } // Use moderates this forum $modperms = get_moderator_permissions($fid, $mybb->user['uid']); if($modperms['canviewunapprove'] == 1) { $unapprove_forums[] = $fid; } if($modperms['canviewdeleted'] == 1) { $deleted_forums[] = $fid; } } if(!empty($unapprove_forums)) { $unapproved_where .= " OR ({$aliasdot}visible = 0 AND {$aliasdot}fid IN(".implode(',', $unapprove_forums)."))"; } if(!empty($deleted_forums)) { $unapproved_where .= " OR ({$aliasdot}visible = -1 AND {$aliasdot}fid IN(".implode(',', $deleted_forums)."))"; } $unapproved_where .= ')'; return $unapproved_where; } }
// Normal users if($mybb->user['uid'] > 0 && $mybb->settings['showownunapproved'] == 1) { return "({$aliasdot}visible = 1 OR ({$aliasdot}visible = 0 AND {$aliasdot}uid = {$mybb->user['uid']}))"; } return "{$aliasdot}visible = 1";
|
}
/**
| }
/**
|
Zeile 202 | Zeile 262 |
---|
$pass_fids = array(); foreach($fids as $fid) {
|
$pass_fids = array(); foreach($fids as $fid) {
|
if(empty($forum_cache[$fid]['password'])) { continue; }
if(md5($mybb->user['uid'].$forum_cache[$fid]['password']) !== $mybb->cookies['forumpass'][$fid])
| if(!forum_password_validated($forum_cache[$fid], true))
|
{ $pass_fids[] = $fid;
|
{ $pass_fids[] = $fid;
|
$child_list = get_child_list($fid); }
if(is_array($child_list)) { $pass_fids = array_merge($pass_fids, $child_list);
| $pass_fids = array_merge($pass_fids, get_child_list($fid));
|
} } return array_unique($pass_fids);
| } } return array_unique($pass_fids);
|
Zeile 272 | Zeile 322 |
---|
// Separate braces for further processing $keywords = preg_replace("#((\+|-|<|>|~)?\(|\))#s", " $1 ", $keywords); $keywords = preg_replace("#\s+#s", " ", $keywords);
|
// Separate braces for further processing $keywords = preg_replace("#((\+|-|<|>|~)?\(|\))#s", " $1 ", $keywords); $keywords = preg_replace("#\s+#s", " ", $keywords);
|
|
|
global $mybb;
|
global $mybb;
|
|
|
$min_word_length = (int) $mybb->settings['minsearchword']; if($min_word_length <= 0) { $min_word_length = 3;
|
$min_word_length = (int) $mybb->settings['minsearchword']; if($min_word_length <= 0) { $min_word_length = 3;
|
}
| }
|
$min_word_length -= 1;
|
$min_word_length -= 1;
|
| $word_length_regex = ''; if($min_word_length > 1) { $word_length_regex = "{1,{$min_word_length}}"; }
|
// Replaces less than 3 characters
|
// Replaces less than 3 characters
|
$keywords = preg_replace("/(\b.{1,{$min_word_length}})(\s)|(\b.{1,{$min_word_length}}$)/", '$2', $keywords);
| $keywords = preg_replace("/(\b.{$word_length_regex})(\s)|(\b.{$word_length_regex}$)/u", '$2', $keywords);
|
// Collapse multiple spaces $keywords = preg_replace('/(\s)+/', '$1', $keywords); $keywords = trim($keywords);
| // Collapse multiple spaces $keywords = preg_replace('/(\s)+/', '$1', $keywords); $keywords = trim($keywords);
|
Zeile 344 | Zeile 400 |
---|
$last = substr($last, 1); } $words[$depth][] = $last;
|
$last = substr($last, 1); } $words[$depth][] = $last;
|
}
| }
|
} elseif($word == "and")
|
} elseif($word == "and")
|
{
| {
|
$boolean[$depth] = "+"; } elseif($word == "not") { $boolean[$depth] = "-";
|
$boolean[$depth] = "+"; } elseif($word == "not") { $boolean[$depth] = "-";
|
}
| }
|
// Closing braces elseif($word == ")")
|
// Closing braces elseif($word == ")")
|
{
| {
|
// Ignore when no brace was opened if($depth > 0) {
| // Ignore when no brace was opened if($depth > 0) {
|
Zeile 368 | Zeile 424 |
---|
elseif($word == '+(' || $word == '-(' || $word == '<(' || $word == '>(' || $word == '~(' || $word == '(') { if(strlen($word) == 2)
|
elseif($word == '+(' || $word == '-(' || $word == '<(' || $word == '>(' || $word == '~(' || $word == '(') { if(strlen($word) == 2)
|
{
| {
|
$boolean[$depth] = substr($word, 0, 1); } $words[++$depth] = array();
| $boolean[$depth] = substr($word, 0, 1); } $words[++$depth] = array();
|
Zeile 462 | Zeile 518 |
---|
default: $sfield = 'LOWER(subject)'; $mfield = 'LOWER(message)';
|
default: $sfield = 'LOWER(subject)'; $mfield = 'LOWER(message)';
|
break; }
| break; }
|
if(preg_match("#\s(and|or)\s#", $keywords)) { $string = "AND"; if($search['subject'] == 1)
|
if(preg_match("#\s(and|or)\s#", $keywords)) { $string = "AND"; if($search['subject'] == 1)
|
{
| {
|
$string = "OR"; $subject_lookin = " AND ("; }
| $string = "OR"; $subject_lookin = " AND ("; }
|
Zeile 485 | Zeile 541 |
---|
$boolean = '';
foreach($keywords_exp as $phrase)
|
$boolean = '';
foreach($keywords_exp as $phrase)
|
{
| {
|
// If we're not in a double quoted section if(!$inquote) {
| // If we're not in a double quoted section if(!$inquote) {
|
Zeile 508 | Zeile 564 |
---|
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 (") { // Just in a subject?
| elseif($search['subject'] && !$search['message'] && $subject_lookin == " AND (") { // Just in a subject?
|
Zeile 556 | Zeile 612 |
---|
{ $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 {$sfield} LIKE '%{$phrase}%'"; if($search['message'] == 1)
| // Add phrase to search query $subject_lookin .= " $boolean {$sfield} LIKE '%{$phrase}%'"; if($search['message'] == 1)
|
Zeile 602 | Zeile 658 |
---|
if($search['message'] == 1) { $message_lookin .= ")";
|
if($search['message'] == 1) { $message_lookin .= ")";
|
}
| }
|
$searchsql .= "{$subject_lookin} {$message_lookin}"; } else
| $searchsql .= "{$subject_lookin} {$message_lookin}"; } else
|
Zeile 651 | Zeile 707 |
---|
break; } $query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'");
|
break; } $query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'");
|
while($user = $db->fetch_array($query)) { $userids[] = $user['uid']; }
if(count($userids) < 1) { error($lang->error_nosearchresults);
| while($user = $db->fetch_array($query)) { $userids[] = $user['uid']; }
if(count($userids) < 1) { 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();
$search['folder'] = array_map("intval", $search['folder']);
|
if(!empty($search['folder'])) { $folderids = array();
$search['folder'] = array_map("intval", $search['folder']);
|
|
|
$folderids = implode(',', $search['folder']);
if($folderids) { $searchsql .= " AND folder IN (".$folderids.")";
|
$folderids = implode(',', $search['folder']);
if($folderids) { $searchsql .= " AND folder IN (".$folderids.")";
|
}
| }
|
}
if($search['status'])
| }
if($search['status'])
|
Zeile 692 | Zeile 748 |
---|
if($search['status']['new']) { $statussql[] = " status='0' ";
|
if($search['status']['new']) { $statussql[] = " status='0' ";
|
}
| }
|
if($search['status']['replied']) { $statussql[] = " status='3' "; } if($search['status']['forwarded'])
|
if($search['status']['replied']) { $statussql[] = " status='3' "; } if($search['status']['forwarded'])
|
{
| {
|
$statussql[] = " status='4' "; } if($search['status']['read'])
| $statussql[] = " status='4' "; } if($search['status']['read'])
|
Zeile 707 | Zeile 763 |
---|
} // Sent Folder if(in_array(2, $search['folder']))
|
} // Sent Folder if(in_array(2, $search['folder']))
|
{
| {
|
$statussql[] = " status='1' "; } $statussql = implode("OR", $statussql);
| $statussql[] = " status='1' "; } $statussql = implode("OR", $statussql);
|
Zeile 720 | Zeile 776 |
---|
$limitsql = " LIMIT ".(int)$mybb->settings['searchhardlimit']; } $searchsql .= $limitsql;
|
$limitsql = " LIMIT ".(int)$mybb->settings['searchhardlimit']; } $searchsql .= $limitsql;
|
|
|
// 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 732 | Zeile 788 |
---|
if(count($pms) < 1) { error($lang->error_nosearchresults);
|
if(count($pms) < 1) { error($lang->error_nosearchresults);
|
}
| }
|
$pms = implode(',', $pms);
return array(
| $pms = implode(',', $pms);
return array(
|
Zeile 829 | Zeile 885 |
---|
elseif($search['name'] && !$search['document'] && $name_lookin == " AND (") { // Just in a name?
|
elseif($search['name'] && !$search['document'] && $name_lookin == " AND (") { // Just in a name?
|
continue; }
| continue; }
|
elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (") { // Just in a document? continue; }
|
elseif(!$search['name'] && $search['document'] && $document_lookin == " {$string} (") { // Just in a document? continue; }
|
}
| }
|
$boolean = $word; }
| $boolean = $word; }
|
Zeile 854 | Zeile 910 |
---|
if($search['name'] == 1) { $name_lookin .= " $boolean {$nfield} LIKE '%{$word}%'";
|
if($search['name'] == 1) { $name_lookin .= " $boolean {$nfield} LIKE '%{$word}%'";
|
}
| }
|
if($search['document'] == 1) { $document_lookin .= " $boolean {$dfield} LIKE '%{$word}%'";
| if($search['document'] == 1) { $document_lookin .= " $boolean {$dfield} LIKE '%{$word}%'";
|
Zeile 1239 | Zeile 1295 |
---|
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1) { $onlyusfids[] = $fid;
|
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1) { $onlyusfids[] = $fid;
|
} } } if(!empty($onlyusfids)) { $permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))"; }
| } } } if(!empty($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 1258 | Zeile 1314 |
---|
$permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
$permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";
| $visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = "";
|
if(isset($search['visible'])) { if($search['visible'] == 1) { $visiblesql = " AND t.visible = '1'";
|
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'";
|
}
| }
|
} elseif($search['visible'] == -1) { $visiblesql = " AND t.visible = '-1'";
|
} elseif($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 1286 | Zeile 1342 |
---|
$visiblesql = " AND t.visible == '0'";
if($search['postthread'] == 1)
|
$visiblesql = " AND t.visible == '0'";
if($search['postthread'] == 1)
|
{
| {
|
$post_visiblesql = " AND p.visible == '0'"; $plain_post_visiblesql = " AND visible == '0'"; } } }
|
$post_visiblesql = " AND p.visible == '0'"; $plain_post_visiblesql = " AND visible == '0'"; } } }
|
| // Moderators can view unapproved threads and deleted threads from forums they moderate $unapproved_where_t = get_visible_where('t'); $unapproved_where_p = get_visible_where('p');
|
// Searching a specific thread? $tidsql = '';
| // Searching a specific thread? $tidsql = '';
|
Zeile 1318 | Zeile 1378 |
---|
$query = $db->query(" SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t
|
$query = $db->query(" SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t
|
WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND t.closed NOT LIKE 'moved|%' {$subject_lookin}
| WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND ({$unapproved_where_t}) AND t.closed NOT LIKE 'moved|%' {$subject_lookin}
|
{$limitsql} "); while($thread = $db->fetch_array($query))
| {$limitsql} "); while($thread = $db->fetch_array($query))
|
Zeile 1335 | Zeile 1395 |
---|
SELECT p.pid, p.tid FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
SELECT p.pid, p.tid FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$visiblesql} {$post_visiblesql} AND t.closed NOT LIKE 'moved|%' {$message_lookin}
| WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$visiblesql} {$post_visiblesql} AND ({$unapproved_where_t}) AND ({$unapproved_where_p}) AND t.closed NOT LIKE 'moved|%' {$message_lookin}
|
{$limitsql} "); while($post = $db->fetch_array($query))
| {$limitsql} "); while($post = $db->fetch_array($query))
|
Zeile 1345 | Zeile 1405 |
---|
}
if(count($posts) < 1 && count($threads) < 1)
|
}
if(count($posts) < 1 && count($threads) < 1)
|
{ error($lang->error_nosearchresults); } $threads = implode(',', $threads);
| { error($lang->error_nosearchresults); } $threads = implode(',', $threads);
|
$posts = implode(',', $posts);
}
| $posts = implode(',', $posts);
}
|
Zeile 1367 | Zeile 1427 |
---|
if($thread['firstpost']) { $firstposts[$thread['tid']] = $thread['firstpost'];
|
if($thread['firstpost']) { $firstposts[$thread['tid']] = $thread['firstpost'];
|
} }
| } }
|
if(count($threads) < 1) { error($lang->error_nosearchresults);
| if(count($threads) < 1) { error($lang->error_nosearchresults);
|
Zeile 1404 | Zeile 1464 |
---|
global $mybb, $db, $lang;
$keywords = clean_keywords_ft($search['keywords']);
|
global $mybb, $db, $lang;
$keywords = clean_keywords_ft($search['keywords']);
|
// Attempt to determine minimum word length from MySQL for fulltext searches $query = $db->query("SHOW VARIABLES LIKE 'ft_min_word_len';"); $min_length = $db->fetch_field($query, 'Value'); if(is_numeric($min_length)) { $mybb->settings['minsearchword'] = $min_length; } // Otherwise, could not fetch - default back to MySQL fulltext default setting else
| if($mybb->settings['minsearchword'] < 1)
|
{ $mybb->settings['minsearchword'] = 4; }
| { $mybb->settings['minsearchword'] = 4; }
|
Zeile 1613 | Zeile 1665 |
---|
$permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
$permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = "";
| $visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = "";
|
if(isset($search['visible'])) { if($search['visible'] == 1)
| if(isset($search['visible'])) { if($search['visible'] == 1)
|
Zeile 1647 | Zeile 1699 |
---|
} } }
|
} } }
|
| // Moderators can view unapproved threads and deleted threads from forums they moderate $unapproved_where_t = get_visible_where('t'); $unapproved_where_p = get_visible_where('p');
|
// Searching a specific thread? if($search['tid'])
| // Searching a specific thread? if($search['tid'])
|
Zeile 1672 | Zeile 1728 |
---|
$query = $db->query(" SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t
|
$query = $db->query(" SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t
|
WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND t.closed NOT LIKE 'moved|%' {$subject_lookin}
| WHERE 1=1 {$thread_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$thread_usersql} {$permsql} {$visiblesql} AND ({$unapproved_where_t}) AND t.closed NOT LIKE 'moved|%' {$subject_lookin}
|
{$limitsql} "); while($thread = $db->fetch_array($query))
| {$limitsql} "); while($thread = $db->fetch_array($query))
|
Zeile 1689 | Zeile 1745 |
---|
SELECT p.pid, p.tid FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
SELECT p.pid, p.tid FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$post_visiblesql} {$visiblesql} AND t.closed NOT LIKE 'moved|%' {$message_lookin}
| WHERE 1=1 {$post_datecut} {$thread_replycut} {$thread_prefixcut} {$forumin} {$post_usersql} {$permsql} {$tidsql} {$post_visiblesql} {$visiblesql} AND ({$unapproved_where_t}) AND {$unapproved_where_p} AND t.closed NOT LIKE 'moved|%' {$message_lookin}
|
{$limitsql} "); while($post = $db->fetch_array($query))
| {$limitsql} "); while($post = $db->fetch_array($query))
|