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-10-23 23:02:21 +0200 (dim, 23 oct 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 911 $ |
---|
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 | |
---|
28 | if (!defined('PHPWG_ROOT_PATH')) |
---|
29 | { |
---|
30 | die ('This page cannot be loaded directly, load upgrade.php'); |
---|
31 | } |
---|
32 | else |
---|
33 | { |
---|
34 | if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE) |
---|
35 | { |
---|
36 | die ('Hacking attempt!'); |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | tag_replace_keywords(); |
---|
41 | |
---|
42 | $queries = array( |
---|
43 | " |
---|
44 | CREATE TABLE ".PREFIX_TABLE."search ( |
---|
45 | id int UNSIGNED NOT NULL AUTO_INCREMENT, |
---|
46 | last_seen date DEFAULT NULL, |
---|
47 | rules text, |
---|
48 | PRIMARY KEY (id) |
---|
49 | );", |
---|
50 | |
---|
51 | " |
---|
52 | CREATE TABLE ".PREFIX_TABLE."user_mail_notification ( |
---|
53 | user_id smallint(5) NOT NULL default '0', |
---|
54 | check_key varchar(16) binary NOT NULL default '', |
---|
55 | enabled enum('true','false') NOT NULL default 'false', |
---|
56 | last_send datetime default NULL, |
---|
57 | PRIMARY KEY (user_id), |
---|
58 | UNIQUE KEY uidx_check_key (check_key) |
---|
59 | );", |
---|
60 | |
---|
61 | " |
---|
62 | CREATE TABLE ".PREFIX_TABLE."upgrade ( |
---|
63 | id varchar(20) NOT NULL default '', |
---|
64 | applied datetime NOT NULL default '0000-00-00 00:00:00', |
---|
65 | description varchar(255) default NULL, |
---|
66 | PRIMARY KEY (`id`) |
---|
67 | );", |
---|
68 | |
---|
69 | " |
---|
70 | ALTER TABLE ".PREFIX_TABLE."config |
---|
71 | MODIFY COLUMN value TEXT |
---|
72 | ;", |
---|
73 | |
---|
74 | " |
---|
75 | ALTER TABLE ".PREFIX_TABLE."images |
---|
76 | ADD COLUMN has_high enum('true') default NULL |
---|
77 | ;", |
---|
78 | |
---|
79 | " |
---|
80 | ALTER TABLE ".PREFIX_TABLE."rate |
---|
81 | ADD COLUMN anonymous_id varchar(45) NOT NULL default '' |
---|
82 | ;", |
---|
83 | " |
---|
84 | ALTER TABLE ".PREFIX_TABLE."rate |
---|
85 | ADD COLUMN date date NOT NULL default '0000-00-00' |
---|
86 | ;", |
---|
87 | " |
---|
88 | ALTER TABLE ".PREFIX_TABLE."rate |
---|
89 | DROP PRIMARY KEY |
---|
90 | ;", |
---|
91 | " |
---|
92 | ALTER TABLE ".PREFIX_TABLE."rate |
---|
93 | ADD PRIMARY KEY (element_id,user_id,anonymous_id) |
---|
94 | ;", |
---|
95 | " |
---|
96 | UPDATE ".PREFIX_TABLE."rate |
---|
97 | SET date = CURDATE() |
---|
98 | ;", |
---|
99 | |
---|
100 | " |
---|
101 | DELETE |
---|
102 | FROM ".PREFIX_TABLE."sessions |
---|
103 | ;", |
---|
104 | " |
---|
105 | ALTER TABLE ".PREFIX_TABLE."sessions |
---|
106 | DROP COLUMN user_id |
---|
107 | ;", |
---|
108 | " |
---|
109 | ALTER TABLE ".PREFIX_TABLE."sessions |
---|
110 | ADD COLUMN data text NOT NULL |
---|
111 | ;", |
---|
112 | |
---|
113 | " |
---|
114 | ALTER TABLE ".PREFIX_TABLE."user_cache |
---|
115 | ADD COLUMN nb_total_images mediumint(8) unsigned default NULL |
---|
116 | ;", |
---|
117 | |
---|
118 | " |
---|
119 | ALTER TABLE ".PREFIX_TABLE."user_infos |
---|
120 | CHANGE COLUMN status |
---|
121 | status enum('webmaster','admin','normal','generic','guest') |
---|
122 | NOT NULL default 'guest' |
---|
123 | ;", |
---|
124 | " |
---|
125 | UPDATE ".PREFIX_TABLE."user_infos |
---|
126 | SET status = 'normal' |
---|
127 | WHERE status = 'guest' |
---|
128 | ;", |
---|
129 | " |
---|
130 | UPDATE ".PREFIX_TABLE."user_infos |
---|
131 | SET status = 'guest' |
---|
132 | WHERE user_id = ".$conf['guest_id']." |
---|
133 | ;", |
---|
134 | " |
---|
135 | UPDATE ".PREFIX_TABLE."user_infos |
---|
136 | SET status = 'webmaster' |
---|
137 | WHERE user_id = ".$conf['webmaster_id']." |
---|
138 | ;", |
---|
139 | |
---|
140 | " |
---|
141 | ALTER TABLE ".PREFIX_TABLE."user_infos |
---|
142 | CHANGE COLUMN template template varchar(255) NOT NULL default 'yoga/clear' |
---|
143 | ;", |
---|
144 | |
---|
145 | " |
---|
146 | UPDATE ".PREFIX_TABLE."user_infos |
---|
147 | SET template = 'yoga/dark' |
---|
148 | WHERE template = 'yoga-dark' |
---|
149 | ;", |
---|
150 | " |
---|
151 | UPDATE ".PREFIX_TABLE."user_infos |
---|
152 | SET template = 'yoga/clear' |
---|
153 | WHERE template != 'yoga/dark' |
---|
154 | ;", |
---|
155 | " |
---|
156 | ALTER TABLE ".PREFIX_TABLE."user_infos |
---|
157 | ADD COLUMN adviser enum('true','false') NOT NULL default 'false' |
---|
158 | ;", |
---|
159 | " |
---|
160 | ALTER TABLE ".PREFIX_TABLE."user_infos |
---|
161 | ADD COLUMN enabled_high enum('true','false') NOT NULL default 'true' |
---|
162 | ;", |
---|
163 | |
---|
164 | // configuration table |
---|
165 | " |
---|
166 | UPDATE ".PREFIX_TABLE."config |
---|
167 | SET value = 'yoga/clear' |
---|
168 | WHERE param = 'default_template' |
---|
169 | ;" |
---|
170 | ); |
---|
171 | |
---|
172 | foreach ($queries as $query) |
---|
173 | { |
---|
174 | pwg_query($query); |
---|
175 | } |
---|
176 | |
---|
177 | // |
---|
178 | // Move rate, rate_anonymous and gallery_url from config file to database |
---|
179 | // |
---|
180 | $params = array( |
---|
181 | 'gallery_url' => array( |
---|
182 | 'http://demo.phpwebgallery.net', |
---|
183 | 'URL given in RSS feed' |
---|
184 | ), |
---|
185 | 'rate' => array( |
---|
186 | 'true', |
---|
187 | 'Rating pictures feature is enabled' |
---|
188 | ), |
---|
189 | 'rate_anonymous' => array( |
---|
190 | 'true', |
---|
191 | 'Rating pictures feature is also enabled for visitors' |
---|
192 | ) |
---|
193 | ); |
---|
194 | // Get real values from config file |
---|
195 | $conf_save = $conf; |
---|
196 | unset($conf); |
---|
197 | @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); |
---|
198 | if ( isset($conf['gallery_url']) ) |
---|
199 | { |
---|
200 | $params['gallery_url'][0] = $conf['gallery_url']; |
---|
201 | } |
---|
202 | if ( isset($conf['rate']) and is_bool($conf['rate']) ) |
---|
203 | { |
---|
204 | $params['rate'][0] = $conf['rate'] ? 'true' : 'false'; |
---|
205 | } |
---|
206 | if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) ) |
---|
207 | { |
---|
208 | $params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false'; |
---|
209 | } |
---|
210 | $conf = $conf_save; |
---|
211 | |
---|
212 | // Do I already have them in DB ? |
---|
213 | $query = 'SELECT param FROM '.PREFIX_TABLE.'config'; |
---|
214 | $result = pwg_query($query); |
---|
215 | while ($row = mysql_fetch_array($result)) |
---|
216 | { |
---|
217 | unset( $params[ $row['param'] ] ); |
---|
218 | } |
---|
219 | |
---|
220 | // Perform the insert query |
---|
221 | foreach ($params as $param_key => $param_values) |
---|
222 | { |
---|
223 | $query = ' |
---|
224 | INSERT INTO '.PREFIX_TABLE.'config |
---|
225 | (param,value,comment) |
---|
226 | VALUES |
---|
227 | ('."'$param_key','$param_values[0]','$param_values[1]') |
---|
228 | ;"; |
---|
229 | pwg_query($query); |
---|
230 | } |
---|
231 | |
---|
232 | $query = " |
---|
233 | ALTER TABLE ".PREFIX_TABLE."config MODIFY COLUMN `value` TEXT;"; |
---|
234 | pwg_query($query); |
---|
235 | |
---|
236 | |
---|
237 | // |
---|
238 | // replace gallery_description by page_banner |
---|
239 | // |
---|
240 | $query = ' |
---|
241 | SELECT value |
---|
242 | FROM '.PREFIX_TABLE.'config |
---|
243 | WHERE param=\'gallery_title\' |
---|
244 | ;'; |
---|
245 | list($t) = array_from_query($query, 'value'); |
---|
246 | |
---|
247 | $query = ' |
---|
248 | SELECT value |
---|
249 | FROM '.PREFIX_TABLE.'config |
---|
250 | WHERE param=\'gallery_description\' |
---|
251 | ;'; |
---|
252 | list($d) = array_from_query($query, 'value'); |
---|
253 | |
---|
254 | $page_banner='<div id="theHeader"><h1>'.$t.'</h1><p>'.$d.'</p></div>'; |
---|
255 | $page_banner=addslashes($page_banner); |
---|
256 | $query = ' |
---|
257 | INSERT INTO '.PREFIX_TABLE.'config |
---|
258 | (param,value,comment) |
---|
259 | VALUES |
---|
260 | ( |
---|
261 | \'page_banner\', |
---|
262 | \''.$page_banner.'\', |
---|
263 | \'html displayed on the top each page of your gallery\' |
---|
264 | ) |
---|
265 | ;'; |
---|
266 | pwg_query($query); |
---|
267 | |
---|
268 | $query = ' |
---|
269 | DELETE FROM '.PREFIX_TABLE.'config |
---|
270 | WHERE param=\'gallery_description\' |
---|
271 | ;'; |
---|
272 | pwg_query($query); |
---|
273 | |
---|
274 | // |
---|
275 | // configuration for notification by mail |
---|
276 | // |
---|
277 | $query = " |
---|
278 | INSERT INTO ".CONFIG_TABLE." |
---|
279 | (param,value,comment) |
---|
280 | VALUES |
---|
281 | ( |
---|
282 | 'nbm_send_mail_as', |
---|
283 | '', |
---|
284 | 'Send mail as param value for notification by mail' |
---|
285 | ), |
---|
286 | ( |
---|
287 | 'nbm_send_detailed_content', |
---|
288 | 'true', |
---|
289 | 'Send detailed content for notification by mail' |
---|
290 | ), |
---|
291 | ( |
---|
292 | 'nbm_complementary_mail_content', |
---|
293 | '', |
---|
294 | 'Complementary mail content for notification by mail' |
---|
295 | ) |
---|
296 | ; |
---|
297 | "; |
---|
298 | pwg_query($query); |
---|
299 | |
---|
300 | ?> |
---|