1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008 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 | // | PhpWebGallery - a PHP based picture gallery | |
---|
25 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
26 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | // | file : $Id: upgrade_1.6.2.php 2297 2008-04-04 22:57:23Z plg $ |
---|
29 | // | last update : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $ |
---|
30 | // | last modifier : $Author: plg $ |
---|
31 | // | revision : $Revision: 2297 $ |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // | This program is free software; you can redistribute it and/or modify | |
---|
34 | // | it under the terms of the GNU General Public License as published by | |
---|
35 | // | the Free Software Foundation | |
---|
36 | // | | |
---|
37 | // | This program is distributed in the hope that it will be useful, but | |
---|
38 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
39 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
40 | // | General Public License for more details. | |
---|
41 | // | | |
---|
42 | // | You should have received a copy of the GNU General Public License | |
---|
43 | // | along with this program; if not, write to the Free Software | |
---|
44 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
45 | // | USA. | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | |
---|
48 | if (!defined('PHPWG_ROOT_PATH')) |
---|
49 | { |
---|
50 | die ('This page cannot be loaded directly, load upgrade.php'); |
---|
51 | } |
---|
52 | else |
---|
53 | { |
---|
54 | if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE) |
---|
55 | { |
---|
56 | die ('Hacking attempt!'); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | $queries = array( |
---|
61 | " |
---|
62 | ALTER TABLE `".PREFIX_TABLE."categories` |
---|
63 | ADD COLUMN `permalink` varchar(64) default NULL |
---|
64 | ;", |
---|
65 | |
---|
66 | " |
---|
67 | ALTER TABLE `".PREFIX_TABLE."categories` |
---|
68 | ADD COLUMN `image_order` varchar(128) default NULL |
---|
69 | ;", |
---|
70 | |
---|
71 | " |
---|
72 | ALTER TABLE `".PREFIX_TABLE."categories` |
---|
73 | ADD UNIQUE `categories_i3` (`permalink`) |
---|
74 | ;", |
---|
75 | |
---|
76 | " |
---|
77 | ALTER TABLE `".PREFIX_TABLE."groups` |
---|
78 | ADD COLUMN `is_default` enum('true','false') NOT NULL default 'false' |
---|
79 | ;", |
---|
80 | |
---|
81 | " |
---|
82 | RENAME TABLE `".PREFIX_TABLE."history` TO `".PREFIX_TABLE."history_backup` |
---|
83 | ;", |
---|
84 | |
---|
85 | " |
---|
86 | CREATE TABLE `".PREFIX_TABLE."history` ( |
---|
87 | `id` int(10) unsigned NOT NULL auto_increment, |
---|
88 | `date` date NOT NULL default '0000-00-00', |
---|
89 | `time` time NOT NULL default '00:00:00', |
---|
90 | `year` smallint(4) NOT NULL default '0', |
---|
91 | `month` tinyint(2) NOT NULL default '0', |
---|
92 | `day` tinyint(2) NOT NULL default '0', |
---|
93 | `hour` tinyint(2) NOT NULL default '0', |
---|
94 | `user_id` smallint(5) NOT NULL default '0', |
---|
95 | `IP` varchar(15) NOT NULL default '', |
---|
96 | `section` enum('categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats') default NULL, |
---|
97 | `category_id` smallint(5) default NULL, |
---|
98 | `tag_ids` varchar(50) default NULL, |
---|
99 | `image_id` mediumint(8) default NULL, |
---|
100 | `summarized` enum('true','false') default 'false', |
---|
101 | `image_type` enum('picture','high','other') default NULL, |
---|
102 | PRIMARY KEY (`id`), |
---|
103 | KEY `history_i1` (`summarized`) |
---|
104 | ) TYPE=MyISAM |
---|
105 | ;", |
---|
106 | |
---|
107 | " |
---|
108 | ALTER TABLE `".PREFIX_TABLE."image_category` |
---|
109 | DROP INDEX `image_category_i1` |
---|
110 | ;", |
---|
111 | |
---|
112 | " |
---|
113 | ALTER TABLE `".PREFIX_TABLE."image_category` |
---|
114 | ADD INDEX `image_category_i1` (`category_id`) |
---|
115 | ;", |
---|
116 | |
---|
117 | " |
---|
118 | ALTER TABLE `".PREFIX_TABLE."image_category` |
---|
119 | DROP INDEX `image_category_i2` |
---|
120 | ;", |
---|
121 | |
---|
122 | " |
---|
123 | ALTER TABLE `".PREFIX_TABLE."images` |
---|
124 | ADD COLUMN `high_filesize` mediumint(9) unsigned default NULL |
---|
125 | ;", |
---|
126 | |
---|
127 | " |
---|
128 | ALTER TABLE `".PREFIX_TABLE."user_infos` |
---|
129 | CHANGE COLUMN `language` |
---|
130 | `language` varchar(50) NOT NULL default 'en_UK.iso-8859-1' |
---|
131 | ;", |
---|
132 | |
---|
133 | " |
---|
134 | ALTER TABLE `".PREFIX_TABLE."user_infos` |
---|
135 | DROP COLUMN `auto_login_key` |
---|
136 | ;", |
---|
137 | |
---|
138 | " |
---|
139 | ALTER TABLE `".PREFIX_TABLE."user_infos` |
---|
140 | ADD COLUMN `show_nb_hits` enum('true','false') NOT NULL default 'false' |
---|
141 | ;", |
---|
142 | |
---|
143 | " |
---|
144 | ALTER TABLE `".PREFIX_TABLE."user_mail_notification` |
---|
145 | DROP INDEX `uidx_check_key` |
---|
146 | ;", |
---|
147 | |
---|
148 | " |
---|
149 | ALTER TABLE `".PREFIX_TABLE."user_mail_notification` |
---|
150 | ADD UNIQUE `user_mail_notification_ui1` (`check_key`) |
---|
151 | ;", |
---|
152 | |
---|
153 | " |
---|
154 | CREATE TABLE `".PREFIX_TABLE."history_summary` ( |
---|
155 | `id` varchar(13) NOT NULL default '', |
---|
156 | `year` smallint(4) NOT NULL default '0', |
---|
157 | `month` tinyint(2) default NULL, |
---|
158 | `day` tinyint(2) default NULL, |
---|
159 | `hour` tinyint(2) default NULL, |
---|
160 | `nb_pages` int(11) default NULL, |
---|
161 | PRIMARY KEY (`id`) |
---|
162 | ) TYPE=MyISAM |
---|
163 | ;", |
---|
164 | |
---|
165 | " |
---|
166 | CREATE TABLE `".PREFIX_TABLE."old_permalinks` ( |
---|
167 | `cat_id` smallint(5) unsigned NOT NULL default '0', |
---|
168 | `permalink` varchar(64) NOT NULL default '', |
---|
169 | `date_deleted` datetime NOT NULL default '0000-00-00 00:00:00', |
---|
170 | `last_hit` datetime default NULL, |
---|
171 | `hit` int(10) unsigned NOT NULL default '0', |
---|
172 | PRIMARY KEY (`permalink`) |
---|
173 | ) TYPE=MyISAM |
---|
174 | ;", |
---|
175 | |
---|
176 | " |
---|
177 | CREATE TABLE `".PREFIX_TABLE."plugins` ( |
---|
178 | `id` varchar(64) binary NOT NULL default '', |
---|
179 | `state` enum('inactive','active') NOT NULL default 'inactive', |
---|
180 | `version` varchar(64) NOT NULL default '0', |
---|
181 | PRIMARY KEY (`id`) |
---|
182 | ) TYPE=MyISAM |
---|
183 | ;", |
---|
184 | |
---|
185 | " |
---|
186 | CREATE TABLE `".PREFIX_TABLE."user_cache_categories` ( |
---|
187 | `user_id` smallint(5) NOT NULL default '0', |
---|
188 | `cat_id` smallint(5) unsigned NOT NULL default '0', |
---|
189 | `max_date_last` datetime default NULL, |
---|
190 | `count_images` mediumint(8) unsigned default '0', |
---|
191 | `count_categories` mediumint(8) unsigned default '0', |
---|
192 | PRIMARY KEY (`user_id`,`cat_id`) |
---|
193 | ) TYPE=MyISAM |
---|
194 | ;", |
---|
195 | |
---|
196 | " |
---|
197 | CREATE TABLE `".PREFIX_TABLE."ws_access` ( |
---|
198 | `id` smallint(5) unsigned NOT NULL auto_increment, |
---|
199 | `name` varchar(32) NOT NULL default '', |
---|
200 | `access` varchar(255) default NULL, |
---|
201 | `start` datetime default NULL, |
---|
202 | `end` datetime default NULL, |
---|
203 | `request` varchar(255) default NULL, |
---|
204 | `limit` smallint(5) unsigned default NULL, |
---|
205 | `comment` varchar(255) default NULL, |
---|
206 | PRIMARY KEY (`id`), |
---|
207 | UNIQUE KEY `ws_access_ui1` (`name`) |
---|
208 | ) TYPE=MyISAM COMMENT='Access for Web Services' |
---|
209 | ;", |
---|
210 | |
---|
211 | " |
---|
212 | INSERT INTO ".PREFIX_TABLE."config |
---|
213 | (param,value,comment) |
---|
214 | VALUES |
---|
215 | ('show_nb_hits', 'false', 'Show hits count under thumbnails') |
---|
216 | ;", |
---|
217 | |
---|
218 | " |
---|
219 | INSERT INTO ".PREFIX_TABLE."config |
---|
220 | (param,value,comment) |
---|
221 | VALUES |
---|
222 | ('history_admin','false','keep a history of administrator visits on your website') |
---|
223 | ;", |
---|
224 | |
---|
225 | " |
---|
226 | INSERT INTO ".PREFIX_TABLE."config |
---|
227 | (param,value,comment) |
---|
228 | VALUES |
---|
229 | ('history_guest','true','keep a history of guest visits on your website') |
---|
230 | ;", |
---|
231 | |
---|
232 | " |
---|
233 | INSERT INTO ".PREFIX_TABLE."config |
---|
234 | (param,value,comment) |
---|
235 | VALUES |
---|
236 | ('allow_user_registration','true','allow visitors to register?') |
---|
237 | ;", |
---|
238 | |
---|
239 | " |
---|
240 | INSERT INTO ".PREFIX_TABLE."config |
---|
241 | (param,value,comment) |
---|
242 | VALUES |
---|
243 | ('secret_key', MD5(RAND()), 'a secret key specific to the gallery for internal use') |
---|
244 | ;", |
---|
245 | |
---|
246 | " |
---|
247 | INSERT INTO ".PREFIX_TABLE."config |
---|
248 | (param,value,comment) |
---|
249 | VALUES |
---|
250 | ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail') |
---|
251 | ;", |
---|
252 | |
---|
253 | " |
---|
254 | INSERT INTO ".PREFIX_TABLE."config |
---|
255 | (param,value,comment) |
---|
256 | VALUES |
---|
257 | ('nbm_send_recent_post_dates','true','Send recent post by dates for notification by mail') |
---|
258 | ;", |
---|
259 | |
---|
260 | " |
---|
261 | INSERT INTO ".PREFIX_TABLE."config |
---|
262 | (param,value,comment) |
---|
263 | VALUES |
---|
264 | ('email_admin_on_new_user','false','Send an email to theadministrators when a user registers') |
---|
265 | ;", |
---|
266 | |
---|
267 | " |
---|
268 | INSERT INTO ".PREFIX_TABLE."config |
---|
269 | (param,value,comment) |
---|
270 | VALUES |
---|
271 | ('email_admin_on_comment','false','Send an email to the administrators when a valid comment is entered') |
---|
272 | ;", |
---|
273 | |
---|
274 | " |
---|
275 | INSERT INTO ".PREFIX_TABLE."config |
---|
276 | (param,value,comment) |
---|
277 | VALUES |
---|
278 | ('email_admin_on_comment_validation','false','Send an email to the administrators when a comment requires validation') |
---|
279 | ;", |
---|
280 | |
---|
281 | " |
---|
282 | INSERT INTO ".PREFIX_TABLE."config |
---|
283 | (param,value,comment) |
---|
284 | VALUES |
---|
285 | ('email_admin_on_picture_uploaded','false','Send an email to the administrators when a picture is uploaded') |
---|
286 | ;", |
---|
287 | |
---|
288 | " |
---|
289 | UPDATE ".PREFIX_TABLE."user_cache |
---|
290 | SET need_update = 'true' |
---|
291 | ;", |
---|
292 | |
---|
293 | ); |
---|
294 | |
---|
295 | foreach ($queries as $query) |
---|
296 | { |
---|
297 | pwg_query($query); |
---|
298 | } |
---|
299 | |
---|
300 | $replacements = array( |
---|
301 | array(''', '\''), |
---|
302 | array('"', '"'), |
---|
303 | array('<', '<'), |
---|
304 | array('>', '>'), |
---|
305 | array('&', '&') // <- this must be the last one |
---|
306 | ); |
---|
307 | |
---|
308 | foreach ($replacements as $replacement) |
---|
309 | { |
---|
310 | $query = ' |
---|
311 | UPDATE '.PREFIX_TABLE.'comments |
---|
312 | SET content = REPLACE(content, "'. |
---|
313 | addslashes($replacement[0]). |
---|
314 | '", "'. |
---|
315 | addslashes($replacement[1]). |
---|
316 | '") |
---|
317 | ;'; |
---|
318 | pwg_query($query); |
---|
319 | } |
---|
320 | |
---|
321 | load_conf_from_db(); |
---|
322 | |
---|
323 | $query = " |
---|
324 | UPDATE ".USER_INFOS_TABLE." |
---|
325 | SET |
---|
326 | template = '".$conf['default_template']."', |
---|
327 | nb_image_line = ".$conf['nb_image_line'].", |
---|
328 | nb_line_page = ".$conf['nb_line_page'].", |
---|
329 | language = '".$conf['default_language']."', |
---|
330 | maxwidth = ". |
---|
331 | (empty($conf['default_maxwidth']) ? "NULL" : $conf['default_maxwidth']). |
---|
332 | ", |
---|
333 | maxheight = ". |
---|
334 | (empty($conf['default_maxheight']) ? "NULL" : $conf['default_maxheight']). |
---|
335 | ", |
---|
336 | recent_period = ".$conf['recent_period'].", |
---|
337 | expand = '".boolean_to_string($conf['auto_expand'])."', |
---|
338 | show_nb_comments = '".boolean_to_string($conf['show_nb_comments'])."', |
---|
339 | show_nb_hits = '".boolean_to_string($conf['show_nb_hits'])."', |
---|
340 | enabled_high = '".boolean_to_string( |
---|
341 | (isset($conf['newuser_default_enabled_high']) ? |
---|
342 | $conf['newuser_default_enabled_high'] : true) |
---|
343 | ). |
---|
344 | "' |
---|
345 | WHERE |
---|
346 | user_id = ".$conf['default_user_id'].";"; |
---|
347 | pwg_query($query); |
---|
348 | |
---|
349 | $query = " |
---|
350 | DELETE FROM ".CONFIG_TABLE." |
---|
351 | WHERE |
---|
352 | param IN |
---|
353 | ( |
---|
354 | 'default_template', |
---|
355 | 'nb_image_line', |
---|
356 | 'nb_line_page', |
---|
357 | 'default_language', |
---|
358 | 'default_maxwidth', |
---|
359 | 'default_maxheight', |
---|
360 | 'recent_period', |
---|
361 | 'auto_expand', |
---|
362 | 'show_nb_comments', |
---|
363 | 'show_nb_hits' |
---|
364 | ) |
---|
365 | ;"; |
---|
366 | pwg_query($query); |
---|
367 | |
---|
368 | // now we upgrade from 1.7.0 |
---|
369 | // include_once(PHPWG_ROOT_PATH.'install/upgrade_1.7.0.php'); |
---|
370 | ?> |
---|