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

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

Modification: new header on PHP files, PhpWebGallery renamed Piwigo.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 10.9 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// +-----------------------------------------------------------------------+
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
48if (!defined('PHPWG_ROOT_PATH'))
49{
50  die ('This page cannot be loaded directly, load upgrade.php');
51}
52else
53{
54  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
55  {
56    die ('Hacking attempt!');
57  }
58}
59
60$queries = array(
61"
62ALTER TABLE `".PREFIX_TABLE."categories`
63  ADD COLUMN `permalink` varchar(64) default NULL
64;",
65
66"
67ALTER TABLE `".PREFIX_TABLE."categories`
68  ADD COLUMN `image_order` varchar(128) default NULL
69;",
70
71"
72ALTER TABLE `".PREFIX_TABLE."categories`
73  ADD UNIQUE `categories_i3` (`permalink`)
74;",
75
76"
77ALTER TABLE `".PREFIX_TABLE."groups`
78  ADD COLUMN `is_default` enum('true','false') NOT NULL default 'false'
79;",
80
81"
82RENAME TABLE `".PREFIX_TABLE."history` TO `".PREFIX_TABLE."history_backup`
83;",
84
85"
86CREATE 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"
108ALTER TABLE `".PREFIX_TABLE."image_category`
109  DROP INDEX `image_category_i1`
110;",
111
112"
113ALTER TABLE `".PREFIX_TABLE."image_category`
114  ADD INDEX `image_category_i1` (`category_id`)
115;",
116
117"
118ALTER TABLE `".PREFIX_TABLE."image_category`
119  DROP INDEX `image_category_i2`
120;",
121
122"
123ALTER TABLE `".PREFIX_TABLE."images`
124  ADD COLUMN `high_filesize` mediumint(9) unsigned default NULL
125;",
126
127"
128ALTER TABLE `".PREFIX_TABLE."user_infos`
129  CHANGE COLUMN `language`
130    `language` varchar(50) NOT NULL default 'en_UK.iso-8859-1'
131;",
132
133"
134ALTER TABLE `".PREFIX_TABLE."user_infos`
135  DROP COLUMN `auto_login_key`
136;",
137
138"
139ALTER TABLE `".PREFIX_TABLE."user_infos`
140  ADD COLUMN `show_nb_hits` enum('true','false') NOT NULL default 'false'
141;",
142
143"
144ALTER TABLE `".PREFIX_TABLE."user_mail_notification`
145  DROP INDEX `uidx_check_key`
146;",
147
148"
149ALTER TABLE `".PREFIX_TABLE."user_mail_notification`
150  ADD UNIQUE `user_mail_notification_ui1` (`check_key`)
151;",
152
153"
154CREATE 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"
166CREATE 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"
177CREATE 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"
186CREATE 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"
197CREATE 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"
212INSERT INTO ".PREFIX_TABLE."config
213  (param,value,comment)
214  VALUES
215  ('show_nb_hits', 'false', 'Show hits count under thumbnails')
216;",
217
218"
219INSERT 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"
226INSERT 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"
233INSERT INTO ".PREFIX_TABLE."config
234  (param,value,comment)
235  VALUES
236  ('allow_user_registration','true','allow visitors to register?')
237;",
238
239"
240INSERT 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"
247INSERT 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"
254INSERT 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"
261INSERT 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"
268INSERT 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"
275INSERT 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"
282INSERT 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"
289UPDATE ".PREFIX_TABLE."user_cache
290  SET need_update = 'true'
291;",
292
293);
294
295foreach ($queries as $query)
296{
297  pwg_query($query);
298}
299
300$replacements = array(
301  array('&#039;', '\''),
302  array('&quot;', '"'),
303  array('&lt;',   '<'),
304  array('&gt;',   '>'),
305  array('&amp;',  '&') // <- this must be the last one
306  );
307
308foreach ($replacements as $replacement)
309{
310    $query = '
311UPDATE '.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
321load_conf_from_db();
322
323$query = "
324UPDATE ".USER_INFOS_TABLE."
325SET
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  "'
345WHERE
346  user_id = ".$conf['default_user_id'].";";
347pwg_query($query);
348
349$query = "
350DELETE FROM ".CONFIG_TABLE."
351WHERE
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;";
366pwg_query($query);
367
368// now we upgrade from 1.7.0
369// include_once(PHPWG_ROOT_PATH.'install/upgrade_1.7.0.php');
370?>
Note: See TracBrowser for help on using the repository browser.