diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 353e36b4b9..42f763d24b 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -64,7 +64,7 @@ function sync($type, $id) case 'all forums': $sql = "SELECT forum_id FROM " . FORUMS_TABLE; - if ( !$result = $db->sql_query($sql) ) + if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get forum IDs', '', __LINE__, __FILE__, $sql); } @@ -78,7 +78,7 @@ function sync($type, $id) case 'all topics': $sql = "SELECT topic_id FROM " . TOPICS_TABLE; - if ( !$result = $db->sql_query($sql) ) + if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql); } @@ -90,12 +90,10 @@ function sync($type, $id) break; case 'forum': - $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) ) + $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total + FROM " . POSTS_TABLE . " + WHERE forum_id = $id"; + if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql); } @@ -113,9 +111,8 @@ function sync($type, $id) $sql = "SELECT COUNT(topic_id) AS total FROM " . TOPICS_TABLE . " - WHERE forum_id = $id - AND topic_status <> " . TOPIC_MOVED; - if ( !$result = $db->sql_query($sql) ) + WHERE forum_id = $id"; + if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql); } @@ -135,22 +132,19 @@ function sync($type, $id) $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts FROM " . POSTS_TABLE . " 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); } if ( $row = $db->sql_fetchrow($result) ) { - $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"; + $sql = ( $row['total_posts'] ) ? "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" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = $id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql); } } - break; } diff --git a/phpBB/includes/functions_post.php b/phpBB/includes/functions_post.php index 9c77d25316..934b8bf5c8 100644 --- a/phpBB/includes/functions_post.php +++ b/phpBB/includes/functions_post.php @@ -249,7 +249,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ WHERE $where_sql"; if ( $result = $db->sql_query($sql) ) { - if( $row = $db->sql_fetchrow($result) ) + if ( $row = $db->sql_fetchrow($result) ) { if ( $row['last_post_time'] > 0 && ( $current_time - $row['last_post_time'] ) < $board_config['flood_interval'] ) { @@ -272,7 +272,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); } - if( $mode == 'newtopic' ) + if ( $mode == 'newtopic' ) { $topic_id = $db->sql_nextid(); } @@ -285,7 +285,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); } - if( $mode != 'editpost' ) + if ( $mode != 'editpost' ) { $post_id = $db->sql_nextid(); } @@ -326,7 +326,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ { $old_poll_result[$row['vote_option_id']] = $row['vote_result']; - if( !isset($poll_options[$row['vote_option_id']]) ) + if ( !isset($poll_options[$row['vote_option_id']]) ) { $delete_option_sql .= ( $delete_option_sql != '' ) ? ', ' . $row['vote_option_id'] : $row['vote_option_id']; } @@ -342,7 +342,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ $poll_option_id = 1; while ( list($option_id, $option_text) = each($poll_options) ) { - if( !empty($option_text) ) + if ( !empty($option_text) ) { $option_text = str_replace("\'", "''", $option_text); $poll_result = ( $mode == "editpost" && isset($old_poll_result[$option_id]) ) ? $old_poll_result[$option_id] : 0; @@ -356,7 +356,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ } } - if( $delete_option_sql != '' ) + if ( $delete_option_sql != '' ) { $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " WHERE vote_option_id IN ($delete_option_sql)"; @@ -469,7 +469,8 @@ function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_i { $sql = "UPDATE " . TOPICS_TABLE . " SET $topic_update_sql - WHERE topic_id = $topic_id"; + WHERE topic_id = $topic_id + OR topic_moved_id = $topic_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); @@ -500,7 +501,6 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ include($phpbb_root_path . 'includes/functions_search.'.$phpEx); - $topic_update_sql = ''; if ( $mode != 'poll_delete' ) { $sql = "DELETE FROM " . POSTS_TABLE . " @@ -517,7 +517,6 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } - $topic_update_sql .= 'topic_replies = topic_replies - 1'; if ( $post_data['last_post'] ) { if ( $post_data['first_post'] ) @@ -543,7 +542,7 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ remove_search_post($post_id); } - if( $mode == 'poll_delete' || ( $mode == 'delete' && $post_data['first_post'] && $post_data['last_post'] ) && $post_data['has_poll'] && $post_data['edit_poll'] ) + if ( $mode == 'poll_delete' || ( $mode == 'delete' && $post_data['first_post'] && $post_data['last_post'] ) && $post_data['has_poll'] && $post_data['edit_poll'] ) { $sql = "DELETE FROM " . VOTE_DESC_TABLE . " WHERE topic_id = $topic_id"; @@ -567,31 +566,15 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ } } - // - // Ok we set variables above that were intended to update the topics table - // so let's go ahead and use it already :) - // - if( !empty($topic_update_sql) && !($post_data['first_post'] && $post_data['last_post']) ) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $topic_update_sql . " - WHERE topic_id = $topic_id OR - topic_moved_id = $topic_id"; - if ( !($db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Error in updating reply counts', '', __LINE__, __FILE__, $sql); - } - } - if ( $mode == 'delete' && $post_data['first_post'] && $post_data['last_post'] ) { - $meta = ''; + $meta = ''; $message = $lang['Deleted']; } else { - $meta = ''; - $message = ( ( $mode == "poll_delete" ) ? $lang['Poll_delete'] : $lang['Deleted'] ) . '

' . sprintf($lang['Click_return_topic'], '', ''); + $meta = ''; + $message = ( ( $mode == 'poll_delete' ) ? $lang['Poll_delete'] : $lang['Deleted'] ) . '

' . sprintf($lang['Click_return_topic'], '', ''); } $message .= '

' . sprintf($lang['Click_return_forum'], '', ''); @@ -611,7 +594,7 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id if ( $mode == 'delete' ) { - $delete_sql = ( !$post_data['first_post'] && !$post_data['last_post'] ) ? " AND user_id = " . $userdata['user_id'] : ""; + $delete_sql = ( !$post_data['first_post'] && !$post_data['last_post'] ) ? " AND user_id = " . $userdata['user_id'] : ''; $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id" . $delete_sql; if ( !($result = $db->sql_query($sql)) ) { @@ -663,7 +646,7 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; - $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"; $update_watched_sql = ''; if ( $row = $db->sql_fetchrow($result) ) @@ -852,4 +835,4 @@ function generate_smilies($mode, $page_id) } } -?> +?> \ No newline at end of file diff --git a/phpBB/includes/usercp_sendpasswd.php b/phpBB/includes/usercp_sendpasswd.php index 9d36344eba..0f4a43a283 100644 --- a/phpBB/includes/usercp_sendpasswd.php +++ b/phpBB/includes/usercp_sendpasswd.php @@ -125,7 +125,9 @@ $template->assign_vars(array( 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'L_SUBMIT' => $lang['Submit'], - 'L_RESET' => $lang['Reset']) + 'L_RESET' => $lang['Reset'], + + 'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=sendpassword")) ); $template->pparse('body'); diff --git a/phpBB/update_to_201.php b/phpBB/update_to_201.php index cd82bd39d0..adf7293131 100644 --- a/phpBB/update_to_201.php +++ b/phpBB/update_to_201.php @@ -20,32 +20,38 @@ if ( !($result = $db->sql_query($sql)) ) if ( $row = $db->sql_fetchrow($result) ) { - if ( $row['config_value'] == 'RC-3' || $row['config_value'] == 'RC-4' || $row['config_value'] == '.0.0' ) + switch ( $row['config_value'] ) { - if ( $row['config_value'] == 'RC-3' ) - { + case 'RC-3': + case 'RC-4': + case '.0.0': $sql = array(); - switch ( SQL_LAYER ) + + switch ( $row['config_value'] ) { - case 'mysql': - case 'mysql4': - $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP - COLUMN user_autologin_key"; - break; + case 'RC-3': + switch ( SQL_LAYER ) + { + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + break; - case 'mssql-odbc': - case 'mssql': - case 'msaccess': - $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP - COLUMN user_autologin_key"; - break; + case 'mssql-odbc': + case 'mssql': + case 'msaccess': + $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP + COLUMN user_autologin_key"; + break; - case 'postgresql': - $sql[] = "ALTER TABLE " . USERS_TABLE . " ALTER - COLUMN user_autologin_key DROP"; - default: - die("No DB LAYER found!"); - break; + case 'postgresql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " ALTER + COLUMN user_autologin_key DROP"; + default: + die("No DB LAYER found!"); + break; + } } $errored = false; @@ -65,19 +71,67 @@ if ( $row = $db->sql_fetchrow($result) ) echo " -> COMPLETED

\n\n"; } } - } - unset($sql); + unset($sql); - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '.0.1' - WHERE config_name = 'version'"; - if ( !($result = $db->sql_query($sql)) ) - { - die("Couldn't update version info"); - } + switch ( $row['config_value'] ) + { + case 'RC-3': + case 'RC-4': + case '.0.0': + $sql = "SELECT topic_id, topic_moved_id + FROM " . TOPICS_TABLE . " + WHERE topic_moved_id <> 0"; + if ( !($result = $db->sql_query($sql)) ) + { + die("Couldn't update version info"); + } - die("UPDATING COMPLETE -> 2.0.1 Final installed"); + $topic_ary = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $topic_ary[$row['topic_id']] = $row['topic_moved_id']; + } + + while ( list($topic_id, $topic_moved_id) = each($topic_ary) ) + { + $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_moved_id"; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql); + } + + if ( $row = $db->sql_fetchrow($result) ) + { + $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 = $topic_id"; + if ( !$db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql); + } + } + } + } + + unset($sql); + + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '.0.1' + WHERE config_name = 'version'"; + if ( !($result = $db->sql_query($sql)) ) + { + die("Couldn't update version info"); + } + + die("UPDATING COMPLETE -> 2.0.1 Final installed"); + break; + + default: + die("NO UPDATES REQUIRED"); + break; } } diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index ae510c44f0..f576c4eaab 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -102,7 +102,7 @@ if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] ) { if ( !$userdata['session_logged_in'] ) { - $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : "" ); + $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' ); $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: "; header($header_location . append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true)); exit; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index f09649a272..07f6e985ea 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -113,20 +113,14 @@ if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) ) message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql); } - if ( !($row = $db->sql_fetchrow($result)) ) + if ( $row = $db->sql_fetchrow($result) ) { - if( $HTTP_GET_VARS['view'] == 'next' ) - { - message_die(GENERAL_MESSAGE, 'No_newer_topics'); - } - else - { - message_die(GENERAL_MESSAGE, 'No_older_topics'); - } + $topic_id = $row['topic_id']; } else { - $topic_id = $row['topic_id']; + $message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics'; + message_die(GENERAL_MESSAGE, $message); } } }