source: branches/branch-1_7/install/upgrade_1.6.2.php @ 2307

Last change on this file since 2307 was 1932, checked in by rub, 17 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: 9.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.6.2.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$queries = array(
40"
41ALTER TABLE `".PREFIX_TABLE."categories`
42  ADD COLUMN `permalink` varchar(64) default NULL
43;",
44
45"
46ALTER TABLE `".PREFIX_TABLE."categories`
47  ADD COLUMN `image_order` varchar(128) default NULL
48;",
49
50"
51ALTER TABLE `".PREFIX_TABLE."categories`
52  ADD UNIQUE `categories_i3` (`permalink`)
53;",
54
55"
56ALTER TABLE `".PREFIX_TABLE."groups`
57  ADD COLUMN `is_default` enum('true','false') NOT NULL default 'false'
58;",
59
60"
61RENAME TABLE `".PREFIX_TABLE."history` TO `".PREFIX_TABLE."history_backup`
62;",
63
64"
65CREATE TABLE `".PREFIX_TABLE."history` (
66  `id` int(10) unsigned NOT NULL auto_increment,
67  `date` date NOT NULL default '0000-00-00',
68  `time` time NOT NULL default '00:00:00',
69  `year` smallint(4) NOT NULL default '0',
70  `month` tinyint(2) NOT NULL default '0',
71  `day` tinyint(2) NOT NULL default '0',
72  `hour` tinyint(2) NOT NULL default '0',
73  `user_id` smallint(5) NOT NULL default '0',
74  `IP` varchar(15) NOT NULL default '',
75  `section` enum('categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats') default NULL,
76  `category_id` smallint(5) default NULL,
77  `tag_ids` varchar(50) default NULL,
78  `image_id` mediumint(8) default NULL,
79  `summarized` enum('true','false') default 'false',
80  `image_type` enum('picture','high','other') default NULL,
81  PRIMARY KEY  (`id`),
82  KEY `history_i1` (`summarized`)
83) TYPE=MyISAM
84;",
85
86"
87ALTER TABLE `".PREFIX_TABLE."image_category`
88  DROP INDEX `image_category_i1`
89;",
90
91"
92ALTER TABLE `".PREFIX_TABLE."image_category`
93  ADD INDEX `image_category_i1` (`category_id`)
94;",
95
96"
97ALTER TABLE `".PREFIX_TABLE."image_category`
98  DROP INDEX `image_category_i2`
99;",
100
101"
102ALTER TABLE `".PREFIX_TABLE."images`
103  ADD COLUMN `high_filesize` mediumint(9) unsigned default NULL
104;",
105
106"
107ALTER TABLE `".PREFIX_TABLE."user_infos`
108  CHANGE COLUMN `language`
109    `language` varchar(50) NOT NULL default 'en_UK.iso-8859-1'
110;",
111
112"
113ALTER TABLE `".PREFIX_TABLE."user_infos`
114  DROP COLUMN `auto_login_key`
115;",
116
117"
118ALTER TABLE `".PREFIX_TABLE."user_infos`
119  ADD COLUMN `show_nb_hits` enum('true','false') NOT NULL default 'false'
120;",
121
122"
123ALTER TABLE `".PREFIX_TABLE."user_mail_notification`
124  DROP INDEX `uidx_check_key`
125;",
126
127"
128ALTER TABLE `".PREFIX_TABLE."user_mail_notification`
129  ADD UNIQUE `user_mail_notification_ui1` (`check_key`)
130;",
131
132"
133CREATE TABLE `".PREFIX_TABLE."history_summary` (
134  `id` varchar(13) NOT NULL default '',
135  `year` smallint(4) NOT NULL default '0',
136  `month` tinyint(2) default NULL,
137  `day` tinyint(2) default NULL,
138  `hour` tinyint(2) default NULL,
139  `nb_pages` int(11) default NULL,
140  PRIMARY KEY  (`id`)
141) TYPE=MyISAM
142;",
143
144"
145CREATE TABLE `".PREFIX_TABLE."old_permalinks` (
146  `cat_id` smallint(5) unsigned NOT NULL default '0',
147  `permalink` varchar(64) NOT NULL default '',
148  `date_deleted` datetime NOT NULL default '0000-00-00 00:00:00',
149  `last_hit` datetime default NULL,
150  `hit` int(10) unsigned NOT NULL default '0',
151  PRIMARY KEY  (`permalink`)
152) TYPE=MyISAM
153;",
154
155"
156CREATE TABLE `".PREFIX_TABLE."plugins` (
157  `id` varchar(64) binary NOT NULL default '',
158  `state` enum('inactive','active') NOT NULL default 'inactive',
159  `version` varchar(64) NOT NULL default '0',
160  PRIMARY KEY  (`id`)
161) TYPE=MyISAM
162;",
163
164"
165CREATE TABLE `".PREFIX_TABLE."user_cache_categories` (
166  `user_id` smallint(5) NOT NULL default '0',
167  `cat_id` smallint(5) unsigned NOT NULL default '0',
168  `max_date_last` datetime default NULL,
169  `count_images` mediumint(8) unsigned default '0',
170  `count_categories` mediumint(8) unsigned default '0',
171  PRIMARY KEY  (`user_id`,`cat_id`)
172) TYPE=MyISAM
173;",
174
175"
176CREATE TABLE `".PREFIX_TABLE."ws_access` (
177  `id` smallint(5) unsigned NOT NULL auto_increment,
178  `name` varchar(32) NOT NULL default '',
179  `access` varchar(255) default NULL,
180  `start` datetime default NULL,
181  `end` datetime default NULL,
182  `request` varchar(255) default NULL,
183  `limit` smallint(5) unsigned default NULL,
184  `comment` varchar(255) default NULL,
185  PRIMARY KEY  (`id`),
186  UNIQUE KEY `ws_access_ui1` (`name`)
187) TYPE=MyISAM COMMENT='Access for Web Services'
188;",
189
190"
191INSERT INTO ".PREFIX_TABLE."config
192  (param,value,comment)
193  VALUES
194  ('show_nb_hits', 'false', 'Show hits count under thumbnails')
195;",
196
197"
198INSERT INTO ".PREFIX_TABLE."config
199  (param,value,comment)
200  VALUES
201  ('history_admin','false','keep a history of administrator visits on your website')
202;",
203
204"
205INSERT INTO ".PREFIX_TABLE."config
206  (param,value,comment)
207  VALUES
208  ('history_guest','true','keep a history of guest visits on your website')
209;",
210
211"
212INSERT INTO ".PREFIX_TABLE."config
213  (param,value,comment)
214  VALUES
215  ('allow_user_registration','true','allow visitors to register?')
216;",
217
218"
219INSERT INTO ".PREFIX_TABLE."config
220  (param,value,comment)
221  VALUES
222  ('secret_key', MD5(RAND()), 'a secret key specific to the gallery for internal use')
223;",
224
225"
226INSERT INTO ".PREFIX_TABLE."config
227  (param,value,comment)
228  VALUES
229  ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail')
230;",
231
232"
233INSERT INTO ".PREFIX_TABLE."config
234  (param,value,comment)
235  VALUES
236  ('nbm_send_recent_post_dates','true','Send recent post by dates for notification by mail')
237;",
238
239"
240INSERT INTO ".PREFIX_TABLE."config
241  (param,value,comment)
242  VALUES
243  ('email_admin_on_new_user','false','Send an email to theadministrators when a user registers')
244;",
245
246"
247INSERT INTO ".PREFIX_TABLE."config
248  (param,value,comment)
249  VALUES
250  ('email_admin_on_comment','false','Send an email to the administrators when a valid comment is entered')
251;",
252
253"
254INSERT INTO ".PREFIX_TABLE."config
255  (param,value,comment)
256  VALUES
257  ('email_admin_on_comment_validation','false','Send an email to the administrators when a comment requires validation')
258;",
259
260"
261INSERT INTO ".PREFIX_TABLE."config
262  (param,value,comment)
263  VALUES
264  ('email_admin_on_picture_uploaded','false','Send an email to the administrators when a picture is uploaded')
265;",
266
267"
268UPDATE ".PREFIX_TABLE."user_cache
269  SET need_update = 'true'
270;",
271
272);
273
274foreach ($queries as $query)
275{
276  pwg_query($query);
277}
278
279$replacements = array(
280  array('&#039;', '\''),
281  array('&quot;', '"'),
282  array('&lt;',   '<'),
283  array('&gt;',   '>'),
284  array('&amp;',  '&') // <- this must be the last one
285  );
286
287foreach ($replacements as $replacement)
288{
289    $query = '
290UPDATE '.PREFIX_TABLE.'comments
291  SET content = REPLACE(content, "'.
292  addslashes($replacement[0]).
293  '", "'.
294  addslashes($replacement[1]).
295  '")
296;';
297    pwg_query($query);
298}
299
300load_conf_from_db();
301
302$query = "
303UPDATE ".USER_INFOS_TABLE."
304SET
305  template = '".$conf['default_template']."',
306  nb_image_line = ".$conf['nb_image_line'].",
307  nb_line_page = ".$conf['nb_line_page'].",
308  language = '".$conf['default_language']."',
309  maxwidth = ".
310  (empty($conf['default_maxwidth']) ? "NULL" : $conf['default_maxwidth']).
311  ",
312  maxheight = ".
313  (empty($conf['default_maxheight']) ? "NULL" : $conf['default_maxheight']).
314  ",
315  recent_period = ".$conf['recent_period'].",
316  expand = '".boolean_to_string($conf['auto_expand'])."',
317  show_nb_comments = '".boolean_to_string($conf['show_nb_comments'])."',
318  show_nb_hits = '".boolean_to_string($conf['show_nb_hits'])."',
319  enabled_high = '".boolean_to_string(
320    (isset($conf['newuser_default_enabled_high']) ?
321      $conf['newuser_default_enabled_high'] : true)
322    ).
323  "'
324WHERE
325  user_id = ".$conf['default_user_id'].";";
326pwg_query($query);
327
328$query = "
329DELETE FROM ".CONFIG_TABLE."
330WHERE
331  param IN
332(
333  'default_template',
334  'nb_image_line',
335  'nb_line_page',
336  'default_language',
337  'default_maxwidth',
338  'default_maxheight',
339  'recent_period',
340  'auto_expand',
341  'show_nb_comments',
342  'show_nb_hits'
343)
344;";
345pwg_query($query);
346
347// now we upgrade from 1.7.0
348// include_once(PHPWG_ROOT_PATH.'install/upgrade_1.7.0.php');
349?>
Note: See TracBrowser for help on using the repository browser.