From 461ae0f7e07cfbd340f5665a0b0007336ca948a5 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 13 Mar 2003 12:18:52 +0000 Subject: Redirect path changes git-svn-id: file:///svn/phpbb/trunk@3647 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/update_script.php | 204 +++++++++++++++++++++------------------- 1 file changed, 109 insertions(+), 95 deletions(-) (limited to 'phpBB/install/update_script.php') diff --git a/phpBB/install/update_script.php b/phpBB/install/update_script.php index f03ada3459..6899e8b968 100644 --- a/phpBB/install/update_script.php +++ b/phpBB/install/update_script.php @@ -20,7 +20,7 @@ $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); // // Updates to this version ... // -$version = '2.1.0 [20020820]'; +$version = '2.1.1 [20030221]'; // ---------------- // BEGIN VARS DEFNS @@ -135,7 +135,7 @@ page_header(); $field_ary ) + foreach ($anon_id_tbl as $table => $field_ary) { - foreach ( $field_ary as $field ) + foreach ($field_ary as $field) { $sql = "UPDATE " . $table_prefix . "$table SET $field = " . ANONYMOUS . " @@ -188,7 +188,7 @@ switch ( $this_version )

Updating current schema

sql_query('SHOW TABLES'); $currenttables = array(); -while( $table = $db->sql_fetchrow($result) ) +while($table = $db->sql_fetchrow($result)) { $currenttables[] = $table[0]; } @@ -213,9 +213,9 @@ while( $table = $db->sql_fetchrow($result) ) // // Check what tables we need to CREATE // -foreach( $table_def as $table => $definition ) +foreach($table_def as $table => $definition) { - if ( !in_array($table, $currenttables) ) + if (!in_array($table, $currenttables)) { gen_str_init("* Creating $table"); @@ -228,7 +228,7 @@ foreach( $table_def as $table => $definition ) // // Loop tables in schema // -foreach ( $field_def as $table => $table_def ) +foreach ($field_def as $table => $table_def) { // Loop fields in table gen_str_init("* Updating table $table"); @@ -238,17 +238,17 @@ foreach ( $field_def as $table => $table_def ) $result = $db->sql_query($sql); $current_fields = array(); - while ( $row = $db->sql_fetchrow($result) ) + while ($row = $db->sql_fetchrow($result)) { $current_fields[] = $row['Field']; } $alter_sql = "ALTER TABLE $table "; - if ( is_array($table_def) ) + if (is_array($table_def)) { - foreach ( $table_def as $field => $definition ) + foreach ($table_def as $field => $definition) { - if ( $field == '' ) + if ($field == '') { // // Skip empty fields if any (shouldn't be needed) @@ -271,7 +271,7 @@ foreach ( $field_def as $table => $table_def ) // If the current is not a key of $current_def and it is not a field that is // to be renamed then the field doesn't currently exist. // - $changes[] = ( !in_array($field, $current_fields) && $oldfield == $field ) ? " ADD $field " . $create_def[$table][$field] : " CHANGE $oldfield $field " . $create_def[$table][$field]; + $changes[] = (!in_array($field, $current_fields) && $oldfield == $field) ? " ADD $field " . $create_def[$table][$field] : " CHANGE $oldfield $field " . $create_def[$table][$field]; } } @@ -285,18 +285,18 @@ foreach ( $field_def as $table => $table_def ) $result = $db->sql_query($sql); $indices = array(); - while( $row = $db->sql_fetchrow($result) ) + while($row = $db->sql_fetchrow($result)) { $indices[] = $row['Key_name']; } - if ( is_array($key_def[$table]) ) + if (is_array($key_def[$table])) { - foreach ( $key_def[$table] as $key_name => $key_field ) + foreach ($key_def[$table] as $key_name => $key_field) { - if ( !in_array($key_name, $indices) ) + if (!in_array($key_name, $indices)) { - $alter_sql .= ( $key_name == 'PRIMARY' ) ? ", ADD PRIMARY KEY ($key_field)" : ", ADD INDEX $key_name ($key_field)"; + $alter_sql .= ($key_name == 'PRIMARY') ? ", ADD PRIMARY KEY ($key_field)" : ", ADD INDEX $key_name ($key_field)"; } } } @@ -307,7 +307,7 @@ foreach ( $field_def as $table => $table_def ) gen_str_ok(); } - +*/ ?>

Updating table data

@@ -315,7 +315,7 @@ foreach ( $field_def as $table => $table_def ) sql_query($sql); $sql_ary = array(); - if ( $row = $db->sql_fetchrow($result) ) + if ($row = $db->sql_fetchrow($result)) { do { @@ -400,7 +400,7 @@ switch ( $this_version ) WHERE ban_id = " . $row['ban_id']; $db->sql_query($sql); } - while ( $row = $db->sql_fetchrow($result) ); + while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); @@ -419,16 +419,16 @@ switch ( $this_version ) // ), $batchsize = 1000; - foreach ( $upd_ip_sql as $table => $field_ary ) + foreach ($upd_ip_sql as $table => $field_ary) { - foreach ( $field_ary as $field ) + foreach ($field_ary as $field) { gen_str_init("* Decoding $table.$field"); $db->sql_return_on_error(true); $sql = "SELECT MAX($field) AS max_id FROM " . $table_prefix . "$table"; - if ( $result = $db->sql_query($sql) ) + if ($result = $db->sql_query($sql)) { $db->sql_return_on_error(false); @@ -449,7 +449,7 @@ switch ( $this_version ) AND $batchend"; $result = $db->sql_query($sql); - if ( $row = $db->sql_fetchrow($result) ) + if ($row = $db->sql_fetchrow($result)) { do { @@ -458,7 +458,7 @@ switch ( $this_version ) WHERE $field LIKE '" . $row[$field] . "'"; $db->sql_query($sql); } - while ( $row = $db->sql_fetchrow($result) ); + while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); } @@ -530,7 +530,7 @@ switch ( $this_version ) "UPDATE " . $table_prefix . "config SET config_value = '1' WHERE config_name = 'default_style'", ); - if ( SQL_LAYER == 'mysql' || SQL_LAYER == 'mysql4' ) + if (SQL_LAYER == 'mysql' || SQL_LAYER == 'mysql4') { $sql_ary[] = "ALTER TABLE " . $table_prefix . "users AUTO_INCREMENT = 1"; } @@ -546,9 +546,7 @@ switch ( $this_version ) gen_str_ok(); gen_str_init('* Updating permissions'); - // // Grab user id of first user with user_level of ADMIN - // $sql = "SELECT user_id FROM " . $table_prefix . "users WHERE user_level = 1 @@ -568,7 +566,7 @@ switch ( $this_version ) $result = $db->sql_query($sql); $forum_access = array(); - while ( $row = $db->sql_fetchrow($result) ) + while ($row = $db->sql_fetchrow($result)) { $forum_access[] = $row; } @@ -585,7 +583,7 @@ switch ( $this_version ) $result = $db->sql_query($sql); $user_access = array(); - while ( $row = $db->sql_fetchrow($result) ) + while ($row = $db->sql_fetchrow($result)) { $user_access[$row['forum_id']] = $row; } @@ -601,7 +599,7 @@ switch ( $this_version ) $result = $db->sql_query($sql); $group_access = array(); - while ( $row = $db->sql_fetchrow($result) ) + while ($row = $db->sql_fetchrow($result)) { $group_access[$row['forum_id']] = $row; } @@ -617,20 +615,20 @@ switch ( $this_version ) $result = $db->sql_query($sql); $delete_ug_sql = ''; - if ( $row = $db->sql_fetchrow($result) ) + if ($row = $db->sql_fetchrow($result)) { do { - $delete_ug_sql .= ( ( $delete_ug_sql != '' ) ? ', ' : '' ) . $row['group_id']; + $delete_ug_sql .= (($delete_ug_sql != '') ? ', ' : '') . $row['group_id']; } - while ( $row = $db->sql_fetchrow($result) ); + while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); // // Clean up user_group and groups // - if ( $delete_ug_sql ) + if ($delete_ug_sql) { $sql = "DELETE FROM " . $table_prefix . "user_group WHERE group_id NOT IN ($delete_ug_sql)"; @@ -657,7 +655,7 @@ switch ( $this_version ) $all_options = array_merge($auth_options, array_merge($auth_mod_options, $auth_admin_options)); $option_ids = array(); - foreach ( $all_options as $value ) + foreach ($all_options as $value) { $sql = "INSERT INTO " . $table_prefix . "auth_options (auth_value) VALUES ('$value')"; @@ -666,7 +664,7 @@ switch ( $this_version ) $option_ids[$value] = $db->sql_nextid(); } - foreach ( $new_groups as $k => $sql ) + foreach ($new_groups as $k => $sql) { $db->sql_query($sql); $$k = $db->sql_nextid(); @@ -707,11 +705,11 @@ switch ( $this_version ) $group_acl = array(); $user_acl = array(); - foreach ( $forum_access as $forum ) + foreach ($forum_access as $forum) { - foreach( $auth_map as $k => $v ) + foreach($auth_map as $k => $v) { - switch ( $forum[$k] ) + switch ($forum[$k]) { case AUTH_ALL: $group_acl[$guest_id][$forum['forum_id']][$v] = ACL_ALLOW; @@ -724,22 +722,22 @@ switch ( $this_version ) break; case AUTH_ACL: - foreach( $group_access as $forum_id => $access ) + foreach($group_access as $forum_id => $access) { - if ( $forum_id == $forum['forum_id'] ) + if ($forum_id == $forum['forum_id']) { - if ( !empty($access[$k]) ) + if (!empty($access[$k])) { $group_acl[$access['group_id']][$forum['forum_id']][$v] = ACL_ALLOW; } } } - foreach( $user_access as $forum_id => $access ) + foreach($user_access as $forum_id => $access) { - if ( $forum_id == $forum['forum_id'] ) + if ($forum_id == $forum['forum_id']) { - if ( !empty($access[$k]) ) + if (!empty($access[$k])) { $user_acl[$access['user_id']][$forum['forum_id']][$v] = ACL_ALLOW; } @@ -750,22 +748,22 @@ switch ( $this_version ) case AUTH_MOD: $group_acl[$super_mod_id][$forum['forum_id']][$v] = ACL_ALLOW; - foreach( $group_access as $forum_id => $access ) + foreach($group_access as $forum_id => $access) { - if ( $forum_id == $forum['forum_id'] ) + if ($forum_id == $forum['forum_id']) { - if ( !empty($access[$k]) ) + if (!empty($access[$k])) { $group_acl[$access['group_id']][$forum['forum_id']][$v] = ACL_ALLOW; } } } - foreach( $user_access as $forum_id => $access ) + foreach($user_access as $forum_id => $access) { - if ( $forum_id == $forum['forum_id'] ) + if ($forum_id == $forum['forum_id']) { - if ( !empty($access[$k]) ) + if (!empty($access[$k])) { $user_acl[$access['user_id']][$forum['forum_id']][$v] = ACL_ALLOW; } @@ -801,9 +799,9 @@ switch ( $this_version ) // // Do Moderators // - foreach( $user_access as $forum_id => $access ) + foreach($user_access as $forum_id => $access) { - if ( !empty($access['auth_mod']) ) + if (!empty($access['auth_mod'])) { $sql_ary[] = "INSERT INTO " . $table_prefix . "auth_users (user_id, forum_id, auth_option_id, auth_allow_deny) SELECT " . $access['user_id'] . ", $forum_id, auth_option_id, " . ACL_ALLOW . " @@ -817,9 +815,9 @@ switch ( $this_version ) } } - foreach( $group_access as $forum_id => $access ) + foreach($group_access as $forum_id => $access) { - if ( !empty($access['auth_mod']) ) + if (!empty($access['auth_mod'])) { $sql_ary[] = "INSERT INTO " . $table_prefix . "auth_groups (group_id, forum_id, auth_option_id, auth_allow_deny) SELECT " . $access['group_id'] . ", $forum_id, auth_option_id, " . ACL_ALLOW . " @@ -836,11 +834,11 @@ switch ( $this_version ) // // Rest of access list // - foreach ( $user_acl as $user_id => $user_acl_ary ) + foreach ($user_acl as $user_id => $user_acl_ary) { - foreach ( $user_acl_ary as $forum_id => $auth ) + foreach ($user_acl_ary as $forum_id => $auth) { - foreach ( $auth as $auth_value => $allow ) + foreach ($auth as $auth_value => $allow) { $auth_option_id = $option_ids[$auth_value]; $sql_ary[] = "INSERT INTO " . $table_prefix . "auth_users (user_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($user_id, $forum_id, $auth_option_id, $allow)"; @@ -848,11 +846,11 @@ switch ( $this_version ) } } - foreach ( $group_acl as $group_id => $group_acl_ary ) + foreach ($group_acl as $group_id => $group_acl_ary) { - foreach ( $group_acl_ary as $forum_id => $auth ) + foreach ($group_acl_ary as $forum_id => $auth) { - foreach ( $auth as $auth_value => $allow ) + foreach ($auth as $auth_value => $allow) { $auth_option_id = $option_ids[$auth_value]; $sql_ary[] = "INSERT INTO " . $table_prefix . "auth_groups (group_id, forum_id, auth_option_id, auth_allow_deny) VALUES ($group_id, $forum_id, $auth_option_id, $allow)"; @@ -860,14 +858,14 @@ switch ( $this_version ) } } - foreach ( $sql_ary as $sql ) + foreach ($sql_ary as $sql) { $db->sql_query($sql); } gen_str_ok(); - case '2.1.0 [20020816]': + case '2.1.1 [20030221]': $sql_ary = array(); @@ -876,7 +874,7 @@ switch ( $this_version ) $sql_ary[] = "UPDATE " . $table_prefix . "posts_text SET post_checksum = MD5(post_text)"; - foreach ( $sql_ary as $sql ) + foreach ($sql_ary as $sql) { $db->sql_query($sql); } @@ -884,7 +882,21 @@ switch ( $this_version ) gen_str_ok(); gen_str_init('* Updating forum post info'); - switch ( SQL_LAYER ) + $sql = "SELECT topic_id, MIN(post_id) AS first_post_id, MAX(post_id) AS last_post_id, COUNT(post_id) AS total_posts + FROM {$table_prefix}posts + GROUP BY topic_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $sql = "UPDATE {$table_prefix}topics + SET topic_first_post_id = " . $row['first_post_id'] . ", topic_last_post_id = " . $row['last_post_id'] . ", topic_replies = " . ($row['total_posts'] - 1) . " + WHERE topic_id = " . $row['topic_id']; + $db->sql_query($sql); + } + $db->sql_freeresult($result); + + switch (SQL_LAYER) { case 'oracle': $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id @@ -895,20 +907,20 @@ switch ( $this_version ) default: $sql = "SELECT f.forum_id, p.post_time, p.post_username, u.username, u.user_id - FROM (( " . $table_prefix . "forums f - LEFT JOIN " . $table_prefix . "posts p ON p.post_id = f.forum_last_post_id ) - LEFT JOIN " . $table_prefix . "users u ON u.user_id = p.poster_id )"; + FROM ((" . $table_prefix . "forums f + LEFT JOIN " . $table_prefix . "posts p ON p.post_id = f.forum_last_post_id) + LEFT JOIN " . $table_prefix . "users u ON u.user_id = p.poster_id)"; break; } $result = $db->sql_query($sql); $sql_ary = array(); - while ( $row = $db->sql_fetchrow($result) ) + while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; $sql_ary[] = "UPDATE " . $table_prefix . "forums - SET forum_last_poster_id = " . ( ( $row['user_id'] ) ? $row['user_id'] : ANONYMOUS ) . ", forum_last_poster_name = '" . addslashes($row['post_username']) . "', forum_last_post_time = " . $row['post_time'] . " + SET forum_last_poster_id = " . (($row['user_id'] != ANONYMOUS) ? $row['user_id'] : ANONYMOUS) . ", forum_last_poster_name = '" . (($row['user_id'] != ANONYMOUS) ? addslashes($row['username']) : addslashes($row['post_username'])) . "', forum_last_post_time = " . $row['post_time'] . " WHERE forum_id = $forum_id"; $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time @@ -920,10 +932,10 @@ switch ( $this_version ) AND u2.user_id = p2.poster_id"; $result2 = $db->sql_query($sql); - while ( $row2 = $db->sql_fetchrow($result2) ) + while ($row2 = $db->sql_fetchrow($result2)) { $sql_ary[] = "UPDATE " . $table_prefix . "topics - SET topic_first_poster_name = '" . addslashes($row2['post_username']) . "', topic_last_poster_id = " . ( ( $row2['id2'] ) ? $row2['id2'] : ANONYMOUS ) . ", topic_last_post_time = " . $row2['post_time'] . ", topic_last_poster_name = '" . addslashes($row2['post_username2']) . "' + SET topic_poster = " . $row['user_id'] . ", topic_first_poster_name = '" . (($row2['user_id'] != ANONYMOUS && $row2['user_id']) ? addslashes($row2['username']) : addslashes($row2['post_username'])) . "', topic_last_poster_id = " . (($row2['id2'] != ANONYMOUS && $row2['id2']) ? $row2['id2'] : ANONYMOUS) . ", topic_last_post_time = " . $row2['post_time'] . ", topic_last_poster_name = '" . (($row2['id2'] != ANONYMOUS && $row2['id2']) ? addslashes($row2['user2']) : addslashes($row2['post_username2'])) . "' WHERE topic_id = " . $row2['topic_id']; } $db->sql_freeresult($result2); @@ -932,8 +944,9 @@ switch ( $this_version ) } $db->sql_freeresult($result); - foreach ( $sql_ary as $sql ) + foreach ($sql_ary as $sql) { + echo $sql . "
"; $db->sql_query($sql); } @@ -941,9 +954,10 @@ switch ( $this_version ) case '2.1.0 [20020817]': - $sql = "INSERT INTO phpbb_config (config_name, config_value) - VALUES ('ip_check', '4')"; - $db->sql_query($sql); +// $sql = "INSERT INTO phpbb_config (config_name, config_value) +// VALUES ('ip_check', '4')"; +// $db->sql_query($sql); + break; default; print "* No updates needed
\n"; @@ -996,11 +1010,11 @@ function page_header() - +