source: trunk/install/upgrade_1.6.2.php @ 1927

Last change on this file since 1927 was 1927, checked in by plg, 17 years ago

New: release upgrade scripts from 1.3.0 come back from branch 1.6. Only
install/upgrade_1.6.2.php is really new, upgrade 60 was taken into
account. Detection of 1.6.0 or 1.6.2 data model in upgrade.php. Release
upgrade scripts added on trunk to be kept in a safer place.

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