diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-03-13 12:18:52 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-03-13 12:18:52 +0000 |
commit | 461ae0f7e07cfbd340f5665a0b0007336ca948a5 (patch) | |
tree | 7cd65c2c54832529a1efe89a845f9ba0476789e2 /phpBB/install | |
parent | 8bb5de9861e30160bac90ae8ba78497fe2c207de (diff) | |
download | forums-461ae0f7e07cfbd340f5665a0b0007336ca948a5.tar forums-461ae0f7e07cfbd340f5665a0b0007336ca948a5.tar.gz forums-461ae0f7e07cfbd340f5665a0b0007336ca948a5.tar.bz2 forums-461ae0f7e07cfbd340f5665a0b0007336ca948a5.tar.xz forums-461ae0f7e07cfbd340f5665a0b0007336ca948a5.zip |
Redirect path changes
git-svn-id: file:///svn/phpbb/trunk@3647 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/install')
-rw-r--r-- | phpBB/install/install.php | 14 | ||||
-rw-r--r-- | phpBB/install/update_script.php | 204 | ||||
-rw-r--r-- | phpBB/install/upgrade.php | 332 |
3 files changed, 282 insertions, 268 deletions
diff --git a/phpBB/install/install.php b/phpBB/install/install.php index 9a76da8d2a..afb74c219a 100644 --- a/phpBB/install/install.php +++ b/phpBB/install/install.php @@ -341,7 +341,7 @@ else if( !empty($_POST['ftp_file']) && !defined("PHPBB_INSTALLED") ) // $s_hidden_fields = '<input type="hidden" name="username" value="' . $admin_name . '" />'; $s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />'; - $s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/index.php" />'; + $s_hidden_fields .= '<input type="hidden" name="redirect" value="adm/index.php" />'; $s_hidden_fields .= '<input type="hidden" name="submit" value="' . $lang['Login'] . '" />'; page_header($lang['Inst_Step_2'], "../login.$phpEx"); @@ -859,7 +859,7 @@ else { $s_hidden_fields = '<input type="hidden" name="username" value="' . $admin_name . '" />'; $s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />'; - $s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/index.php" />'; + $s_hidden_fields .= '<input type="hidden" name="redirect" value="adm/index.php" />'; $s_hidden_fields .= '<input type="hidden" name="login" value="true" />'; } else @@ -897,11 +897,11 @@ function page_header($l_instructions, $s_action) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> -<link rel="stylesheet" href="../admin/subSilver.css" type="text/css"> +<link rel="stylesheet" href="../adm/subSilver.css" type="text/css"> <style type="text/css"> <!-- -th { background-image: url('../admin/images/cellpic3.gif') } -td.cat { background-image: url('../admin/images/cellpic1.gif') } +th { background-image: url('../adm/images/cellpic3.gif') } +td.cat { background-image: url('../adm/images/cellpic1.gif') } //--> </style> <title><?php echo $lang['Welcome_install']; ?></title> @@ -910,8 +910,8 @@ td.cat { background-image: url('../admin/images/cellpic1.gif') } <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> - <td><img src="../admin/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td> - <td width="100%" background="../admin/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle"><?php echo $lang['Welcome_install']; ?></span> </td> + <td><img src="../adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td> + <td width="100%" background="../adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle"><?php echo $lang['Welcome_install']; ?></span> </td> </tr> </table> 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(); <?php -switch ( $this_version ) +switch ($this_version) { case '.0.0': case '.0.1': @@ -163,9 +163,9 @@ switch ( $this_version ) ); $sql = ''; - foreach ( $anon_id_tbl as $table => $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 ) <h1>Updating current schema</h1> <?php - +/* // // Get schema // @@ -205,7 +205,7 @@ $create_def = $schema['create_def']; $result = $db->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 <b>$table</b>"); @@ -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 <b>$table</b>"); @@ -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(); } - +*/ ?> <h1>Updating table data</h1> @@ -315,7 +315,7 @@ foreach ( $field_def as $table => $table_def ) <?php -switch ( $this_version ) +switch ($this_version) { case '.0.0': case '.0.1': @@ -391,7 +391,7 @@ switch ( $this_version ) $result = $db->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 <b>$table.$field</b>"); $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 <b>permissions</b>'); - // // 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 <b>forum post info</b>'); - 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 . "<br />"; $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 "<span class=\"updtext\">* No updates needed</span><br />\n"; @@ -996,11 +1010,11 @@ function page_header() <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"> <meta http-equiv="Content-Style-Type" content="text/css"> -<link rel="stylesheet" href="../admin/subSilver.css" type="text/css"> +<link rel="stylesheet" href="../adm/subSilver.css" type="text/css"> <style type="text/css"> <!-- -th { background-image: url('../admin/images/cellpic3.gif') } -td.cat { background-image: url('../admin/images/cellpic1.gif') } +th { background-image: url('../adm/images/cellpic3.gif') } +td.cat { background-image: url('../adm/images/cellpic1.gif') } h1 { margin-left:15px } @@ -1018,8 +1032,8 @@ h1 { margin-left:15px } <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> - <td><img src="../admin/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td> - <td width="100%" background="../admin/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">Update Script</span> </td> + <td><img src="../adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td> + <td width="100%" background="../adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">Update Script</span> </td> </tr> </table> @@ -1078,7 +1092,7 @@ function get_schema() { $line = $schemafile[$i]; - if ( preg_match('/^CREATE TABLE (\w+)/i', $line, $matches) ) + if (preg_match('/^CREATE TABLE (\w+)/i', $line, $matches)) { // Start of a new table definition, set some variables and go to the next line. $tabledata = 1; @@ -1088,7 +1102,7 @@ function get_schema() continue; } - if ( preg_match('/^\);/', $line) ) + if (preg_match('/^\);/', $line)) { // End of the table definition // After this we will skip everything until the next 'CREATE' line @@ -1096,12 +1110,12 @@ function get_schema() $table_def[$table] .= ')'; // We don't need the closing semicolon } - if ( $tabledata == 1 ) + if ($tabledata == 1) { // We are inside a table definition, parse this line. // Add the current line to the complete table definition: $table_def[$table] .= $line; - if ( preg_match('/^\s*(\w+)\s+(\w+)\(([\d,]+)\)(.*)$/', $line, $matches) ) + if (preg_match('/^\s*(\w+)\s+(\w+)\(([\d,]+)\)(.*)$/', $line, $matches)) { // This is a column definition $field = $matches[1]; @@ -1111,8 +1125,8 @@ function get_schema() preg_match('/DEFAULT (NULL|\'.*?\')[,\s](.*)$/i', $matches[4], $match); $default = $match[1]; - $notnull = ( preg_match('/NOT NULL/i', $matches[4]) ) ? 1 : 0; - $auto_increment = ( preg_match('/auto_increment/i', $matches[4]) ) ? 1 : 0; + $notnull = (preg_match('/NOT NULL/i', $matches[4])) ? 1 : 0; + $auto_increment = (preg_match('/auto_increment/i', $matches[4])) ? 1 : 0; $field_def[$table][$field] = array( 'type' => $type, @@ -1123,17 +1137,17 @@ function get_schema() ); } - if ( preg_match('/\s*PRIMARY\s+KEY\s*\((.*)\).*/', $line, $matches) ) + if (preg_match('/\s*PRIMARY\s+KEY\s*\((.*)\).*/', $line, $matches)) { // Primary key $key_def[$table]['PRIMARY'] = $matches[1]; } - else if ( preg_match('/\s*KEY\s+(\w+)\s*\((.*)\)/', $line, $matches) ) + else if (preg_match('/\s*KEY\s+(\w+)\s*\((.*)\)/', $line, $matches)) { // Normal key $key_def[$table][$matches[1]] = $matches[2]; } - else if ( preg_match('/^\s*(\w+)\s*(.*?),?\s*$/', $line, $matches) ) + else if (preg_match('/^\s*(\w+)\s*(.*?),?\s*$/', $line, $matches)) { // Column definition $create_def[$table][$matches[1]] = $matches[2]; @@ -1164,7 +1178,7 @@ function get_inserts() for($i = 0; $i < count($insertfile); $i++) { - if ( preg_match('/(INSERT INTO (\w+)\s.*);/i', str_replace('phpbb_', $table_prefix, $insertfile[$i]), $matches) ) + if (preg_match('/(INSERT INTO (\w+)\s.*);/i', str_replace('phpbb_', $table_prefix, $insertfile[$i]), $matches)) { $returnvalue[$matches[2]][] = $matches[1]; } diff --git a/phpBB/install/upgrade.php b/phpBB/install/upgrade.php index 7cad1a220a..018076896c 100644 --- a/phpBB/install/upgrade.php +++ b/phpBB/install/upgrade.php @@ -104,13 +104,13 @@ hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;} .ok {color:green} /* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */ -@import url("templates/subSilver/formIE.css"); +@import url("templates/subSilver/formIE.css"); --> </style> </head> <body bgcolor="#FFFFFF" text="#000000" link="#006699" vlink="#5584AA"> -<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center"> +<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> @@ -188,7 +188,7 @@ function smiley_replace($text = '') } return ( $text != '' ) ? preg_replace($search, $replace, $text) : ''; - + } function get_schema() @@ -246,7 +246,7 @@ function get_schema() 'auto_increment' => $auto_increment ); } - + if ( preg_match('/\s*PRIMARY\s+KEY\s*\((.*)\).*/', $line, $matches) ) { // Primary key @@ -373,16 +373,16 @@ function bbdecode($message) // Alternative for in_array() which is only available in PHP4 // function inarray($needle, $haystack) -{ +{ for( $i = 0 ; $i < sizeof($haystack) ; $i++ ) - { + { if ( $haystack[$i] == $needle ) - { - return true; - } - } + { + return true; + } + } - return false; + return false; } function end_step($next) @@ -436,7 +436,7 @@ if ( !empty($next) ) flush(); query("DROP TABLE sessions", "Couldn't drop table 'sessions'"); - query("DROP TABLE themes", "Couldn't drop table 'themes'"); + query("DROP TABLE themes", "Couldn't drop table 'themes'"); print "<span class=\"ok\"><b>OK</b></span><br />\n"; @@ -479,10 +479,10 @@ if ( !empty($next) ) flush(); query("ALTER TABLE $old RENAME $new", "Failed to rename $old to $new"); print "<span class=\"ok\"><b>OK</b></span><br />\n"; - + } end_step('create_tables'); - + case 'create_tables': // Create array with tables in 'old' database $result = query('SHOW TABLES', "Couldn't get list of current tables"); @@ -491,7 +491,7 @@ if ( !empty($next) ) { $currenttables[] = $table[0]; } - + // Check what tables we need to CREATE while( list($table, $definition) = each($table_def) ) { @@ -504,9 +504,9 @@ if ( !empty($next) ) print "<span class=\"ok\"><b>OK</b></span><br />\n"; } } - + end_step('create_config'); - + case 'create_config': print " * Inserting new values into new layout config table :: "; @@ -536,11 +536,11 @@ if ( !empty($next) ) print " <span class=\"ok\"><b>OK</b></span><br />\n"; end_step('convert_config'); - + case 'convert_config': print " * Converting configuration table :: "; - $sql = "SELECT * + $sql = "SELECT * FROM $table_prefix" . "old_config"; $result = query($sql, "Couldn't get info from old config table"); @@ -567,32 +567,32 @@ if ( !empty($next) ) { $name = ( !empty($rename_configs[$name]) ) ? $rename_configs[$name] : $name; - $sql = "REPLACE INTO " . CONFIG_TABLE . " (config_name, config_value) + $sql = "REPLACE INTO " . CONFIG_TABLE . " (config_name, config_value) VALUES ('$name', '" . stripslashes($value) . "')"; query($sql, "Couldn't update config table with values from old config table"); } } - - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = 'dutch' + + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = 'dutch' WHERE config_name = 'default_lang' && config_value = 'nederlands'"; query($sql, "Couldn't rename 'nederlands' to 'dutch' in config table"); - + print "<span class=\"ok\"><b>OK</b></span><br />\n"; end_step('convert_ips'); case 'convert_ips': - $names = array( + $names = array( POSTS_TABLE => array( 'id' => 'post_id', 'field' => 'poster_ip' - ), - PRIVMSGS_TABLE => array( - 'id' => 'msg_id', + ), + PRIVMSGS_TABLE => array( + 'id' => 'msg_id', 'field' => 'poster_ip' - ), - BANLIST_TABLE => array( - 'id' => 'ban_id', + ), + BANLIST_TABLE => array( + 'id' => 'ban_id', 'field' => 'ban_ip' ) ); @@ -602,7 +602,7 @@ if ( !empty($next) ) $batchsize = 2000; while( list($table, $data_array) = each($names) ) { - $sql = "SELECT MAX(" . $data_array['id'] . ") AS max_id + $sql = "SELECT MAX(" . $data_array['id'] . ") AS max_id FROM $table"; $result = query($sql, "Couldn't obtain ip data from $table (" . $fields . ")"); @@ -621,10 +621,10 @@ if ( !empty($next) ) print " * Converting IP format '" . $field . "' / '$table' ( $batchstart to $batchend ) :: "; flush(); - $sql = "SELECT $field_id, $field - FROM $table - WHERE $field_id - BETWEEN $batchstart + $sql = "SELECT $field_id, $field + FROM $table + WHERE $field_id + BETWEEN $batchstart AND $batchend"; $result = query($sql, "Couldn't obtain ip data from $table (" . $fields . ")"); @@ -633,8 +633,8 @@ if ( !empty($next) ) while( $row = $db->sql_fetchrow($result) ) { - $sql = "UPDATE $table - SET $field = '" . encode_ip($row[$field]) . "' + $sql = "UPDATE $table + SET $field = '" . encode_ip($row[$field]) . "' WHERE $field_id = " . $row[$field_id]; query($sql, "Couldn't convert IP format of $field in $table with $field_id of " . $rowset[$field_id]); @@ -657,7 +657,7 @@ if ( !empty($next) ) case 'convert_dates': $names = array( POSTS_TABLE => array('post_time'), - TOPICS_TABLE => array('topic_time'), + TOPICS_TABLE => array('topic_time'), PRIVMSGS_TABLE => array('msg_time') ); @@ -670,7 +670,7 @@ if ( !empty($next) ) for($i = 0; $i < count($fields); $i++) { - $sql = "UPDATE $table + $sql = "UPDATE $table SET " . $fields[$i] . " = UNIX_TIMESTAMP(" . $fields[$i] . ")"; query($sql, "Couldn't convert date format of $table(" . $fields[$i] . ")"); } @@ -711,7 +711,7 @@ if ( !empty($next) ) @reset($slashes); while( list($search, $replace) = each($slashes) ) { - $sql = "UPDATE $table + $sql = "UPDATE $table SET $field = REPLACE($field, '" . addslashes($search) . "', '" . addslashes($replace) . "')"; query($sql, "Couldn't remove extraneous slashes from the old data."); } @@ -727,12 +727,12 @@ if ( !empty($next) ) print " * Removing posts with no corresponding topics :: "; flush(); - $sql = "SELECT p.post_id - FROM " . POSTS_TABLE . " p - LEFT JOIN " . TOPICS_TABLE . " t ON p.topic_id = t.topic_id + $sql = "SELECT p.post_id + FROM " . POSTS_TABLE . " p + LEFT JOIN " . TOPICS_TABLE . " t ON p.topic_id = t.topic_id WHERE t.topic_id IS NULL"; $result = query($sql, "Couldn't obtain list of deleted topics"); - + $post_total = $db->sql_numrows($result); if ( $post_total ) @@ -743,7 +743,7 @@ if ( !empty($next) ) $post_id_ary[] = $row['post_id']; } - $sql = "DELETE FROM " . POSTS_TABLE . " + $sql = "DELETE FROM " . POSTS_TABLE . " WHERE post_id IN (" . implode(", ", $post_id_ary) . ")"; query($sql, "Couldn't update posts to remove deleted user poster_id values"); @@ -759,11 +759,11 @@ if ( !empty($next) ) // // Completely remove old soft-deleted users // - $sql = "DELETE FROM " . USERS_TABLE . " + $sql = "DELETE FROM " . USERS_TABLE . " WHERE user_level = -1"; query($sql, "Couldn't delete old soft-deleted users"); - $sql = "SELECT COUNT(*) AS total, MAX(user_id) AS maxid + $sql = "SELECT COUNT(*) AS total, MAX(user_id) AS maxid FROM " . USERS_TABLE; $result = query($sql, "Couldn't get max post_id."); @@ -772,7 +772,7 @@ if ( !empty($next) ) $totalposts = $maxid['total']; $maxid = $maxid['maxid']; - $sql = "ALTER TABLE " . USERS_TABLE . " + $sql = "ALTER TABLE " . USERS_TABLE . " ADD user_sig_bbcode_uid CHAR(10), MODIFY user_sig text"; query($sql, "Couldn't add user_sig_bbcode_uid field to users table"); @@ -785,14 +785,14 @@ if ( !empty($next) ) { $batchstart = $i; $batchend = $i + $batchsize; - + print " * Converting Users ( $batchstart to $batchend ) :: "; flush(); - $sql = "SELECT * - FROM " . USERS_TABLE . " - WHERE user_id - BETWEEN $batchstart + $sql = "SELECT * + FROM " . USERS_TABLE . " + WHERE user_id + BETWEEN $batchstart AND $batchend"; $result = query($sql, "Couldn't get ". USERS_TABLE .".user_id $batchstart to $batchend"); @@ -814,7 +814,7 @@ if ( !empty($next) ) while( $row = $db->sql_fetchrow($result) ) { - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user) + $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user) VALUES ('" . addslashes($row['username']) . "', 'Personal User', 1)"; query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".GROUPS_TABLE); @@ -822,7 +822,7 @@ if ( !empty($next) ) if ( $group_id != 0 ) { - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) + $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES ($group_id, " . $row['user_id'] . ", 0)"; query($sql, "Wasn't able to insert user ".$row['user_id']." into table ".USER_GROUP_TABLE); } @@ -873,7 +873,7 @@ if ( !empty($next) ) $website = ''; } $row['user_website'] = addslashes($website); - + $row['user_icq'] = (ereg("^[0-9]+$", $row['user_icq'])) ? $row['user_icq'] : ''; reset($checklength); @@ -885,7 +885,7 @@ if ( !empty($next) ) } $row[$field[1]] = addslashes($row[$field[1]]); } - + // // Is user a super moderator? // @@ -913,23 +913,23 @@ if ( !empty($next) ) $row['user_lang'] = 'dutch'; } - $sql = "UPDATE " . USERS_TABLE . " - SET + $sql = "UPDATE " . USERS_TABLE . " + SET user_sig = '" . $row['user_sig'] . "', - user_sig_bbcode_uid = '$uid', + user_sig_bbcode_uid = '$uid', user_regdate = '" . $row['user_regdate'] . "', user_website = '" . $row['user_website'] . "', user_occ = '" . $row['user_occ'] . "', user_email = '" . $row['user_email'] . "', user_from = '" . $row['user_from'] . "', - user_intrest = '" . $row['user_intrest'] . "', + user_intrest = '" . $row['user_intrest'] . "', user_aim = '" . $row['user_aim'] . "', user_yim = '" . $row['user_yim'] . "', user_msnm = '" . $row['user_msnm'] . "', - user_level = '" . $row['user_level'] . "', - user_desmile = NOT(user_desmile), - user_bbcode = 1, - user_theme = 1 + user_level = '" . $row['user_level'] . "', + user_desmile = NOT(user_desmile), + user_bbcode = 1, + user_theme = 1 WHERE user_id = " . $row['user_id']; query($sql, "Couldn't update ".USERS_TABLE." table with new BBcode and regdate for user_id ".$row['user_id']); @@ -973,7 +973,7 @@ if ( !empty($next) ) print " * Updating auth_access for super moderator group :: "; flush(); - $sql = "SELECT forum_id + $sql = "SELECT forum_id FROM " . FORUMS_TABLE; $result = query($sql, "Couldn't obtain forum_id list"); @@ -990,7 +990,7 @@ if ( !empty($next) ) VALUES ($group_id, " . $super_mods[$i] . ", 0)"; query($sql, "Unable to add user_id $user_id to group_id $group_id (super mods)<br>\n"); } - + print "<span class=\"ok\"><b>OK</b></span><br />\n"; } @@ -999,40 +999,40 @@ if ( !empty($next) ) case 'convert_posts': print " * Adding enable_sig field to " . POSTS_TABLE . " :: "; flush(); - $sql = "ALTER TABLE " . POSTS_TABLE . " + $sql = "ALTER TABLE " . POSTS_TABLE . " ADD enable_sig tinyint(1) DEFAULT '1' NOT NULL"; $result = query($sql, "Couldn't add enable_sig field to " . POSTS_TABLE . "."); print "<span class=\"ok\"><b>OK</b></span><br />\n"; - + print " * Adding enable_bbcode field to " . POSTS_TEXT_TABLE . " :: "; flush(); - $sql = "ALTER TABLE " . POSTS_TEXT_TABLE . " + $sql = "ALTER TABLE " . POSTS_TEXT_TABLE . " ADD enable_bbcode tinyint(1) DEFAULT '1' NOT NULL"; $result = query($sql, "Couldn't add enable_bbcode field to " . POSTS_TABLE . "."); print "<span class=\"ok\"><b>OK</b></span><br />\n"; print " * Adding bbcode_uid field to " . POSTS_TEXT_TABLE . " :: "; flush(); - $sql = "ALTER TABLE " . POSTS_TEXT_TABLE . " + $sql = "ALTER TABLE " . POSTS_TEXT_TABLE . " ADD bbcode_uid char(10) NOT NULL"; $result = query($sql, "Couldn't add bbcode_uid field to " . POSTS_TABLE . "."); print "<span class=\"ok\"><b>OK</b></span><br />\n"; - + print " * Adding post_edit_time field to " . POSTS_TABLE . " :: "; flush(); - $sql = "ALTER TABLE " . POSTS_TABLE . " + $sql = "ALTER TABLE " . POSTS_TABLE . " ADD post_edit_time int(11)"; $result = query($sql, "Couldn't add post_edit_time field to " . POSTS_TABLE . "."); print "<span class=\"ok\"><b>OK</b></span><br />\n"; print " * Adding post_edit_count field to " . POSTS_TABLE . " :: "; flush(); - $sql = "ALTER TABLE " . POSTS_TABLE . " + $sql = "ALTER TABLE " . POSTS_TABLE . " ADD post_edit_count smallint(5) UNSIGNED DEFAULT '0' NOT NULL"; $result = query($sql, "Couldn't add post_edit_count field to " . POSTS_TABLE . "."); print "<span class=\"ok\"><b>OK</b></span><br />\n<br />\n"; - $sql = "SELECT COUNT(*) as total, MAX(post_id) as maxid + $sql = "SELECT COUNT(*) as total, MAX(post_id) as maxid FROM " . POSTS_TEXT_TABLE; $result = query($sql, "Couldn't get max post_id."); @@ -1046,14 +1046,14 @@ if ( !empty($next) ) { $batchstart = $i + 1; $batchend = $i + $batchsize; - + print " * Converting BBcode ( $batchstart to $batchend ) :: "; flush(); - $sql = "SELECT * + $sql = "SELECT * FROM " . POSTS_TEXT_TABLE . " - WHERE post_id - BETWEEN $batchstart + WHERE post_id + BETWEEN $batchstart AND $batchend"; $result = query($sql, "Couldn't get ". POSTS_TEXT_TABLE .".post_id $batchstart to $batchend"); @@ -1106,7 +1106,7 @@ if ( !empty($next) ) $edited_sql = ", post_edit_time = $edited_time, post_edit_count = $edit_times"; } } - + if ( preg_match("/^(.*?)\n-----------------\n.*$/is", $row['post_text'], $matches) ) { $row['post_text'] = $matches[1]; @@ -1118,13 +1118,13 @@ if ( !empty($next) ) $enable_sig = ( strlen($checksig) == strlen($row['post_text']) ) ? 0 : 1; } - $sql = "UPDATE " . POSTS_TEXT_TABLE . " + $sql = "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '$checksig', bbcode_uid = '$uid' WHERE post_id = " . $row['post_id']; query($sql, "Couldn't update " . POSTS_TEXT_TABLE . " table with new BBcode for post_id :: " . $row['post_id']); - $sql = "UPDATE " . POSTS_TABLE . " - SET enable_sig = $enable_sig" . $edited_sql . " + $sql = "UPDATE " . POSTS_TABLE . " + SET enable_sig = $enable_sig" . $edited_sql . " WHERE post_id = " . $row['post_id']; query($sql, "Couldn't update " . POSTS_TABLE . " table with signature status for post with post_id :: " . $row['post_id']); @@ -1145,12 +1145,12 @@ if ( !empty($next) ) print "<br />\n * Updating poster_id for deleted users :: "; flush(); - $sql = "SELECT DISTINCT p.post_id - FROM " . POSTS_TABLE . " p - LEFT JOIN " . USERS_TABLE . " u ON p.poster_id = u.user_id + $sql = "SELECT DISTINCT p.post_id + FROM " . POSTS_TABLE . " p + LEFT JOIN " . USERS_TABLE . " u ON p.poster_id = u.user_id WHERE u.user_id IS NULL"; $result = query($sql, "Couldn't obtain list of deleted users"); - + $users_removed = $db->sql_numrows($result); if ( $users_removed ) @@ -1161,8 +1161,8 @@ if ( !empty($next) ) $post_id_ary[] = $row['post_id']; } - $sql = "UPDATE " . POSTS_TABLE . " - SET poster_id = " . ANONYMOUS . ", enable_sig = 0 + $sql = "UPDATE " . POSTS_TABLE . " + SET poster_id = " . ANONYMOUS . ", enable_sig = 0 WHERE post_id IN (" . implode(", ", $post_id_ary) . ")"; query($sql, "Couldn't update posts to remove deleted user poster_id values"); } @@ -1172,7 +1172,7 @@ if ( !empty($next) ) end_step('convert_privmsgs'); case 'convert_privmsgs': - $sql = "SELECT COUNT(*) as total, max(msg_id) as maxid + $sql = "SELECT COUNT(*) as total, max(msg_id) as maxid FROM " . PRIVMSGS_TABLE; $result = query($sql, "Couldn't get max privmsgs_id."); @@ -1181,7 +1181,7 @@ if ( !empty($next) ) $totalposts = $maxid['total']; $maxid = $maxid['maxid']; - $sql = "ALTER TABLE " . PRIVMSGS_TABLE . " + $sql = "ALTER TABLE " . PRIVMSGS_TABLE . " ADD privmsgs_subject VARCHAR(255), ADD privmsgs_attach_sig TINYINT(1) DEFAULT 1"; query($sql, "Couldn't add privmsgs_subject field to " . PRIVMSGS_TABLE . " table"); @@ -1191,14 +1191,14 @@ if ( !empty($next) ) { $batchstart = $i + 1; $batchend = $i + $batchsize; - + print " * Converting Private Message ( $batchstart to $batchend ) :: "; flush(); - $sql = "SELECT * + $sql = "SELECT * FROM " . PRIVMSGS_TABLE . " - WHERE msg_id - BETWEEN $batchstart + WHERE msg_id + BETWEEN $batchstart AND $batchend"; $result = query($sql, "Couldn't get " . POSTS_TEXT_TABLE . " post_id $batchstart to $batchend"); @@ -1228,7 +1228,7 @@ if ( !empty($next) ) // do 2.x first-pass encoding.. $row['msg_text'] = smiley_replace($row['msg_text']); $row['msg_text'] = bbencode_first_pass($row['msg_text'], $uid); - + $checksig = preg_replace('/\[addsig\]$/', '', $row['msg_text']); $enable_sig = (strlen($checksig) == strlen($row['msg_text'])) ? 0 : 1; @@ -1239,20 +1239,20 @@ if ( !empty($next) ) } $row['msg_text'] = $checksig; - + $row['msg_status'] = ($row['msg_status'] == 1) ? PRIVMSGS_READ_MAIL : PRIVMSGS_NEW_MAIL; // Subject contains first 60 characters of msg, remove any BBCode tags $subject = addslashes(strip_tags(substr($row['msg_text'], 0, 60))); $subject = preg_replace("/\[.*?\:(([a-z0-9]:)?)$uid.*?\]/si", "", $subject); - + $row['msg_text'] = addslashes($row['msg_text']); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) VALUES ('" . $row['msg_id'] . "', '$uid', '" . $row['msg_text'] . "')"; query($sql, "Couldn't insert PrivMsg text into " . PRIVMSGS_TEXT_TABLE . " table msg_id " . $row['msg_id']); - $sql = "UPDATE " . PRIVMSGS_TABLE . " + $sql = "UPDATE " . PRIVMSGS_TABLE . " SET msg_text = NULL, msg_status = " . $row['msg_status'] . ", privmsgs_subject = '$subject', privmsgs_attach_sig = $enable_sig WHERE msg_id = " . $row['msg_id']; query($sql, "Couldn't update " . PRIVMSGS_TABLE . " table for msg_id " . $row['post_id']); @@ -1273,16 +1273,16 @@ if ( !empty($next) ) end_step('convert_moderators'); case 'convert_moderators'; - $sql = "SELECT * + $sql = "SELECT * FROM forum_mods"; $result = query($sql, "Couldn't get list with all forum moderators"); while( $row = $db->sql_fetchrow($result) ) { // Check if this moderator and this forum still exist - $sql = "SELECT user_id - FROM " . USERS_TABLE . ", " . FORUMS_TABLE . " - WHERE user_id = " . $row['user_id'] . " + $sql = "SELECT user_id + FROM " . USERS_TABLE . ", " . FORUMS_TABLE . " + WHERE user_id = " . $row['user_id'] . " AND forum_id = " . $row['forum_id']; $check_data = query($sql, "Couldn't check if user " . $row['user_id'] . " and forum " . $row['forum_id'] . " exist"); @@ -1292,9 +1292,9 @@ if ( !empty($next) ) continue; } - $sql = "SELECT g.group_id - FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug - WHERE g.group_id = ug.group_id + $sql = "SELECT g.group_id + FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug + WHERE g.group_id = ug.group_id AND ug.user_id = " . $row['user_id'] . " AND g.group_single_user = 1"; $insert_group = query($sql, "Couldn't get group number for user " . $row['user_id'] . "."); @@ -1314,11 +1314,11 @@ if ( !empty($next) ) print " * Setting correct user_level for moderators ::"; flush(); - $sql = "SELECT DISTINCT u.user_id - FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa - WHERE aa.auth_mod = 1 - AND ug.group_id = aa.group_id - AND u.user_id = ug.user_id + $sql = "SELECT DISTINCT u.user_id + FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa + WHERE aa.auth_mod = 1 + AND ug.group_id = aa.group_id + AND u.user_id = ug.user_id AND u.user_level <> " . ADMIN; $result = query($sql, "Couldn't obtain list of moderators"); @@ -1332,20 +1332,20 @@ if ( !empty($next) ) } while ( $row = $db->sql_fetchrow($result) ); - $sql = "UPDATE " . USERS_TABLE . " - SET user_level = " . MOD . " + $sql = "UPDATE " . USERS_TABLE . " + SET user_level = " . MOD . " WHERE user_id IN ($ug_sql)"; query($sql, "Couldn't set moderator status for users"); } print "<span class=\"ok\"><b>OK</b></span><br />\n"; - + end_step('convert_privforums'); case 'convert_privforums': - $sql = "SELECT fa.*, f.forum_name - FROM forum_access fa - LEFT JOIN " . FORUMS_TABLE . " f ON fa.forum_id = f.forum_id + $sql = "SELECT fa.*, f.forum_name + FROM forum_access fa + LEFT JOIN " . FORUMS_TABLE . " f ON fa.forum_id = f.forum_id ORDER BY fa.forum_id, fa.user_id"; $forum_access = query($sql, "Couldn't get list with special forum access (forum_access)"); @@ -1407,8 +1407,8 @@ if ( !empty($next) ) "user_interests" => "user_intrest", "user_allowsmile" => "user_desmile", "user_allowhtml" => "user_html", - "user_allowbbcode" => "user_bbcode", - "user_style" => "user_theme" + "user_allowbbcode" => "user_bbcode", + "user_style" => "user_theme" ), $table_prefix . "privmsgs" => array( "privmsgs_id" => "msg_id", @@ -1416,7 +1416,7 @@ if ( !empty($next) ) "privmsgs_to_userid" => "to_userid", "privmsgs_date" => "msg_time", "privmsgs_ip" => "poster_ip", - "privmsgs_type" => "msg_status" + "privmsgs_type" => "msg_status" ), $table_prefix . "smilies" => array( "smilies_id" => "id" @@ -1434,8 +1434,8 @@ if ( !empty($next) ) // Loop fields in table print " * Updating table '$table' :: "; flush(); - - $sql = "SHOW FIELDS + + $sql = "SHOW FIELDS FROM $table"; $result = query($sql, "Can't get definition of current $table table"); @@ -1443,7 +1443,7 @@ if ( !empty($next) ) { $current_fields[] = $row['Field']; } - + $alter_sql = "ALTER TABLE $table "; while (list($field, $definition) = each($table_def)) { @@ -1466,7 +1466,7 @@ if ( !empty($next) ) if ( !inarray($field, $current_fields) && $oldfield == $field ) { - // If the current is not a key of $current_def and it is not a field that is + // 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[] = " ADD $field " . $create_def[$table][$field]; } @@ -1475,12 +1475,12 @@ if ( !empty($next) ) $changes[] = " CHANGE $oldfield $field " . $create_def[$table][$field]; } } - + $alter_sql .= join(',', $changes); unset($changes); unset($current_fields); - - $sql = "SHOW INDEX + + $sql = "SHOW INDEX FROM $table"; $result = query($sql, "Couldn't get list of indices for table $table"); @@ -1490,7 +1490,7 @@ if ( !empty($next) ) { $indices[] = $row['Key_name']; } - + while ( list($key_name, $key_field) = each($key_def[$table]) ) { if ( !inarray($key_name, $indices) ) @@ -1500,14 +1500,14 @@ if ( !empty($next) ) } query($alter_sql, "Couldn't alter table $table"); - print "<span class=\"ok\"><b>OK</b></span><br />\n"; + flush(); } end_step('convert_forums'); case 'convert_forums': - $sql = "SELECT * + $sql = "SELECT * FROM " . FORUMS_TABLE; $result = query($sql, "Couldn't get list with all forums"); @@ -1556,7 +1556,7 @@ if ( !empty($next) ) $auth_announce = AUTH_MOD; break; } - + // Old auth structure: // forum_type: (only concerns viewing) // 0 = Public @@ -1569,7 +1569,7 @@ if ( !empty($next) ) break; default: // - // Make it really private ... + // Make it really private ... // $auth_view = AUTH_ACL; $auth_read = AUTH_ACL; @@ -1638,7 +1638,7 @@ if ( !empty($next) ) // // Fetch a batch of posts_text entries // - $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id + $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id FROM " . POSTS_TEXT_TABLE; $result = query($sql, "Couldn't get post count totals"); @@ -1662,11 +1662,11 @@ if ( !empty($next) ) print " * Fulltext Indexing ( $batchstart to $batchend ) :: "; flush(); - + $sql = "SELECT * FROM " . POSTS_TEXT_TABLE ." - WHERE post_id - BETWEEN $batchstart + WHERE post_id + BETWEEN $batchstart AND $batchend"; $posts_result = query($sql, "Couldn't obtain post_text"); @@ -1674,7 +1674,7 @@ if ( !empty($next) ) $inc = 0; if ( $row = $db->sql_fetchrow($posts_result) ) - { + { do { add_search_words($row['post_id'], $row['post_text'], $row['post_subject']); @@ -1691,7 +1691,7 @@ if ( !empty($next) ) } $db->sql_freeresult($posts_result); - + // Remove common words after the first 2 batches and after every 4th batch after that. if ( $batchcount % 4 == 3 ) { @@ -1704,7 +1704,7 @@ if ( !empty($next) ) end_step('update_topics'); case 'update_topics': - $sql = "SELECT MAX(topic_id) AS max_topic + $sql = "SELECT MAX(topic_id) AS max_topic FROM " . TOPICS_TABLE; $result = query($sql, "Couldn't get max topic id"); @@ -1719,16 +1719,16 @@ if ( !empty($next) ) { $batchstart = $i + 1; $batchend = $i + $batchsize; - + print " * Setting topic first post_id ( $batchstart to $batchend ) :: "; flush(); $sql = "SELECT MIN(post_id) AS first_post_id, topic_id FROM " . POSTS_TABLE . " - WHERE topic_id - BETWEEN $batchstart - AND $batchend - GROUP BY topic_id + WHERE topic_id + BETWEEN $batchstart + AND $batchend + GROUP BY topic_id ORDER BY topic_id ASC"; $result = query($sql, "Couldn't get post id data"); @@ -1739,8 +1739,8 @@ if ( !empty($next) ) { do { - $sql = "UPDATE " . TOPICS_TABLE . " - SET topic_first_post_id = " . $row['first_post_id'] . " + $sql = "UPDATE " . TOPICS_TABLE . " + SET topic_first_post_id = " . $row['first_post_id'] . " WHERE topic_id = " . $row['topic_id']; query($sql, "Couldn't update topic first post id in topic :: $topic_id"); @@ -1765,7 +1765,7 @@ if ( !empty($next) ) // // Update forum last post information // - $sql = "SELECT forum_id, forum_name + $sql = "SELECT forum_id, forum_name FROM " . FORUMS_TABLE; $f_result = query($sql, "Couldn't obtain forum_ids"); @@ -1809,7 +1809,7 @@ if ( !empty($next) ) $sql = "SELECT COUNT(topic_id) AS total FROM " . TOPICS_TABLE . " - WHERE forum_id = $id + WHERE forum_id = $id AND topic_status <> " . TOPIC_MOVED; $result = query($sql, "Could not get topic count forum post information :: $id"); @@ -1836,38 +1836,38 @@ if ( !empty($next) ) // // Update the default admin user with their information. // - $sql = "SELECT MIN(user_regdate) AS oldest_time - FROM " . USERS_TABLE . " + $sql = "SELECT MIN(user_regdate) AS oldest_time + FROM " . USERS_TABLE . " WHERE user_regdate > 0 AND user_id > 0"; $result = query($sql, "Couldn't obtain oldest post time"); $row = $db->sql_fetchrow($result); - $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) + $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value) VALUES ('board_startdate', " . $row['oldest_time'] . ")"; query($sql, "Couldn't insert board_startdate"); - $sql = "UPDATE " . $table_prefix . "config - SET config_value = '" . $server_name . "' - WHERE config_name = 'server_name' + $sql = "UPDATE " . $table_prefix . "config + SET config_value = '" . $server_name . "' + WHERE config_name = 'server_name' OR config_name = 'cookie_domain'"; query($sql, "Couldn't insert Board Server domain"); - $sql = "UPDATE " . $table_prefix . "config + $sql = "UPDATE " . $table_prefix . "config SET config_value = '" . $server_port . "' WHERE config_name = 'server_port'"; query($sql, "Couldn't insert Board server port"); - - $sql = "UPDATE " . $table_prefix . "config + + $sql = "UPDATE " . $table_prefix . "config SET config_value = '" . $board_email . "' WHERE config_name = 'board_email'"; query($sql, "Couldn't insert Board admin email"); - - $sql = "UPDATE " . $table_prefix . "config + + $sql = "UPDATE " . $table_prefix . "config SET config_value = '" . $script_path . "' WHERE config_name = 'script_path'"; query($sql, "Couldn't insert Board admin email"); - + // // Change session table to HEAP if MySQL version matches // @@ -1880,7 +1880,7 @@ if ( !empty($next) ) if ( preg_match("/^(3\.23)|(4\.)/", $version) ) { - $sql = "ALTER TABLE " . $table_prefix . "sessions + $sql = "ALTER TABLE " . $table_prefix . "sessions TYPE=HEAP"; $db->sql_query($sql); } @@ -1891,9 +1891,9 @@ if ( !empty($next) ) case 'drop_fields': $fields = array( BANLIST_TABLE => array("ban_start", "ban_end", "ban_time_type"), - FORUMS_TABLE => array("forum_access", "forum_moderator", "forum_type"), - PRIVMSGS_TABLE => array("msg_text"), - RANKS_TABLE => array("rank_max"), + FORUMS_TABLE => array("forum_access", "forum_moderator", "forum_type"), + PRIVMSGS_TABLE => array("msg_text"), + RANKS_TABLE => array("rank_max"), SMILIES_TABLE => array("emotion"), TOPICS_TABLE => array("topic_notify") ); @@ -1905,7 +1905,7 @@ if ( !empty($next) ) print " * Drop field '" . $field_data[$i] . "' in '$table' :: "; flush(); - $sql = "ALTER TABLE $table + $sql = "ALTER TABLE $table DROP COLUMN " . $field_data[$i]; query($sql, "Couldn't drop field :: " . $field_data[$i] . " from table :: $table"); |