Zeile 83 | Zeile 83 |
---|
*/ function get_unsearchable_forums($pid=0, $first=1) {
|
*/ function get_unsearchable_forums($pid=0, $first=1) {
|
global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
| global $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
|
$pid = (int)$pid;
if(!is_array($forum_cache)) {
|
$pid = (int)$pid;
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)) { $forum_cache[$forum['fid']] = $forum; }
| cache_forums();
|
} if(!is_array($permissioncache)) {
| } if(!is_array($permissioncache)) {
|
Zeile 107 | Zeile 102 |
---|
$perms = $permissioncache[$forum['fid']]; } else
|
$perms = $permissioncache[$forum['fid']]; } else
|
{
| {
|
$perms = $mybb->usergroup; }
| $perms = $mybb->usergroup; }
|
Zeile 119 | Zeile 114 |
---|
if($forum_cache[$parent]['active'] == 0) { $forum['active'] = 0;
|
if($forum_cache[$parent]['active'] == 0) { $forum['active'] = 0;
|
}
| }
|
} }
| } }
|
Zeile 168 | Zeile 163 |
---|
if(!empty($table_alias)) { $aliasdot = $table_alias.'.';
|
if(!empty($table_alias)) { $aliasdot = $table_alias.'.';
|
}
| }
|
if($mybb->usergroup['issupermod'] == 1) { // Super moderators (and admins)
| if($mybb->usergroup['issupermod'] == 1) { // Super moderators (and admins)
|
Zeile 219 | Zeile 214 |
---|
$unapproved_where .= ')'; return $unapproved_where;
|
$unapproved_where .= ')'; return $unapproved_where;
|
} }
| } }
|
// Normal users if($mybb->user['uid'] > 0 && $mybb->settings['showownunapproved'] == 1)
|
// 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";
| return "({$aliasdot}visible = 1 OR ({$aliasdot}visible = 0 AND {$aliasdot}uid = {$mybb->user['uid']}))"; } return "{$aliasdot}visible = 1";
|
Zeile 239 | Zeile 234 |
---|
function get_password_protected_forums($fids=array()) { global $forum_cache, $mybb;
|
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(!is_array($forum_cache)) { $forum_cache = cache_forums();
|
Zeile 279 | Zeile 274 |
---|
*/ function clean_keywords($keywords) {
|
*/ function clean_keywords($keywords) {
|
global $db;
| global $db, $lang;
|
$keywords = my_strtolower($keywords); $keywords = $db->escape_string_like($keywords);
| $keywords = my_strtolower($keywords); $keywords = $db->escape_string_like($keywords);
|
Zeile 293 | Zeile 288 |
---|
if(my_strpos($keywords, "or") === 0) { $keywords = substr_replace($keywords, "", 0, 2);
|
if(my_strpos($keywords, "or") === 0) { $keywords = substr_replace($keywords, "", 0, 2);
|
| $keywords = " ".$keywords;
|
}
if(my_strpos($keywords, "and") === 0)
|
}
if(my_strpos($keywords, "and") === 0)
|
{
| {
|
$keywords = substr_replace($keywords, "", 0, 3);
|
$keywords = substr_replace($keywords, "", 0, 3);
|
| $keywords = " ".$keywords; }
if(!$keywords) { error($lang->error_nosearchterms);
|
}
return $keywords;
| }
return $keywords;
|
Zeile 353 | Zeile 355 |
---|
// Brace depth $depth = 0; $phrase_operator = '+';
|
// Brace depth $depth = 0; $phrase_operator = '+';
|
| $inquote = false;
|
foreach($keywords as $phrase) { $phrase = trim($phrase);
| foreach($keywords as $phrase) { $phrase = trim($phrase);
|
Zeile 701 | Zeile 704 |
---|
case 'mysql': case 'mysqli': $field = 'username';
|
case 'mysql': case 'mysqli': $field = 'username';
|
break; default:
| break; default:
|
$field = 'LOWER(username)'; break;
|
$field = 'LOWER(username)'; break;
|
}
| }
|
$query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'"); while($user = $db->fetch_array($query))
|
$query = $db->simple_select("users", "uid", "{$field} LIKE '%".$db->escape_string_like($search['sender'])."%'"); 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 724 | Zeile 727 |
---|
}
if(!is_array($search['folder']))
|
}
if(!is_array($search['folder']))
|
{
| {
|
$search['folder'] = array($search['folder']);
|
$search['folder'] = array($search['folder']);
|
}
| }
|
if(!empty($search['folder']))
|
if(!empty($search['folder']))
|
{
| {
|
$folderids = array();
$search['folder'] = array_map("intval", $search['folder']);
$folderids = implode(',', $search['folder']);
|
$folderids = array();
$search['folder'] = array_map("intval", $search['folder']);
$folderids = implode(',', $search['folder']);
|
|
|
if($folderids) { $searchsql .= " AND folder IN (".$folderids.")";
| if($folderids) { $searchsql .= " AND folder IN (".$folderids.")";
|
Zeile 748 | Zeile 751 |
---|
if($search['status']['new']) { $statussql[] = " status='0' ";
|
if($search['status']['new']) { $statussql[] = " status='0' ";
|
}
| }
|
if($search['status']['replied'])
|
if($search['status']['replied'])
|
{
| {
|
$statussql[] = " status='3' "; } if($search['status']['forwarded']) { $statussql[] = " status='4' ";
|
$statussql[] = " status='3' "; } if($search['status']['forwarded']) { $statussql[] = " status='4' ";
|
}
| }
|
if($search['status']['read']) { $statussql[] = " (status != '0' AND readtime > '0') ";
| if($search['status']['read']) { $statussql[] = " (status != '0' AND readtime > '0') ";
|
Zeile 772 | Zeile 775 |
---|
$limitsql = ""; if((int)$mybb->settings['searchhardlimit'] > 0)
|
$limitsql = ""; if((int)$mybb->settings['searchhardlimit'] > 0)
|
{
| {
|
$limitsql = " LIMIT ".(int)$mybb->settings['searchhardlimit']; } $searchsql .= $limitsql;
| $limitsql = " LIMIT ".(int)$mybb->settings['searchhardlimit']; } $searchsql .= $limitsql;
|
Zeile 820 | Zeile 823 |
---|
$name_lookin = ""; $document_lookin = ""; $searchsql = "enabled='1'";
|
$name_lookin = ""; $document_lookin = ""; $searchsql = "enabled='1'";
|
|
|
if($keywords) { switch($db->type)
| if($keywords) { switch($db->type)
|
Zeile 892 | Zeile 895 |
---|
// Just in a document? continue; }
|
// Just in a document? continue; }
|
}
$boolean = $word; } // Otherwise check the length of the word as it is a normal search term else { $word = trim($word); // Word is too short - show error message if(my_strlen($word) < $mybb->settings['minsearchword']) { $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength); }
| }
$boolean = $word; } // Otherwise check the length of the word as it is a normal search term else { $word = trim($word); // Word is too short - show error message if(my_strlen($word) < $mybb->settings['minsearchword']) { $lang->error_minsearchlength = $lang->sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength); }
|
// Add terms to search query if($search['name'] == 1) {
| // Add terms to search query if($search['name'] == 1) {
|
Zeile 1236 | Zeile 1239 |
---|
$thread_prefixcut = ''; $prefixlist = array();
|
$thread_prefixcut = ''; $prefixlist = array();
|
if($search['threadprefix'] && $search['threadprefix'][0] != 'any')
| if(!empty($search['threadprefix']) && $search['threadprefix'][0] != 'any')
|
{ foreach($search['threadprefix'] as $threadprefix) {
| { foreach($search['threadprefix'] as $threadprefix) {
|
Zeile 1295 | Zeile 1298 |
---|
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)."))"; }
$unsearchforums = get_unsearchable_forums(); if($unsearchforums) { $permsql .= " AND t.fid NOT IN ($unsearchforums)"; } $inactiveforums = get_inactive_forums(); if($inactiveforums) { $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
| } } } 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) { $permsql .= " AND t.fid NOT IN ($unsearchforums)"; } $inactiveforums = get_inactive_forums(); if($inactiveforums) { $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
$visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = ""; if(isset($search['visible']))
| $visiblesql = $post_visiblesql = $plain_post_visiblesql = $unapproved_where_t = $unapproved_where_p = ""; if(isset($search['visible']))
|
Zeile 1470 | Zeile 1473 |
---|
$mybb->settings['minsearchword'] = 4; }
|
$mybb->settings['minsearchword'] = 4; }
|
| $message_lookin = $subject_lookin = '';
|
if($keywords) { $keywords_exp = explode("\"", $keywords);
| if($keywords) { $keywords_exp = explode("\"", $keywords);
|
Zeile 1523 | Zeile 1527 |
---|
} $post_usersql = ''; $thread_usersql = '';
|
} $post_usersql = ''; $thread_usersql = '';
|
if($search['author'])
| if(!empty($search['author']))
|
{ $userids = array(); $search['author'] = my_strtolower($search['author']);
| { $userids = array(); $search['author'] = my_strtolower($search['author']);
|
Zeile 1531 | Zeile 1535 |
---|
{ $user = get_user_by_username($search['author']); if($user)
|
{ $user = get_user_by_username($search['author']); if($user)
|
{ $userids[] = $user['uid']; } }
| { $userids[] = $user['uid']; } }
|
else { $query = $db->simple_select("users", "uid", "username LIKE '%".$db->escape_string_like($search['author'])."%'");
| else { $query = $db->simple_select("users", "uid", "username LIKE '%".$db->escape_string_like($search['author'])."%'");
|
Zeile 1546 | Zeile 1550 |
---|
}
if(count($userids) < 1)
|
}
if(count($userids) < 1)
|
{ error($lang->error_nosearchresults); } else {
| { error($lang->error_nosearchresults); } else {
|
$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'])
| $datecut = $thread_datecut = $post_datecut = ''; if(!empty($search['postdate']))
|
{ if($search['pddir'] == 0)
|
{ if($search['pddir'] == 0)
|
{
| {
|
$datecut = "<="; } else
| $datecut = "<="; } else
|
Zeile 1572 | Zeile 1576 |
---|
$datecut .= "'$datelimit'"; $post_datecut = " AND p.dateline $datecut"; $thread_datecut = " AND t.dateline $datecut";
|
$datecut .= "'$datelimit'"; $post_datecut = " AND p.dateline $datecut"; $thread_datecut = " AND t.dateline $datecut";
|
}
| }
|
$thread_replycut = '';
|
$thread_replycut = '';
|
if($search['numreplies'] != '' && $search['findthreadst'])
| if(!empty($search['numreplies']) && $search['findthreadst'])
|
{ if((int)$search['findthreadst'] == 1)
|
{ if((int)$search['findthreadst'] == 1)
|
{
| {
|
$thread_replycut = " AND t.replies >= '".(int)$search['numreplies']."'"; } else { $thread_replycut = " AND t.replies <= '".(int)$search['numreplies']."'";
|
$thread_replycut = " AND t.replies >= '".(int)$search['numreplies']."'"; } else { $thread_replycut = " AND t.replies <= '".(int)$search['numreplies']."'";
|
}
| }
|
}
$thread_prefixcut = ''; $prefixlist = array();
|
}
$thread_prefixcut = ''; $prefixlist = array();
|
if($search['threadprefix'] && $search['threadprefix'][0] != 'any')
| if(!empty($search['threadprefix']) && $search['threadprefix'][0] != 'any')
|
{ foreach($search['threadprefix'] as $threadprefix) {
| { foreach($search['threadprefix'] as $threadprefix) {
|
Zeile 1598 | Zeile 1602 |
---|
} } if(count($prefixlist) == 1)
|
} } if(count($prefixlist) == 1)
|
{
| {
|
$thread_prefixcut .= " AND t.prefix='$threadprefix' "; } else { if(count($prefixlist) > 1)
|
$thread_prefixcut .= " AND t.prefix='$threadprefix' "; } else { if(count($prefixlist) > 1)
|
{
| {
|
$thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")"; } }
| $thread_prefixcut = " AND t.prefix IN (".implode(',', $prefixlist).")"; } }
|
Zeile 1622 | Zeile 1626 |
---|
{ $forum = (int)$forum; if($forum > 0)
|
{ $forum = (int)$forum; if($forum > 0)
|
{
| {
|
$fidlist[] = $forum; $child_list = get_child_list($forum); if(is_array($child_list))
| $fidlist[] = $forum; $child_list = get_child_list($forum); if(is_array($child_list))
|
Zeile 1630 | Zeile 1634 |
---|
$fidlist = array_merge($fidlist, $child_list); } }
|
$fidlist = array_merge($fidlist, $child_list); } }
|
}
| }
|
$fidlist = array_unique($fidlist); if(count($fidlist) >= 1)
|
$fidlist = array_unique($fidlist); if(count($fidlist) >= 1)
|
{
| {
|
$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
|
$forumin = " AND t.fid IN (".implode(',', $fidlist).")";
|
} }
| } }
|
$permsql = ""; $onlyusfids = array();
| $permsql = ""; $onlyusfids = array();
|
Zeile 1644 | Zeile 1648 |
---|
$group_permissions = forum_permissions(); foreach($group_permissions as $fid => $forum_permissions) {
|
$group_permissions = forum_permissions(); foreach($group_permissions as $fid => $forum_permissions) {
|
if($forum_permissions['canonlyviewownthreads'] == 1)
| if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
|
{ $onlyusfids[] = $fid;
|
{ $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)."))";
|
Zeile 1671 | Zeile 1675 |
---|
if($search['visible'] == 1) { $visiblesql = " AND t.visible = '1'";
|
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 1705 | Zeile 1709 |
---|
$unapproved_where_p = get_visible_where('p');
// Searching a specific thread?
|
$unapproved_where_p = get_visible_where('p');
// Searching a specific thread?
|
if($search['tid'])
| $tidsql = ''; if(!empty($search['tid']))
|
{ $tidsql = " AND t.tid='".(int)$search['tid']."'";
|
{ $tidsql = " AND t.tid='".(int)$search['tid']."'";
|
}
| }
|
$limitsql = ''; if((int)$mybb->settings['searchhardlimit'] > 0)
|
$limitsql = ''; if((int)$mybb->settings['searchhardlimit'] > 0)
|
{
| {
|
$limitsql = "LIMIT ".(int)$mybb->settings['searchhardlimit']; }
| $limitsql = "LIMIT ".(int)$mybb->settings['searchhardlimit']; }
|
Zeile 1723 | Zeile 1728 |
---|
if($search['postthread'] == 1) { // No need to search subjects when looking for results within a specific thread
|
if($search['postthread'] == 1) { // No need to search subjects when looking for results within a specific thread
|
if(!$search['tid'])
| if(empty($search['tid']))
|
{ $query = $db->query(" SELECT t.tid, t.firstpost
| { $query = $db->query(" SELECT t.tid, t.firstpost
|