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: functions_search.php 2299 2006-09-30 17:22:05Z Tikitiki $
| * $Id: functions_search.php 3508 2007-11-23 16:10:16Z Tikitiki $
|
*/
/**
| */
/**
|
Zeile 81 | Zeile 81 |
---|
} if($addselect) {
|
} if($addselect) {
|
$forumlist = "<select name=\"forums\" size=\"15\" multiple=\"multiple\">\n<option value=\"all\" selected=\"selected\">$lang->search_all_forums</option>\n<option value=\"all\">----------------------</option>\n$forumlistbits\n</select>";
| $forumlist = "<select name=\"forums[]\" size=\"15\" multiple=\"multiple\">\n<option value=\"all\" selected=\"selected\">$lang->search_all_forums</option>\n<option value=\"all\">----------------------</option>\n$forumlistbits\n</select>";
|
} return $forumlist; }
| } return $forumlist; }
|
Zeile 309 | Zeile 309 |
---|
$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++)
| for($i=0; $i < $count_matches; $i++)
|
{ $word = trim($matches[$i]); if(empty($word))
| { $word = trim($matches[$i]); if(empty($word))
|
Zeile 416 | Zeile 416 |
---|
{ $datecut = ">="; }
|
{ $datecut = ">="; }
|
| $now = time();
|
$datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'"; $post_datecut = " AND p.dateline $datecut";
| $datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'"; $post_datecut = " AND p.dateline $datecut";
|
Zeile 437 | Zeile 438 |
---|
$forumin = ""; $fidlist = array();
|
$forumin = ""; $fidlist = array();
|
| $searchin = array();
|
if($search['forums'] != "all") { if(!is_array($search['forums']))
| if($search['forums'] != "all") { if(!is_array($search['forums']))
|
Zeile 448 | Zeile 450 |
---|
if(!$searchin[$forum]) { $forum = intval($forum);
|
if(!$searchin[$forum]) { $forum = intval($forum);
|
$query = $db->query("SELECT f.fid FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user[usergroup]."') WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!='no' AND (ISNULL(p.fid) OR p.cansearch='yes')"); if($db->num_rows($query) == 1)
| $query = $db->query("SELECT DISTINCT f.fid FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user[usergroup]."') WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!='no' AND (ISNULL(p.fid) OR p.cansearch='yes')"); while($sforum = $db->fetch_array($query))
|
{
|
{
|
$forumin .= " AND t.fid='$forum' "; $searchin[$fid] = 1; } else { while($sforum = $db->fetch_array($query)) { $fidlist[] = $sforum['fid']; } if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(",", $fidlist).")"; }
| $fidlist[] = $sforum['fid'];
|
}
|
}
|
| } } if(count($fidlist) == 1) { $forumin .= " AND t.fid='$forum' "; $searchin[$fid] = 1; } else { if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(",", $fidlist).")";
|
} } } $unsearchforums = get_unsearchable_forums(); if($unsearchforums)
|
} } } $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)";
|
$permsql = " AND t.fid NOT IN ($unsearchforums)"; } $inactiveforums = get_inactive_forums(); if($inactiveforums) { $permsql .= " AND t.fid NOT IN ($inactiveforums)";
|
| } $limitsql = ""; if(intval($mybb->settings['searchhardlimit']) > 0) { $limitsql = "LIMIT ".intval($mybb->settings['searchhardlimit']);
|
}
// Searching both posts and thread titles
| }
// Searching both posts and thread titles
|
Zeile 490 | Zeile 498 |
---|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
|
");
| {$limitsql} ");
|
while($thread = $db->fetch_array($query)) { $threads[$thread['tid']] = $thread['tid'];
| while($thread = $db->fetch_array($query)) { $threads[$thread['tid']] = $thread['tid'];
|
Zeile 504 | Zeile 513 |
---|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) WHERE 1=1 $post_datecut $thread_replycut $forumin $post_usersql $permsql AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $message_lookin
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) WHERE 1=1 $post_datecut $thread_replycut $forumin $post_usersql $permsql AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $message_lookin
|
| {$limitsql}
|
"); while($post = $db->fetch_array($query)) {
| "); while($post = $db->fetch_array($query)) {
|
Zeile 526 | Zeile 536 |
---|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
|
| {$limitsql}
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|
Zeile 548 | Zeile 559 |
---|
SELECT p.pid FROM ".TABLE_PREFIX."posts p WHERE p.pid IN ($firstposts) AND p.visible>0
|
SELECT p.pid FROM ".TABLE_PREFIX."posts p WHERE p.pid IN ($firstposts) AND p.visible>0
|
| {$limitsql}
|
"); while($post = $db->fetch_array($query)) {
| "); while($post = $db->fetch_array($query)) {
|
Zeile 589 | Zeile 601 |
---|
} // Otherwise, could not fetch - default back to MySQL fulltext default setting else
|
} // Otherwise, could not fetch - default back to MySQL fulltext default setting else
|
{
| {
|
$mybb->settings['minsearchword'] = 4; }
| $mybb->settings['minsearchword'] = 4; }
|
Zeile 600 | Zeile 612 |
---|
foreach($keywords_exp as $phrase) { if(!$inquote)
|
foreach($keywords_exp as $phrase) { if(!$inquote)
|
{
| {
|
$split_words = preg_split("#\s{1,}#", $phrase, -1); foreach($split_words as $word) {
| $split_words = preg_split("#\s{1,}#", $phrase, -1); foreach($split_words as $word) {
|
Zeile 608 | Zeile 620 |
---|
if(!$word) { continue;
|
if(!$word) { continue;
|
}
| }
|
if(my_strlen($word) < $mybb->settings['minsearchword']) {
|
if(my_strlen($word) < $mybb->settings['minsearchword']) {
|
$lang->error_minsearchlength = sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
| $all_too_short = true;
|
}
|
}
|
} }
| else { $all_too_short = false; break; } } }
|
else { $phrase = str_replace(array("+", "-", "*"), "", $phrase); if(my_strlen($phrase) < $mybb->settings['minsearchword'])
|
else { $phrase = str_replace(array("+", "-", "*"), "", $phrase); if(my_strlen($phrase) < $mybb->settings['minsearchword'])
|
{ $lang->error_minsearchlength = sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength); } }
| { $all_too_short = true; } else { $all_too_short = false; break; } }
|
$inquote = !$inquote;
|
$inquote = !$inquote;
|
| } // Show the minimum search term error only if all search terms are too short if($all_too_short == true) { $lang->error_minsearchlength = sprintf($lang->error_minsearchlength, $mybb->settings['minsearchword']); error($lang->error_minsearchlength);
|
} $message_lookin = "AND MATCH(message) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)"; $subject_lookin = "AND MATCH(subject) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)";
| } $message_lookin = "AND MATCH(message) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)"; $subject_lookin = "AND MATCH(subject) AGAINST('".$db->escape_string($keywords)."' IN BOOLEAN MODE)";
|
Zeile 644 | Zeile 670 |
---|
$search['author'] = strtolower($search['author']); $query = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE LOWER(username) LIKE '%".$db->escape_string($search['author'])."%'"); }
|
$search['author'] = strtolower($search['author']); $query = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE LOWER(username) LIKE '%".$db->escape_string($search['author'])."%'"); }
|
|
|
while($user = $db->fetch_array($query))
|
while($user = $db->fetch_array($query))
|
{
| {
|
$userids[] = $user['uid']; } if(count($userids) < 1)
|
$userids[] = $user['uid']; } if(count($userids) < 1)
|
{
| {
|
error($lang->error_nosearchresults); } else
| error($lang->error_nosearchresults); } else
|
Zeile 657 | Zeile 684 |
---|
$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 = ""; if($search['postdate'])
|
Zeile 670 | Zeile 697 |
---|
{ $datecut = ">="; }
|
{ $datecut = ">="; }
|
| $now = time();
|
$datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'"; $post_datecut = " AND p.dateline $datecut";
| $datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'"; $post_datecut = " AND p.dateline $datecut";
|
Zeile 691 | Zeile 719 |
---|
$forumin = ""; $fidlist = array();
|
$forumin = ""; $fidlist = array();
|
| $searchin = array();
|
if($search['forums'] != "all") { if(!is_array($search['forums']))
| if($search['forums'] != "all") { if(!is_array($search['forums']))
|
Zeile 702 | Zeile 731 |
---|
$forum = intval($forum); if(!$searchin[$forum]) {
|
$forum = intval($forum); if(!$searchin[$forum]) {
|
$query = $db->query("SELECT f.fid FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user[usergroup]."') WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!='no' AND (ISNULL(p.fid) OR p.cansearch='yes')"); if($db->num_rows($query) == 1)
| $query = $db->query("SELECT DISTINCT f.fid FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user['usergroup']."') WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!='no' AND (ISNULL(p.fid) OR p.cansearch='yes')"); while($sforum = $db->fetch_array($query))
|
{
|
{
|
$forumin .= " AND t.fid='$forum' "; $searchin[$fid] = 1; } else { while($sforum = $db->fetch_array($query)) { $fidlist[] = $sforum['fid']; } if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(",", $fidlist).")"; }
| $fidlist[] = $sforum['fid'];
|
} } }
|
} } }
|
}
| if(count($fidlist) == 1) { $forumin .= " AND t.fid='$forum' "; $searchin[$fid] = 1; } else { if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(",", $fidlist).")"; } } }
|
$unsearchforums = get_unsearchable_forums(); if($unsearchforums) { $permsql = " AND t.fid NOT IN ($unsearchforums)";
|
$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)";
|
$inactiveforums = get_inactive_forums(); if($inactiveforums) { $permsql .= " AND t.fid NOT IN ($inactiveforums)";
|
| } $limitsql = ""; if(intval($mybb->settings['searchhardlimit']) > 0) { $limitsql = "LIMIT ".intval($mybb->settings['searchhardlimit']);
|
}
// Searching both posts and thread titles
| }
// Searching both posts and thread titles
|
Zeile 744 | Zeile 779 |
---|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
|
| {$limitsql}
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|
Zeile 758 | Zeile 794 |
---|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) WHERE 1=1 $post_datecut $thread_replycut $forumin $post_usersql $permsql AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $message_lookin
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) WHERE 1=1 $post_datecut $thread_replycut $forumin $post_usersql $permsql AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $message_lookin
|
| {$limitsql}
|
"); while($post = $db->fetch_array($query)) {
| "); while($post = $db->fetch_array($query)) {
|
Zeile 780 | Zeile 817 |
---|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
|
SELECT t.tid, t.firstpost FROM ".TABLE_PREFIX."threads t WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
|
| {$limitsql}
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|
Zeile 802 | Zeile 840 |
---|
SELECT p.pid FROM ".TABLE_PREFIX."posts p WHERE p.pid IN ($firstposts) AND p.visible>0
|
SELECT p.pid FROM ".TABLE_PREFIX."posts p WHERE p.pid IN ($firstposts) AND p.visible>0
|
| {$limitsql}
|
"); while($post = $db->fetch_array($query)) {
| "); while($post = $db->fetch_array($query)) {
|