Vergleich inc/functions_search.php - 1.2.1 - 1.2.13

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 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 2281 2006-09-27 12:24:50Z chris $

 * $Id: functions_search.php 3508 2007-11-23 16:10:16Z Tikitiki $

 */

/**

 */

/**

Zeile 81Zeile 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 309Zeile 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 416Zeile 416
		{
$datecut = ">=";
}

		{
$datecut = ">=";
}

 
		$now = time();

		$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";
$post_datecut = " AND p.dateline $datecut";
$thread_datecut = " AND t.dateline $datecut";

		$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";
$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 = "";
$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']))

		{

		{

			$search['forums'] = array(intval($search['forums']));

			$search['forums'] = array(intval($search['forums']));

		}

		}

		foreach($search['forums'] as $forum)
{
if(!$searchin[$forum])
{
$forum = intval($forum);

		foreach($search['forums'] as $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)
{
$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).")";
}
}
}
}
}
$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$permsql = " AND t.fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{

				$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))
{
$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)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{

		$permsql .= " AND t.fid NOT IN ($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 476Zeile 497
		$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
{$limitsql}

		");
while($thread = $db->fetch_array($query))

		");
while($thread = $db->fetch_array($query))

		{

		{

			$threads[$thread['tid']] = $thread['tid'];
if($thread['firstpost'])
{

			$threads[$thread['tid']] = $thread['tid'];
if($thread['firstpost'])
{

Zeile 490Zeile 512
			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
{$limitsql}

		");
while($post = $db->fetch_array($query))
{
$posts[$post['pid']] = $post['pid'];

		");
while($post = $db->fetch_array($query))
{
$posts[$post['pid']] = $post['pid'];

			$threads[$post['tid']] = $post['tid'];
}

			$threads[$post['tid']] = $post['tid'];
}

		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 512Zeile 535
		$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
{$limitsql}

		");
while($thread = $db->fetch_array($query))
{

		");
while($thread = $db->fetch_array($query))
{

Zeile 530Zeile 554
		$threads = implode(",", $threads);
$firstposts = implode(",", $firstposts);
if($firstposts)

		$threads = implode(",", $threads);
$firstposts = implode(",", $firstposts);
if($firstposts)

		{

		{

			$query = $db->query("
SELECT p.pid
FROM ".TABLE_PREFIX."posts p
WHERE p.pid IN ($firstposts) AND p.visible>0

			$query = $db->query("
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 563Zeile 588

$keywords = clean_keywords_ft($search['keywords']);
if(!$keywords && !$search['author'])


$keywords = clean_keywords_ft($search['keywords']);
if(!$keywords && !$search['author'])

	{

	{

		error($lang->error_nosearchterms);
}


		error($lang->error_nosearchterms);
}


Zeile 598Zeile 623
					}
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 631Zeile 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))
{
$userids[] = $user['uid'];

		while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];

Zeile 657Zeile 697
		{
$datecut = ">=";
}

		{
$datecut = ">=";
}

 
		$now = time();

		$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";
$post_datecut = " AND p.dateline $datecut";
$thread_datecut = " AND t.dateline $datecut";

		$datelimit = $now-(86400 * $search['postdate']);
$datecut .= "'$datelimit'";
$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 = "";
$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 676Zeile 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 717Zeile 778
		$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
{$limitsql}

		");
while($thread = $db->fetch_array($query))
{

		");
while($thread = $db->fetch_array($query))
{

Zeile 731Zeile 793
			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
{$limitsql}

		");
while($post = $db->fetch_array($query))
{

		");
while($post = $db->fetch_array($query))
{

Zeile 753Zeile 816
		$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
{$limitsql}

		");
while($thread = $db->fetch_array($query))
{

		");
while($thread = $db->fetch_array($query))
{

Zeile 776Zeile 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))
{