More fixes ... hopefully corrects for moved topic/pagination issues ... needs testing (run update_to_201.php ... if you are already running 2.0.1 you'll need to modify the case statements in update_to_201 or necessary checks won't complete)

git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2579 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-05-14 15:19:20 +00:00
parent beb36a67f9
commit 290a897da4
6 changed files with 118 additions and 91 deletions

View file

@ -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;
}

View file

@ -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 http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id) . '">';
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $forum_id) . '">';
$message = $lang['Deleted'];
}
else
{
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id) . '">';
$message = ( ( $mode == "poll_delete" ) ? $lang['Poll_delete'] : $lang['Deleted'] ) . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id) . '">';
$message = ( ( $mode == 'poll_delete' ) ? $lang['Poll_delete'] : $lang['Deleted'] ) . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
}
$message .= '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
@ -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) )

View file

@ -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');

View file

@ -20,11 +20,16 @@ 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' )
{
if ( $row['config_value'] == 'RC-3' )
switch ( $row['config_value'] )
{
case 'RC-3':
case 'RC-4':
case '.0.0':
$sql = array();
switch ( $row['config_value'] )
{
case 'RC-3':
switch ( SQL_LAYER )
{
case 'mysql':
@ -47,6 +52,7 @@ if ( $row = $db->sql_fetchrow($result) )
die("No DB LAYER found!");
break;
}
}
$errored = false;
for($i = 0; $i < count($sql); $i++)
@ -65,6 +71,49 @@ if ( $row = $db->sql_fetchrow($result) )
echo " -> <b>COMPLETED</b><br /><br />\n\n";
}
}
unset($sql);
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");
}
$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);
@ -78,6 +127,11 @@ if ( $row = $db->sql_fetchrow($result) )
}
die("UPDATING COMPLETE -> 2.0.1 Final installed");
break;
default:
die("NO UPDATES REQUIRED");
break;
}
}

View file

@ -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;

View file

@ -113,21 +113,15 @@ 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( $HTTP_GET_VARS['view'] == 'next' )
{
message_die(GENERAL_MESSAGE, 'No_newer_topics');
}
else
{
message_die(GENERAL_MESSAGE, 'No_older_topics');
}
}
else
if ( $row = $db->sql_fetchrow($result) )
{
$topic_id = $row['topic_id'];
}
else
{
$message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
message_die(GENERAL_MESSAGE, $message);
}
}
}