Vergleich inc/functions_search.php - 1.2.0 - 1.2.12

  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 2163 2006-08-30 05:53:05Z 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 95Zeile 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 127Zeile 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 297Zeile 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 361Zeile 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);
}
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 = "<=";
}

			}
}
}
$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.")";
}
}
$datecut = "";
if($search['postdate'])
{
if($search['pddir'] == 0)
{
$datecut = "<=";
}

		else
{
$datecut = ">=";
}

		else
{
$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 = "";
$fidlist = array();

	}

$forumin = "";
$fidlist = array();

 
	$searchin = array();

	if($search['forums'] != "all")
{
if(!is_array($search['forums']))
{
$search['forums'] = array(intval($search['forums']));

	if($search['forums'] != "all")
{
if(!is_array($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)

				$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).")";

			}
}
}

			}
}
}

Zeile 452Zeile 479
	if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";

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

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

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

Zeile 500Zeile 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 523Zeile 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 586Zeile 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 613Zeile 664
		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'];
}
if(count($userids) < 1)

		while($user = $db->fetch_array($query))
{
$userids[] = $user['uid'];
}
if(count($userids) < 1)

		{

		{

			error($lang->error_nosearchresults);
}
else

			error($lang->error_nosearchresults);
}
else

Zeile 632Zeile 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 640Zeile 692
		if($search['pddir'] == 0)
{
$datecut = "<=";

		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 = "";
$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 664Zeile 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).")";

			}
}
}

			}
}
}

Zeile 693Zeile 760
	if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";

	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 705Zeile 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 719Zeile 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 741Zeile 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 764Zeile 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))
{