source: trunk/install/upgrade_1.4.0.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: 8.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.4.0.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$last_time = get_moment();
61
62// will the user have to edit include/config_local.inc.php for
63// prefix_thumbnail configuration parameter
64$query = '
65SELECT value
66  FROM '.CONFIG_TABLE.'
67  WHERE param = \'prefix_thumbnail\'
68;';
69list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query));
70
71// delete obsolete configuration
72$query = '
73DELETE
74  FROM '.PREFIX_TABLE.'config
75  WHERE param IN (
76   \'prefix_thumbnail\',
77   \'mail_webmaster\',
78   \'upload_maxfilesize\',
79   \'upload_maxwidth\',
80   \'upload_maxheight\',
81   \'upload_maxwidth_thumbnail\',
82   \'upload_maxheight_thumbnail\',
83   \'mail_notification\',
84   \'use_iptc\',
85   \'use_exif\',
86   \'show_iptc\',
87   \'show_exif\',
88   \'authorize_remembering\'
89   )
90;';
91mysql_query($query);
92
93$queries = array(
94
95  "
96ALTER TABLE phpwebgallery_categories
97  CHANGE COLUMN date_last date_last datetime default NULL
98;",
99
100  "
101ALTER TABLE phpwebgallery_comments
102  ADD COLUMN validation_date datetime default NULL
103;",
104
105  "
106UPDATE phpwebgallery_comments
107  SET validation_date = date
108",
109
110  "
111ALTER TABLE phpwebgallery_comments
112  ADD INDEX comments_i1 (image_id)
113;",
114
115  "
116ALTER TABLE phpwebgallery_comments
117  ADD INDEX comments_i2 (validation_date)
118;",
119
120  "
121ALTER TABLE phpwebgallery_favorites
122  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
123;",
124
125  "
126ALTER TABLE phpwebgallery_images
127  CHANGE COLUMN date_available
128    date_available datetime NOT NULL default '0000-00-00 00:00:00'
129;",
130
131  "
132ALTER TABLE phpwebgallery_rate
133  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
134;",
135
136  "
137ALTER TABLE phpwebgallery_sessions
138  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
139;",
140
141  "
142ALTER TABLE phpwebgallery_user_access
143  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
144;",
145
146  "
147DROP TABLE phpwebgallery_user_forbidden
148;",
149
150  "
151ALTER TABLE phpwebgallery_user_group
152 CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
153;",
154
155  "
156ALTER TABLE phpwebgallery_users
157  CHANGE COLUMN id id smallint(5) NOT NULL auto_increment
158;",
159
160  "
161CREATE TABLE phpwebgallery_caddie (
162  user_id smallint(5) NOT NULL default '0',
163  element_id mediumint(8) NOT NULL default '0',
164  PRIMARY KEY  (user_id,element_id)
165) TYPE=MyISAM
166;",
167
168  "
169CREATE TABLE phpwebgallery_user_cache (
170  user_id smallint(5) NOT NULL default '0',
171  need_update enum('true','false') NOT NULL default 'true',
172  forbidden_categories text,
173  PRIMARY KEY  (user_id)
174) TYPE=MyISAM
175;",
176
177  "
178CREATE TABLE phpwebgallery_user_feed (
179  id varchar(50) binary NOT NULL default '',
180  user_id smallint(5) NOT NULL default '0',
181  last_check datetime default NULL,
182  PRIMARY KEY  (id)
183) TYPE=MyISAM
184;",
185
186  "
187CREATE TABLE phpwebgallery_user_infos (
188  user_id smallint(5) NOT NULL default '0',
189  nb_image_line tinyint(1) unsigned NOT NULL default '5',
190  nb_line_page tinyint(3) unsigned NOT NULL default '3',
191  status enum('admin','guest') NOT NULL default 'guest',
192  language varchar(50) NOT NULL default 'english',
193  maxwidth smallint(6) default NULL,
194  maxheight smallint(6) default NULL,
195  expand enum('true','false') NOT NULL default 'false',
196  show_nb_comments enum('true','false') NOT NULL default 'false',
197  recent_period tinyint(3) unsigned NOT NULL default '7',
198  template varchar(255) NOT NULL default 'yoga',
199  registration_date datetime NOT NULL default '0000-00-00 00:00:00',
200  UNIQUE KEY user_infos_ui1 (user_id)
201) TYPE=MyISAM
202;"
203  );
204
205foreach ($queries as $query)
206{
207  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
208  pwg_query($query);
209}
210
211// user datas migration from phpwebgallery_users to phpwebgallery_user_infos
212$query = '
213SELECT *
214  FROM '.USERS_TABLE.'
215;';
216
217$datas = array();
218list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
219
220$result = pwg_query($query);
221while ($row = mysql_fetch_array($result))
222{
223  $row['user_id'] = $row['id'];
224  $row['registration_date'] = $dbnow;
225  array_push($datas, $row);
226}
227
228include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
229mass_inserts(
230  USER_INFOS_TABLE,
231  array(
232    'user_id',
233    'nb_image_line',
234    'nb_line_page',
235    'status',
236    'language',
237    'maxwidth',
238    'maxheight',
239    'expand',
240    'show_nb_comments',
241    'recent_period',
242    'template',
243    'registration_date'
244    ),
245  $datas
246  );
247
248$queries = array(
249
250  "
251UPDATE ".USER_INFOS_TABLE."
252  SET template = 'yoga'
253;",
254
255  "
256UPDATE ".USER_INFOS_TABLE."
257  SET language = 'en_UK.iso-8859-1'
258  WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
259;",
260
261  "
262UPDATE ".CONFIG_TABLE."
263  SET value = 'en_UK.iso-8859-1'
264  WHERE param = 'default_language'
265    AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
266;",
267
268  "
269UPDATE ".CONFIG_TABLE."
270  SET value = 'yoga'
271  WHERE param = 'default_template'
272;",
273
274  "
275INSERT INTO ".CONFIG_TABLE."
276  (param,value,comment)
277  VALUES
278  (
279    'gallery_title',
280    'PhpWebGallery demonstration site',
281    'Title at top of each page and for RSS feed'
282  )
283;",
284
285  "
286INSERT INTO ".CONFIG_TABLE."
287  (param,value,comment)
288  VALUES
289  (
290    'gallery_description',
291    'My photos web site',
292    'Short description displayed with gallery title'
293  )
294;"
295
296  );
297
298foreach ($queries as $query)
299{
300  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
301  pwg_query($query);
302}
303
304if ($prefix_thumbnail != 'TN-')
305{
306  array_push(
307    $page['infos'],
308    'the thumbnail prefix configuration parameter was moved to configuration
309file, copy config_local.inc.php from "tools" directory to "include" directory
310and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail
311    );
312}
313
314// now we upgrade from 1.5.0 to 1.6.0
315include_once(PHPWG_ROOT_PATH.'install/upgrade_1.5.0.php');
316?>
Note: See TracBrowser for help on using the repository browser.