Various updates with any luck they fix a few minor issues without causing new ones ...

git-svn-id: file:///svn/phpbb/trunk@2462 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-04-02 14:04:18 +00:00
parent 374f7adca2
commit 51d9bdeca7
9 changed files with 80 additions and 115 deletions

View file

@ -19,7 +19,7 @@
* *
***************************************************************************/ ***************************************************************************/
define('IN_PHPBB', 1); define('IN_PHPBB', true);
if ( !empty($setmodules) ) if ( !empty($setmodules) )
{ {
@ -32,7 +32,7 @@ if ( !empty($setmodules) )
// //
// Load default header // Load default header
// //
$phpbb_root_path = "../"; $phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/prune.'.$phpEx); require($phpbb_root_path . 'includes/prune.'.$phpEx);
@ -47,7 +47,7 @@ if( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_UR
if( $forum_id == -1 ) if( $forum_id == -1 )
{ {
$forum_sql = ""; $forum_sql = '';
} }
else else
{ {
@ -57,8 +57,8 @@ if( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_UR
} }
else else
{ {
$forum_id = ""; $forum_id = '';
$forum_sql = ""; $forum_sql = '';
} }
// //
// Get a list of forum's or the data for the forum that we are pruning. // Get a list of forum's or the data for the forum that we are pruning.
@ -90,13 +90,12 @@ if( isset($HTTP_POST_VARS['doprune']) )
$prunedate = time() - ( $prunedays * 86400 ); $prunedate = time() - ( $prunedays * 86400 );
$template->set_filenames(array( $template->set_filenames(array(
"body" => "admin/forum_prune_result_body.tpl") 'body' => 'admin/forum_prune_result_body.tpl')
); );
for($i = 0; $i < count($forum_rows); $i++) for($i = 0; $i < count($forum_rows); $i++)
{ {
$p_result = prune($forum_rows[$i]['forum_id'], $prunedate); $p_result = prune($forum_rows[$i]['forum_id'], $prunedate);
sync('forum', $forum_rows[$i]['forum_id']);
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

View file

@ -214,15 +214,6 @@ function init_userprefs($userdata)
$board_config['board_timezone'] = $userdata['user_timezone']; $board_config['board_timezone'] = $userdata['user_timezone'];
} }
} }
/*switch( getenv('HTTP_ACCEPT_LANGUAGE') )
{
case 'en-gb':
$board_config['default_lang'] = 'english';
break;
case 'fr':
$board_config['default_lang'] = 'french';
break;
}*/
if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx) ) if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx) )
{ {
@ -350,7 +341,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
if ( $total_pages == 1 ) if ( $total_pages == 1 )
{ {
return ""; return '';
} }
$on_page = floor($start_item / $per_page) + 1; $on_page = floor($start_item / $per_page) + 1;
@ -442,7 +433,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
function phpbb_preg_quote($str, $delimiter) function phpbb_preg_quote($str, $delimiter)
{ {
$text = preg_quote($str); $text = preg_quote($str);
$text = str_replace($delimiter, "\\" . $delimiter, $text); $text = str_replace($delimiter, '\\' . $delimiter, $text);
return $text; return $text;
} }
@ -470,7 +461,7 @@ function obtain_word_list(&$orig_word, &$replacement_word)
{ {
do do
{ {
$orig_word[] = "#\b(" . str_replace("\*", "\w*?", phpbb_preg_quote($row['word'], "#")) . ")\b#i"; $orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement']; $replacement_word[] = $row['replacement'];
} }
while ( $row = $db->sql_fetchrow($result) ); while ( $row = $db->sql_fetchrow($result) );

View file

@ -90,9 +90,11 @@ function sync($type, $id)
break; break;
case 'forum': case 'forum':
$sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total $sql = "SELECT MAX(p.post_id) AS last_post, COUNT(p.post_id) AS total
FROM " . POSTS_TABLE . " FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
WHERE forum_id = $id"; WHERE p.forum_id = $id
AND t.topic_id = p.topic_id
AND t.topic_status <> " . TOPIC_MOVED;
if ( !$result = $db->sql_query($sql) ) if ( !$result = $db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
@ -118,21 +120,14 @@ function sync($type, $id)
message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql);
} }
if ( $row = $db->sql_fetchrow($result) ) $total_topics = ( $row = $db->sql_fetchrow($result) ) ? ( ( $row['total'] ) ? $row['total'] : 0 ) : 0;
{
$total_topics = ($row['total']) ? $row['total'] : 0;
}
else
{
$total_topics = 0;
}
$sql = "UPDATE " . FORUMS_TABLE . " $sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics
WHERE forum_id = $id"; WHERE forum_id = $id";
if ( !$result = $db->sql_query($sql) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, "Could not update forum $id", '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
} }
break; break;
@ -142,7 +137,7 @@ function sync($type, $id)
WHERE topic_id = $id"; WHERE topic_id = $id";
if ( !$result = $db->sql_query($sql) ) if ( !$result = $db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, "Could not get post ID", '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
} }
if ( $row = $db->sql_fetchrow($result) ) if ( $row = $db->sql_fetchrow($result) )
@ -150,9 +145,9 @@ function sync($type, $id)
$sql = "UPDATE " . TOPICS_TABLE . " $sql = "UPDATE " . TOPICS_TABLE . "
SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . "
WHERE topic_id = $id"; WHERE topic_id = $id";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, "Could not update topic $id", '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
} }
} }

View file

@ -527,7 +527,8 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
if ( $post_data['first_post'] ) if ( $post_data['first_post'] )
{ {
$sql = "DELETE FROM " . TOPICS_TABLE . " $sql = "DELETE FROM " . TOPICS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id
OR topic_moved_id = $topic_id";
if ( !($db->sql_query($sql)) ) if ( !($db->sql_query($sql)) )
{ {
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);

View file

@ -206,7 +206,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
default: default:
$sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text)
VALUES ('" . $word[$i] . "')"; VALUES ('" . $word[$i] . "')";
if( !($result = $db->sql_query($sql)) ) if( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
} }
@ -230,7 +230,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
break; break;
} }
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
} }
@ -247,7 +247,7 @@ function add_search_words($post_id, $post_text, $post_title = '')
SELECT $post_id, word_id, $title_match SELECT $post_id, word_id, $title_match
FROM " . SEARCH_WORD_TABLE . " FROM " . SEARCH_WORD_TABLE . "
WHERE word_text IN ($match_sql)"; WHERE word_text IN ($match_sql)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql);
} }
@ -314,7 +314,6 @@ function remove_common($mode, $fraction, $word_id_list = array())
{ {
$common_word_id .= ( ( $common_word_id != '' ) ? ', ' : '' ) . $row['word_id']; $common_word_id .= ( ( $common_word_id != '' ) ? ', ' : '' ) . $row['word_id'];
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
if ( $common_word_id != '' ) if ( $common_word_id != '' )
@ -322,14 +321,14 @@ function remove_common($mode, $fraction, $word_id_list = array())
$sql = "UPDATE " . SEARCH_WORD_TABLE . " $sql = "UPDATE " . SEARCH_WORD_TABLE . "
SET word_common = " . TRUE . " SET word_common = " . TRUE . "
WHERE word_id IN ($common_word_id)"; WHERE word_id IN ($common_word_id)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
} }
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE word_id IN ($common_word_id)"; WHERE word_id IN ($common_word_id)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete word match entry', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete word match entry', '', __LINE__, __FILE__, $sql);
} }
@ -378,7 +377,7 @@ function remove_search_post($post_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 ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
} }
@ -403,7 +402,7 @@ function remove_search_post($post_id_sql)
GROUP BY word_id GROUP BY word_id
HAVING COUNT(word_id) = 1 HAVING COUNT(word_id) = 1
)"; )";
if ( !($result = $db->sql_query($sql, END_TRANSACTION)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql);
} }
@ -415,7 +414,7 @@ function remove_search_post($post_id_sql)
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($post_id_sql)"; WHERE post_id IN ($post_id_sql)";
if ( !($db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
} }
@ -457,6 +456,7 @@ function username_search($search_match)
{ {
$username_list .= '<option>' . $lang['No_match']. '</option>'; $username_list .= '<option>' . $lang['No_match']. '</option>';
} }
$db->sql_freeresult($result);
} }
$gen_simple_header = TRUE; $gen_simple_header = TRUE;

View file

@ -26,6 +26,7 @@ if ( !defined('IN_PHPBB') )
} }
require($phpbb_root_path . 'includes/functions_search.'.$phpEx); require($phpbb_root_path . 'includes/functions_search.'.$phpEx);
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
function prune($forum_id, $prune_date) function prune($forum_id, $prune_date)
{ {
@ -44,6 +45,7 @@ function prune($forum_id, $prune_date)
{ {
$sql .= " AND p.post_time < $prune_date"; $sql .= " AND p.post_time < $prune_date";
} }
if ( !($result = $db->sql_query($sql)) ) if ( !($result = $db->sql_query($sql)) )
{ {
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
@ -76,7 +78,7 @@ function prune($forum_id, $prune_date)
{ {
$sql = "DELETE FROM " . TOPICS_TABLE . " $sql = "DELETE FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($sql_topics)"; WHERE topic_id IN ($sql_topics)";
if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{ {
message_die(GENERAL_ERROR, 'Could not delete topics during prune', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete topics during prune', '', __LINE__, __FILE__, $sql);
} }
@ -85,7 +87,7 @@ function prune($forum_id, $prune_date)
$sql = "DELETE FROM " . POSTS_TABLE . " $sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post)"; WHERE post_id IN ($sql_post)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete post_text during prune', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete post_text during prune', '', __LINE__, __FILE__, $sql);
} }
@ -94,27 +96,21 @@ function prune($forum_id, $prune_date)
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . " $sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($sql_post)"; WHERE post_id IN ($sql_post)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete post during prune', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete post during prune', '', __LINE__, __FILE__, $sql);
} }
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($sql_post)"; WHERE post_id IN ($sql_post)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete search matches', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete search matches', '', __LINE__, __FILE__, $sql);
} }
remove_search_post($sql_post); remove_search_post($sql_post);
$sql = "UPDATE " . FORUMS_TABLE . " sync('forum', $forum_id);
SET forum_topics = forum_topics - $pruned_topics, forum_posts = forum_posts - $pruned_posts
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update forum data after prune', '', __LINE__, __FILE__, $sql);
}
return array ('topics' => $pruned_topics, 'posts' => $pruned_posts); return array ('topics' => $pruned_topics, 'posts' => $pruned_posts);
} }
@ -144,10 +140,10 @@ function auto_prune($forum_id = 0)
if ( $row['prune_freq'] && $row['prune_days'] ) if ( $row['prune_freq'] && $row['prune_days'] )
{ {
$prune_date = time() - ( $row['prune_days'] * 86400 ); $prune_date = time() - ( $row['prune_days'] * 86400 );
prune($forum_id, $prune_date);
$next_prune = time() + ( $row['prune_freq'] * 86400 ); $next_prune = time() + ( $row['prune_freq'] * 86400 );
$pruned = prune($forum_id, $prune_date);
$sql = "UPDATE " . FORUMS_TABLE . " $sql = "UPDATE " . FORUMS_TABLE . "
SET prune_next = $next_prune SET prune_next = $next_prune
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";

View file

@ -23,7 +23,7 @@
if ( !defined('IN_PHPBB') ) if ( !defined('IN_PHPBB') )
{ {
die("Hacking attempt"); die('Hacking attempt');
exit; exit;
} }
@ -34,7 +34,7 @@ if ( $result = $db->sql_query($sql) )
{ {
if ( $row = $db->sql_fetchrow($result) ) if ( $row = $db->sql_fetchrow($result) )
{ {
$sql_update_pass = ( $row['user_newpasswd'] != "" ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : ""; $sql_update_pass = ( $row['user_newpasswd'] != '' ) ? ", user_password = '" . str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : "";
$sql = "UPDATE " . USERS_TABLE . " $sql = "UPDATE " . USERS_TABLE . "
SET user_active = 1, user_actkey = ''" . $sql_update_pass . " SET user_active = 1, user_actkey = ''" . $sql_update_pass . "
@ -46,24 +46,24 @@ if ( $result = $db->sql_query($sql) )
include($phpbb_root_path . 'includes/emailer.'.$phpEx); include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']); $emailer = new emailer($board_config['smtp_delivery']);
$email_headers = "From: " . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n"; $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n";
$emailer->use_template("admin_welcome_activated", $row['user_lang']); $emailer->use_template('admin_welcome_activated', $row['user_lang']);
$emailer->email_address($row['user_email']); $emailer->email_address($row['user_email']);
$emailer->set_subject();//$lang['Account_activated_subject'] $emailer->set_subject();//$lang['Account_activated_subject']
$emailer->extra_headers($email_headers); $emailer->extra_headers($email_headers);
$emailer->assign_vars(array( $emailer->assign_vars(array(
"SITENAME" => $board_config['sitename'], 'SITENAME' => $board_config['sitename'],
"USERNAME" => $username, 'USERNAME' => $username,
"PASSWORD" => $password_confirm, 'PASSWORD' => $password_confirm,
"EMAIL_SIG" => str_replace("<br />", "\n", "-- \n" . $board_config['board_email_sig'])) 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']))
); );
$emailer->send(); $emailer->send();
$emailer->reset(); $emailer->reset();
$template->assign_vars(array( $template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">') 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
); );
message_die(GENERAL_MESSAGE, $lang['Account_active_admin']); message_die(GENERAL_MESSAGE, $lang['Account_active_admin']);
@ -71,16 +71,16 @@ if ( $result = $db->sql_query($sql) )
else else
{ {
$template->assign_vars(array( $template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">') 'META' => '<meta http-equiv="refresh" content="10;url=' . append_sid("index.$phpEx") . '">')
); );
$message = ( $sql_update_pass == "" ) ? $lang['Account_active'] : $lang['Password_activated']; $message = ( $sql_update_pass == '' ) ? $lang['Account_active'] : $lang['Password_activated'];
message_die(GENERAL_MESSAGE, $message); message_die(GENERAL_MESSAGE, $message);
} }
} }
else else
{ {
message_die(GENERAL_ERROR, "Couldn't update users table", "", __LINE__, __FILE__, $sql_update); message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql_update);
} }
} }
else else
@ -90,7 +90,7 @@ if ( $result = $db->sql_query($sql) )
} }
else else
{ {
message_die(GENERAL_ERROR, "Couldn't obtain user information", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql);
} }
?> ?>

View file

@ -217,13 +217,13 @@ switch($mode)
{ {
message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
} }
$rowset = $db->sql_fetchrowset($result);
$post_id_sql = ''; $post_id_sql = '';
for($i = 0; $i < count($rowset); $i++) while ( $row = $db->sql_fetchrow($result) )
{ {
$post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . $rowset[$i]['post_id']; $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . $row['post_id'];
} }
$db->sql_freeresult($result);
$sql = "SELECT vote_id $sql = "SELECT vote_id
FROM " . VOTE_DESC_TABLE . " FROM " . VOTE_DESC_TABLE . "
@ -232,13 +232,13 @@ switch($mode)
{ {
message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
} }
$rowset = $db->sql_fetchrowset($result);
$vote_id_sql = ''; $vote_id_sql = '';
for($i = 0; $i < count($rowset); $i++) while ( $row = $db->sql_fetchrow($result) )
{ {
$vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $rowset[$i]['vote_id']; $vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
} }
$db->sql_freeresult($result);
// //
// Got all required info so go ahead and start deleting everything // Got all required info so go ahead and start deleting everything
@ -247,7 +247,7 @@ switch($mode)
FROM " . TOPICS_TABLE . " FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($topic_id_sql) WHERE topic_id IN ($topic_id_sql)
OR topic_moved_id IN ($topic_id_sql)"; OR topic_moved_id IN ($topic_id_sql)";
if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{ {
message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
} }
@ -257,7 +257,7 @@ switch($mode)
$sql = "DELETE $sql = "DELETE
FROM " . POSTS_TABLE . " FROM " . POSTS_TABLE . "
WHERE post_id IN ($post_id_sql)"; WHERE post_id IN ($post_id_sql)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
} }
@ -265,22 +265,11 @@ switch($mode)
$sql = "DELETE $sql = "DELETE
FROM " . POSTS_TEXT_TABLE . " FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($post_id_sql)"; WHERE post_id IN ($post_id_sql)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
} }
$sql = "DELETE
FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($post_id_sql)";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
}
//
// Delete unmatched words
//
remove_search_post($post_id_sql); remove_search_post($post_id_sql);
} }
@ -289,7 +278,7 @@ switch($mode)
$sql = "DELETE $sql = "DELETE
FROM " . VOTE_DESC_TABLE . " FROM " . VOTE_DESC_TABLE . "
WHERE vote_id IN ($vote_id_sql)"; WHERE vote_id IN ($vote_id_sql)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
} }
@ -297,7 +286,7 @@ switch($mode)
$sql = "DELETE $sql = "DELETE
FROM " . VOTE_RESULTS_TABLE . " FROM " . VOTE_RESULTS_TABLE . "
WHERE vote_id IN ($vote_id_sql)"; WHERE vote_id IN ($vote_id_sql)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
} }
@ -305,7 +294,7 @@ switch($mode)
$sql = "DELETE $sql = "DELETE
FROM " . VOTE_USERS_TABLE . " FROM " . VOTE_USERS_TABLE . "
WHERE vote_id IN ($vote_id_sql)"; WHERE vote_id IN ($vote_id_sql)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
} }
@ -314,7 +303,7 @@ switch($mode)
$sql = "DELETE $sql = "DELETE
FROM " . TOPICS_WATCH_TABLE . " FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id IN ($topic_id_sql)"; WHERE topic_id IN ($topic_id_sql)";
if ( !($result = $db->sql_query($sql, END_TRANSACTION)) ) if ( !$db->sql_query($sql, END_TRANSACTION) )
{ {
message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
} }
@ -408,7 +397,7 @@ switch($mode)
$sql = "SELECT * $sql = "SELECT *
FROM " . TOPICS_TABLE . " FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($topic_list) WHERE topic_id IN ($topic_list)
AND topic_moved_id = 0"; AND topic_status <> " . TOPIC_MOVED;
if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
{ {
message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
@ -426,7 +415,7 @@ switch($mode)
// Insert topic in the old forum that indicates that the forum has moved. // Insert topic in the old forum that indicates that the forum has moved.
$sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id) $sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id)
VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)"; VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
} }
@ -435,7 +424,7 @@ switch($mode)
$sql = "UPDATE " . TOPICS_TABLE . " $sql = "UPDATE " . TOPICS_TABLE . "
SET forum_id = $new_forum_id SET forum_id = $new_forum_id
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
} }
@ -443,7 +432,7 @@ switch($mode)
$sql = "UPDATE " . POSTS_TABLE . " $sql = "UPDATE " . POSTS_TABLE . "
SET forum_id = $new_forum_id SET forum_id = $new_forum_id
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
if ( !($result = $db->sql_query($sql)) ) if ( !$db->sql_query($sql) )
{ {
message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
} }
@ -629,7 +618,7 @@ switch($mode)
$topic_id = $post_rowset['topic_id']; $topic_id = $post_rowset['topic_id'];
$post_time = $post_rowset['post_time']; $post_time = $post_rowset['post_time'];
$post_subject = trim(strip_tags($HTTP_POST_VARS['subject'])); $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
if ( empty($post_subject) ) if ( empty($post_subject) )
{ {
message_die(GENERAL_MESSAGE, $lang['Empty_subject']); message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
@ -667,7 +656,7 @@ switch($mode)
AND topic_id = $topic_id"; AND topic_id = $topic_id";
} }
if( !($result = $db->sql_query($sql, END_TRANSACTION)) ) if( !$db->sql_query($sql, END_TRANSACTION) )
{ {
message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
} }
@ -953,12 +942,6 @@ switch($mode)
break; break;
case 'auth':
//
// For future use ...
//
break;
default: default:
$page_title = $lang['Mod_CP']; $page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx); include($phpbb_root_path . 'includes/page_header.'.$phpEx);

View file

@ -255,7 +255,7 @@ if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays'])
} }
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$topics_count = $row['forum_topics']; $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
$limit_topics_time = "AND p.post_time >= $min_topic_time"; $limit_topics_time = "AND p.post_time >= $min_topic_time";
if ( !empty($HTTP_POST_VARS['topicdays']) ) if ( !empty($HTTP_POST_VARS['topicdays']) )
@ -265,7 +265,7 @@ if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays'])
} }
else else
{ {
$topics_count = $forum_row['forum_topics']; $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
$limit_topics_time = ''; $limit_topics_time = '';
$topic_days = 0; $topic_days = 0;