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 2163 2006-08-30 05:53:05Z chris $
| * $Id: functions_search.php 3065 2007-05-16 00:36:39Z 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 95 | Zeile 95 |
---|
*/ function get_unsearchable_forums($pid="0", $first=1) {
|
*/ function get_unsearchable_forums($pid="0", $first=1) {
|
global $db, $forumcache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
| global $db, $forum_cache, $permissioncache, $mybb, $unsearchableforums, $unsearchable, $templates, $forumpass;
|
$pid = intval($pid);
|
$pid = intval($pid);
|
if(!is_array($forumcache))
| if(!is_array($forum_cache))
|
{ // Get Forums $query = $db->query("SELECT f.* FROM ".TABLE_PREFIX."forums f ORDER BY f.pid, f.disporder"); while($forum = $db->fetch_array($query)) {
|
{ // Get Forums $query = $db->query("SELECT f.* FROM ".TABLE_PREFIX."forums f ORDER BY f.pid, f.disporder"); while($forum = $db->fetch_array($query)) {
|
$forumcache[$forum['fid']] = $forum;
| $forum_cache[$forum['fid']] = $forum;
|
} } if(!is_array($permissioncache)) { $permissioncache = forum_permissions(); }
|
} } if(!is_array($permissioncache)) { $permissioncache = forum_permissions(); }
|
foreach($forumcache as $fid => $forum)
| foreach($forum_cache as $fid => $forum)
|
{ if($permissioncache[$forum['fid']]) {
| { if($permissioncache[$forum['fid']]) {
|
Zeile 127 | Zeile 127 |
---|
if($_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
if($_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
| } }
$parents = explode(",", $forum['parentlist']); if(is_array($parents)) { foreach($parents as $parent) { if($forum_cache[$parent]['active'] == "no") { $forum['active'] = "no"; }
|
} }
| } }
|
Zeile 256 | Zeile 268 |
---|
/** * Perform a thread and post search under MySQL or MySQLi
|
/** * Perform a thread and post search under MySQL or MySQLi
|
* * @param array Array of search data
| * * @param array Array of search data
|
* @return array Array of search data with results mixed in */ function perform_search_mysql($search)
| * @return array Array of search data with results mixed in */ function perform_search_mysql($search)
|
Zeile 361 | Zeile 373 |
---|
if($search['postthread'] == 1) { $message_lookin = " AND LOWER(p.message) LIKE '%".$keywords."%'";
|
if($search['postthread'] == 1) { $message_lookin = " AND LOWER(p.message) LIKE '%".$keywords."%'";
|
} } } $post_usersql = ""; $thread_usersql = ""; if($search['author']) { $userids = array(); if($search['matchusername']) { $query = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE username='".$db->escape_string($search['author'])."'"); } else { $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)) { $userids[] = $user['uid']; } if(count($userids) < 1) { error($lang->error_nosearchresults);
| } } } $post_usersql = ""; $thread_usersql = ""; if($search['author']) { $userids = array(); if($search['matchusername']) { $query = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE username='".$db->escape_string($search['author'])."'"); } else { $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)) { $userids[] = $user['uid']; } if(count($userids) < 1) { error($lang->error_nosearchresults);
|
} else { $userids = implode(",", $userids); $post_usersql = " AND p.uid IN (".$userids.")"; $thread_usersql = " AND t.uid IN (".$userids.")";
|
} else { $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 = "<=";
|
$datecut = ""; if($search['postdate']) { if($search['pddir'] == 0) { $datecut = "<=";
|
} else {
| } else {
|
$datecut = ">=";
|
$datecut = ">=";
|
}
| } $now = time();
|
$datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'";
|
$datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'";
|
$post_datecut = "p.dateline $datecut"; $thread_datecut = "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 = " AND t.replies >= '".intval($search['numreplies'])."'"; } else { $thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'"; }
|
}
$forumin = "";
| }
$forumin = "";
|
Zeile 434 | Zeile 460 |
---|
while($sforum = $db->fetch_array($query)) { $fidlist[] = $sforum['fid'];
|
while($sforum = $db->fetch_array($query)) { $fidlist[] = $sforum['fid'];
|
}
| }
|
if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(",", $fidlist).")";
| if(count($fidlist) > 1) { $forumin = " AND t.fid IN (".implode(",", $fidlist).")";
|
Zeile 442 | Zeile 468 |
---|
} } }
|
} } }
|
}
| }
|
$unsearchforums = get_unsearchable_forums(); if($unsearchforums) {
| $unsearchforums = get_unsearchable_forums(); if($unsearchforums) {
|
Zeile 450 | Zeile 476 |
---|
} $inactiveforums = get_inactive_forums(); if($inactiveforums)
|
} $inactiveforums = get_inactive_forums(); if($inactiveforums)
|
{
| {
|
$permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
| $permsql .= " AND t.fid NOT IN ($inactiveforums)"; }
|
Zeile 464 | Zeile 490 |
---|
$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 $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
| WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|
Zeile 478 | Zeile 504 |
---|
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 $forumin $post_usersql $permsql AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $message_lookin
| 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
|
"); while($post = $db->fetch_array($query)) {
| "); while($post = $db->fetch_array($query)) {
|
Zeile 500 | Zeile 526 |
---|
$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 $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
| WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|
Zeile 581 | Zeile 607 |
---|
{ $word = str_replace(array("+", "-", "*"), "", $word); if(!$word)
|
{ $word = str_replace(array("+", "-", "*"), "", $word); if(!$word)
|
{
| {
|
continue;
|
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 613 | Zeile 653 |
---|
if($search['matchusername']) { $query = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE username='".$db->escape_string($search['author'])."'");
|
if($search['matchusername']) { $query = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE username='".$db->escape_string($search['author'])."'");
|
} else {
| } else {
|
$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)) { $userids[] = $user['uid'];
| while($user = $db->fetch_array($query)) { $userids[] = $user['uid'];
|
Zeile 645 | Zeile 686 |
---|
{ $datecut = ">="; }
|
{ $datecut = ">="; }
|
| $now = time();
|
$datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'";
|
$datelimit = $now-(86400 * $search['postdate']); $datecut .= "'$datelimit'";
|
$post_datecut = "p.dateline $datecut"; $thread_datecut = "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 = " AND t.replies >= '".intval($search['numreplies'])."'"; } else { $thread_replycut = " AND t.replies <= '".intval($search['numreplies'])."'"; }
|
}
$forumin = "";
| }
$forumin = "";
|
Zeile 705 | Zeile 760 |
---|
$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 $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
| WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $subject_lookin
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|
Zeile 719 | Zeile 774 |
---|
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 $forumin $post_usersql $permsql AND p.visible>0 AND t.visible>0 AND t.closed NOT LIKE 'moved|%' $message_lookin
| 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
|
"); while($post = $db->fetch_array($query)) {
| "); while($post = $db->fetch_array($query)) {
|
Zeile 741 | Zeile 796 |
---|
$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 $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
| WHERE 1=1 $thread_datecut $thread_replycut $forumin $thread_usersql $permsql AND t.visible>0 $subject_lookin
|
"); while($thread = $db->fetch_array($query)) {
| "); while($thread = $db->fetch_array($query)) {
|