diff options
-rw-r--r-- | phpBB/admin/admin_forum_prune.php | 13 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 19 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 27 | ||||
-rw-r--r-- | phpBB/includes/functions_post.php | 3 | ||||
-rw-r--r-- | phpBB/includes/functions_search.php | 18 | ||||
-rw-r--r-- | phpBB/includes/prune.php | 26 | ||||
-rw-r--r-- | phpBB/includes/usercp_activate.php | 28 | ||||
-rw-r--r-- | phpBB/modcp.php | 57 | ||||
-rw-r--r-- | phpBB/viewforum.php | 4 |
9 files changed, 80 insertions, 115 deletions
diff --git a/phpBB/admin/admin_forum_prune.php b/phpBB/admin/admin_forum_prune.php index ec04cc7291..f3e528e35a 100644 --- a/phpBB/admin/admin_forum_prune.php +++ b/phpBB/admin/admin_forum_prune.php @@ -19,7 +19,7 @@ * ***************************************************************************/ -define('IN_PHPBB', 1); +define('IN_PHPBB', true); if ( !empty($setmodules) ) { @@ -32,7 +32,7 @@ if ( !empty($setmodules) ) // // Load default header // -$phpbb_root_path = "../"; +$phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $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 ) { - $forum_sql = ""; + $forum_sql = ''; } else { @@ -57,8 +57,8 @@ if( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_UR } else { - $forum_id = ""; - $forum_sql = ""; + $forum_id = ''; + $forum_sql = ''; } // // 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 ); $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++) { $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_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8ae87f656f..13fe5bd60c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -214,15 +214,6 @@ function init_userprefs($userdata) $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) ) { @@ -314,8 +305,8 @@ function encode_ip($dotquad_ip) function decode_ip($int_ip) { - $hexipbang = explode('.',chunk_split($int_ip, 2, '.')); - return hexdec($hexipbang[0]).'.'.hexdec($hexipbang[1]).'.'.hexdec($hexipbang[2]).'.'.hexdec($hexipbang[3]); + $hexipbang = explode('.', chunk_split($int_ip, 2, '.')); + return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); } // @@ -350,7 +341,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add if ( $total_pages == 1 ) { - return ""; + return ''; } $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) { $text = preg_quote($str); - $text = str_replace($delimiter, "\\" . $delimiter, $text); + $text = str_replace($delimiter, '\\' . $delimiter, $text); return $text; } @@ -470,7 +461,7 @@ function obtain_word_list(&$orig_word, &$replacement_word) { 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']; } while ( $row = $db->sql_fetchrow($result) ); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5d5df857fa..456742fd38 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -90,9 +90,11 @@ function sync($type, $id) break; case 'forum': - $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total - FROM " . POSTS_TABLE . " - WHERE forum_id = $id"; + $sql = "SELECT MAX(p.post_id) AS last_post, COUNT(p.post_id) AS total + FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t + WHERE p.forum_id = $id + AND t.topic_id = p.topic_id + AND t.topic_status <> " . TOPIC_MOVED; if ( !$result = $db->sql_query($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); } - if ( $row = $db->sql_fetchrow($result) ) - { - $total_topics = ($row['total']) ? $row['total'] : 0; - } - else - { - $total_topics = 0; - } + $total_topics = ( $row = $db->sql_fetchrow($result) ) ? ( ( $row['total'] ) ? $row['total'] : 0 ) : 0; $sql = "UPDATE " . FORUMS_TABLE . " SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics 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; @@ -142,7 +137,7 @@ function sync($type, $id) WHERE topic_id = $id"; 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) ) @@ -150,9 +145,9 @@ function sync($type, $id) $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'] . " 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); } } diff --git a/phpBB/includes/functions_post.php b/phpBB/includes/functions_post.php index 2dc3bd2bfa..ce1049ac13 100644 --- a/phpBB/includes/functions_post.php +++ b/phpBB/includes/functions_post.php @@ -527,7 +527,8 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ if ( $post_data['first_post'] ) { $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)) ) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); diff --git a/phpBB/includes/functions_search.php b/phpBB/includes/functions_search.php index b74ac398b4..f42ff475c4 100644 --- a/phpBB/includes/functions_search.php +++ b/phpBB/includes/functions_search.php @@ -206,7 +206,7 @@ function add_search_words($post_id, $post_text, $post_title = '') default: $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text) 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); } @@ -230,7 +230,7 @@ function add_search_words($post_id, $post_text, $post_title = '') break; } - if ( !($result = $db->sql_query($sql)) ) + if ( !$db->sql_query($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 FROM " . SEARCH_WORD_TABLE . " 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); } @@ -314,7 +314,6 @@ function remove_common($mode, $fraction, $word_id_list = array()) { $common_word_id .= ( ( $common_word_id != '' ) ? ', ' : '' ) . $row['word_id']; } - $db->sql_freeresult($result); if ( $common_word_id != '' ) @@ -322,14 +321,14 @@ function remove_common($mode, $fraction, $word_id_list = array()) $sql = "UPDATE " . SEARCH_WORD_TABLE . " SET word_common = " . TRUE . " 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); } $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " 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); } @@ -378,7 +377,7 @@ function remove_search_post($post_id_sql) { $sql = "DELETE FROM " . SEARCH_WORD_TABLE . " 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); } @@ -403,7 +402,7 @@ function remove_search_post($post_id_sql) GROUP BY word_id 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); } @@ -415,7 +414,7 @@ function remove_search_post($post_id_sql) $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " 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); } @@ -457,6 +456,7 @@ function username_search($search_match) { $username_list .= '<option>' . $lang['No_match']. '</option>'; } + $db->sql_freeresult($result); } $gen_simple_header = TRUE; diff --git a/phpBB/includes/prune.php b/phpBB/includes/prune.php index c59217eea1..84f552ec91 100644 --- a/phpBB/includes/prune.php +++ b/phpBB/includes/prune.php @@ -26,6 +26,7 @@ if ( !defined('IN_PHPBB') ) } require($phpbb_root_path . 'includes/functions_search.'.$phpEx); +require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); function prune($forum_id, $prune_date) { @@ -38,12 +39,13 @@ function prune($forum_id, $prune_date) FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t WHERE t.forum_id = $forum_id AND t.topic_vote = 0 - AND t.topic_type <> " . POST_ANNOUNCE . " + AND t.topic_type <> " . POST_ANNOUNCE . " AND p.post_id = t.topic_last_post_id"; if ( $prune_date != '' ) { $sql .= " AND p.post_time < $prune_date"; } + if ( !($result = $db->sql_query($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 . " 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); } @@ -85,7 +87,7 @@ function prune($forum_id, $prune_date) $sql = "DELETE FROM " . POSTS_TABLE . " 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); } @@ -94,27 +96,21 @@ function prune($forum_id, $prune_date) $sql = "DELETE FROM " . POSTS_TEXT_TABLE . " 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); } $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " 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); } remove_search_post($sql_post); - $sql = "UPDATE " . FORUMS_TABLE . " - 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); - } + sync('forum', $forum_id); return array ('topics' => $pruned_topics, 'posts' => $pruned_posts); } @@ -144,12 +140,12 @@ function auto_prune($forum_id = 0) if ( $row['prune_freq'] && $row['prune_days'] ) { $prune_date = time() - ( $row['prune_days'] * 86400 ); - prune($forum_id, $prune_date); - $next_prune = time() + ( $row['prune_freq'] * 86400 ); + $pruned = prune($forum_id, $prune_date); + $sql = "UPDATE " . FORUMS_TABLE . " - SET prune_next = $next_prune + SET prune_next = $next_prune WHERE forum_id = $forum_id"; if ( !$db->sql_query($sql) ) { diff --git a/phpBB/includes/usercp_activate.php b/phpBB/includes/usercp_activate.php index bfc4a92a36..4e2e865460 100644 --- a/phpBB/includes/usercp_activate.php +++ b/phpBB/includes/usercp_activate.php @@ -23,7 +23,7 @@ if ( !defined('IN_PHPBB') ) { - die("Hacking attempt"); + die('Hacking attempt'); exit; } @@ -34,7 +34,7 @@ if ( $result = $db->sql_query($sql) ) { 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 . " 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); $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->set_subject();//$lang['Account_activated_subject'] $emailer->extra_headers($email_headers); $emailer->assign_vars(array( - "SITENAME" => $board_config['sitename'], - "USERNAME" => $username, - "PASSWORD" => $password_confirm, - "EMAIL_SIG" => str_replace("<br />", "\n", "-- \n" . $board_config['board_email_sig'])) + 'SITENAME' => $board_config['sitename'], + 'USERNAME' => $username, + 'PASSWORD' => $password_confirm, + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig'])) ); $emailer->send(); $emailer->reset(); $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']); @@ -71,16 +71,16 @@ if ( $result = $db->sql_query($sql) ) else { $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); } } 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 @@ -90,7 +90,7 @@ if ( $result = $db->sql_query($sql) ) } 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); } -?> +?>
\ No newline at end of file diff --git a/phpBB/modcp.php b/phpBB/modcp.php index 6cd2140329..3b15b57a3f 100644 --- a/phpBB/modcp.php +++ b/phpBB/modcp.php @@ -192,7 +192,7 @@ if ( !$is_auth['auth_mod'] ) // // Do major work ... // -switch($mode) +switch( $mode ) { case 'delete': $page_title = $lang['Mod_CP']; @@ -217,13 +217,13 @@ switch($mode) { message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql); } - $rowset = $db->sql_fetchrowset($result); $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 FROM " . VOTE_DESC_TABLE . " @@ -232,13 +232,13 @@ switch($mode) { message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql); } - $rowset = $db->sql_fetchrowset($result); $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 @@ -247,7 +247,7 @@ switch($mode) FROM " . TOPICS_TABLE . " WHERE topic_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); } @@ -257,7 +257,7 @@ switch($mode) $sql = "DELETE FROM " . POSTS_TABLE . " 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); } @@ -265,22 +265,11 @@ switch($mode) $sql = "DELETE FROM " . POSTS_TEXT_TABLE . " 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); } - $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); } @@ -289,7 +278,7 @@ switch($mode) $sql = "DELETE FROM " . VOTE_DESC_TABLE . " 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); } @@ -297,7 +286,7 @@ switch($mode) $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " 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); } @@ -305,7 +294,7 @@ switch($mode) $sql = "DELETE FROM " . VOTE_USERS_TABLE . " 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); } @@ -314,7 +303,7 @@ switch($mode) $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " 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); } @@ -408,7 +397,7 @@ switch($mode) $sql = "SELECT * FROM " . TOPICS_TABLE . " WHERE topic_id IN ($topic_list) - AND topic_moved_id = 0"; + AND topic_status <> " . TOPIC_MOVED; if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) { 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. $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)"; - if ( !($result = $db->sql_query($sql)) ) + if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql); } @@ -435,7 +424,7 @@ switch($mode) $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = $new_forum_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); } @@ -443,7 +432,7 @@ switch($mode) $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = $new_forum_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); } @@ -629,7 +618,7 @@ switch($mode) $topic_id = $post_rowset['topic_id']; $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) ) { message_die(GENERAL_MESSAGE, $lang['Empty_subject']); @@ -667,7 +656,7 @@ switch($mode) 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); } @@ -953,12 +942,6 @@ switch($mode) break; - case 'auth': - // - // For future use ... - // - break; - default: $page_title = $lang['Mod_CP']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 96e1619d03..632a7d6682 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -255,7 +255,7 @@ if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) } $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"; if ( !empty($HTTP_POST_VARS['topicdays']) ) @@ -265,7 +265,7 @@ if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) } else { - $topics_count = $forum_row['forum_topics']; + $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1; $limit_topics_time = ''; $topic_days = 0; |