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

Last change on this file since 2022 was 1932, checked in by rub, 18 years ago

o add missing $lang
o use of l10n_dec
o normalize file header

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 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-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: upgrade_1.4.0.php 1932 2007-03-29 19:04:54Z rub $
8// | last update   : $Date: 2007-03-29 19:04:54 +0000 (Thu, 29 Mar 2007) $
9// | last modifier : $Author: rub $
10// | revision      : $Revision: 1932 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27if (!defined('PHPWG_ROOT_PATH'))
28{
29  die ('This page cannot be loaded directly, load upgrade.php');
30}
31else
32{
33  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
34  {
35    die ('Hacking attempt!');
36  }
37}
38
39$last_time = get_moment();
40
41// will the user have to edit include/config_local.inc.php for
42// prefix_thumbnail configuration parameter
43$query = '
44SELECT value
45  FROM '.CONFIG_TABLE.'
46  WHERE param = \'prefix_thumbnail\'
47;';
48list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query));
49
50// delete obsolete configuration
51$query = '
52DELETE
53  FROM '.PREFIX_TABLE.'config
54  WHERE param IN (
55   \'prefix_thumbnail\',
56   \'mail_webmaster\',
57   \'upload_maxfilesize\',
58   \'upload_maxwidth\',
59   \'upload_maxheight\',
60   \'upload_maxwidth_thumbnail\',
61   \'upload_maxheight_thumbnail\',
62   \'mail_notification\',
63   \'use_iptc\',
64   \'use_exif\',
65   \'show_iptc\',
66   \'show_exif\',
67   \'authorize_remembering\'
68   )
69;';
70mysql_query($query);
71
72$queries = array(
73
74  "
75ALTER TABLE phpwebgallery_categories
76  CHANGE COLUMN date_last date_last datetime default NULL
77;",
78
79  "
80ALTER TABLE phpwebgallery_comments
81  ADD COLUMN validation_date datetime default NULL
82;",
83
84  "
85UPDATE phpwebgallery_comments
86  SET validation_date = date
87",
88
89  "
90ALTER TABLE phpwebgallery_comments
91  ADD INDEX comments_i1 (image_id)
92;",
93
94  "
95ALTER TABLE phpwebgallery_comments
96  ADD INDEX comments_i2 (validation_date)
97;",
98
99  "
100ALTER TABLE phpwebgallery_favorites
101  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
102;",
103
104  "
105ALTER TABLE phpwebgallery_images
106  CHANGE COLUMN date_available
107    date_available datetime NOT NULL default '0000-00-00 00:00:00'
108;",
109
110  "
111ALTER TABLE phpwebgallery_rate
112  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
113;",
114
115  "
116ALTER TABLE phpwebgallery_sessions
117  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
118;",
119
120  "
121ALTER TABLE phpwebgallery_user_access
122  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
123;",
124
125  "
126DROP TABLE phpwebgallery_user_forbidden
127;",
128
129  "
130ALTER TABLE phpwebgallery_user_group
131 CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
132;",
133
134  "
135ALTER TABLE phpwebgallery_users
136  CHANGE COLUMN id id smallint(5) NOT NULL auto_increment
137;",
138
139  "
140CREATE TABLE phpwebgallery_caddie (
141  user_id smallint(5) NOT NULL default '0',
142  element_id mediumint(8) NOT NULL default '0',
143  PRIMARY KEY  (user_id,element_id)
144) TYPE=MyISAM
145;",
146
147  "
148CREATE TABLE phpwebgallery_user_cache (
149  user_id smallint(5) NOT NULL default '0',
150  need_update enum('true','false') NOT NULL default 'true',
151  forbidden_categories text,
152  PRIMARY KEY  (user_id)
153) TYPE=MyISAM
154;",
155
156  "
157CREATE TABLE phpwebgallery_user_feed (
158  id varchar(50) binary NOT NULL default '',
159  user_id smallint(5) NOT NULL default '0',
160  last_check datetime default NULL,
161  PRIMARY KEY  (id)
162) TYPE=MyISAM
163;",
164
165  "
166CREATE TABLE phpwebgallery_user_infos (
167  user_id smallint(5) NOT NULL default '0',
168  nb_image_line tinyint(1) unsigned NOT NULL default '5',
169  nb_line_page tinyint(3) unsigned NOT NULL default '3',
170  status enum('admin','guest') NOT NULL default 'guest',
171  language varchar(50) NOT NULL default 'english',
172  maxwidth smallint(6) default NULL,
173  maxheight smallint(6) default NULL,
174  expand enum('true','false') NOT NULL default 'false',
175  show_nb_comments enum('true','false') NOT NULL default 'false',
176  recent_period tinyint(3) unsigned NOT NULL default '7',
177  template varchar(255) NOT NULL default 'yoga',
178  registration_date datetime NOT NULL default '0000-00-00 00:00:00',
179  UNIQUE KEY user_infos_ui1 (user_id)
180) TYPE=MyISAM
181;"
182  );
183
184foreach ($queries as $query)
185{
186  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
187  pwg_query($query);
188}
189
190// user datas migration from phpwebgallery_users to phpwebgallery_user_infos
191$query = '
192SELECT *
193  FROM '.USERS_TABLE.'
194;';
195
196$datas = array();
197list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
198
199$result = pwg_query($query);
200while ($row = mysql_fetch_array($result))
201{
202  $row['user_id'] = $row['id'];
203  $row['registration_date'] = $dbnow;
204  array_push($datas, $row);
205}
206
207include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
208mass_inserts(
209  USER_INFOS_TABLE,
210  array(
211    'user_id',
212    'nb_image_line',
213    'nb_line_page',
214    'status',
215    'language',
216    'maxwidth',
217    'maxheight',
218    'expand',
219    'show_nb_comments',
220    'recent_period',
221    'template',
222    'registration_date'
223    ),
224  $datas
225  );
226
227$queries = array(
228
229  "
230UPDATE ".USER_INFOS_TABLE."
231  SET template = 'yoga'
232;",
233
234  "
235UPDATE ".USER_INFOS_TABLE."
236  SET language = 'en_UK.iso-8859-1'
237  WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
238;",
239
240  "
241UPDATE ".CONFIG_TABLE."
242  SET value = 'en_UK.iso-8859-1'
243  WHERE param = 'default_language'
244    AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
245;",
246
247  "
248UPDATE ".CONFIG_TABLE."
249  SET value = 'yoga'
250  WHERE param = 'default_template'
251;",
252
253  "
254INSERT INTO ".CONFIG_TABLE."
255  (param,value,comment)
256  VALUES
257  (
258    'gallery_title',
259    'PhpWebGallery demonstration site',
260    'Title at top of each page and for RSS feed'
261  )
262;",
263
264  "
265INSERT INTO ".CONFIG_TABLE."
266  (param,value,comment)
267  VALUES
268  (
269    'gallery_description',
270    'My photos web site',
271    'Short description displayed with gallery title'
272  )
273;"
274
275  );
276
277foreach ($queries as $query)
278{
279  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
280  pwg_query($query);
281}
282
283if ($prefix_thumbnail != 'TN-')
284{
285  array_push(
286    $page['infos'],
287    'the thumbnail prefix configuration parameter was moved to configuration
288file, copy config_local.inc.php from "tools" directory to "include" directory
289and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail
290    );
291}
292
293// now we upgrade from 1.5.0 to 1.6.0
294include_once(PHPWG_ROOT_PATH.'install/upgrade_1.5.0.php');
295?>
Note: See TracBrowser for help on using the repository browser.