source: tags/release-1_5_0RC2/install/upgrade_1.4.0.php @ 13668

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