mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
pre-freeze on main templates, various bug fixes (highlighting search results, various search related issues, blah blah). These updates need _thorough_ checking, quickly
git-svn-id: file:///svn/phpbb/trunk@2448 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -22,20 +22,12 @@
|
||||
function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
|
||||
{
|
||||
// Weird, $init_match doesn't work with static when double quotes (") are used...
|
||||
static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', "'", '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
|
||||
static $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ', ' ', ' ');
|
||||
|
||||
// static $accent_match = array("<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>", "<22>");
|
||||
// static $accent_replace = array("s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y");
|
||||
static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
|
||||
static $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ', ' ', ' ');
|
||||
|
||||
$entry = ' ' . strip_tags(strtolower($entry)) . ' ';
|
||||
|
||||
for($i = 0; $i < count($accent_match); $i++)
|
||||
{
|
||||
$entry = str_replace($accent_match[$i], $accent_replace[$i], $entry);
|
||||
}
|
||||
|
||||
if( $mode == 'post' )
|
||||
if ( $mode == 'post' )
|
||||
{
|
||||
// Replace line endings by a space
|
||||
$entry = preg_replace('/[\n\r]/is', ' ', $entry);
|
||||
@@ -48,7 +40,7 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
|
||||
$entry = preg_replace('/\[\/?url(=.*?)?\]/', ' ', $entry);
|
||||
$entry = preg_replace('/\[\/?[a-z\*=\+\-]+(\:?[0-9a-z]+)?:[a-z0-9]{10,}(\:[a-z0-9]+)?=?.*?\]/', ' ', $entry);
|
||||
}
|
||||
else if( $mode == 'search' )
|
||||
else if ( $mode == 'search' )
|
||||
{
|
||||
$entry = str_replace('+', ' and ', $entry);
|
||||
$entry = str_replace('-', ' not ', $entry);
|
||||
@@ -65,15 +57,15 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
|
||||
$entry = str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
|
||||
}
|
||||
|
||||
if( $mode == 'post' )
|
||||
if ( $mode == 'post' )
|
||||
{
|
||||
$entry = str_replace('*', ' ', $entry);
|
||||
|
||||
// 'words' that consist of <=3 or >=25 characters are removed.
|
||||
$entry = preg_replace('/\b([a-z0-9]{1,3}|[a-z0-9]{25,})\b/',' ', $entry);
|
||||
$entry = preg_replace('/\b([a-z0-9]{1,3}|[a-z0-9]{20,})\b/',' ', $entry);
|
||||
}
|
||||
|
||||
if( !empty($stopword_list) )
|
||||
if ( !empty($stopword_list) )
|
||||
{
|
||||
for ($j = 0; $j < count($stopword_list); $j++)
|
||||
{
|
||||
@@ -86,7 +78,7 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
|
||||
}
|
||||
}
|
||||
|
||||
if( !empty($synonym_list) )
|
||||
if ( !empty($synonym_list) )
|
||||
{
|
||||
for ($j = 0; $j < count($synonym_list); $j++)
|
||||
{
|
||||
@@ -103,7 +95,7 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
|
||||
|
||||
function split_words(&$entry, $mode = 'post')
|
||||
{
|
||||
if( $mode == 'post' )
|
||||
if ( $mode == 'post' )
|
||||
{
|
||||
preg_match_all("/\b(\w[\w']*\w+|\w+?)\b/", $entry, $split_entries);
|
||||
}
|
||||
@@ -128,10 +120,10 @@ function add_search_words($post_id, $post_text, $post_title = '')
|
||||
|
||||
$word = array();
|
||||
$word_insert_sql = array();
|
||||
while( list($word_in, $search_matches) = @each($search_raw_words) )
|
||||
while ( list($word_in, $search_matches) = @each($search_raw_words) )
|
||||
{
|
||||
$word_insert_sql[$word_in] = '';
|
||||
if( !empty($search_matches) )
|
||||
if ( !empty($search_matches) )
|
||||
{
|
||||
for ($i = 0; $i < count($search_matches); $i++)
|
||||
{
|
||||
@@ -149,7 +141,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
|
||||
}
|
||||
}
|
||||
|
||||
if( count($word) )
|
||||
if ( count($word) )
|
||||
{
|
||||
sort($word);
|
||||
|
||||
@@ -178,12 +170,12 @@ function add_search_words($post_id, $post_text, $post_title = '')
|
||||
$sql = "SELECT word_id, word_text
|
||||
FROM " . SEARCH_WORD_TABLE . "
|
||||
WHERE word_text IN ($word_text_sql)";
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not select words', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
while ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$check_words[$row['word_text']] = $row['word_id'];
|
||||
}
|
||||
@@ -195,18 +187,18 @@ function add_search_words($post_id, $post_text, $post_title = '')
|
||||
for ($i = 0; $i < count($word); $i++)
|
||||
{
|
||||
$new_match = true;
|
||||
if( isset($check_words[$word[$i]]) )
|
||||
if ( isset($check_words[$word[$i]]) )
|
||||
{
|
||||
$new_match = false;
|
||||
}
|
||||
|
||||
if( $new_match )
|
||||
if ( $new_match )
|
||||
{
|
||||
switch( SQL_LAYER )
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
$value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . "('" . $word[$i] . "')";
|
||||
$value_sql .= ( ( $value_sql != '' ) ? ', ' : '' ) . '(\'' . $word[$i] . '\')';
|
||||
break;
|
||||
case 'mssql':
|
||||
$value_sql .= ( ( $value_sql != '' ) ? ' UNION ALL ' : '' ) . "SELECT '" . $word[$i] . "'";
|
||||
@@ -238,7 +230,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
|
||||
break;
|
||||
}
|
||||
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
@@ -255,7 +247,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
|
||||
SELECT $post_id, word_id, $title_match
|
||||
FROM " . SEARCH_WORD_TABLE . "
|
||||
WHERE word_text IN ($match_sql)";
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
@@ -278,18 +270,18 @@ function remove_common($mode, $fraction, $word_id_list = array())
|
||||
global $db;
|
||||
|
||||
$sql = ( $mode == 'global' ) ? "SELECT COUNT(post_id) AS total_posts FROM " . SEARCH_MATCH_TABLE . " GROUP BY post_id" : "SELECT SUM(forum_posts) AS total_posts FROM " . FORUMS_TABLE;
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not obtain post count', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
if( $row['total_posts'] >= 100 )
|
||||
if ( $row['total_posts'] >= 100 )
|
||||
{
|
||||
$common_threshold = floor($row['total_posts'] * $fraction);
|
||||
|
||||
if( $mode == 'single' && count($word_id_list) )
|
||||
if ( $mode == 'single' && count($word_id_list) )
|
||||
{
|
||||
$word_id_sql = '';
|
||||
for($i = 0; $i < count($word_id_list); $i++)
|
||||
@@ -312,32 +304,32 @@ function remove_common($mode, $fraction, $word_id_list = array())
|
||||
HAVING COUNT(word_id) > $common_threshold";
|
||||
}
|
||||
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not obtain common word list', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
$common_word_id = '';
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
while ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$common_word_id .= ( ( $common_word_id != '' ) ? ', ' : '' ) . $row['word_id'];
|
||||
}
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if( $common_word_id != '' )
|
||||
if ( $common_word_id != '' )
|
||||
{
|
||||
$sql = "UPDATE " . SEARCH_WORD_TABLE . "
|
||||
SET word_common = " . TRUE . "
|
||||
WHERE word_id IN ($common_word_id)";
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
|
||||
WHERE word_id IN ($common_word_id)";
|
||||
if( !($result = $db->sql_query($sql)) )
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not delete word match entry', '', __LINE__, __FILE__, $sql);
|
||||
}
|
||||
@@ -353,7 +345,7 @@ function remove_search_post($post_id_sql)
|
||||
|
||||
$words_removed = false;
|
||||
|
||||
switch( SQL_LAYER )
|
||||
switch ( SQL_LAYER )
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
@@ -364,7 +356,7 @@ function remove_search_post($post_id_sql)
|
||||
if ( $result = $db->sql_query($sql) )
|
||||
{
|
||||
$word_id_sql = '';
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
while ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id'];
|
||||
}
|
||||
@@ -377,7 +369,7 @@ function remove_search_post($post_id_sql)
|
||||
if ( $result = $db->sql_query($sql) )
|
||||
{
|
||||
$word_id_sql = '';
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
while ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id'];
|
||||
}
|
||||
@@ -434,12 +426,12 @@ function remove_search_post($post_id_sql)
|
||||
//
|
||||
// Username search
|
||||
//
|
||||
function username_search($search_match, $is_inline_review = 0, $default_list = "")
|
||||
function username_search($search_match)
|
||||
{
|
||||
global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
|
||||
global $starttime;
|
||||
|
||||
$author_list = '';
|
||||
$username_list = '';
|
||||
if ( !empty($search_match) )
|
||||
{
|
||||
$username_search = preg_replace('/\*/', '%', trim(strip_tags($search_match)));
|
||||
@@ -457,55 +449,49 @@ function username_search($search_match, $is_inline_review = 0, $default_list = "
|
||||
{
|
||||
do
|
||||
{
|
||||
$author_list .= '<option value="' . $row['username'] . '">' .$row['username'] . '</option>';
|
||||
$username_list .= '<option value="' . $row['username'] . '">' . $row['username'] . '</option>';
|
||||
}
|
||||
while ( $row = $db->sql_fetchrow($result) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$author_list = '<option>' . $lang['No_match']. '</option>';
|
||||
$username_list .= '<option>' . $lang['No_match']. '</option>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !$is_inline_review )
|
||||
$gen_simple_header = TRUE;
|
||||
$page_title = $lang['Search'];
|
||||
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'search_user_body' => 'search_username.tpl')
|
||||
);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'USERNAME' => ( !empty($search_match) ) ? $search_match : '',
|
||||
|
||||
'L_CLOSE_WINDOW' => $lang['Close_window'],
|
||||
'L_SEARCH_USERNAME' => $lang['Find_username'],
|
||||
'L_UPDATE_USERNAME' => $lang['Select_username'],
|
||||
'L_SELECT' => $lang['Select'],
|
||||
'L_SEARCH' => $lang['Search'],
|
||||
'L_SEARCH_EXPLAIN' => $lang['Search_author_explain'],
|
||||
'L_CLOSE_WINDOW' => $lang['Close_window'],
|
||||
|
||||
'S_USERNAME_OPTIONS' => $username_list,
|
||||
'S_SEARCH_ACTION' => append_sid("search.$phpEx?mode=searchuser"))
|
||||
);
|
||||
|
||||
if ( $username_list != '' )
|
||||
{
|
||||
$gen_simple_header = TRUE;
|
||||
$page_title = $lang['Search'];
|
||||
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'search_user_body' => 'search_username.tpl')
|
||||
);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'L_CLOSE_WINDOW' => $lang['Close_window'],
|
||||
'L_SEARCH_USERNAME' => $lang['Find_username'],
|
||||
'L_UPDATE_USERNAME' => $lang['Select_username'],
|
||||
'L_SELECT' => $lang['Select'],
|
||||
'L_SEARCH' => $lang['Search'],
|
||||
'L_SEARCH_EXPLAIN' => $lang['Search_author_explain'],
|
||||
'L_CLOSE_WINDOW' => $lang['Close_window'],
|
||||
|
||||
'S_AUTHOR_OPTIONS' => $author_list,
|
||||
'S_SEARCH_ACTION' => append_sid("search.$phpEx?mode=searchuser"))
|
||||
);
|
||||
|
||||
//
|
||||
// If we have results then dump them out and enable
|
||||
// the appropriate switch block
|
||||
//
|
||||
if ( !empty($author_list) )
|
||||
{
|
||||
$template->assign_block_vars('switch_select_name', array());
|
||||
}
|
||||
|
||||
$template->pparse('search_user_body');
|
||||
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
$template->assign_block_vars('switch_select_name', array());
|
||||
}
|
||||
|
||||
return($author_list);
|
||||
$template->pparse('search_user_body');
|
||||
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user