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