mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
- fixed bugs #1395, #1177, fixed floating point assignment bug within older php versions ($fraction), adjusted search a little bit by implementing a workaround for database timeouts (hopefully Paul will not slap me for this. :D) - should be tested within high-traffic boards or those affected by the database timeout.
git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3585 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
0d75cfc914
commit
d6bdd83306
7 changed files with 147 additions and 84 deletions
|
@ -246,7 +246,7 @@ function add_search_words($mode, $post_id, $post_text, $post_title = '')
|
|||
|
||||
if ($mode == 'single')
|
||||
{
|
||||
remove_common('single', 0.4, $word);
|
||||
remove_common('single', 4/10, $word);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -486,4 +486,4 @@ function username_search($search_match)
|
|||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -712,7 +712,7 @@ switch ($row['config_value'])
|
|||
closedir($dir);
|
||||
|
||||
// Mark common words ...
|
||||
remove_common('global', 0.4);
|
||||
remove_common('global', 4/10);
|
||||
|
||||
// remove superfluous polls ... grab polls with topics then delete polls
|
||||
// not in that list
|
||||
|
|
|
@ -1926,7 +1926,7 @@ if ( !empty($next) )
|
|||
// Remove common words after the first 2 batches and after every 4th batch after that.
|
||||
if ( $batchcount % 4 == 3 )
|
||||
{
|
||||
remove_common('global', 0.4);
|
||||
remove_common('global', 4/10);
|
||||
}
|
||||
|
||||
print " <span class=\"ok\"><b>OK</b></span><br />\n";
|
||||
|
|
|
@ -115,9 +115,7 @@ if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
|
|||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect(append_sid("index.$phpEx", true));
|
||||
}
|
||||
|
||||
redirect(append_sid("index.$phpEx", true));
|
||||
|
||||
?>
|
213
phpBB/search.php
213
phpBB/search.php
|
@ -145,6 +145,10 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
|
|||
{
|
||||
$store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars');
|
||||
|
||||
//
|
||||
// Search ID Limiter, decrease this value if you experience further timeout problems with searching forums
|
||||
$limiter = 5000;
|
||||
|
||||
//
|
||||
// Cycle through options ...
|
||||
//
|
||||
|
@ -175,7 +179,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
|
|||
{
|
||||
$sql = "SELECT post_id
|
||||
FROM " . POSTS_TABLE . "
|
||||
WHERE poster_id = " . $userdata['user_id'];;
|
||||
WHERE poster_id = " . $userdata['user_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -215,6 +219,11 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
|
|||
$sql = "SELECT post_id
|
||||
FROM " . POSTS_TABLE . "
|
||||
WHERE poster_id IN ($matching_userids)";
|
||||
|
||||
if ($search_time)
|
||||
{
|
||||
$sql .= " AND post_time >= " . $search_time;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
|
@ -400,29 +409,124 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
|
|||
{
|
||||
if ( $show_results == 'topics' )
|
||||
{
|
||||
$where_sql = '';
|
||||
//
|
||||
// This one is a beast, try to seperate it a bit (workaround for connection timeouts)
|
||||
//
|
||||
$search_id_chunks = array();
|
||||
$count = 0;
|
||||
$chunk = 0;
|
||||
|
||||
if ( $search_time )
|
||||
if (count($search_ids) > $limiter)
|
||||
{
|
||||
$where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time ";
|
||||
}
|
||||
|
||||
if ( $search_author == '' && $auth_sql == '' )
|
||||
{
|
||||
$sql = "SELECT topic_id
|
||||
FROM " . POSTS_TABLE . "
|
||||
WHERE post_id IN (" . implode(", ", $search_ids) . ")
|
||||
$where_sql
|
||||
GROUP BY topic_id";
|
||||
for ($i = 0; $i < count($search_ids); $i++)
|
||||
{
|
||||
if ($count == $limiter)
|
||||
{
|
||||
$chunk++;
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
$search_id_chunks[$chunk][$count] = $search_ids[$i];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$from_sql = POSTS_TABLE . " p";
|
||||
$search_id_chunks[0] = $search_ids;
|
||||
}
|
||||
|
||||
if ( $search_author != '' )
|
||||
$search_ids = array();
|
||||
|
||||
for ($i = 0; $i < count($search_id_chunks); $i++)
|
||||
{
|
||||
$where_sql = '';
|
||||
|
||||
if ( $search_time )
|
||||
{
|
||||
$from_sql .= ", " . USERS_TABLE . " u";
|
||||
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author' ";
|
||||
$where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time ";
|
||||
}
|
||||
|
||||
if ( $search_author == '' && $auth_sql == '' )
|
||||
{
|
||||
$sql = "SELECT topic_id
|
||||
FROM " . POSTS_TABLE . "
|
||||
WHERE post_id IN (" . implode(", ", $search_id_chunks[$i]) . ")
|
||||
$where_sql
|
||||
GROUP BY topic_id";
|
||||
}
|
||||
else
|
||||
{
|
||||
$from_sql = POSTS_TABLE . " p";
|
||||
|
||||
if ( $search_author != '' )
|
||||
{
|
||||
$from_sql .= ", " . USERS_TABLE . " u";
|
||||
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author' ";
|
||||
}
|
||||
|
||||
if ( $auth_sql != '' )
|
||||
{
|
||||
$from_sql .= ", " . FORUMS_TABLE . " f";
|
||||
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
|
||||
}
|
||||
|
||||
$sql = "SELECT p.topic_id
|
||||
FROM $from_sql
|
||||
WHERE p.post_id IN (" . implode(", ", $search_id_chunks[$i]) . ")
|
||||
$where_sql
|
||||
GROUP BY p.topic_id";
|
||||
}
|
||||
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$search_ids[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$total_match_count = sizeof($search_ids);
|
||||
|
||||
}
|
||||
else if ( $search_author != '' || $search_time || $auth_sql != '' )
|
||||
{
|
||||
$search_id_chunks = array();
|
||||
$count = 0;
|
||||
$chunk = 0;
|
||||
|
||||
if (count($search_ids) > $limiter)
|
||||
{
|
||||
for ($i = 0; $i < count($search_ids); $i++)
|
||||
{
|
||||
if ($count == $limiter)
|
||||
{
|
||||
$chunk++;
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
$search_id_chunks[$chunk][$count] = $search_ids[$i];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_id_chunks[0] = $search_ids;
|
||||
}
|
||||
|
||||
$search_ids = array();
|
||||
|
||||
for ($i = 0; $i < count($search_id_chunks); $i++)
|
||||
{
|
||||
$where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')';
|
||||
$from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p';
|
||||
|
||||
if ( $search_time )
|
||||
{
|
||||
$where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time";
|
||||
}
|
||||
|
||||
if ( $auth_sql != '' )
|
||||
|
@ -431,66 +535,27 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
|
|||
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
|
||||
}
|
||||
|
||||
$sql = "SELECT p.topic_id
|
||||
if ( $search_author != '' )
|
||||
{
|
||||
$from_sql .= ", " . USERS_TABLE . " u";
|
||||
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author'";
|
||||
}
|
||||
|
||||
$sql = "SELECT p.post_id
|
||||
FROM $from_sql
|
||||
WHERE p.post_id IN (" . implode(", ", $search_ids) . ")
|
||||
$where_sql
|
||||
GROUP BY p.topic_id";
|
||||
WHERE $where_sql";
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$search_ids[] = $row['post_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
$search_ids = array();
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$search_ids[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$total_match_count = sizeof($search_ids);
|
||||
|
||||
}
|
||||
else if ( $search_author != '' || $search_time || $auth_sql != '' )
|
||||
{
|
||||
$where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_ids) . ')' : 'p.post_id IN (' . implode(', ', $search_ids) . ')';
|
||||
$from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p';
|
||||
|
||||
if ( $search_time )
|
||||
{
|
||||
$where_sql .= ( $search_author == '' && $auth_sql == '' ) ? " AND post_time >= $search_time " : " AND p.post_time >= $search_time";
|
||||
}
|
||||
|
||||
if ( $auth_sql != '' )
|
||||
{
|
||||
$from_sql .= ", " . FORUMS_TABLE . " f";
|
||||
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
|
||||
}
|
||||
|
||||
if ( $search_author != '' )
|
||||
{
|
||||
$from_sql .= ", " . USERS_TABLE . " u";
|
||||
$where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author'";
|
||||
}
|
||||
|
||||
$sql = "SELECT p.post_id
|
||||
FROM $from_sql
|
||||
WHERE $where_sql";
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
$search_ids = array();
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$search_ids[] = $row['post_id'];
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$total_match_count = count($search_ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<td valign="middle" nowrap="nowrap">{PROFILE_IMG} {PM_IMG} {EMAIL_IMG}
|
||||
{WWW_IMG} {AIM_IMG} {YIM_IMG} {MSN_IMG}</td><td> </td><td valign="top" nowrap="nowrap"><script language="JavaScript" type="text/javascript"><!--
|
||||
|
||||
if ( navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && navigator.userAgent.indexOf('5.') == -1 )
|
||||
if ( navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && navigator.userAgent.indexOf('5.') == -1 && navigator.userAgent.indexOf('6.') == -1 )
|
||||
document.write('{ICQ_IMG}');
|
||||
else
|
||||
document.write('<div style="position:relative"><div style="position:absolute">{ICQ_IMG}</div><div style="position:absolute;left:3px">{ICQ_STATUS_IMG}</div></div>');
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<td valign="middle" nowrap="nowrap" align="right"><span class="gen">{L_ICQ_NUMBER}:</span></td>
|
||||
<td class="row1"><script language="JavaScript" type="text/javascript"><!--
|
||||
|
||||
if ( navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && navigator.userAgent.indexOf('5.') == -1 )
|
||||
if ( navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && navigator.userAgent.indexOf('5.') == -1 && navigator.userAgent.indexOf('6.') == -1 )
|
||||
document.write(' {ICQ_IMG}');
|
||||
else
|
||||
document.write('<table cellspacing="0" cellpadding="0" border="0"><tr><td nowrap="nowrap"><div style="position:relative;height:18px"><div style="position:absolute">{ICQ_IMG}</div><div style="position:absolute;left:3px;top:-1px">{ICQ_STATUS_IMG}</div></div></td></tr></table>');
|
||||
|
|
Loading…
Add table
Reference in a new issue