[Phpbb-php5mod-cvs-checkins] phpbb-php5/install update_to_20225.php, NONE, 1.1
Brought to you by:
jelly_doughnut
From: Josh <jel...@us...> - 2006-12-23 23:26:53
|
Update of /cvsroot/phpbb-php5mod/phpbb-php5/install In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24137/install_ Added Files: update_to_20225.php Log Message: 2.0.22.5 --- NEW FILE: update_to_20225.php --- <?php /*************************************************************************** * update_to_20xy.php * ------------------- * begin : Friday, Nov. * copyright : (C) 2005 phpBB-php5 * email : n/a * * $Id: update_to_20225.php,v 1.1 2006/12/23 23:26:52 jelly_doughnut Exp $ * * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ // This script is basically phpBB's update_to_20x.php // Except it doesn't have information to upgrade from ancient versions. function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { global $db; if (is_array($sql) && sizeof($sql)) { foreach ($sql as $query) { if (!($result = $db->sql_query($query))) { $errored = true; $error_ary['sql'][] = (is_array($query)) ? $query[$i] : $query; $error_ary['error_code'][] = $db->sql_error(); } } } else { if (!($result = $db->sql_query($sql))) { $errored = true; $error_ary['sql'][] = (is_array($sql)) ? $sql[$i] : $sql; $error_ary['error_code'][] = $db->sql_error(); } } if ($echo_dot) { echo ". \n"; flush(); } return $result; } @set_time_limit(120); define('IN_PHPBB', 1); $phpbb_root_path = './../'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'config.'.$phpEx); if(!isset($dbms)) { die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update."); } include($phpbb_root_path . 'includes/constants.'.$phpEx); include($phpbb_root_path . 'includes/functions.'.$phpEx); include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); include($phpbb_root_path . 'includes/functions_search.'.$phpEx); include($phpbb_root_path . 'includes/db.'.$phpEx); // // // $updates_to_version = ".0.22"; $update_php5mod_version = ".0.22.5"; // // // ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"> <!-- font,th,td,p,body { font-family: "Courier New", courier; font-size: 11pt } a:link,a:active,a:visited { color : #006699; } a:hover { text-decoration: underline; color : #DD6900;} hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;} .maintitle,h1,h2 {font-weight: bold; font-size: 22px; font-family: "Trebuchet MS",Verdana, Arial, Helvetica, sans-serif; text-decoration: none; line-height : 120%; color : #000000;} .ok {color:green} /* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */ @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"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="../templates/subSilver/images/logo_phpBB.gif" border="0" alt="Forum Home" vspace="1" /></td> <td align="center" width="100%" valign="middle"><span class="maintitle">Updating to latest stable release</span></td> </tr> </table></td> </tr> </table> <br clear="all" /> <h2>Information</h2> <?php echo '<p>Database type :: <b>' . SQL_LAYER . '</b><br />'; $sql = "SELECT config_value FROM " . CONFIG_TABLE . " WHERE config_name = 'version'"; if (!($result = $db->sql_query($sql))) { die("Couldn't obtain version info"); } $row = $db->sql_fetchrow($result); $sql = array(); echo 'Previous version :: <b>2' . $row['config_value'] . '</b><br />'; echo 'Updated version :: <b>2' . $updates_to_version . '</b></p>' ."\n"; echo "<h2>Updating database schema</h2>\n"; echo "<p>Progress :: <b>"; flush(); // // Data updates // unset($sql); $error_ary = array(); $errored = false; echo "<h2>Updating data</h2>\n"; echo "<p>Progress :: <b>"; flush(); if ($row['config_value'] < '.0.14'); { $sql[] = 'ALTER TABLE ' . SESSIONS_TABLE . ' ADD session_admin int(1)'; switch (SQL_LAYER) { case 'mysql': case 'mysql4': $sql[] = 'CREATE TABLE ' . $table_prefix . 'sessions_keys (key_id varchar(32) DEFAULT \'0\' NOT NULL, user_id mediumint(8) DEFAULT \'0\' NOT NULL, last_ip varchar(8) DEFAULT \'0\' NOT NULL, last_login int(11) DEFAULT \'0\' NOT NULL, PRIMARY KEY (key_id, user_id), KEY last_login (last_login))'; break; case 'mssql': case 'mssql-odbc': $sql[] = 'CREATE TABLE [' . $table_prefix . 'sessions_keys] ([key_id] [char] (32) NOT NULL , [user_id] [int] NOT NULL , [last_ip] [char] (8) NOT NULL , [last_login] [int] NOT NULL) ON [PRIMARY]'; $sql[] = 'CREATE INDEX [IX_' . $table_prefix . 'sessions_keys] ON [' . $table_prefix . 'sessions_keys]([key_id], [user_id]) ON [PRIMARY]'; $sql[] = 'CREATE INDEX [IX_' . $table_prefix . 'sessions_keys] ON [' . $table_prefix . 'sessions_keys]([last_login]) ON [PRIMARY]'; break; case 'msaccess': $sql[] = 'CREATE TABLE ' . $table_prefix . 'sessions_keys (key_id char(32) NOT NULL, user_id int NOT NULL, last_ip char(8) NOT NULL, last_login int NOT NULL)'; $sql[] = 'ALTER TABLE ' . $table_prefix . 'sessions_keys ADD PRIMARY KEY (key_id, user_id)'; break; case 'postgresql': $sql[] = 'CREATE TABLE ' . $table_prefix . 'sessions_keys (key_id char(32) DEFAULT \'0\' NOT NULL, user_id int4 DEFAULT \'0\' NOT NULL, last_ip char(8) DEFAULT \'0\' NOT NULL, last_login int4 DEFAULT \'0\' NOT NULL, CONSTRAINT ' . $table_prefix . 'sessions_keys_pkey PRIMARY KEY (key_id, user_id))'; $sql[] = 'CREATE INDEX last_login_' . $table_prefix . 'sessions_keys_index ON ' . $table_prefix . 'sessions_keys (last_login)'; break; } _sql($sql, $errored, $error_ary); $sql = array(); $sql[] = 'UPDATE ' . USERS_TABLE . ' SET user_active = 0 WHERE user_id = ' . ANONYMOUS; $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('allow_autologin', '1')"; $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('max_autologin_time', '0')"; _sql($sql, $errored, $error_ary); $sql = array(); } if ($row['config_value'] < '.0.17') { switch (SQL_LAYER) { case 'mysql': case 'mysql4': $sql[] = 'CREATE TABLE ' . $table_prefix . 'sessions_keys (key_id varchar(32) DEFAULT \'0\' NOT NULL, user_id mediumint(8) DEFAULT \'0\' NOT NULL, last_ip varchar(8) DEFAULT \'0\' NOT NULL, last_login int(11) DEFAULT \'0\' NOT NULL, PRIMARY KEY (key_id, user_id), KEY last_login (last_login))'; break; case 'mssql': case 'mssql-odbc': $sql[] = 'CREATE TABLE [' . $table_prefix . 'sessions_keys] ([key_id] [char] (32) NOT NULL , [user_id] [int] NOT NULL , [last_ip] [char] (8) NOT NULL , [last_login] [int] NOT NULL) ON [PRIMARY]'; $sql[] = 'CREATE INDEX [IX_' . $table_prefix . 'sessions_keys] ON [' . $table_prefix . 'sessions_keys]([key_id], [user_id]) ON [PRIMARY]'; $sql[] = 'CREATE INDEX [IX_' . $table_prefix . 'sessions_keys] ON [' . $table_prefix . 'sessions_keys]([last_login]) ON [PRIMARY]'; break; case 'msaccess': $sql[] = 'CREATE TABLE ' . $table_prefix . 'sessions_keys (key_id char(32) NOT NULL, user_id int NOT NULL, last_ip char(8) NOT NULL, last_login int NOT NULL)'; $sql[] = 'ALTER TABLE ' . $table_prefix . 'sessions_keys ADD PRIMARY KEY (key_id, user_id)'; break; case 'postgresql': $sql[] = 'CREATE TABLE ' . $table_prefix . 'sessions_keys (key_id char(32) DEFAULT \'0\' NOT NULL, user_id int4 DEFAULT \'0\' NOT NULL, last_ip char(8) DEFAULT \'0\' NOT NULL, last_login int4 DEFAULT \'0\' NOT NULL, CONSTRAINT ' . $table_prefix . 'sessions_keys_pkey PRIMARY KEY (key_id, user_id))'; $sql[] = 'CREATE INDEX last_login_' . $table_prefix . 'sessions_keys_index ON ' . $table_prefix . 'sessions_keys (last_login)'; break; } _sql($sql, $errored, $error_ary); $sql[] = 'UPDATE ' . USERS_TABLE . ' SET user_active = 0 WHERE user_id = ' . ANONYMOUS; $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('allow_autologin', '1')"; $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('max_autologin_time', '0')"; _sql($sql, $errored, $error_ary); } if ($row['version'] < '.0.19') { $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('max_login_attempts', '5')"; $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('login_reset_time', '30')"; // Add login columns to user table switch (SQL_LAYER) { case 'mysql': case 'mysql4': case 'mysqli': $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD COLUMN user_login_tries smallint(5) UNSIGNED DEFAULT '0' NOT NULL"; $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD COLUMN user_last_login_try int(11) DEFAULT '0' NOT NULL"; break; case 'postgresql': $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD COLUMN user_login_tries int2"; $sql[] = "ALTER TABLE " . USERS_TABLE . " ALTER COLUMN user_login_tries SET DEFAULT '0'"; $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD COLUMN user_last_login_try int4"; $sql[] = "ALTER TABLE " . USERS_TABLE . " ALTER COLUMN user_last_login_try SET DEFAULT '0'"; break; case 'mssql-odbc': case 'mssql': $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD user_login_tries smallint NOT NULL, CONSTRAINT [DF_" . $table_prefix . "users_user_login_tries] DEFAULT (0) FOR [user_login_tries]"; $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD user_last_login_try int NOT NULL, CONSTRAINT [DF_" . $table_prefix . "users_user_last_login_try] DEFAULT (0) FOR [user_last_login_try]"; break; case 'msaccess': $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD user_login_tries smallint NOT NULL"; $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD user_last_login_try int NOT NULL"; break; } _sql($sql, $errored, $error_ary); $sql = array(); } if ($row['version'] < '.0.20') { $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('search_flood_interval', '15')"; $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('rand_seed', '0')"; _sql($sql, $errored, $error_ary); $sql = array(); } if ($row['version'] < '.0.21') { $sql[] = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('search_min_chars', '3')"; // We reset those having autologin enabled and forcing the re-assignment of a session id // since there have been changes to the way these are handled from previous versions $sql[] = 'DELETE FROM ' . SESSIONS_TABLE; $sql[] = 'DELETE FROM ' . SESSIONS_KEYS_TABLE; _sql($sql, $errored, $error_ary); $sql = array(); } else { echo " No updates were required</b></p>\n"; } echo "<h2>Updating version and optimizing tables</h2>\n"; echo "<p>Progress :: <b>"; flush(); // update the version $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '$updates_to_version' WHERE config_name = 'version'"; _sql($sql, $errored, $error_ary); $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '$update_php5mod_version' WHERE config_name = 'version5'"; _sql($sql, $errored, $error_ary); // Optimize/vacuum analyze the tables where appropriate // this should be done for each version in future along with // the version number update switch (SQL_LAYER) { case 'mysql': case 'mysql4': case 'mysqli': $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; _sql($sql, $errored, $error_ary); break; case 'postgresql': $sql = 'VACCUUM ANALYZE'; _sql($sql, $errored, $error_ary); break; } echo "</b> <b class=\"ok\">Done</b><br />Result :: \n"; if ($errored) { echo " <b>Some queries failed, the statements and errors are listing below</b>\n<ul>"; for ($i = 0; $i < count($error_ary['sql']); $i++) { echo "<li>Error :: <b>" . $error_ary['error_code'][$i]['message'] . "</b><br />"; echo "SQL :: <b>" . $error_ary['sql'][$i] . "</b><br /><br /></li>"; } echo "</ul>\n<p>This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See <a href=\"docs\README.html\">README</a> for details on how to obtain advice.</p>\n"; } else { echo "<b>No errors</b>\n"; } echo "<h2>Update completed</h2>\n"; echo "\n<p>You should now visit the General Configuration settings page in the <a href=\"../admin/\">Administration Panel</a> and check the General Configuration of the board. If you updated from versions prior to RC-3 you <b>must</b> update some entries. If you do not do this emails sent from the board will contain incorrect information. Don't forget to delete this file!</p>\n"; ?> <br clear="all" /> </body> </html> |