phpBB
Statistics
| Revision:

root / tags / release_2_0_1 / phpBB / update_to_201.php

History | View | Annotate | Download (24.3 kB)

1 2523 psotfx
<?php
2 2582 psotfx
/***************************************************************************
3 2582 psotfx
 *                             update_to_xxx.php
4 2582 psotfx
 *                            -------------------
5 2582 psotfx
 *   begin                : Wednesday, May 16, 2002
6 2582 psotfx
 *   copyright            : (C) 2001 The phpBB Group
7 2582 psotfx
 *   email                : support@phpbb.com
8 2582 psotfx
 *
9 2582 psotfx
 *   $Id$
10 2582 psotfx
 *
11 2582 psotfx
 ***************************************************************************/
12 2523 psotfx
13 2582 psotfx
/***************************************************************************
14 2582 psotfx
 *
15 2582 psotfx
 *   This program is free software; you can redistribute it and/or modify
16 2582 psotfx
 *   it under the terms of the GNU General Public License as published by
17 2582 psotfx
 *   the Free Software Foundation; either version 2 of the License, or
18 2582 psotfx
 *   (at your option) any later version.
19 2582 psotfx
 *
20 2582 psotfx
 ***************************************************************************/
21 2582 psotfx
22 2582 psotfx
function _sql($sql, &$errored, &$error_ary, $echo_dot = true)
23 2582 psotfx
{
24 2582 psotfx
        global $db;
25 2582 psotfx
26 2595 psotfx
        if( !($result = $db->sql_query($sql)) )
27 2582 psotfx
        {
28 2582 psotfx
                $errored = true;
29 2582 psotfx
                $error_ary['sql'][] = ( is_array($sql) ) ? $sql[$i] : $sql;
30 2582 psotfx
                $error_ary['error_code'][] = $db->sql_error();
31 2582 psotfx
        }
32 2582 psotfx
33 2582 psotfx
        if ( $echo_dot )
34 2582 psotfx
        {
35 2582 psotfx
                echo ".";
36 2582 psotfx
                flush();
37 2582 psotfx
        }
38 2582 psotfx
39 2595 psotfx
        return $result;
40 2582 psotfx
}
41 2582 psotfx
42 2523 psotfx
define('IN_PHPBB', 1);
43 2523 psotfx
$phpbb_root_path = './';
44 2523 psotfx
include($phpbb_root_path . 'extension.inc');
45 2523 psotfx
include($phpbb_root_path . 'config.'.$phpEx);
46 2523 psotfx
include($phpbb_root_path . 'includes/constants.'.$phpEx);
47 2523 psotfx
include($phpbb_root_path . 'includes/functions.'.$phpEx);
48 2580 psotfx
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
49 2523 psotfx
include($phpbb_root_path . 'includes/db.'.$phpEx);
50 2523 psotfx
51 2582 psotfx
//
52 2582 psotfx
//
53 2582 psotfx
//
54 2582 psotfx
$updates_to_version = ".0.1";
55 2582 psotfx
//
56 2582 psotfx
//
57 2582 psotfx
//
58 2523 psotfx
59 2582 psotfx
?>
60 2582 psotfx
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
61 2582 psotfx
<html>
62 2582 psotfx
<head>
63 2582 psotfx
<meta http-equiv="Content-Type" content="text/html;">
64 2582 psotfx
<meta http-equiv="Content-Style-Type" content="text/css">
65 2582 psotfx
<style type="text/css">
66 2582 psotfx
<!--
67 2579 psotfx
68 2582 psotfx
font,th,td,p,body { font-family: "Courier New", courier; font-size: 11pt }
69 2523 psotfx
70 2582 psotfx
a:link,a:active,a:visited { color : #006699; }
71 2582 psotfx
a:hover                { text-decoration: underline; color : #DD6900;}
72 2523 psotfx
73 2582 psotfx
hr        { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
74 2523 psotfx
75 2582 psotfx
.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;}
76 2523 psotfx
77 2582 psotfx
.ok {color:green}
78 2523 psotfx
79 2582 psotfx
/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */
80 2582 psotfx
@import url("templates/subSilver/formIE.css");
81 2582 psotfx
-->
82 2582 psotfx
</style>
83 2582 psotfx
</head>
84 2582 psotfx
<body bgcolor="#FFFFFF" text="#000000" link="#006699" vlink="#5584AA">
85 2523 psotfx
86 2582 psotfx
<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center">
87 2582 psotfx
        <tr>
88 2582 psotfx
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
89 2582 psotfx
                        <tr>
90 2582 psotfx
                                <td><img src="templates/subSilver/images/logo_phpBB.gif" border="0" alt="Forum Home" vspace="1" /></td>
91 2582 psotfx
                                <td align="center" width="100%" valign="middle"><span class="maintitle">Updating to latest stable  release</span></td>
92 2582 psotfx
                        </tr>
93 2582 psotfx
                </table></td>
94 2582 psotfx
        </tr>
95 2582 psotfx
</table>
96 2579 psotfx
97 2582 psotfx
<br clear="all" />
98 2580 psotfx
99 2582 psotfx
<h2>Information</h2>
100 2580 psotfx
101 2582 psotfx
<?php
102 2579 psotfx
103 2582 psotfx
echo '<p>Database type &nbsp; &nbsp;:: <b>' . SQL_LAYER . '</b><br />';
104 2579 psotfx
105 2582 psotfx
$sql = "SELECT config_value
106 2582 psotfx
        FROM " . CONFIG_TABLE . "
107 2582 psotfx
        WHERE config_name = 'version'";
108 2582 psotfx
if ( !($result = $db->sql_query($sql)) )
109 2582 psotfx
{
110 2582 psotfx
        die("Couldn't obtain version info");
111 2582 psotfx
}
112 2579 psotfx
113 2582 psotfx
$row = $db->sql_fetchrow($result);
114 2579 psotfx
115 2582 psotfx
$sql = array();
116 2580 psotfx
117 2582 psotfx
switch ( $row['config_value'] )
118 2582 psotfx
{
119 2582 psotfx
        case '':
120 2582 psotfx
                echo 'Previous version :: <b>&lt; RC-3</b></p><br />';
121 2582 psotfx
                break;
122 2582 psotfx
        case 'RC-3':
123 2582 psotfx
                echo 'Previous version :: <b>RC-3</b></p><br />';
124 2582 psotfx
                break;
125 2582 psotfx
        case 'RC-4':
126 2582 psotfx
                echo 'Previous version :: <b>RC-4</b></p><br />';
127 2582 psotfx
                break;
128 2582 psotfx
        default:
129 2582 psotfx
                echo 'Previous version :: <b>2' . $row['config_value'] . '</b><br />';
130 2582 psotfx
                break;
131 2523 psotfx
}
132 2523 psotfx
133 2582 psotfx
echo 'Updated version &nbsp;:: <b>2' . $updates_to_version . '</b></p>' ."\n";
134 2523 psotfx
135 2582 psotfx
switch ( $row['config_value'] )
136 2523 psotfx
{
137 2582 psotfx
        case '':
138 2582 psotfx
                switch ( SQL_LAYER )
139 2582 psotfx
                {
140 2582 psotfx
                        case 'mysql':
141 2582 psotfx
                        case 'mysql4':
142 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP
143 2582 psotfx
                                        COLUMN user_autologin_key";
144 2523 psotfx
145 2582 psotfx
                                $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP
146 2582 psotfx
                                        COLUMN rank_max";
147 2523 psotfx
148 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
149 2582 psotfx
                                        ADD COLUMN user_session_time int(11) DEFAULT '0' NOT NULL,
150 2582 psotfx
                                        ADD COLUMN user_session_page smallint(5) DEFAULT '0' NOT NULL,
151 2582 psotfx
                                        ADD INDEX (user_session_time)";
152 2582 psotfx
                                $sql[] = "ALTER TABLE " . SEARCH_TABLE . "
153 2582 psotfx
                                        MODIFY search_id int(11) NOT NULL";
154 2582 psotfx
155 2582 psotfx
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . "
156 2582 psotfx
                                        MODIFY topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
157 2582 psotfx
                                        ADD COLUMN topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
158 2582 psotfx
                                        ADD INDEX (topic_first_post_id)";
159 2523 psotfx
160 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
161 2582 psotfx
                                        ADD COLUMN tr_class1_name varchar(50) NULL,
162 2582 psotfx
                                        ADD COLUMN tr_class2_name varchar(50) NULL,
163 2582 psotfx
                                        ADD COLUMN tr_class3_name varchar(50) NULL,
164 2582 psotfx
                                        ADD COLUMN th_class1_name varchar(50) NULL,
165 2582 psotfx
                                        ADD COLUMN th_class2_name varchar(50) NULL,
166 2582 psotfx
                                        ADD COLUMN th_class3_name varchar(50) NULL,
167 2582 psotfx
                                        ADD COLUMN td_class1_name varchar(50) NULL,
168 2582 psotfx
                                        ADD COLUMN td_class2_name varchar(50) NULL,
169 2582 psotfx
                                        ADD COLUMN td_class3_name varchar(50) NULL,
170 2582 psotfx
                                        ADD COLUMN span_class1_name varchar(50) NULL,
171 2582 psotfx
                                        ADD COLUMN span_class2_name varchar(50) NULL,
172 2582 psotfx
                                        ADD COLUMN span_class3_name varchar(50) NULL";
173 2582 psotfx
                                break;
174 2523 psotfx
175 2582 psotfx
                        case 'postgresql':
176 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
177 2582 psotfx
                                        ADD COLUMN user_session_time int4";
178 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
179 2582 psotfx
                                        ADD COLUMN user_session_page int2";
180 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
181 2582 psotfx
                                        ALTER COLUMN user_session_time SET DEFAULT '0'";
182 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
183 2582 psotfx
                                        ALTER COLUMN user_session_page SET DEFAULT '0'";
184 2582 psotfx
                                $sql[] = "CREATE INDEX user_session_time_" . $table_prefix . "users_index
185 2582 psotfx
                                        ON " . USERS_TABLE . " (user_session_time)";
186 2523 psotfx
187 2582 psotfx
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . "
188 2582 psotfx
                                        ADD COLUMN topic_first_post_id int4";
189 2582 psotfx
                                $sql[] = "CREATE INDEX topic_first_post_id_" . $table_prefix . "topics_index
190 2582 psotfx
                                        ON " . TOPICS_TABLE . " (topic_first_post_id)";
191 2523 psotfx
192 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
193 2582 psotfx
                                        ADD COLUMN tr_class1_name varchar(50) NULL";
194 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
195 2582 psotfx
                                        ADD COLUMN tr_class2_name varchar(50) NULL";
196 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
197 2582 psotfx
                                        ADD COLUMN tr_class3_name varchar(50) NULL";
198 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
199 2582 psotfx
                                        ADD COLUMN th_class1_name varchar(50) NULL";
200 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
201 2582 psotfx
                                        ADD COLUMN th_class2_name varchar(50) NULL";
202 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
203 2582 psotfx
                                        ADD COLUMN th_class3_name varchar(50) NULL";
204 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
205 2582 psotfx
                                        ADD COLUMN td_class1_name varchar(50) NULL";
206 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
207 2582 psotfx
                                        ADD COLUMN td_class2_name varchar(50) NULL";
208 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
209 2582 psotfx
                                        ADD COLUMN td_class3_name varchar(50) NULL";
210 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
211 2582 psotfx
                                        ADD COLUMN span_class1_name varchar(50) NULL";
212 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
213 2582 psotfx
                                        ADD COLUMN span_class2_name varchar(50) NULL";
214 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . "
215 2582 psotfx
                                        ADD COLUMN span_class3_name varchar(50) NULL";
216 2582 psotfx
                                break;
217 2523 psotfx
218 2582 psotfx
                        case 'mssql-odbc':
219 2582 psotfx
                        case 'mssql':
220 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP
221 2582 psotfx
                                        COLUMN user_autologin_key";
222 2523 psotfx
223 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD
224 2582 psotfx
                                        user_session_time int NOT NULL,
225 2582 psotfx
                                        user_session_page smallint NOT NULL,
226 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "users_user_session_time] DEFAULT (0) FOR [user_session_time],
227 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "users_user_session_page] DEFAULT (0) FOR [user_session_page]";
228 2582 psotfx
                                $sql[] = "CREATE INDEX [IX_" . $table_prefix . "users]
229 2582 psotfx
                                        ON [" . USERS_TABLE . "]([user_session_time]) ON [PRIMARY]";
230 2523 psotfx
231 2582 psotfx
                                /* ---------------------------------------------------------------------
232 2582 psotfx
                                        DROP FORUM TABLE -- if this may cause you problems you can safely
233 2582 psotfx
                                        comment it out, remember to manually remove the IDENTITY setting on
234 2582 psotfx
                                        the forum_id column
235 2582 psotfx
                                   --------------------------------------------------------------------- */
236 2582 psotfx
                                $sql [] = "ALTER TABLE " . FORUMS_TABLE . " DROP
237 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts],
238 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics],
239 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id],
240 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable],
241 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_view],
242 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_read],
243 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_post],
244 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply],
245 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit],
246 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete],
247 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky],
248 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce],
249 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote],
250 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate],
251 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments]";
252 2582 psotfx
                                $sql[] = "CREATE TABLE Tmp_" . FORUMS_TABLE . "
253 2582 psotfx
                                        (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]";
254 2582 psotfx
                                $sql[] = "ALTER TABLE [Tmp_" . FORUMS_TABLE . "] WITH NOCHECK ADD
255 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts] DEFAULT (0) FOR [forum_posts],
256 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics] DEFAULT (0) FOR [forum_topics],
257 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id] DEFAULT (0) FOR [forum_last_post_id],
258 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable] DEFAULT (0) FOR [prune_enable],
259 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_view] DEFAULT (0) FOR [auth_view],
260 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_read] DEFAULT (0) FOR [auth_read],
261 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_post] DEFAULT (0) FOR [auth_post],
262 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply] DEFAULT (0) FOR [auth_reply],
263 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit] DEFAULT (0) FOR [auth_edit],
264 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete] DEFAULT (0) FOR [auth_delete],
265 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky] DEFAULT (0) FOR [auth_sticky],
266 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce] DEFAULT (0) FOR [auth_announce],
267 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote] DEFAULT (0) FOR [auth_vote],
268 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate] DEFAULT (0) FOR [auth_pollcreate],
269 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments] DEFAULT (0) FOR [auth_attachments]";
270 2582 psotfx
                                $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)
271 2582 psotfx
                                                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";
272 2582 psotfx
                                $sql[] = "DROP TABLE " . FORUMS_TABLE;
273 2582 psotfx
                                $sql[] = "EXECUTE sp_rename N'Tmp_" . FORUMS_TABLE . "', N'" . FORUMS_TABLE . "', 'OBJECT'";
274 2582 psotfx
                                $sql[] = "ALTER TABLE " . FORUMS_TABLE . " ADD
275 2582 psotfx
                                        CONSTRAINT [PK_" . $table_prefix . "forums] PRIMARY KEY CLUSTERED (forum_id) ON [PRIMARY]";
276 2582 psotfx
                                $sql[] = "CREATE NONCLUSTERED INDEX [IX_" . $table_prefix . "forums]
277 2582 psotfx
                                        ON " . FORUMS_TABLE . " (cat_id, forum_order, forum_last_post_id) ON [PRIMARY]";
278 2582 psotfx
                                /* --------------------------------------------------------------
279 2582 psotfx
                                        END OF DROP FORUM -- don't remove anything after this point!
280 2582 psotfx
                                   -------------------------------------------------------------- */
281 2523 psotfx
282 2582 psotfx
                                $sql[] = "DROP INDEX " . RANKS_TABLE . ".IX_" . $table_prefix . "ranks";
283 2582 psotfx
                                $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP
284 2582 psotfx
                                        COLUMN rank_max";
285 2582 psotfx
                                $sql[] = "CREATE  INDEX [IX_" . $table_prefix . "ranks]
286 2582 psotfx
                                        ON [" . RANKS_TABLE . "]([rank_min], [rank_special]) ON [PRIMARY]";
287 2523 psotfx
288 2582 psotfx
                                $sql[] = "DROP INDEX " . TOPICS_TABLE . ".IX_" . $table_prefix . "topics";
289 2582 psotfx
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD
290 2582 psotfx
                                        topic_first_post_id int NULL,
291 2582 psotfx
                                        CONSTRAINT [DF_" . $table_prefix . "topics_topic_first_post_id] FOR [topic_first_post_id]";
292 2582 psotfx
                                $sql[] = "CREATE  INDEX [IX_" . $table_prefix . "topics]
293 2582 psotfx
                                        ON [" . TOPICS_TABLE . "]([forum_id], [topic_type], [topic_first_post_id], [topic_last_post_id]) ON [PRIMARY]";
294 2523 psotfx
295 2582 psotfx
                                $sql[] = "ALTER TABLE " . SEARCH_WORD_TABLE . " DROP
296 2582 psotfx
                                        CONSTRAINT [PK_" . $table_prefix . "search_wordlist]";
297 2582 psotfx
                                $sql[] = "CREATE UNIQUE INDEX [IX_" . $table_prefix . "search_wordlist]
298 2582 psotfx
                                        ON [" . SEARCH_WORD_TABLE . "]([word_text]) WITH IGNORE_DUP_KEY ON [PRIMARY]";
299 2582 psotfx
                                $sql[] = "CREATE  INDEX [IX_" . $table_prefix . "search_wordlist_1]
300 2582 psotfx
                                        ON [" . SEARCH_WORD_TABLE . "]([word_common]) ON [PRIMARY]";
301 2523 psotfx
302 2582 psotfx
                                $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordmatch_1]
303 2582 psotfx
                                        ON [" . SEARCH_MATCH_TABLE . "]([word_id]) ON [PRIMARY]";
304 2523 psotfx
305 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD
306 2582 psotfx
                                        tr_class1_name varchar(50) NULL,
307 2582 psotfx
                                        tr_class2_name varchar(50) NULL,
308 2582 psotfx
                                        tr_class3_name varchar(50) NULL,
309 2582 psotfx
                                        th_class1_name varchar(50) NULL,
310 2582 psotfx
                                        th_class2_name varchar(50) NULL,
311 2582 psotfx
                                        th_class3_name varchar(50) NULL,
312 2582 psotfx
                                        td_class1_name varchar(50) NULL,
313 2582 psotfx
                                        td_class2_name varchar(50) NULL,
314 2582 psotfx
                                        td_class3_name varchar(50) NULL,
315 2582 psotfx
                                        span_class1_name varchar(50) NULL,
316 2582 psotfx
                                        span_class2_name varchar(50) NULL,
317 2582 psotfx
                                        span_class3_name varchar(50) NULL";
318 2582 psotfx
                                break;
319 2523 psotfx
320 2582 psotfx
                        case 'msaccess':
321 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP
322 2582 psotfx
                                        COLUMN user_autologin_key";
323 2523 psotfx
324 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD
325 2582 psotfx
                                        user_session_time int NOT NULL,
326 2582 psotfx
                                        user_session_page smallint NOT NULL";
327 2582 psotfx
                                $sql[] = "CREATE INDEX user_session_time
328 2582 psotfx
                                        ON " . USERS_TABLE . " (user_session_time)";
329 2582 psotfx
330 2582 psotfx
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD
331 2582 psotfx
                                        topic_first_post_id int NULL";
332 2582 psotfx
                                $sql[] = "CREATE INDEX topic_first_post_id
333 2582 psotfx
                                        ON " . TOPICS_TABLE . " (topic_first_post_id)";
334 2523 psotfx
335 2582 psotfx
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD
336 2582 psotfx
                                        tr_class1_name varchar(50) NULL,
337 2582 psotfx
                                        tr_class2_name varchar(50) NULL,
338 2582 psotfx
                                        tr_class3_name varchar(50) NULL,
339 2582 psotfx
                                        th_class1_name varchar(50) NULL,
340 2582 psotfx
                                        th_class2_name varchar(50) NULL,
341 2582 psotfx
                                        th_class3_name varchar(50) NULL,
342 2582 psotfx
                                        td_class1_name varchar(50) NULL,
343 2582 psotfx
                                        td_class2_name varchar(50) NULL,
344 2582 psotfx
                                        td_class3_name varchar(50) NULL,
345 2582 psotfx
                                        span_class1_name varchar(50) NULL,
346 2582 psotfx
                                        span_class2_name varchar(50) NULL,
347 2582 psotfx
                                        span_class3_name varchar(50) NULL";
348 2582 psotfx
                                break;
349 2523 psotfx
350 2582 psotfx
                        default:
351 2582 psotfx
                                die("No DB LAYER found!");
352 2582 psotfx
                                break;
353 2582 psotfx
                }
354 2582 psotfx
355 2582 psotfx
        case 'RC-3':
356 2582 psotfx
        case 'RC-4':
357 2582 psotfx
        case '.0.0':
358 2582 psotfx
                switch ( SQL_LAYER )
359 2582 psotfx
                {
360 2582 psotfx
                        case 'mysql':
361 2582 psotfx
                        case 'mysql4':
362 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
363 2582 psotfx
                                        MODIFY COLUMN user_id  mediumint(8) NOT NULL,
364 2582 psotfx
                                        MODIFY COLUMN user_timezone decimal(4,2) DEFAULT '0' NOT NULL";
365 2582 psotfx
                                $sql[] = "ALTER TABLE " . GROUPS_TABLE . "
366 2582 psotfx
                                        MODIFY COLUMN group_id mediumint(8) NOT NULL";
367 2582 psotfx
                                break;
368 2582 psotfx
                        case 'postgresql':
369 2584 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
370 2584 psotfx
                                        RENAME COLUMN user_timezone TO user_timezone_old";
371 2584 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
372 2584 psotfx
                                        ADD COLUMN user_timezone decimal(4)";
373 2582 psotfx
                                break;
374 2582 psotfx
                        case 'mssql':
375 2582 psotfx
                        case 'mssql-odbc':
376 2582 psotfx
                                $sql[] = "ALTER TABLE " . USERS_TABLE . "
377 2582 psotfx
                                        ALTER COLUMN [user_timezone] [decimal] (4,2) NOT NULL";
378 2582 psotfx
                                break;
379 2582 psotfx
                }
380 2523 psotfx
}
381 2523 psotfx
382 2582 psotfx
echo "<h2>Updating database schema</h2>\n";
383 2582 psotfx
echo "<p>Progress :: <b>";
384 2582 psotfx
flush();
385 2582 psotfx
386 2582 psotfx
$error_ary = array();
387 2523 psotfx
$errored = false;
388 2582 psotfx
if ( count($sql) )
389 2523 psotfx
{
390 2582 psotfx
        for($i = 0; $i < count($sql); $i++)
391 2582 psotfx
        {
392 2582 psotfx
                _sql($sql[$i], $errored, $error_ary);
393 2582 psotfx
        }
394 2523 psotfx
395 2582 psotfx
        echo "</b> <b class=\"ok\">Done</b><br />Result &nbsp; :: \n";
396 2582 psotfx
397 2582 psotfx
        if ( $errored )
398 2523 psotfx
        {
399 2582 psotfx
                echo " <b>Some queries failed, the statements and errors are listing below</b>\n<ul>";
400 2582 psotfx
401 2582 psotfx
                for($i = 0; $i < count($error_ary['sql']); $i++)
402 2582 psotfx
                {
403 2582 psotfx
                        echo "<li>Error :: <b>" . $error_ary['error_code'][$i]['message'] . "</b><br />";
404 2582 psotfx
                        echo "SQL &nbsp; :: <b>" . $error_ary['sql'][$i] . "</b><br /><br /></li>";
405 2582 psotfx
                }
406 2582 psotfx
407 2582 psotfx
                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";
408 2523 psotfx
        }
409 2523 psotfx
        else
410 2523 psotfx
        {
411 2582 psotfx
                echo "<b>No errors</b>\n";
412 2523 psotfx
        }
413 2523 psotfx
}
414 2582 psotfx
else
415 2523 psotfx
{
416 2582 psotfx
        echo " No updates required</b></p>\n";
417 2523 psotfx
}
418 2523 psotfx
419 2582 psotfx
//
420 2582 psotfx
//
421 2582 psotfx
//
422 2582 psotfx
unset($sql);
423 2582 psotfx
$error_ary = array();
424 2582 psotfx
$errored = false;
425 2523 psotfx
426 2582 psotfx
echo "<h2>Updating data</h2>\n";
427 2582 psotfx
echo "<p>Progress :: <b>";
428 2582 psotfx
flush();
429 2582 psotfx
430 2582 psotfx
switch ( $row['config_value'] )
431 2523 psotfx
{
432 2582 psotfx
        case '':
433 2582 psotfx
                $sql = "SELECT themes_id
434 2582 psotfx
                        FROM " . THEMES_TABLE . "
435 2582 psotfx
                        WHERE template_name = 'subSilver'";
436 2595 psotfx
                $result = _sql($sql, $errored, $error_ary);
437 2523 psotfx
438 2582 psotfx
                if( $row = $db->sql_fetchrow($result) )
439 2582 psotfx
                {
440 2582 psotfx
                        $theme_id = $row['themes_id'];
441 2523 psotfx
442 2582 psotfx
                        $sql = "UPDATE " . THEMES_TABLE . "
443 2582 psotfx
                                SET head_stylesheet = 'subSilver.css', body_background = '', body_bgcolor = 'E5E5E5', body_text = '000000', body_link = '006699', body_vlink = '5493B4', body_alink = '', body_hlink = 'DD6900', tr_color1 = 'EFEFEF', tr_color2 = 'DEE3E7', tr_color3 = 'D1D7DC', tr_class1 = '', tr_class2 = '', tr_class3 = '', th_color1 = '98AAB1', th_color2 = '006699', th_color3 = 'FFFFFF', th_class1 = 'cellpic1.gif', th_class2 = 'cellpic3.gif', th_class3 = 'cellpic2.jpg', td_color1 = 'FAFAFA', td_color2 = 'FFFFFF', td_color3 = '', td_class1 = 'row1', td_class2 = 'row2', td_class3 = '', fontface1 = 'Verdana, Arial, Helvetica, sans-serif', fontface2 = 'Trebuchet MS', fontface3 = 'Courier, ''Courier New'', sans-serif', fontsize1 = 10, fontsize2 = 11, fontsize3 = 12, fontcolor1 = '444444', fontcolor2 = '006600', fontcolor3 = 'FFA34F', span_class1 = '', span_class2 = '', span_class3 = ''
444 2582 psotfx
                                WHERE themes_id = $theme_id";
445 2582 psotfx
                        _sql($sql, $errored, $error_ary);
446 2523 psotfx
447 2582 psotfx
                        $sql = "DELETE FROM " . THEMES_NAME_TABLE . "
448 2582 psotfx
                                WHERE themes_id = $theme_id";
449 2582 psotfx
                        _sql($sql, $errored, $error_ary);
450 2523 psotfx
451 2582 psotfx
                        $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, tr_class1_name, tr_class2_name, tr_class3_name, th_color1_name, th_color2_name, th_color3_name, th_class1_name, th_class2_name, th_class3_name, td_color1_name, td_color2_name, td_color3_name, td_class1_name, td_class2_name, td_class3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, span_class1_name, span_class2_name, span_class3_name)
452 2582 psotfx
                                VALUES ($theme_id, 'The lightest row colour', 'The medium row color', 'The darkest row colour', '', '', '', 'Border round the whole page', 'Outer table border', 'Inner table border', 'Silver gradient picture', 'Blue gradient picture', 'Fade-out gradient on index', 'Background for quote boxes', 'All white areas', '', 'Background for topic posts', '2nd background for topic posts', '', 'Main fonts', 'Additional topic title font', 'Form fonts', 'Smallest font size', 'Medium font size', 'Normal font size (post body etc)', 'Quote & copyright text', 'Code text colour', 'Main table header text colour', '', '', '')";
453 2582 psotfx
                        _sql($sql, $errored, $error_ary);
454 2582 psotfx
                }
455 2523 psotfx
456 2582 psotfx
                $sql = "SELECT MIN(post_id) AS first_post_id, topic_id
457 2582 psotfx
                        FROM " . POSTS_TABLE . "
458 2582 psotfx
                        GROUP BY topic_id
459 2582 psotfx
                        ORDER BY topic_id ASC";
460 2595 psotfx
                $result = _sql($sql, $errored, $error_ary);
461 2523 psotfx
462 2582 psotfx
                if ( $row = $db->sql_fetchrow($result) )
463 2582 psotfx
                {
464 2582 psotfx
                        do
465 2582 psotfx
                        {
466 2582 psotfx
                                $sql = "UPDATE " . TOPICS_TABLE . "
467 2582 psotfx
                                        SET topic_first_post_id = " . $row['first_post_id'] . "
468 2582 psotfx
                                        WHERE topic_id = " . $row['topic_id'];
469 2582 psotfx
                                _sql($sql, $errored, $error_ary);
470 2582 psotfx
                        }
471 2582 psotfx
                        while ( $row = $db->sql_fetchrow($result) );
472 2582 psotfx
                }
473 2523 psotfx
474 2582 psotfx
                $sql = "SELECT DISTINCT u.user_id
475 2582 psotfx
                        FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa
476 2582 psotfx
                        WHERE aa.auth_mod = 1
477 2582 psotfx
                                AND ug.group_id = aa.group_id
478 2582 psotfx
                                AND u.user_id = ug.user_id
479 2582 psotfx
                                AND u.user_level <> " . ADMIN;
480 2595 psotfx
                $result = _sql($sql, $errored, $error_ary);
481 2582 psotfx
482 2582 psotfx
                $mod_user = array();
483 2582 psotfx
                while ( $row = $db->sql_fetchrow($result) )
484 2523 psotfx
                {
485 2582 psotfx
                        $mod_user[] = $row['user_id'];
486 2523 psotfx
                }
487 2523 psotfx
488 2582 psotfx
                if ( count($mod_user) )
489 2582 psotfx
                {
490 2582 psotfx
                        $sql = "UPDATE " . USERS_TABLE . "
491 2582 psotfx
                                SET user_level = " . MOD . "
492 2582 psotfx
                                WHERE user_id IN (" . implode(', ', $mod_user) . ")";
493 2582 psotfx
                        _sql($sql, $errored, $error_ary);
494 2582 psotfx
                }
495 2523 psotfx
496 2582 psotfx
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value)
497 2582 psotfx
                        VALUES ('server_name', 'www.myserver.tld')";
498 2582 psotfx
                _sql($sql, $errored, $error_ary);
499 2523 psotfx
500 2582 psotfx
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value)
501 2582 psotfx
                        VALUES ('script_path', '/phpBB2/')";
502 2582 psotfx
                _sql($sql, $errored, $error_ary);
503 2523 psotfx
504 2582 psotfx
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value)
505 2582 psotfx
                        VALUES ('server_port', '80')";
506 2582 psotfx
                _sql($sql, $errored, $error_ary);
507 2523 psotfx
508 2582 psotfx
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value)
509 2582 psotfx
                        VALUES ('record_online_users', '1')";
510 2582 psotfx
                _sql($sql, $errored, $error_ary);
511 2523 psotfx
512 2582 psotfx
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value)
513 2582 psotfx
                        VALUES ('record_online_date', '" . time() . "')";
514 2582 psotfx
                _sql($sql, $errored, $error_ary);
515 2523 psotfx
516 2582 psotfx
        case 'RC-3':
517 2582 psotfx
        case 'RC-4':
518 2582 psotfx
        case '.0.0':
519 2584 psotfx
                if ( SQL_LAYER == 'postgresql' )
520 2584 psotfx
                {
521 2584 psotfx
                        $sql = "SELECT user_id, user_timezone_old
522 2584 psotfx
                                FROM " . USERS_TABLE;
523 2595 psotfx
                        $result = _sql($sql, $errored, $error_ary);
524 2584 psotfx
525 2584 psotfx
                        while ( $row = $db->sql_fetchrow($result) )
526 2584 psotfx
                        {
527 2584 psotfx
                                $sql = "UPDATE " . USERS_TABLE . "
528 2584 psotfx
                                        SET user_timezone = " . $row['user_timezone_old'] . "
529 2584 psotfx
                                        WHERE user_id = " . $row['user_id'];
530 2584 psotfx
                                _sql($sql, $errored, $error_ary);
531 2584 psotfx
                        }
532 2584 psotfx
                }
533 2584 psotfx
534 2582 psotfx
                $sql = "SELECT topic_id, topic_moved_id
535 2582 psotfx
                        FROM " . TOPICS_TABLE . "
536 2582 psotfx
                        WHERE topic_moved_id <> 0";
537 2595 psotfx
                $result = _sql($sql, $errored, $error_ary);
538 2523 psotfx
539 2582 psotfx
                $topic_ary = array();
540 2582 psotfx
                while ( $row = $db->sql_fetchrow($result) )
541 2582 psotfx
                {
542 2582 psotfx
                        $topic_ary[$row['topic_id']] = $row['topic_moved_id'];
543 2582 psotfx
                }
544 2523 psotfx
545 2582 psotfx
                while ( list($topic_id, $topic_moved_id) = each($topic_ary) )
546 2582 psotfx
                {
547 2582 psotfx
                        $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts
548 2582 psotfx
                                FROM " . POSTS_TABLE . "
549 2582 psotfx
                                WHERE topic_id = $topic_moved_id";
550 2595 psotfx
                        $result = _sql($sql, $errored, $error_ary);
551 2523 psotfx
552 2582 psotfx
                        $sql = ( $row = $db->sql_fetchrow($result) ) ? "UPDATE " . TOPICS_TABLE . "        SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = $topic_id" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = " . $row['topic_id'];
553 2582 psotfx
                        _sql($sql, $errored, $error_ary);
554 2582 psotfx
                }
555 2523 psotfx
556 2582 psotfx
                unset($sql);
557 2582 psotfx
558 2582 psotfx
                $sql = "UPDATE " . CONFIG_TABLE . "
559 2582 psotfx
                        SET config_value = '$updates_to_version'
560 2582 psotfx
                        WHERE config_name = 'version'";
561 2582 psotfx
                _sql($sql, $errored, $error_ary);
562 2582 psotfx
563 2582 psotfx
                sync('all forums');
564 2582 psotfx
565 2582 psotfx
                echo "</b> <b class=\"ok\">Done</b><br />Result &nbsp; :: \n";
566 2582 psotfx
567 2582 psotfx
                if ( $errored )
568 2582 psotfx
                {
569 2582 psotfx
                        echo " <b>Some queries failed, the statements and errors are listing below</b>\n<ul>";
570 2582 psotfx
571 2582 psotfx
                        for($i = 0; $i < count($error_ary['sql']); $i++)
572 2582 psotfx
                        {
573 2582 psotfx
                                echo "<li>Error :: <b>" . $error_ary['error_code'][$i]['message'] . "</b><br />";
574 2582 psotfx
                                echo "SQL &nbsp; :: <b>" . $error_ary['sql'][$i] . "</b><br /><br /></li>";
575 2582 psotfx
                        }
576 2582 psotfx
577 2582 psotfx
                        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";
578 2582 psotfx
                }
579 2582 psotfx
                else
580 2582 psotfx
                {
581 2582 psotfx
                        echo "<b>No errors</b>\n";
582 2582 psotfx
                }
583 2582 psotfx
584 2582 psotfx
                break;
585 2582 psotfx
586 2582 psotfx
                default:
587 2582 psotfx
                        echo " No updates where required</b></p>\n";
588 2582 psotfx
                        break;
589 2523 psotfx
}
590 2523 psotfx
591 2582 psotfx
echo "<h2>Update completed</h2>\n";
592 2582 psotfx
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";
593 2523 psotfx
594 2523 psotfx
?>
595 2582 psotfx
596 2582 psotfx
<br clear="all" />
597 2582 psotfx
598 2523 psotfx
</body>
599 2582 psotfx
</html>