phpBB
Statistics
| Revision:

root / tags / release_2_0_1 / phpBB / update_to_201.php

History | View | Annotate | Download (24.3 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_201.php 2610 2002-05-20 13:52:12Z  $
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.1";
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
175
                        case 'postgresql':
176
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
177
                                        ADD COLUMN user_session_time int4";
178
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
179
                                        ADD COLUMN user_session_page int2";
180
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
181
                                        ALTER COLUMN user_session_time SET DEFAULT '0'";
182
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
183
                                        ALTER COLUMN user_session_page SET DEFAULT '0'";
184
                                $sql[] = "CREATE INDEX user_session_time_" . $table_prefix . "users_index 
185
                                        ON " . USERS_TABLE . " (user_session_time)";
186
187
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . " 
188
                                        ADD COLUMN topic_first_post_id int4";
189
                                $sql[] = "CREATE INDEX topic_first_post_id_" . $table_prefix . "topics_index 
190
                                        ON " . TOPICS_TABLE . " (topic_first_post_id)";
191
192
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
193
                                        ADD COLUMN tr_class1_name varchar(50) NULL"; 
194
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
195
                                        ADD COLUMN tr_class2_name varchar(50) NULL"; 
196
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
197
                                        ADD COLUMN tr_class3_name varchar(50) NULL"; 
198
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
199
                                        ADD COLUMN th_class1_name varchar(50) NULL"; 
200
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
201
                                        ADD COLUMN th_class2_name varchar(50) NULL"; 
202
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
203
                                        ADD COLUMN th_class3_name varchar(50) NULL"; 
204
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
205
                                        ADD COLUMN td_class1_name varchar(50) NULL"; 
206
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
207
                                        ADD COLUMN td_class2_name varchar(50) NULL"; 
208
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
209
                                        ADD COLUMN td_class3_name varchar(50) NULL"; 
210
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
211
                                        ADD COLUMN span_class1_name varchar(50) NULL"; 
212
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
213
                                        ADD COLUMN span_class2_name varchar(50) NULL"; 
214
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " 
215
                                        ADD COLUMN span_class3_name varchar(50) NULL";
216
                                break;
217
218
                        case 'mssql-odbc':
219
                        case 'mssql':
220
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP 
221
                                        COLUMN user_autologin_key";
222
223
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD 
224
                                        user_session_time int NOT NULL, 
225
                                        user_session_page smallint NOT NULL, 
226
                                        CONSTRAINT [DF_" . $table_prefix . "users_user_session_time] DEFAULT (0) FOR [user_session_time],
227
                                        CONSTRAINT [DF_" . $table_prefix . "users_user_session_page] DEFAULT (0) FOR [user_session_page]";
228
                                $sql[] = "CREATE INDEX [IX_" . $table_prefix . "users] 
229
                                        ON [" . USERS_TABLE . "]([user_session_time]) ON [PRIMARY]";
230
231
                                /* ---------------------------------------------------------------------
232
                                        DROP FORUM TABLE -- if this may cause you problems you can safely 
233
                                        comment it out, remember to manually remove the IDENTITY setting on 
234
                                        the forum_id column 
235
                                   --------------------------------------------------------------------- */
236
                                $sql [] = "ALTER TABLE " . FORUMS_TABLE . " DROP 
237
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts], 
238
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics], 
239
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id], 
240
                                        CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable], 
241
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_view], 
242
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_read], 
243
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_post], 
244
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply], 
245
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit], 
246
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete], 
247
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky], 
248
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce], 
249
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote], 
250
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate], 
251
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments]";
252
                                $sql[] = "CREATE TABLE Tmp_" . FORUMS_TABLE . " 
253
                                        (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
                                $sql[] = "ALTER TABLE [Tmp_" . FORUMS_TABLE . "] WITH NOCHECK ADD 
255
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_posts] DEFAULT (0) FOR [forum_posts], 
256
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_topics] DEFAULT (0) FOR [forum_topics], 
257
                                        CONSTRAINT [DF_" . $table_prefix . "forums_forum_last_post_id] DEFAULT (0) FOR [forum_last_post_id], 
258
                                        CONSTRAINT [DF_" . $table_prefix . "forums_prune_enable] DEFAULT (0) FOR [prune_enable], 
259
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_view] DEFAULT (0) FOR [auth_view], 
260
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_read] DEFAULT (0) FOR [auth_read], 
261
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_post] DEFAULT (0) FOR [auth_post], 
262
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_reply] DEFAULT (0) FOR [auth_reply], 
263
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_edit] DEFAULT (0) FOR [auth_edit], 
264
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_delete] DEFAULT (0) FOR [auth_delete], 
265
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_sticky] DEFAULT (0) FOR [auth_sticky], 
266
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_announce] DEFAULT (0) FOR [auth_announce], 
267
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_vote] DEFAULT (0) FOR [auth_vote], 
268
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_pollcreate] DEFAULT (0) FOR [auth_pollcreate], 
269
                                        CONSTRAINT [DF_" . $table_prefix . "forums_auth_attachments] DEFAULT (0) FOR [auth_attachments]";
270
                                $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
                                                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
                                $sql[] = "DROP TABLE " . FORUMS_TABLE;
273
                                $sql[] = "EXECUTE sp_rename N'Tmp_" . FORUMS_TABLE . "', N'" . FORUMS_TABLE . "', 'OBJECT'";
274
                                $sql[] = "ALTER TABLE " . FORUMS_TABLE . " ADD 
275
                                        CONSTRAINT [PK_" . $table_prefix . "forums] PRIMARY KEY CLUSTERED (forum_id) ON [PRIMARY]";
276
                                $sql[] = "CREATE NONCLUSTERED INDEX [IX_" . $table_prefix . "forums]
277
                                        ON " . FORUMS_TABLE . " (cat_id, forum_order, forum_last_post_id) ON [PRIMARY]";
278
                                /* --------------------------------------------------------------
279
                                        END OF DROP FORUM -- don't remove anything after this point! 
280
                                   -------------------------------------------------------------- */
281
282
                                $sql[] = "DROP INDEX " . RANKS_TABLE . ".IX_" . $table_prefix . "ranks";
283
                                $sql[] = "ALTER TABLE " . RANKS_TABLE . " DROP 
284
                                        COLUMN rank_max";
285
                                $sql[] = "CREATE  INDEX [IX_" . $table_prefix . "ranks] 
286
                                        ON [" . RANKS_TABLE . "]([rank_min], [rank_special]) ON [PRIMARY]";
287
288
                                $sql[] = "DROP INDEX " . TOPICS_TABLE . ".IX_" . $table_prefix . "topics";
289
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD 
290
                                        topic_first_post_id int NULL, 
291
                                        CONSTRAINT [DF_" . $table_prefix . "topics_topic_first_post_id] FOR [topic_first_post_id]";
292
                                $sql[] = "CREATE  INDEX [IX_" . $table_prefix . "topics] 
293
                                        ON [" . TOPICS_TABLE . "]([forum_id], [topic_type], [topic_first_post_id], [topic_last_post_id]) ON [PRIMARY]";
294
295
                                $sql[] = "ALTER TABLE " . SEARCH_WORD_TABLE . " DROP 
296
                                        CONSTRAINT [PK_" . $table_prefix . "search_wordlist]";
297
                                $sql[] = "CREATE UNIQUE INDEX [IX_" . $table_prefix . "search_wordlist] 
298
                                        ON [" . SEARCH_WORD_TABLE . "]([word_text]) WITH IGNORE_DUP_KEY ON [PRIMARY]";
299
                                $sql[] = "CREATE  INDEX [IX_" . $table_prefix . "search_wordlist_1] 
300
                                        ON [" . SEARCH_WORD_TABLE . "]([word_common]) ON [PRIMARY]";
301
302
                                $sql[] = "CREATE INDEX [IX_" . $table_prefix . "search_wordmatch_1] 
303
                                        ON [" . SEARCH_MATCH_TABLE . "]([word_id]) ON [PRIMARY]";
304
305
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD
306
                                        tr_class1_name varchar(50) NULL, 
307
                                        tr_class2_name varchar(50) NULL, 
308
                                        tr_class3_name varchar(50) NULL, 
309
                                        th_class1_name varchar(50) NULL, 
310
                                        th_class2_name varchar(50) NULL, 
311
                                        th_class3_name varchar(50) NULL, 
312
                                        td_class1_name varchar(50) NULL, 
313
                                        td_class2_name varchar(50) NULL, 
314
                                        td_class3_name varchar(50) NULL, 
315
                                        span_class1_name varchar(50) NULL, 
316
                                        span_class2_name varchar(50) NULL, 
317
                                        span_class3_name varchar(50) NULL";
318
                                break;
319
320
                        case 'msaccess':
321
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " DROP 
322
                                        COLUMN user_autologin_key";
323
324
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " ADD 
325
                                        user_session_time int NOT NULL, 
326
                                        user_session_page smallint NOT NULL";
327
                                $sql[] = "CREATE INDEX user_session_time 
328
                                        ON " . USERS_TABLE . " (user_session_time)";
329
                        
330
                                $sql[] = "ALTER TABLE " . TOPICS_TABLE . " ADD 
331
                                        topic_first_post_id int NULL";
332
                                $sql[] = "CREATE INDEX topic_first_post_id 
333
                                        ON " . TOPICS_TABLE . " (topic_first_post_id)";
334
335
                                $sql[] = "ALTER TABLE " . THEMES_NAME_TABLE . " ADD
336
                                        tr_class1_name varchar(50) NULL, 
337
                                        tr_class2_name varchar(50) NULL, 
338
                                        tr_class3_name varchar(50) NULL, 
339
                                        th_class1_name varchar(50) NULL, 
340
                                        th_class2_name varchar(50) NULL, 
341
                                        th_class3_name varchar(50) NULL, 
342
                                        td_class1_name varchar(50) NULL, 
343
                                        td_class2_name varchar(50) NULL, 
344
                                        td_class3_name varchar(50) NULL, 
345
                                        span_class1_name varchar(50) NULL, 
346
                                        span_class2_name varchar(50) NULL, 
347
                                        span_class3_name varchar(50) NULL";
348
                                break;
349
350
                        default:
351
                                die("No DB LAYER found!");
352
                                break;
353
                }
354
355
        case 'RC-3':
356
        case 'RC-4':
357
        case '.0.0':
358
                switch ( SQL_LAYER )
359
                {
360
                        case 'mysql':
361
                        case 'mysql4':
362
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
363
                                        MODIFY COLUMN user_id  mediumint(8) NOT NULL, 
364
                                        MODIFY COLUMN user_timezone decimal(4,2) DEFAULT '0' NOT NULL";
365
                                $sql[] = "ALTER TABLE " . GROUPS_TABLE . " 
366
                                        MODIFY COLUMN group_id mediumint(8) NOT NULL";
367
                                break;
368
                        case 'postgresql':
369
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
370
                                        RENAME COLUMN user_timezone TO user_timezone_old";
371
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
372
                                        ADD COLUMN user_timezone decimal(4)";
373
                                break;
374
                        case 'mssql':
375
                        case 'mssql-odbc':
376
                                $sql[] = "ALTER TABLE " . USERS_TABLE . " 
377
                                        ALTER COLUMN [user_timezone] [decimal] (4,2) NOT NULL";
378
                                break;
379
                }
380
}
381
382
echo "<h2>Updating database schema</h2>\n";
383
echo "<p>Progress :: <b>";
384
flush();
385
386
$error_ary = array();
387
$errored = false;
388
if ( count($sql) )
389
{
390
        for($i = 0; $i < count($sql); $i++)
391
        {
392
                _sql($sql[$i], $errored, $error_ary);
393
        }
394
395
        echo "</b> <b class=\"ok\">Done</b><br />Result &nbsp; :: \n";
396
397
        if ( $errored )
398
        {
399
                echo " <b>Some queries failed, the statements and errors are listing below</b>\n<ul>";
400
401
                for($i = 0; $i < count($error_ary['sql']); $i++)
402
                {
403
                        echo "<li>Error :: <b>" . $error_ary['error_code'][$i]['message'] . "</b><br />";
404
                        echo "SQL &nbsp; :: <b>" . $error_ary['sql'][$i] . "</b><br /><br /></li>";
405
                }
406
407
                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
        }
409
        else
410
        {
411
                echo "<b>No errors</b>\n";
412
        }
413
}
414
else
415
{
416
        echo " No updates required</b></p>\n";
417
}
418
419
//
420
// 
421
//
422
unset($sql);
423
$error_ary = array();
424
$errored = false;
425
426
echo "<h2>Updating data</h2>\n";
427
echo "<p>Progress :: <b>";
428
flush();
429
430
switch ( $row['config_value'] )
431
{
432
        case '':
433
                $sql = "SELECT themes_id 
434
                        FROM " . THEMES_TABLE . " 
435
                        WHERE template_name = 'subSilver'";
436
                $result = _sql($sql, $errored, $error_ary);
437
438
                if( $row = $db->sql_fetchrow($result) )
439
                {
440
                        $theme_id = $row['themes_id'];
441
442
                        $sql = "UPDATE " . THEMES_TABLE . " 
443
                                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
                                WHERE themes_id = $theme_id";
445
                        _sql($sql, $errored, $error_ary);
446
447
                        $sql = "DELETE FROM " . THEMES_NAME_TABLE . " 
448
                                WHERE themes_id = $theme_id";
449
                        _sql($sql, $errored, $error_ary);
450
451
                        $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
                                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
                        _sql($sql, $errored, $error_ary);
454
                }
455
456
                $sql = "SELECT MIN(post_id) AS first_post_id, topic_id
457
                        FROM " . POSTS_TABLE . "
458
                        GROUP BY topic_id
459
                        ORDER BY topic_id ASC";
460
                $result = _sql($sql, $errored, $error_ary);
461
462
                if ( $row = $db->sql_fetchrow($result) )
463
                {
464
                        do
465
                        {
466
                                $sql = "UPDATE " . TOPICS_TABLE . " 
467
                                        SET topic_first_post_id = " . $row['first_post_id'] . "  
468
                                        WHERE topic_id = " . $row['topic_id'];
469
                                _sql($sql, $errored, $error_ary);
470
                        }
471
                        while ( $row = $db->sql_fetchrow($result) );
472
                }
473
474
                $sql = "SELECT DISTINCT u.user_id 
475
                        FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa 
476
                        WHERE aa.auth_mod = 1
477
                                AND ug.group_id = aa.group_id
478
                                AND u.user_id = ug.user_id 
479
                                AND u.user_level <> " . ADMIN;
480
                $result = _sql($sql, $errored, $error_ary);
481
482
                $mod_user = array();
483
                while ( $row = $db->sql_fetchrow($result) )
484
                {
485
                        $mod_user[] = $row['user_id'];
486
                }
487
488
                if ( count($mod_user) )
489
                {
490
                        $sql = "UPDATE " . USERS_TABLE . " 
491
                                SET user_level = " . MOD . " 
492
                                WHERE user_id IN (" . implode(', ', $mod_user) . ")"; 
493
                        _sql($sql, $errored, $error_ary);
494
                }
495
496
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) 
497
                        VALUES ('server_name', 'www.myserver.tld')";
498
                _sql($sql, $errored, $error_ary);
499
500
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) 
501
                        VALUES ('script_path', '/phpBB2/')";
502
                _sql($sql, $errored, $error_ary);
503
504
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) 
505
                        VALUES ('server_port', '80')";
506
                _sql($sql, $errored, $error_ary);
507
508
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) 
509
                        VALUES ('record_online_users', '1')";
510
                _sql($sql, $errored, $error_ary);
511
512
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) 
513
                        VALUES ('record_online_date', '" . time() . "')";
514
                _sql($sql, $errored, $error_ary);
515
516
        case 'RC-3':
517
        case 'RC-4':
518
        case '.0.0':
519
                if ( SQL_LAYER == 'postgresql' )
520
                {
521
                        $sql = "SELECT user_id, user_timezone_old 
522
                                FROM " . USERS_TABLE;
523
                        $result = _sql($sql, $errored, $error_ary);
524
525
                        while ( $row = $db->sql_fetchrow($result) )
526
                        {
527
                                $sql = "UPDATE " . USERS_TABLE . " 
528
                                        SET user_timezone = " . $row['user_timezone_old'] . " 
529
                                        WHERE user_id = " . $row['user_id'];
530
                                _sql($sql, $errored, $error_ary);
531
                        }                        
532
                }
533
534
                $sql = "SELECT topic_id, topic_moved_id 
535
                        FROM " . TOPICS_TABLE . " 
536
                        WHERE topic_moved_id <> 0";
537
                $result = _sql($sql, $errored, $error_ary);
538
539
                $topic_ary = array();
540
                while ( $row = $db->sql_fetchrow($result) )
541
                {
542
                        $topic_ary[$row['topic_id']] = $row['topic_moved_id'];
543
                }
544
545
                while ( list($topic_id, $topic_moved_id) = each($topic_ary) )
546
                {
547
                        $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts
548
                                FROM " . POSTS_TABLE . "
549
                                WHERE topic_id = $topic_moved_id";
550
                        $result = _sql($sql, $errored, $error_ary);
551
552
                        $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
                        _sql($sql, $errored, $error_ary);
554
                }
555
556
                unset($sql);
557
558
                $sql = "UPDATE " . CONFIG_TABLE . " 
559
                        SET config_value = '$updates_to_version' 
560
                        WHERE config_name = 'version'";
561
                _sql($sql, $errored, $error_ary);
562
563
                sync('all forums');
564
565
                echo "</b> <b class=\"ok\">Done</b><br />Result &nbsp; :: \n";
566
567
                if ( $errored )
568
                {
569
                        echo " <b>Some queries failed, the statements and errors are listing below</b>\n<ul>";
570
571
                        for($i = 0; $i < count($error_ary['sql']); $i++)
572
                        {
573
                                echo "<li>Error :: <b>" . $error_ary['error_code'][$i]['message'] . "</b><br />";
574
                                echo "SQL &nbsp; :: <b>" . $error_ary['sql'][$i] . "</b><br /><br /></li>";
575
                        }
576
577
                        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
                }
579
                else
580
                {
581
                        echo "<b>No errors</b>\n";
582
                }
583
584
                break;
585
586
                default:
587
                        echo " No updates where required</b></p>\n";
588
                        break;
589
}
590
591
echo "<h2>Update completed</h2>\n";
592
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
594
?>
595
596
<br clear="all" />
597
598
</body>
599
</html>