phpBB
Statistics
| Revision:

root / tags / release_2_0_2 / phpBB / update_to_202.php

History | View | Annotate | Download (28.8 kB)

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