mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Various updates
git-svn-id: file:///svn/phpbb/trunk@2301 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
34b0719c02
commit
b1a4782f93
2 changed files with 58 additions and 40 deletions
|
@ -252,6 +252,10 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( $mode == 'editpost' )
|
||||||
|
{
|
||||||
|
$result = remove_search_post($post_id);
|
||||||
|
}
|
||||||
|
|
||||||
if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
|
if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
|
||||||
{
|
{
|
||||||
|
@ -286,16 +290,6 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
||||||
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
|
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $mode == 'editpost' )
|
|
||||||
{
|
|
||||||
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
|
|
||||||
WHERE post_id = $post_id";
|
|
||||||
if ( !($db->sql_query($sql)) )
|
|
||||||
{
|
|
||||||
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject));
|
add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -367,11 +361,6 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $mode == 'editpost' )
|
|
||||||
{
|
|
||||||
remove_unmatched_words();
|
|
||||||
}
|
|
||||||
|
|
||||||
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
|
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
|
||||||
$message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
|
$message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
|
||||||
|
|
||||||
|
@ -381,7 +370,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
||||||
//
|
//
|
||||||
// Update post stats and details
|
// Update post stats and details
|
||||||
//
|
//
|
||||||
function update_post_stats($mode, &$post_data, &$forum_id, &$topic_id, &$post_id)
|
function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id)
|
||||||
{
|
{
|
||||||
global $db, $userdata;
|
global $db, $userdata;
|
||||||
|
|
||||||
|
@ -447,7 +436,7 @@ function update_post_stats($mode, &$post_data, &$forum_id, &$topic_id, &$post_id
|
||||||
}
|
}
|
||||||
else if ( $mode != 'poll_delete' )
|
else if ( $mode != 'poll_delete' )
|
||||||
{
|
{
|
||||||
$forum_update_sql .= ", forum_last_post_id = $post_id" . ( ( $mode = 'newtopic' ) ? ", forum_topics = forum_topics $sign" : "" );
|
$forum_update_sql .= ", forum_last_post_id = $post_id" . ( ( $mode == 'newtopic' ) ? ", forum_topics = forum_topics $sign" : "" );
|
||||||
$topic_update_sql = "topic_last_post_id = $post_id" . ( ( $mode == 'reply' ) ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id" );
|
$topic_update_sql = "topic_last_post_id = $post_id" . ( ( $mode == 'reply' ) ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -347,57 +347,86 @@ function remove_common($mode, $fraction, $word_id_list = array())
|
||||||
return $word_count;
|
return $word_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_unmatched_words()
|
function remove_search_post($post_id)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
switch(SQL_LAYER)
|
$words_removed = false;
|
||||||
|
|
||||||
|
switch( SQL_LAYER )
|
||||||
{
|
{
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'mysql4':
|
case 'mysql4':
|
||||||
$sql = "SELECT w.word_id
|
$sql = "SELECT word_id
|
||||||
FROM " . SEARCH_WORD_TABLE . " w
|
FROM " . SEARCH_MATCH_TABLE . "
|
||||||
LEFT JOIN " . SEARCH_MATCH_TABLE . " m ON m.word_id = w.word_id
|
WHERE post_id = $post_id";
|
||||||
WHERE m.word_id IS NULL";
|
if ( $result = $db->sql_query($sql) )
|
||||||
if( $result = $db->sql_query($sql) )
|
|
||||||
{
|
{
|
||||||
$word_id_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'];
|
$word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $word_id_sql != "" )
|
$sql = "SELECT word_id
|
||||||
|
FROM " . SEARCH_MATCH_TABLE . "
|
||||||
|
WHERE word_id IN ($word_id_sql)
|
||||||
|
GROUP BY word_id
|
||||||
|
HAVING COUNT(word_id) = 1";
|
||||||
|
if ( $result = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
$word_id_sql = '';
|
||||||
|
while( $row = $db->sql_fetchrow($result) )
|
||||||
|
{
|
||||||
|
$word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $word_id_sql != '' )
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
|
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
|
||||||
WHERE word_id IN ($word_id_sql)";
|
WHERE word_id IN ($word_id_sql)";
|
||||||
if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
|
if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
|
||||||
{
|
{
|
||||||
message_die(GENERAL_ERROR, "Couldn't delete word list entry", "", __LINE__, __FILE__, $sql);
|
message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $db->sql_affectedrows();
|
$words_removed = $db->sql_affectedrows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
|
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
|
||||||
WHERE word_id NOT IN (
|
WHERE word_id IN (
|
||||||
SELECT word_id
|
SELECT word_id
|
||||||
FROM " . SEARCH_MATCH_TABLE . "
|
FROM " . SEARCH_MATCH_TABLE . "
|
||||||
GROUP BY word_id)";
|
WHERE word_id IN (
|
||||||
if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
|
SELECT word_id
|
||||||
|
FROM " . SEARCH_MATCH_TABLE . "
|
||||||
|
WHERE post_id = $post_id
|
||||||
|
)
|
||||||
|
GROUP BY word_id
|
||||||
|
HAVING COUNT(word_id) = 1
|
||||||
|
)";
|
||||||
|
if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
|
||||||
{
|
{
|
||||||
message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
|
message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $db->sql_affectedrows();
|
$words_removed = $db->sql_affectedrows();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
|
||||||
|
WHERE post_id = $post_id";
|
||||||
|
if ( !($db->sql_query($sql)) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $words_removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Reference in a new issue