1 | <?php |
---|
2 | /** |
---|
3 | * @author Eric@piwigo.org |
---|
4 | * |
---|
5 | * Upgrade processes for old plugin version |
---|
6 | * Called from maintain.inc.php on plugin activation |
---|
7 | * |
---|
8 | */ |
---|
9 | |
---|
10 | if(!defined('UAM_PATH')) |
---|
11 | { |
---|
12 | define('UAM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
13 | } |
---|
14 | if (!defined('UAM_ROOT')) |
---|
15 | { |
---|
16 | define('UAM_ROOT', dirname(__FILE__).'/'); |
---|
17 | } |
---|
18 | |
---|
19 | include_once (UAM_PATH.'include/constants.php'); |
---|
20 | include_once (UAM_PATH.'include/functions.inc.php'); |
---|
21 | |
---|
22 | // +----------------------------------------------------------+ |
---|
23 | // | Upgrading database from old plugin versions | |
---|
24 | // +----------------------------------------------------------+ |
---|
25 | |
---|
26 | /* upgrade from branch 2.10 to 2.11 */ |
---|
27 | /* ******************************** */ |
---|
28 | function upgrade_210_211() |
---|
29 | { |
---|
30 | global $conf; |
---|
31 | |
---|
32 | $q = ' |
---|
33 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
34 | VALUES ("nbc_UserAdvManager_ConfirmMail","false;5;Hello. |
---|
35 | |
---|
36 | This is a reminder message because you registered on our gallery but you do not validate your registration and your validation key has expired. To still allow you to access to our gallery, your validation period has been reset. You have again 5 days to validate your registration. |
---|
37 | |
---|
38 | Note: After this period, your account will be permanently deleted.;false;Hello. |
---|
39 | |
---|
40 | This is a reminder message because you registered on our gallery but you do not validate your registration and your validation key will expire. To allow you access to our gallery, you have 2 days to confirm your registration by clicking on the link in the message you should have received when you registered. |
---|
41 | |
---|
42 | Note: After this period, your account will be permanently deleted.","Parametres nbc_UserAdvManager - ConfirmMail") |
---|
43 | ;'; |
---|
44 | pwg_query($q); |
---|
45 | |
---|
46 | upgrade_211_212(); |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | /* upgrade from branch 2.11 to 2.12 */ |
---|
51 | /* ******************************** */ |
---|
52 | function upgrade_211_212() |
---|
53 | { |
---|
54 | global $conf; |
---|
55 | |
---|
56 | $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
57 | |
---|
58 | if ((!isset($conf_UAM[14]) and !isset($conf_UAM[15])) and !isset($conf_UAM[16]) and !isset($conf_UAM[17])) |
---|
59 | { |
---|
60 | $upgrade_UAM = $conf_UAM[0].';'.$conf_UAM[1].';'.$conf_UAM[2].';'.$conf_UAM[3].';'.$conf_UAM[4].';'.$conf_UAM[5].';'.$conf_UAM[6].';'.$conf_UAM[7].';'.$conf_UAM[8].';'.$conf_UAM[9].';'.$conf_UAM[10].';'.$conf_UAM[11].';'.$conf_UAM[12].';'.$conf_UAM[13].';false;100;false;false;10;Hello. |
---|
61 | |
---|
62 | This is a reminder because a very long time passed since your last visit on our gallery. If you do not want anymore to use your access account, please let us know by replying to this email. Your account will be deleted. |
---|
63 | |
---|
64 | On receipt of this message and no new visit within 15 days, we would be obliged to automatically delete your account. |
---|
65 | |
---|
66 | Best regards, |
---|
67 | |
---|
68 | The admin of the gallery.'; |
---|
69 | |
---|
70 | $query = ' |
---|
71 | UPDATE '.CONFIG_TABLE.' |
---|
72 | SET value="'.$upgrade_UAM.'" |
---|
73 | WHERE param="nbc_UserAdvManager" |
---|
74 | LIMIT 1 |
---|
75 | ;'; |
---|
76 | pwg_query($query); |
---|
77 | } |
---|
78 | |
---|
79 | $q = " |
---|
80 | CREATE TABLE IF NOT EXISTS ".USER_LASTVISIT_TABLE." ( |
---|
81 | user_id SMALLINT(5) NOT NULL DEFAULT '0', |
---|
82 | lastvisit DATETIME NULL DEFAULT NULL, |
---|
83 | reminder ENUM('true','false') NULL, |
---|
84 | PRIMARY KEY (`user_id`) |
---|
85 | ) |
---|
86 | ;"; |
---|
87 | pwg_query($q); |
---|
88 | |
---|
89 | upgrade_212_213(); |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | /* upgrade from branch 2.12 to 2.13 */ |
---|
94 | /* ******************************** */ |
---|
95 | function upgrade_212_213() |
---|
96 | { |
---|
97 | // Create missing table |
---|
98 | $query = " |
---|
99 | ALTER TABLE ".USER_CONFIRM_MAIL_TABLE." |
---|
100 | ADD reminder ENUM('true', 'false') NULL DEFAULT NULL |
---|
101 | ;"; |
---|
102 | |
---|
103 | pwg_query($query); |
---|
104 | |
---|
105 | // Upgrade plugin configuration |
---|
106 | global $conf; |
---|
107 | |
---|
108 | $conf_UAM = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
109 | |
---|
110 | if ((!isset($conf_UAM[20]))) |
---|
111 | { |
---|
112 | $upgrade_UAM = $conf_UAM[0].';'.$conf_UAM[1].';'.$conf_UAM[2].';'.$conf_UAM[3].';'.$conf_UAM[4].';'.$conf_UAM[5].';'.$conf_UAM[6].';'.$conf_UAM[7].';'.$conf_UAM[8].';'.$conf_UAM[9].';'.$conf_UAM[10].';'.$conf_UAM[11].';'.$conf_UAM[12].';'.$conf_UAM[13].';'.$conf_UAM[14].';'.$conf_UAM[15].';'.$conf_UAM[16].';'.$conf_UAM[17].';'.$conf_UAM[18].';'.$conf_UAM[19].';false'; |
---|
113 | |
---|
114 | $query = ' |
---|
115 | UPDATE '.CONFIG_TABLE.' |
---|
116 | SET value="'.$upgrade_UAM.'" |
---|
117 | WHERE param="nbc_UserAdvManager" |
---|
118 | LIMIT 1 |
---|
119 | ;'; |
---|
120 | pwg_query($query); |
---|
121 | |
---|
122 | upgrade_213_214(); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | /* upgrade from branch 2.13 to 2.14 */ |
---|
128 | /* ******************************** */ |
---|
129 | function upgrade_213_214() |
---|
130 | { |
---|
131 | global $conf; |
---|
132 | |
---|
133 | $conf_UAM = explode(';', $conf['nbc_UserAdvManager']); |
---|
134 | |
---|
135 | $upgrade_UAM = array($conf_UAM[0],$conf_UAM[1],$conf_UAM[2],$conf_UAM[3],$conf_UAM[4],$conf_UAM[5],$conf_UAM[6],$conf_UAM[7],$conf_UAM[8],$conf_UAM[9],$conf_UAM[10],$conf_UAM[11],$conf_UAM[12],$conf_UAM[13],$conf_UAM[14],$conf_UAM[15],$conf_UAM[16],$conf_UAM[17],$conf_UAM[18],$conf_UAM[19],$conf_UAM[20],'false'); |
---|
136 | |
---|
137 | $query = ' |
---|
138 | UPDATE '.CONFIG_TABLE.' |
---|
139 | SET value = "'.addslashes(serialize($upgrade_UAM)).'" |
---|
140 | WHERE param = "nbc_UserAdvManager" |
---|
141 | ;'; |
---|
142 | pwg_query($query); |
---|
143 | |
---|
144 | if (unserialize($conf['nbc_UserAdvManager_ConfirmMail']) === false) |
---|
145 | { |
---|
146 | $data = explode(';', $conf['nbc_UserAdvManager_ConfirmMail']); |
---|
147 | |
---|
148 | $query = ' |
---|
149 | UPDATE '.CONFIG_TABLE.' |
---|
150 | SET value = "'.addslashes(serialize($data)).'" |
---|
151 | WHERE param = "nbc_UserAdvManager_ConfirmMail" |
---|
152 | ;'; |
---|
153 | pwg_query($query); |
---|
154 | |
---|
155 | upgrade_214_215(); |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | /* upgrade from branch 2.14 to 2.15 */ |
---|
160 | /* ******************************** */ |
---|
161 | function upgrade_214_215() |
---|
162 | { |
---|
163 | global $conf; |
---|
164 | |
---|
165 | // Changing parameter name |
---|
166 | $q = ' |
---|
167 | UPDATE '.CONFIG_TABLE.' |
---|
168 | SET param = "UserAdvManager" |
---|
169 | WHERE param = "nbc_UserAdvManager" |
---|
170 | ;'; |
---|
171 | pwg_query($q); |
---|
172 | |
---|
173 | $q = ' |
---|
174 | UPDATE '.CONFIG_TABLE.' |
---|
175 | SET param = "UserAdvManager_ConfirmMail" |
---|
176 | WHERE param = "nbc_UserAdvManager_ConfirmMail" |
---|
177 | ;'; |
---|
178 | pwg_query($q); |
---|
179 | |
---|
180 | // Upgrading ConfirmMail options |
---|
181 | $query = ' |
---|
182 | SELECT value |
---|
183 | FROM '.CONFIG_TABLE.' |
---|
184 | WHERE param = "UserAdvManager_ConfirmMail" |
---|
185 | ;'; |
---|
186 | |
---|
187 | $result = pwg_query($query); |
---|
188 | $conf_UAM_ConfirmMail = pwg_db_fetch_assoc($result); |
---|
189 | |
---|
190 | $conf_ConfirmMail = unserialize($conf_UAM_ConfirmMail['value']); |
---|
191 | |
---|
192 | $conf_ConfirmMail[5] ='Thank you to have confirmed your email address and your registration on the gallery. Have fun !'; |
---|
193 | $conf_ConfirmMail[6] ='Your activation key is incorrect or expired or you have already validated your account, please contact the webmaster to fix this problem.'; |
---|
194 | |
---|
195 | $update_conf = serialize($conf_ConfirmMail); |
---|
196 | |
---|
197 | $query = ' |
---|
198 | UPDATE '.CONFIG_TABLE.' |
---|
199 | SET value="'.addslashes($update_conf).'" |
---|
200 | WHERE param="UserAdvManager_ConfirmMail" |
---|
201 | LIMIT 1 |
---|
202 | ;'; |
---|
203 | |
---|
204 | pwg_query($query); |
---|
205 | |
---|
206 | upgrade_2153_2154(); |
---|
207 | } |
---|
208 | |
---|
209 | /* upgrade from 2.15.3 to 2.15.4 */ |
---|
210 | /* ***************************** */ |
---|
211 | function upgrade_2153_2154() |
---|
212 | { |
---|
213 | global $conf; |
---|
214 | |
---|
215 | // Upgrading options |
---|
216 | $query = ' |
---|
217 | SELECT value |
---|
218 | FROM '.CONFIG_TABLE.' |
---|
219 | WHERE param = "UserAdvManager" |
---|
220 | ;'; |
---|
221 | |
---|
222 | $result = pwg_query($query); |
---|
223 | $conf_UAM = pwg_db_fetch_assoc($result); |
---|
224 | |
---|
225 | $Newconf_UAM = unserialize($conf_UAM['value']); |
---|
226 | |
---|
227 | $Newconf_UAM[0] = $Newconf_UAM[0]; |
---|
228 | $Newconf_UAM[1] = $Newconf_UAM[2]; |
---|
229 | $Newconf_UAM[2] = $Newconf_UAM[3]; |
---|
230 | $Newconf_UAM[3] = $Newconf_UAM[4]; |
---|
231 | $Newconf_UAM[4] = $Newconf_UAM[5]; |
---|
232 | $Newconf_UAM[5] = $Newconf_UAM[6]; |
---|
233 | $Newconf_UAM[6] = $Newconf_UAM[7]; |
---|
234 | $Newconf_UAM[7] = $Newconf_UAM[8]; |
---|
235 | $Newconf_UAM[8] = $Newconf_UAM[9]; |
---|
236 | $Newconf_UAM[9] = $Newconf_UAM[10]; |
---|
237 | $Newconf_UAM[10] = $Newconf_UAM[11]; |
---|
238 | $Newconf_UAM[11] = $Newconf_UAM[12]; |
---|
239 | $Newconf_UAM[12] = $Newconf_UAM[13]; |
---|
240 | $Newconf_UAM[13] = $Newconf_UAM[14]; |
---|
241 | $Newconf_UAM[14] = $Newconf_UAM[15]; |
---|
242 | $Newconf_UAM[15] = $Newconf_UAM[16]; |
---|
243 | $Newconf_UAM[16] = $Newconf_UAM[17]; |
---|
244 | $Newconf_UAM[17] = $Newconf_UAM[18]; |
---|
245 | $Newconf_UAM[18] = $Newconf_UAM[19]; |
---|
246 | $Newconf_UAM[19] = $Newconf_UAM[20]; |
---|
247 | $Newconf_UAM[20] = $Newconf_UAM[21]; |
---|
248 | $Newconf_UAM[21] = 'false'; |
---|
249 | |
---|
250 | $update_conf = serialize($Newconf_UAM); |
---|
251 | |
---|
252 | $query = ' |
---|
253 | UPDATE '.CONFIG_TABLE.' |
---|
254 | SET value="'.addslashes($update_conf).'" |
---|
255 | WHERE param="UserAdvManager" |
---|
256 | LIMIT 1 |
---|
257 | ;'; |
---|
258 | |
---|
259 | pwg_query($query); |
---|
260 | |
---|
261 | $query = ' |
---|
262 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
263 | VALUES ("UserAdvManager_Redir","0","UAM Redirections") |
---|
264 | ;'; |
---|
265 | |
---|
266 | pwg_query($query); |
---|
267 | } |
---|
268 | |
---|
269 | /* upgrade from 2.15.x to 2.16.0 */ |
---|
270 | /* ***************************** */ |
---|
271 | function upgrade_215_2160() |
---|
272 | { |
---|
273 | global $conf; |
---|
274 | |
---|
275 | // Upgrading options |
---|
276 | $query = ' |
---|
277 | SELECT value |
---|
278 | FROM '.CONFIG_TABLE.' |
---|
279 | WHERE param = "UserAdvManager" |
---|
280 | ;'; |
---|
281 | |
---|
282 | $result = pwg_query($query); |
---|
283 | $conf_UAM = pwg_db_fetch_assoc($result); |
---|
284 | |
---|
285 | $Newconf_UAM = unserialize($conf_UAM['value']); |
---|
286 | |
---|
287 | $Newconf_UAM[22] = 'false'; |
---|
288 | $Newconf_UAM[23] = 'false'; |
---|
289 | $Newconf_UAM[24] = 'Sorry, your account has been deleted due to a too long time passed since your last visit.'; |
---|
290 | $Newconf_UAM[25] = 'Sorry, your account has been deprecated due to a too long time passed since your last visit. Please, use the following link to revalidate your account.'; |
---|
291 | $Newconf_UAM[26] = '-1'; |
---|
292 | $Newconf_UAM[27] = '-1'; |
---|
293 | $Newconf_UAM[28] = 'Thank you to have registered the gallery. Your account has been manually validated by admin. You can now visit all the gallery for free !'; |
---|
294 | |
---|
295 | $update_conf = serialize($Newconf_UAM); |
---|
296 | |
---|
297 | $query = ' |
---|
298 | UPDATE '.CONFIG_TABLE.' |
---|
299 | SET value="'.addslashes($update_conf).'" |
---|
300 | WHERE param="UserAdvManager" |
---|
301 | LIMIT 1 |
---|
302 | ;'; |
---|
303 | |
---|
304 | pwg_query($query); |
---|
305 | |
---|
306 | // Insert a new config entry for futur plugin's version check |
---|
307 | $query = ' |
---|
308 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
309 | VALUES ("UserAdvManager_Version","2.16.0","UAM version check") |
---|
310 | ;'; |
---|
311 | |
---|
312 | pwg_query($query); |
---|
313 | } |
---|
314 | |
---|
315 | |
---|
316 | /* upgrade from 2.16.x to 2.20.0 */ |
---|
317 | /* ***************************** */ |
---|
318 | function upgrade_216_220() |
---|
319 | { |
---|
320 | global $conf; |
---|
321 | |
---|
322 | $uam_new_version = "2.20.0"; |
---|
323 | |
---|
324 | // Upgrading options |
---|
325 | $query = ' |
---|
326 | SELECT value |
---|
327 | FROM '.CONFIG_TABLE.' |
---|
328 | WHERE param = "UserAdvManager" |
---|
329 | ;'; |
---|
330 | |
---|
331 | $result = pwg_query($query); |
---|
332 | $conf_UAM = pwg_db_fetch_assoc($result); |
---|
333 | |
---|
334 | $Newconf_UAM = unserialize($conf_UAM['value']); |
---|
335 | |
---|
336 | $Newconf_UAM[29] = 'false'; |
---|
337 | $Newconf_UAM[30] = 'You have requested a password reset on our gallery. Please, find below your new connection settings.'; |
---|
338 | $Newconf_UAM[31] = 'false'; |
---|
339 | $Newconf_UAM[32] = 'Sorry [username], your account has been deleted because you have not validated your registration in requested time. Please, try registration with a valid and non blocked email account.'; |
---|
340 | $Newconf_UAM[33] = 'false'; |
---|
341 | |
---|
342 | $update_conf = serialize($Newconf_UAM); |
---|
343 | |
---|
344 | $query = ' |
---|
345 | UPDATE '.CONFIG_TABLE.' |
---|
346 | SET value="'.addslashes($update_conf).'" |
---|
347 | WHERE param="UserAdvManager" |
---|
348 | LIMIT 1 |
---|
349 | ;'; |
---|
350 | |
---|
351 | pwg_query($query); |
---|
352 | |
---|
353 | // Update plugin version |
---|
354 | $query = ' |
---|
355 | UPDATE '.CONFIG_TABLE.' |
---|
356 | SET value="'.$uam_new_version.'" |
---|
357 | WHERE param="UserAdvManager_Version" |
---|
358 | LIMIT 1 |
---|
359 | ;'; |
---|
360 | |
---|
361 | pwg_query($query); |
---|
362 | } |
---|
363 | ?> |
---|