⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update_to_204.php

📁 这是php编的论坛的原代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
/***************************************************************************
 *                             update_to_xxx.php
 *                            -------------------
 *   begin                : Wednesday, May 16, 2002
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: update_to_204.php,v 1.1.1.1 2003/02/11 22:27:33 wei.gao 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.
 *
 ***************************************************************************/

function _sql($sql, &$errored, &$error_ary, $echo_dot = true)
{
	global $db;

	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.4";
//
//
//

?>
<!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 &nbsp; &nbsp;:: <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();

switch ($row['config_value'])
{
	case '':
		echo 'Previous version :: <b>&lt; RC-3</b></p><br />';
		break;
	case 'RC-3':
		echo 'Previous version :: <b>RC-3</b></p><br />';
		break;
	case 'RC-4':
		echo 'Previous version :: <b>RC-4</b></p><br />';
		break;
	default:
		echo 'Previous version :: <b>2' . $row['config_value'] . '</b><br />';
		break;
}

echo 'Updated version &nbsp;:: <b>2' . $updates_to_version . '</b></p>' ."\n";

//
// Schema updates
//
switch ($row['config_value'])
{
	case '':
		switch (SQL_LAYER)
		{
			case 'mysql':
			case 'mysql4':
				$sql[] = "ALTER TABLE " . USERS_TABLE . " DROP
					COLUMN user_autologin_key";

				$sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP
					COLUMN rank_max";

				$sql[] = "ALTER TABLE " . USERS_TABLE . "
					ADD COLUMN user_session_time int(11) DEFAULT '0' NOT NULL,
					ADD COLUMN user_session_page smallint(5) DEFAULT '0' NOT NULL,
					ADD INDEX (user_session_time)";
				$sql[] = "ALTER TABLE " . SEARCH_TABLE . "
					MODIFY search_id int(11) NOT NULL";

				$sql[] = "ALTER TABLE " . TOPICS_TABLE . "
					MODIFY topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					ADD COLUMN topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					ADD INDEX (topic_first_post_id)";

				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN tr_class1_name varchar(50) NULL,
					ADD COLUMN tr_class2_name varchar(50) NULL,
					ADD COLUMN tr_class3_name varchar(50) NULL,
					ADD COLUMN th_class1_name varchar(50) NULL,
					ADD COLUMN th_class2_name varchar(50) NULL,
					ADD COLUMN th_class3_name varchar(50) NULL,
					ADD COLUMN td_class1_name varchar(50) NULL,
					ADD COLUMN td_class2_name varchar(50) NULL,
					ADD COLUMN td_class3_name varchar(50) NULL,
					ADD COLUMN span_class1_name varchar(50) NULL,
					ADD COLUMN span_class2_name varchar(50) NULL,
					ADD COLUMN span_class3_name varchar(50) NULL";
				break;
			case 'postgresql':
				$sql[] = "ALTER TABLE " . USERS_TABLE . "
					ADD COLUMN user_session_time int4";
				$sql[] = "ALTER TABLE " . USERS_TABLE . "
					ADD COLUMN user_session_page int2";
				$sql[] = "ALTER TABLE " . USERS_TABLE . "
					ALTER COLUMN user_session_time SET DEFAULT '0'";
				$sql[] = "ALTER TABLE " . USERS_TABLE . "
					ALTER COLUMN user_session_page SET DEFAULT '0'";
				$sql[] = "CREATE INDEX user_session_time_" . $table_prefix . "users_index
					ON " . USERS_TABLE . " (user_session_time)";

				$sql[] = "ALTER TABLE " . TOPICS_TABLE . "
					ADD COLUMN topic_first_post_id int4";
				$sql[] = "CREATE INDEX topic_first_post_id_" . $table_prefix . "topics_index
					ON " . TOPICS_TABLE . " (topic_first_post_id)";

				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN tr_class1_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN tr_class2_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN tr_class3_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN th_class1_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN th_class2_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN th_class3_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN td_class1_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN td_class2_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN td_class3_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN span_class1_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN span_class2_name varchar(50) NULL";
				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
					ADD COLUMN span_class3_name varchar(50) NULL";
				break;

			case 'mssql-odbc':
			case 'mssql':
				$sql[] = "ALTER TABLE " . USERS_TABLE . " DROP
					COLUMN user_autologin_key";

				$sql[] = "ALTER TABLE " . USERS_TABLE . " ADD
					user_session_time int NOT NULL,
					user_session_page smallint NOT NULL,
					CONSTRAINT [DF_" . $table_prefix . "users_user_session_time] DEFAULT (0) FOR [user_session_time],
					CONSTRAINT [DF_" . $table_prefix . "users_user_session_page] DEFAULT (0) FOR [user_session_page]";
				$sql[] = "CREATE INDEX [IX_" . $table_prefix . "users]
					ON [" . USERS_TABLE . "]([user_session_time]) ON [PRIMARY]";

				/* ---------------------------------------------------------------------
					DROP FORUM TABLE -- if this may cause you problems you can safely
					comment it out, remember to manually remove the IDENTITY setting on
					the forum_id column
				   --------------------------------------------------------------------- */
				$sql [] = "ALTER TABLE " . FORUMS_TABLE . " DROP
					CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts],
					CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics],
					CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id],
					CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_view],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_read],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_post],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments]";
				$sql[] = "CREATE TABLE Tmp_" . FORUMS_TABLE . "
					(forum_id int NOT NULL, cat_id int NOT NULL, forum_name varchar(100) NOT NULL, forum_desc varchar(255) NULL, forum_status smallint NOT NULL, forum_order int NOT NULL, forum_posts int NOT NULL, forum_topics smallint NOT NULL, forum_last_post_id int NOT NULL, prune_next int NULL, prune_enable smallint NOT NULL, auth_view smallint NOT NULL, auth_read smallint NOT NULL, auth_post smallint NOT NULL, auth_reply smallint NOT NULL, auth_edit smallint NOT NULL, auth_delete smallint NOT NULL,	auth_sticky smallint NOT NULL, auth_announce smallint NOT NULL, auth_vote smallint NOT NULL, auth_pollcreate smallint NOT NULL, auth_attachments smallint NOT NULL) ON [PRIMARY]";
				$sql[] = "ALTER TABLE [Tmp_" . FORUMS_TABLE . "] WITH NOCHECK ADD
					CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts] DEFAULT (0) FOR [forum_posts],
					CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics] DEFAULT (0) FOR [forum_topics],
					CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id] DEFAULT (0) FOR [forum_last_post_id],
					CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable] DEFAULT (0) FOR [prune_enable],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_view] DEFAULT (0) FOR [auth_view],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_read] DEFAULT (0) FOR [auth_read],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_post] DEFAULT (0) FOR [auth_post],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply] DEFAULT (0) FOR [auth_reply],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit] DEFAULT (0) FOR [auth_edit],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete] DEFAULT (0) FOR [auth_delete],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky] DEFAULT (0) FOR [auth_sticky],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce] DEFAULT (0) FOR [auth_announce],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote] DEFAULT (0) FOR [auth_vote],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate] DEFAULT (0) FOR [auth_pollcreate],
					CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments] DEFAULT (0) FOR [auth_attachments]";
				$sql[] = "INSERT INTO Tmp_" . FORUMS_TABLE . " (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments)
						SELECT forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments FROM " . FORUMS_TABLE . " TABLOCKX";
				$sql[] = "DROP TABLE " . FORUMS_TABLE;
				$sql[] = "EXECUTE sp_rename N'Tmp_" . FORUMS_TABLE . "', N'" . FORUMS_TABLE . "', 'OBJECT'";
				$sql[] = "ALTER TABLE " . FORUMS_TABLE . " ADD
					CONSTRAINT [PK_" . $table_prefix . "forums] PRIMARY KEY CLUSTERED (forum_id) ON [PRIMARY]";
				$sql[] = "CREATE NONCLUSTERED INDEX [IX_" . $table_prefix . "forums]
					ON " . FORUMS_TABLE . " (cat_id, forum_order, forum_last_post_id) ON [PRIMARY]";
				/* --------------------------------------------------------------
					END OF DROP FORUM -- don't remove anything after this point!
				   -------------------------------------------------------------- */

				$sql[] = "DROP INDEX " . RANKS_TABLE . ".IX_" . $table_prefix . "ranks";
				$sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP
					COLUMN rank_max";
				$sql[] = "CREATE  INDEX [IX_" . $table_prefix . "ranks]
					ON [" . RANKS_TABLE . "]([rank_min], [rank_special]) ON [PRIMARY]";

				$sql[] = "DROP INDEX " . TOPICS_TABLE . ".IX_" . $table_prefix . "topics";
				$sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD
					topic_first_post_id int NULL,
					CONSTRAINT [DF_" . $table_prefix . "topics_topic_first_post_id] FOR [topic_first_post_id]";
				$sql[] = "CREATE  INDEX [IX_" . $table_prefix . "topics]
					ON [" . TOPICS_TABLE . "]([forum_id], [topic_type], [topic_first_post_id], [topic_last_post_id]) ON [PRIMARY]";

				$sql[] = "ALTER TABLE " . SEARCH_WORD_TABLE . " DROP
					CONSTRAINT [PK_" . $table_prefix . "search_wordlist]";
				$sql[] = "CREATE UNIQUE INDEX [IX_" . $table_prefix . "search_wordlist]
					ON [" . SEARCH_WORD_TABLE . "]([word_text]) WITH IGNORE_DUP_KEY ON [PRIMARY]";
				$sql[] = "CREATE  INDEX [IX_" . $table_prefix . "search_wordlist_1]
					ON [" . SEARCH_WORD_TABLE . "]([word_common]) ON [PRIMARY]";

				$sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordmatch_1]
					ON [" . SEARCH_MATCH_TABLE . "]([word_id]) ON [PRIMARY]";

				$sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD
					tr_class1_name varchar(50) NULL,
					tr_class2_name varchar(50) NULL,
					tr_class3_name varchar(50) NULL,
					th_class1_name varchar(50) NULL,
					th_class2_name varchar(50) NULL,
					th_class3_name varchar(50) NULL,
					td_class1_name varchar(50) NULL,
					td_class2_name varchar(50) NULL,
					td_class3_name varchar(50) NULL,
					span_class1_name varchar(50) NULL,
					span_class2_name varchar(50) NULL,
					span_class3_name varchar(50) NULL";
				break;

			case 'msaccess':
				$sql[] = "ALTER TABLE " . USERS_TABLE . " DROP
					COLUMN user_autologin_key";

				$sql[] = "ALTER TABLE " . USERS_TABLE . " ADD
					user_session_time int NOT NULL,
					user_session_page smallint NOT NULL";
				$sql[] = "CREATE INDEX user_session_time
					ON " . USERS_TABLE . " (user_session_time)";

				$sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD
					topic_first_post_id int NULL";
				$sql[] = "CREATE INDEX topic_first_post_id
					ON " . TOPICS_TABLE . " (topic_first_post_id)";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -