source: trunk/install/upgrade_1.4.0.php @ 29482

Last change on this file since 29482 was 26461, checked in by mistic100, 11 years ago

Update headers to 2014. Happy new year!!

  • Property svn:eol-style set to LF
File size: 7.1 KB
RevLine 
[1927]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[26461]5// | Copyright(C) 2008-2014 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[1927]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$last_time = get_moment();
37
38// will the user have to edit include/config_local.inc.php for
39// prefix_thumbnail configuration parameter
40$query = '
41SELECT value
42  FROM '.CONFIG_TABLE.'
43  WHERE param = \'prefix_thumbnail\'
44;';
[4325]45list($prefix_thumbnail) = pwg_db_fetch_row(pwg_query($query));
[1927]46
47// delete obsolete configuration
48$query = '
49DELETE
50  FROM '.PREFIX_TABLE.'config
51  WHERE param IN (
52   \'prefix_thumbnail\',
53   \'mail_webmaster\',
54   \'upload_maxfilesize\',
55   \'upload_maxwidth\',
56   \'upload_maxheight\',
57   \'upload_maxwidth_thumbnail\',
58   \'upload_maxheight_thumbnail\',
59   \'mail_notification\',
60   \'use_iptc\',
61   \'use_exif\',
62   \'show_iptc\',
63   \'show_exif\',
64   \'authorize_remembering\'
65   )
66;';
[2884]67pwg_query($query);
[1927]68
69$queries = array(
70
71  "
[2339]72ALTER TABLE piwigo_categories
[1927]73  CHANGE COLUMN date_last date_last datetime default NULL
74;",
75
76  "
[2339]77ALTER TABLE piwigo_comments
[1927]78  ADD COLUMN validation_date datetime default NULL
79;",
80
81  "
[2339]82UPDATE piwigo_comments
[1927]83  SET validation_date = date
84",
85
86  "
[2339]87ALTER TABLE piwigo_comments
[1927]88  ADD INDEX comments_i1 (image_id)
89;",
90
91  "
[2339]92ALTER TABLE piwigo_comments
[1927]93  ADD INDEX comments_i2 (validation_date)
94;",
95
96  "
[2339]97ALTER TABLE piwigo_favorites
[1927]98  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
99;",
100
101  "
[2339]102ALTER TABLE piwigo_images
[1927]103  CHANGE COLUMN date_available
104    date_available datetime NOT NULL default '0000-00-00 00:00:00'
105;",
106
107  "
[2339]108ALTER TABLE piwigo_rate
[1927]109  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
110;",
111
112  "
[2339]113ALTER TABLE piwigo_sessions
[1927]114  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
115;",
116
117  "
[2339]118ALTER TABLE piwigo_user_access
[1927]119  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
120;",
121
122  "
[2339]123DROP TABLE piwigo_user_forbidden
[1927]124;",
125
126  "
[2339]127ALTER TABLE piwigo_user_group
[1927]128 CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
129;",
130
131  "
[2339]132ALTER TABLE piwigo_users
[1927]133  CHANGE COLUMN id id smallint(5) NOT NULL auto_increment
134;",
135
136  "
[2339]137CREATE TABLE piwigo_caddie (
[1927]138  user_id smallint(5) NOT NULL default '0',
139  element_id mediumint(8) NOT NULL default '0',
140  PRIMARY KEY  (user_id,element_id)
[9086]141) ENGINE=MyISAM
[1927]142;",
143
144  "
[2339]145CREATE TABLE piwigo_user_cache (
[1927]146  user_id smallint(5) NOT NULL default '0',
147  need_update enum('true','false') NOT NULL default 'true',
148  forbidden_categories text,
149  PRIMARY KEY  (user_id)
[9086]150) ENGINE=MyISAM
[1927]151;",
152
153  "
[2339]154CREATE TABLE piwigo_user_feed (
[1927]155  id varchar(50) binary NOT NULL default '',
156  user_id smallint(5) NOT NULL default '0',
157  last_check datetime default NULL,
158  PRIMARY KEY  (id)
[9086]159) ENGINE=MyISAM
[1927]160;",
161
162  "
[2339]163CREATE TABLE piwigo_user_infos (
[1927]164  user_id smallint(5) NOT NULL default '0',
165  nb_image_line tinyint(1) unsigned NOT NULL default '5',
166  nb_line_page tinyint(3) unsigned NOT NULL default '3',
167  status enum('admin','guest') NOT NULL default 'guest',
168  language varchar(50) NOT NULL default 'english',
169  maxwidth smallint(6) default NULL,
170  maxheight smallint(6) default NULL,
171  expand enum('true','false') NOT NULL default 'false',
172  show_nb_comments enum('true','false') NOT NULL default 'false',
173  recent_period tinyint(3) unsigned NOT NULL default '7',
174  template varchar(255) NOT NULL default 'yoga',
175  registration_date datetime NOT NULL default '0000-00-00 00:00:00',
176  UNIQUE KEY user_infos_ui1 (user_id)
[9086]177) ENGINE=MyISAM
[1927]178;"
179  );
180
181foreach ($queries as $query)
182{
[2339]183  $query = str_replace('piwigo_', PREFIX_TABLE, $query);
[1927]184  pwg_query($query);
185}
186
[2339]187// user datas migration from piwigo_users to piwigo_user_infos
[1927]188$query = '
189SELECT *
190  FROM '.USERS_TABLE.'
191;';
192
193$datas = array();
[4325]194list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
[1927]195
196$result = pwg_query($query);
[4325]197while ($row = pwg_db_fetch_assoc($result))
[1927]198{
199  $row['user_id'] = $row['id'];
200  $row['registration_date'] = $dbnow;
201  array_push($datas, $row);
202}
203
204include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
205mass_inserts(
206  USER_INFOS_TABLE,
207  array(
208    'user_id',
209    'nb_image_line',
210    'nb_line_page',
211    'status',
212    'language',
213    'maxwidth',
214    'maxheight',
215    'expand',
216    'show_nb_comments',
217    'recent_period',
218    'template',
219    'registration_date'
220    ),
221  $datas
222  );
223
224$queries = array(
225
226  "
227UPDATE ".USER_INFOS_TABLE."
228  SET template = 'yoga'
229;",
230
231  "
232UPDATE ".USER_INFOS_TABLE."
233  SET language = 'en_UK.iso-8859-1'
234  WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
235;",
236
237  "
238UPDATE ".CONFIG_TABLE."
239  SET value = 'en_UK.iso-8859-1'
240  WHERE param = 'default_language'
241    AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
242;",
243
244  "
245UPDATE ".CONFIG_TABLE."
246  SET value = 'yoga'
247  WHERE param = 'default_template'
248;",
249
250  "
251INSERT INTO ".CONFIG_TABLE."
252  (param,value,comment)
253  VALUES
254  (
255    'gallery_title',
[2339]256    'Piwigo demonstration site',
[1927]257    'Title at top of each page and for RSS feed'
258  )
259;",
260
261  "
262INSERT INTO ".CONFIG_TABLE."
263  (param,value,comment)
264  VALUES
265  (
266    'gallery_description',
267    'My photos web site',
268    'Short description displayed with gallery title'
269  )
270;"
271
272  );
273
274foreach ($queries as $query)
275{
[2339]276  $query = str_replace('piwigo_', PREFIX_TABLE, $query);
[1927]277  pwg_query($query);
278}
279
280if ($prefix_thumbnail != 'TN-')
281{
282  array_push(
283    $page['infos'],
284    'the thumbnail prefix configuration parameter was moved to configuration
[5215]285file, copy config.inc.php from "tools" directory to "local/config" directory
[1927]286and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail
287    );
288}
289
290// now we upgrade from 1.5.0 to 1.6.0
291include_once(PHPWG_ROOT_PATH.'install/upgrade_1.5.0.php');
292?>
Note: See TracBrowser for help on using the repository browser.