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

Last change on this file since 2339 was 2299, checked in by plg, 16 years ago

Bug fixed: as rvelices notified me by email, my header replacement script was
bugged (r2297 was repeating new and old header).

By the way, I've also removed the replacement keywords. We were using them
because it was a common usage with CVS but it is advised not to use them with
Subversion. Personnaly, it is a problem when I search differences between 2
Piwigo installations outside Subversion.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ('This page cannot be loaded directly, load upgrade.php');
27}
28else
29{
30  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
31  {
32    die ('Hacking attempt!');
33  }
34}
35
36$queries = array(
37"
38ALTER TABLE `".PREFIX_TABLE."categories`
39  ADD COLUMN `permalink` varchar(64) default NULL
40;",
41
42"
43ALTER TABLE `".PREFIX_TABLE."categories`
44  ADD COLUMN `image_order` varchar(128) default NULL
45;",
46
47"
48ALTER TABLE `".PREFIX_TABLE."categories`
49  ADD UNIQUE `categories_i3` (`permalink`)
50;",
51
52"
53ALTER TABLE `".PREFIX_TABLE."groups`
54  ADD COLUMN `is_default` enum('true','false') NOT NULL default 'false'
55;",
56
57"
58RENAME TABLE `".PREFIX_TABLE."history` TO `".PREFIX_TABLE."history_backup`
59;",
60
61"
62CREATE 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"
84ALTER TABLE `".PREFIX_TABLE."image_category`
85  DROP INDEX `image_category_i1`
86;",
87
88"
89ALTER TABLE `".PREFIX_TABLE."image_category`
90  ADD INDEX `image_category_i1` (`category_id`)
91;",
92
93"
94ALTER TABLE `".PREFIX_TABLE."image_category`
95  DROP INDEX `image_category_i2`
96;",
97
98"
99ALTER TABLE `".PREFIX_TABLE."images`
100  ADD COLUMN `high_filesize` mediumint(9) unsigned default NULL
101;",
102
103"
104ALTER TABLE `".PREFIX_TABLE."user_infos`
105  CHANGE COLUMN `language`
106    `language` varchar(50) NOT NULL default 'en_UK.iso-8859-1'
107;",
108
109"
110ALTER TABLE `".PREFIX_TABLE."user_infos`
111  DROP COLUMN `auto_login_key`
112;",
113
114"
115ALTER TABLE `".PREFIX_TABLE."user_infos`
116  ADD COLUMN `show_nb_hits` enum('true','false') NOT NULL default 'false'
117;",
118
119"
120ALTER TABLE `".PREFIX_TABLE."user_mail_notification`
121  DROP INDEX `uidx_check_key`
122;",
123
124"
125ALTER TABLE `".PREFIX_TABLE."user_mail_notification`
126  ADD UNIQUE `user_mail_notification_ui1` (`check_key`)
127;",
128
129"
130CREATE 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"
142CREATE 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"
153CREATE 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"
162CREATE 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"
173CREATE TABLE `".PREFIX_TABLE."ws_access` (
174  `id` smallint(5) unsigned NOT NULL auto_increment,
175  `name` varchar(32) NOT NULL default '',
176  `access` varchar(255) default NULL,
177  `start` datetime default NULL,
178  `end` datetime default NULL,
179  `request` varchar(255) default NULL,
180  `limit` smallint(5) unsigned default NULL,
181  `comment` varchar(255) default NULL,
182  PRIMARY KEY  (`id`),
183  UNIQUE KEY `ws_access_ui1` (`name`)
184) TYPE=MyISAM COMMENT='Access for Web Services'
185;",
186
187"
188INSERT INTO ".PREFIX_TABLE."config
189  (param,value,comment)
190  VALUES
191  ('show_nb_hits', 'false', 'Show hits count under thumbnails')
192;",
193
194"
195INSERT INTO ".PREFIX_TABLE."config
196  (param,value,comment)
197  VALUES
198  ('history_admin','false','keep a history of administrator visits on your website')
199;",
200
201"
202INSERT INTO ".PREFIX_TABLE."config
203  (param,value,comment)
204  VALUES
205  ('history_guest','true','keep a history of guest visits on your website')
206;",
207
208"
209INSERT INTO ".PREFIX_TABLE."config
210  (param,value,comment)
211  VALUES
212  ('allow_user_registration','true','allow visitors to register?')
213;",
214
215"
216INSERT INTO ".PREFIX_TABLE."config
217  (param,value,comment)
218  VALUES
219  ('secret_key', MD5(RAND()), 'a secret key specific to the gallery for internal use')
220;",
221
222"
223INSERT INTO ".PREFIX_TABLE."config
224  (param,value,comment)
225  VALUES
226  ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail')
227;",
228
229"
230INSERT INTO ".PREFIX_TABLE."config
231  (param,value,comment)
232  VALUES
233  ('nbm_send_recent_post_dates','true','Send recent post by dates for notification by mail')
234;",
235
236"
237INSERT INTO ".PREFIX_TABLE."config
238  (param,value,comment)
239  VALUES
240  ('email_admin_on_new_user','false','Send an email to theadministrators when a user registers')
241;",
242
243"
244INSERT INTO ".PREFIX_TABLE."config
245  (param,value,comment)
246  VALUES
247  ('email_admin_on_comment','false','Send an email to the administrators when a valid comment is entered')
248;",
249
250"
251INSERT INTO ".PREFIX_TABLE."config
252  (param,value,comment)
253  VALUES
254  ('email_admin_on_comment_validation','false','Send an email to the administrators when a comment requires validation')
255;",
256
257"
258INSERT INTO ".PREFIX_TABLE."config
259  (param,value,comment)
260  VALUES
261  ('email_admin_on_picture_uploaded','false','Send an email to the administrators when a picture is uploaded')
262;",
263
264"
265UPDATE ".PREFIX_TABLE."user_cache
266  SET need_update = 'true'
267;",
268
269);
270
271foreach ($queries as $query)
272{
273  pwg_query($query);
274}
275
276$replacements = array(
277  array('&#039;', '\''),
278  array('&quot;', '"'),
279  array('&lt;',   '<'),
280  array('&gt;',   '>'),
281  array('&amp;',  '&') // <- this must be the last one
282  );
283
284foreach ($replacements as $replacement)
285{
286    $query = '
287UPDATE '.PREFIX_TABLE.'comments
288  SET content = REPLACE(content, "'.
289  addslashes($replacement[0]).
290  '", "'.
291  addslashes($replacement[1]).
292  '")
293;';
294    pwg_query($query);
295}
296
297load_conf_from_db();
298
299$query = "
300UPDATE ".USER_INFOS_TABLE."
301SET
302  template = '".$conf['default_template']."',
303  nb_image_line = ".$conf['nb_image_line'].",
304  nb_line_page = ".$conf['nb_line_page'].",
305  language = '".$conf['default_language']."',
306  maxwidth = ".
307  (empty($conf['default_maxwidth']) ? "NULL" : $conf['default_maxwidth']).
308  ",
309  maxheight = ".
310  (empty($conf['default_maxheight']) ? "NULL" : $conf['default_maxheight']).
311  ",
312  recent_period = ".$conf['recent_period'].",
313  expand = '".boolean_to_string($conf['auto_expand'])."',
314  show_nb_comments = '".boolean_to_string($conf['show_nb_comments'])."',
315  show_nb_hits = '".boolean_to_string($conf['show_nb_hits'])."',
316  enabled_high = '".boolean_to_string(
317    (isset($conf['newuser_default_enabled_high']) ?
318      $conf['newuser_default_enabled_high'] : true)
319    ).
320  "'
321WHERE
322  user_id = ".$conf['default_user_id'].";";
323pwg_query($query);
324
325$query = "
326DELETE FROM ".CONFIG_TABLE."
327WHERE
328  param IN
329(
330  'default_template',
331  'nb_image_line',
332  'nb_line_page',
333  'default_language',
334  'default_maxwidth',
335  'default_maxheight',
336  'recent_period',
337  'auto_expand',
338  'show_nb_comments',
339  'show_nb_hits'
340)
341;";
342pwg_query($query);
343
344// now we upgrade from 1.7.0
345// include_once(PHPWG_ROOT_PATH.'install/upgrade_1.7.0.php');
346?>
Note: See TracBrowser for help on using the repository browser.