1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-04-19 20:54:13 +0000 (Wed, 19 Apr 2006) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 1209 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | if (!defined('PHPWG_ROOT_PATH')) |
---|
29 | { |
---|
30 | die ('This page cannot be loaded directly, load upgrade.php'); |
---|
31 | } |
---|
32 | else |
---|
33 | { |
---|
34 | if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE) |
---|
35 | { |
---|
36 | die ('Hacking attempt!'); |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | $last_time = get_moment(); |
---|
41 | |
---|
42 | // will the user have to edit include/config_local.inc.php for |
---|
43 | // prefix_thumbnail configuration parameter |
---|
44 | $query = ' |
---|
45 | SELECT value |
---|
46 | FROM '.CONFIG_TABLE.' |
---|
47 | WHERE param = \'prefix_thumbnail\' |
---|
48 | ;'; |
---|
49 | list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query)); |
---|
50 | |
---|
51 | // delete obsolete configuration |
---|
52 | $query = ' |
---|
53 | DELETE |
---|
54 | FROM '.PREFIX_TABLE.'config |
---|
55 | WHERE param IN ( |
---|
56 | \'prefix_thumbnail\', |
---|
57 | \'mail_webmaster\', |
---|
58 | \'upload_maxfilesize\', |
---|
59 | \'upload_maxwidth\', |
---|
60 | \'upload_maxheight\', |
---|
61 | \'upload_maxwidth_thumbnail\', |
---|
62 | \'upload_maxheight_thumbnail\', |
---|
63 | \'mail_notification\', |
---|
64 | \'use_iptc\', |
---|
65 | \'use_exif\', |
---|
66 | \'show_iptc\', |
---|
67 | \'show_exif\', |
---|
68 | \'authorize_remembering\' |
---|
69 | ) |
---|
70 | ;'; |
---|
71 | mysql_query($query); |
---|
72 | |
---|
73 | $queries = array( |
---|
74 | |
---|
75 | " |
---|
76 | ALTER TABLE phpwebgallery_categories |
---|
77 | CHANGE COLUMN date_last date_last datetime default NULL |
---|
78 | ;", |
---|
79 | |
---|
80 | " |
---|
81 | ALTER TABLE phpwebgallery_comments |
---|
82 | ADD COLUMN validation_date datetime default NULL |
---|
83 | ;", |
---|
84 | |
---|
85 | " |
---|
86 | UPDATE phpwebgallery_comments |
---|
87 | SET validation_date = date |
---|
88 | ", |
---|
89 | |
---|
90 | " |
---|
91 | ALTER TABLE phpwebgallery_comments |
---|
92 | ADD INDEX comments_i1 (image_id) |
---|
93 | ;", |
---|
94 | |
---|
95 | " |
---|
96 | ALTER TABLE phpwebgallery_comments |
---|
97 | ADD INDEX comments_i2 (validation_date) |
---|
98 | ;", |
---|
99 | |
---|
100 | " |
---|
101 | ALTER TABLE phpwebgallery_favorites |
---|
102 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
103 | ;", |
---|
104 | |
---|
105 | " |
---|
106 | ALTER TABLE phpwebgallery_images |
---|
107 | CHANGE COLUMN date_available |
---|
108 | date_available datetime NOT NULL default '0000-00-00 00:00:00' |
---|
109 | ;", |
---|
110 | |
---|
111 | " |
---|
112 | ALTER TABLE phpwebgallery_rate |
---|
113 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
114 | ;", |
---|
115 | |
---|
116 | " |
---|
117 | ALTER TABLE phpwebgallery_sessions |
---|
118 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
119 | ;", |
---|
120 | |
---|
121 | " |
---|
122 | ALTER TABLE phpwebgallery_user_access |
---|
123 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
124 | ;", |
---|
125 | |
---|
126 | " |
---|
127 | DROP TABLE phpwebgallery_user_forbidden |
---|
128 | ;", |
---|
129 | |
---|
130 | " |
---|
131 | ALTER TABLE phpwebgallery_user_group |
---|
132 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
133 | ;", |
---|
134 | |
---|
135 | " |
---|
136 | ALTER TABLE phpwebgallery_users |
---|
137 | CHANGE COLUMN id id smallint(5) NOT NULL auto_increment |
---|
138 | ;", |
---|
139 | |
---|
140 | " |
---|
141 | CREATE TABLE phpwebgallery_caddie ( |
---|
142 | user_id smallint(5) NOT NULL default '0', |
---|
143 | element_id mediumint(8) NOT NULL default '0', |
---|
144 | PRIMARY KEY (user_id,element_id) |
---|
145 | ) TYPE=MyISAM |
---|
146 | ;", |
---|
147 | |
---|
148 | " |
---|
149 | CREATE TABLE phpwebgallery_user_cache ( |
---|
150 | user_id smallint(5) NOT NULL default '0', |
---|
151 | need_update enum('true','false') NOT NULL default 'true', |
---|
152 | forbidden_categories text, |
---|
153 | PRIMARY KEY (user_id) |
---|
154 | ) TYPE=MyISAM |
---|
155 | ;", |
---|
156 | |
---|
157 | " |
---|
158 | CREATE TABLE phpwebgallery_user_feed ( |
---|
159 | id varchar(50) binary NOT NULL default '', |
---|
160 | user_id smallint(5) NOT NULL default '0', |
---|
161 | last_check datetime default NULL, |
---|
162 | PRIMARY KEY (id) |
---|
163 | ) TYPE=MyISAM |
---|
164 | ;", |
---|
165 | |
---|
166 | " |
---|
167 | CREATE TABLE phpwebgallery_user_infos ( |
---|
168 | user_id smallint(5) NOT NULL default '0', |
---|
169 | nb_image_line tinyint(1) unsigned NOT NULL default '5', |
---|
170 | nb_line_page tinyint(3) unsigned NOT NULL default '3', |
---|
171 | status enum('admin','guest') NOT NULL default 'guest', |
---|
172 | language varchar(50) NOT NULL default 'english', |
---|
173 | maxwidth smallint(6) default NULL, |
---|
174 | maxheight smallint(6) default NULL, |
---|
175 | expand enum('true','false') NOT NULL default 'false', |
---|
176 | show_nb_comments enum('true','false') NOT NULL default 'false', |
---|
177 | recent_period tinyint(3) unsigned NOT NULL default '7', |
---|
178 | template varchar(255) NOT NULL default 'yoga', |
---|
179 | registration_date datetime NOT NULL default '0000-00-00 00:00:00', |
---|
180 | UNIQUE KEY user_infos_ui1 (user_id) |
---|
181 | ) TYPE=MyISAM |
---|
182 | ;" |
---|
183 | ); |
---|
184 | |
---|
185 | foreach ($queries as $query) |
---|
186 | { |
---|
187 | $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query); |
---|
188 | pwg_query($query); |
---|
189 | } |
---|
190 | |
---|
191 | // user datas migration from phpwebgallery_users to phpwebgallery_user_infos |
---|
192 | $query = ' |
---|
193 | SELECT * |
---|
194 | FROM '.USERS_TABLE.' |
---|
195 | ;'; |
---|
196 | |
---|
197 | $datas = array(); |
---|
198 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
199 | |
---|
200 | $result = pwg_query($query); |
---|
201 | while ($row = mysql_fetch_array($result)) |
---|
202 | { |
---|
203 | $row['user_id'] = $row['id']; |
---|
204 | $row['registration_date'] = $dbnow; |
---|
205 | array_push($datas, $row); |
---|
206 | } |
---|
207 | |
---|
208 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
209 | mass_inserts( |
---|
210 | USER_INFOS_TABLE, |
---|
211 | array( |
---|
212 | 'user_id', |
---|
213 | 'nb_image_line', |
---|
214 | 'nb_line_page', |
---|
215 | 'status', |
---|
216 | 'language', |
---|
217 | 'maxwidth', |
---|
218 | 'maxheight', |
---|
219 | 'expand', |
---|
220 | 'show_nb_comments', |
---|
221 | 'recent_period', |
---|
222 | 'template', |
---|
223 | 'registration_date' |
---|
224 | ), |
---|
225 | $datas |
---|
226 | ); |
---|
227 | |
---|
228 | $queries = array( |
---|
229 | |
---|
230 | " |
---|
231 | UPDATE ".USER_INFOS_TABLE." |
---|
232 | SET template = 'yoga' |
---|
233 | ;", |
---|
234 | |
---|
235 | " |
---|
236 | UPDATE ".USER_INFOS_TABLE." |
---|
237 | SET language = 'en_UK.iso-8859-1' |
---|
238 | WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1') |
---|
239 | ;", |
---|
240 | |
---|
241 | " |
---|
242 | UPDATE ".CONFIG_TABLE." |
---|
243 | SET value = 'en_UK.iso-8859-1' |
---|
244 | WHERE param = 'default_language' |
---|
245 | AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1') |
---|
246 | ;", |
---|
247 | |
---|
248 | " |
---|
249 | UPDATE ".CONFIG_TABLE." |
---|
250 | SET value = 'yoga' |
---|
251 | WHERE param = 'default_template' |
---|
252 | ;", |
---|
253 | |
---|
254 | " |
---|
255 | INSERT INTO ".CONFIG_TABLE." |
---|
256 | (param,value,comment) |
---|
257 | VALUES |
---|
258 | ( |
---|
259 | 'gallery_title', |
---|
260 | 'PhpWebGallery demonstration site', |
---|
261 | 'Title at top of each page and for RSS feed' |
---|
262 | ) |
---|
263 | ;", |
---|
264 | |
---|
265 | " |
---|
266 | INSERT INTO ".CONFIG_TABLE." |
---|
267 | (param,value,comment) |
---|
268 | VALUES |
---|
269 | ( |
---|
270 | 'gallery_description', |
---|
271 | 'My photos web site', |
---|
272 | 'Short description displayed with gallery title' |
---|
273 | ) |
---|
274 | ;" |
---|
275 | |
---|
276 | ); |
---|
277 | |
---|
278 | foreach ($queries as $query) |
---|
279 | { |
---|
280 | $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query); |
---|
281 | pwg_query($query); |
---|
282 | } |
---|
283 | |
---|
284 | if ($prefix_thumbnail != 'TN-') |
---|
285 | { |
---|
286 | array_push( |
---|
287 | $page['infos'], |
---|
288 | 'the thumbnail prefix configuration parameter was moved to configuration |
---|
289 | file, copy config_local.inc.php from "tools" directory to "include" directory |
---|
290 | and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail |
---|
291 | ); |
---|
292 | } |
---|
293 | |
---|
294 | // now we upgrade from 1.5.0 to 1.6.0 |
---|
295 | include_once(PHPWG_ROOT_PATH.'install/upgrade_1.5.0.php'); |
---|
296 | ?> |
---|