[1927] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1932] | 5 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[1927] | 6 | // +-----------------------------------------------------------------------+ |
---|
[1932] | 7 | // | file : $Id: upgrade_1.4.0.php 1932 2007-03-29 19:04:54Z rub $ |
---|
[1931] | 8 | // | last update : $Date: 2007-03-29 19:04:54 +0000 (Thu, 29 Mar 2007) $ |
---|
| 9 | // | last modifier : $Author: rub $ |
---|
| 10 | // | revision : $Revision: 1932 $ |
---|
[1927] | 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 | |
---|
| 27 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 28 | { |
---|
| 29 | die ('This page cannot be loaded directly, load upgrade.php'); |
---|
| 30 | } |
---|
| 31 | else |
---|
| 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 = ' |
---|
| 44 | SELECT value |
---|
| 45 | FROM '.CONFIG_TABLE.' |
---|
| 46 | WHERE param = \'prefix_thumbnail\' |
---|
| 47 | ;'; |
---|
| 48 | list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query)); |
---|
| 49 | |
---|
| 50 | // delete obsolete configuration |
---|
| 51 | $query = ' |
---|
| 52 | DELETE |
---|
| 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 | ;'; |
---|
| 70 | mysql_query($query); |
---|
| 71 | |
---|
| 72 | $queries = array( |
---|
| 73 | |
---|
| 74 | " |
---|
| 75 | ALTER TABLE phpwebgallery_categories |
---|
| 76 | CHANGE COLUMN date_last date_last datetime default NULL |
---|
| 77 | ;", |
---|
| 78 | |
---|
| 79 | " |
---|
| 80 | ALTER TABLE phpwebgallery_comments |
---|
| 81 | ADD COLUMN validation_date datetime default NULL |
---|
| 82 | ;", |
---|
| 83 | |
---|
| 84 | " |
---|
| 85 | UPDATE phpwebgallery_comments |
---|
| 86 | SET validation_date = date |
---|
| 87 | ", |
---|
| 88 | |
---|
| 89 | " |
---|
| 90 | ALTER TABLE phpwebgallery_comments |
---|
| 91 | ADD INDEX comments_i1 (image_id) |
---|
| 92 | ;", |
---|
| 93 | |
---|
| 94 | " |
---|
| 95 | ALTER TABLE phpwebgallery_comments |
---|
| 96 | ADD INDEX comments_i2 (validation_date) |
---|
| 97 | ;", |
---|
| 98 | |
---|
| 99 | " |
---|
| 100 | ALTER TABLE phpwebgallery_favorites |
---|
| 101 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
| 102 | ;", |
---|
| 103 | |
---|
| 104 | " |
---|
| 105 | ALTER TABLE phpwebgallery_images |
---|
| 106 | CHANGE COLUMN date_available |
---|
| 107 | date_available datetime NOT NULL default '0000-00-00 00:00:00' |
---|
| 108 | ;", |
---|
| 109 | |
---|
| 110 | " |
---|
| 111 | ALTER TABLE phpwebgallery_rate |
---|
| 112 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
| 113 | ;", |
---|
| 114 | |
---|
| 115 | " |
---|
| 116 | ALTER TABLE phpwebgallery_sessions |
---|
| 117 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
| 118 | ;", |
---|
| 119 | |
---|
| 120 | " |
---|
| 121 | ALTER TABLE phpwebgallery_user_access |
---|
| 122 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
| 123 | ;", |
---|
| 124 | |
---|
| 125 | " |
---|
| 126 | DROP TABLE phpwebgallery_user_forbidden |
---|
| 127 | ;", |
---|
| 128 | |
---|
| 129 | " |
---|
| 130 | ALTER TABLE phpwebgallery_user_group |
---|
| 131 | CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0' |
---|
| 132 | ;", |
---|
| 133 | |
---|
| 134 | " |
---|
| 135 | ALTER TABLE phpwebgallery_users |
---|
| 136 | CHANGE COLUMN id id smallint(5) NOT NULL auto_increment |
---|
| 137 | ;", |
---|
| 138 | |
---|
| 139 | " |
---|
| 140 | CREATE 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 | " |
---|
| 148 | CREATE 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 | " |
---|
| 157 | CREATE 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 | " |
---|
| 166 | CREATE 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 | |
---|
| 184 | foreach ($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 = ' |
---|
| 192 | SELECT * |
---|
| 193 | FROM '.USERS_TABLE.' |
---|
| 194 | ;'; |
---|
| 195 | |
---|
| 196 | $datas = array(); |
---|
| 197 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
| 198 | |
---|
| 199 | $result = pwg_query($query); |
---|
| 200 | while ($row = mysql_fetch_array($result)) |
---|
| 201 | { |
---|
| 202 | $row['user_id'] = $row['id']; |
---|
| 203 | $row['registration_date'] = $dbnow; |
---|
| 204 | array_push($datas, $row); |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 208 | mass_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 | " |
---|
| 230 | UPDATE ".USER_INFOS_TABLE." |
---|
| 231 | SET template = 'yoga' |
---|
| 232 | ;", |
---|
| 233 | |
---|
| 234 | " |
---|
| 235 | UPDATE ".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 | " |
---|
| 241 | UPDATE ".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 | " |
---|
| 248 | UPDATE ".CONFIG_TABLE." |
---|
| 249 | SET value = 'yoga' |
---|
| 250 | WHERE param = 'default_template' |
---|
| 251 | ;", |
---|
| 252 | |
---|
| 253 | " |
---|
| 254 | INSERT 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 | " |
---|
| 265 | INSERT 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 | |
---|
| 277 | foreach ($queries as $query) |
---|
| 278 | { |
---|
| 279 | $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query); |
---|
| 280 | pwg_query($query); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | if ($prefix_thumbnail != 'TN-') |
---|
| 284 | { |
---|
| 285 | array_push( |
---|
| 286 | $page['infos'], |
---|
| 287 | 'the thumbnail prefix configuration parameter was moved to configuration |
---|
| 288 | file, copy config_local.inc.php from "tools" directory to "include" directory |
---|
| 289 | and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail |
---|
| 290 | ); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | // now we upgrade from 1.5.0 to 1.6.0 |
---|
| 294 | include_once(PHPWG_ROOT_PATH.'install/upgrade_1.5.0.php'); |
---|
| 295 | ?> |
---|