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