1 | <?php |
---|
2 | include_once (NBC_UAM_PATH.'include/constants.php'); |
---|
3 | load_language('plugin.lang', NBC_UAM_PATH); |
---|
4 | |
---|
5 | /* Function called from main.inc.php to send validation email */ |
---|
6 | function SendMail2User($typemail, $id, $username, $password, $email, $confirm) |
---|
7 | { |
---|
8 | /* Only available for next Piwigo release (bug in switch_lang function) */ |
---|
9 | //global $conf; |
---|
10 | |
---|
11 | /* ****************************************************************** */ |
---|
12 | /* Delete this after new Piwigo release (bug in switch_lang function) */ |
---|
13 | global $conf, $user; |
---|
14 | $save_user = $user; |
---|
15 | /* ****************************************************************** */ |
---|
16 | |
---|
17 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
18 | |
---|
19 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
20 | |
---|
21 | $infos1_perso = ""; |
---|
22 | $infos2_perso = ""; |
---|
23 | |
---|
24 | /* We have to get the user's language in database */ |
---|
25 | $query =' |
---|
26 | SELECT user_id, language |
---|
27 | FROM '.USER_INFOS_TABLE.' |
---|
28 | WHERE user_id = '.$id.' |
---|
29 | ;'; |
---|
30 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
31 | |
---|
32 | /* Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language */ |
---|
33 | if (empty($data)) |
---|
34 | { |
---|
35 | /* And switch gallery to this language before using personalized and multilangual contents */ |
---|
36 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
37 | switch_lang_to($language); |
---|
38 | } |
---|
39 | else |
---|
40 | { |
---|
41 | /* And switch gallery to this language before using personalized and multilangual contents */ |
---|
42 | $language = $data['language']; /* Usefull for debugging */ |
---|
43 | switch_lang_to($data['language']); |
---|
44 | load_language('plugin.lang', NBC_UAM_PATH); |
---|
45 | } |
---|
46 | |
---|
47 | switch($typemail) |
---|
48 | { |
---|
49 | case 1: |
---|
50 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Add of %s', stripslashes($username))); |
---|
51 | $password = $password <> '' ? $password : l10n('UserAdvManager_empty_pwd'); |
---|
52 | |
---|
53 | if (isset($conf_nbc_UserAdvManager[10]) and $conf_nbc_UserAdvManager[10] <> '') |
---|
54 | { |
---|
55 | if (function_exists('get_user_language_desc')) |
---|
56 | { |
---|
57 | $infos1_perso = get_user_language_desc($conf_nbc_UserAdvManager[10])."\n\n"; |
---|
58 | } |
---|
59 | else $infos1_perso = l10n($conf_nbc_UserAdvManager[10])."\n\n"; |
---|
60 | } |
---|
61 | |
---|
62 | break; |
---|
63 | |
---|
64 | case 2: |
---|
65 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Update of %s', stripslashes($username))); |
---|
66 | $password = $password <> '' ? $password : l10n('UserAdvManager_empty_pwd'); |
---|
67 | |
---|
68 | break; |
---|
69 | |
---|
70 | case 3: |
---|
71 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Update of %s', stripslashes($username))); |
---|
72 | $password = $password <> '' ? $password : l10n('UserAdvManager_no_update_pwd'); |
---|
73 | |
---|
74 | break; |
---|
75 | } |
---|
76 | |
---|
77 | if (isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') |
---|
78 | { |
---|
79 | $infos1 = array( |
---|
80 | get_l10n_args('infos_mail %s', stripslashes($username)), |
---|
81 | get_l10n_args('User: %s', stripslashes($username)), |
---|
82 | get_l10n_args('Password: %s', $password), |
---|
83 | get_l10n_args('Email: %s', $email), |
---|
84 | get_l10n_args('', ''), |
---|
85 | ); |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | if ( isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and $confirm) |
---|
90 | { |
---|
91 | $infos2 = array |
---|
92 | ( |
---|
93 | get_l10n_args('Link: %s', AddConfirmMail($id, $email)), |
---|
94 | get_l10n_args('', ''), |
---|
95 | ); |
---|
96 | |
---|
97 | if (isset($conf_nbc_UserAdvManager[11]) and $conf_nbc_UserAdvManager[11] <> '') |
---|
98 | { |
---|
99 | if (function_exists('get_user_language_desc')) |
---|
100 | { |
---|
101 | $infos2_perso = get_user_language_desc($conf_nbc_UserAdvManager[11])."\n\n"; |
---|
102 | } |
---|
103 | else $infos2_perso = l10n($conf_nbc_UserAdvManager[11])."\n\n"; |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | /* Sending the email with subject and contents */ |
---|
108 | pwg_mail($email, array( |
---|
109 | 'subject' => $subject, |
---|
110 | 'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), |
---|
111 | )); |
---|
112 | |
---|
113 | /* ********************** */ |
---|
114 | /* Email sending debugger */ |
---|
115 | /* This is only to trace */ |
---|
116 | /* the send of emails for */ |
---|
117 | /* debugging */ |
---|
118 | /* ********************** */ |
---|
119 | //$content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); |
---|
120 | //MailLog($email,$subject,$content,$language); |
---|
121 | /* ********************** */ |
---|
122 | |
---|
123 | /* Switching back to default language */ |
---|
124 | /* ****************************************************************** */ |
---|
125 | /* Delete this after new Piwigo release (bug in switch_lang function) */ |
---|
126 | $user=$save_user ; |
---|
127 | /* ****************************************************************** */ |
---|
128 | switch_lang_back(); |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | /* Function called from UserAdvManager_admin.php to resend validation email with or without new validation key */ |
---|
133 | function ResendMail2User($typemail, $user_id, $username, $email, $confirm) |
---|
134 | { |
---|
135 | /* Only available for next Piwigo release (bug in switch_lang function) */ |
---|
136 | //global $conf; |
---|
137 | |
---|
138 | /* ****************************************************************** */ |
---|
139 | /* Delete this after new Piwigo release (bug in switch_lang function) */ |
---|
140 | global $conf, $user; |
---|
141 | $save_user = $user; |
---|
142 | /* ****************************************************************** */ |
---|
143 | |
---|
144 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
145 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
146 | |
---|
147 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
148 | |
---|
149 | $infos1_perso = ""; |
---|
150 | $infos2_perso = ""; |
---|
151 | |
---|
152 | /* We have to get the user's language in database */ |
---|
153 | $query =' |
---|
154 | SELECT user_id, language |
---|
155 | FROM '.USER_INFOS_TABLE.' |
---|
156 | WHERE user_id = '.$user_id.' |
---|
157 | ;'; |
---|
158 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
159 | $language = $data['language']; |
---|
160 | |
---|
161 | /* And switch gallery to this language before using personalized and multilangual contents */ |
---|
162 | switch_lang_to($data['language']); |
---|
163 | |
---|
164 | load_language('plugin.lang', NBC_UAM_PATH); |
---|
165 | |
---|
166 | switch($typemail) |
---|
167 | { |
---|
168 | case 1: |
---|
169 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_with_key_of_%s', $username)); |
---|
170 | |
---|
171 | if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager_ConfirmMail[3]) and $conf_nbc_UserAdvManager_ConfirmMail[3] == 'true' and $confirm) |
---|
172 | { |
---|
173 | if (function_exists('get_user_language_desc')) |
---|
174 | { |
---|
175 | $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n"; |
---|
176 | } |
---|
177 | else $infos1 = l10n($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n"; |
---|
178 | |
---|
179 | $infos2 = array |
---|
180 | ( |
---|
181 | get_l10n_args('Link: %s', ResetConfirmMail($user_id)), |
---|
182 | get_l10n_args('', ''), |
---|
183 | ); |
---|
184 | } |
---|
185 | |
---|
186 | /* Set reminder true */ |
---|
187 | $query = " |
---|
188 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
189 | SET reminder = 'true' |
---|
190 | WHERE user_id = '".$user_id."' |
---|
191 | ;"; |
---|
192 | pwg_query($query); |
---|
193 | |
---|
194 | break; |
---|
195 | |
---|
196 | case 2: |
---|
197 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_without_key_of_%s',$username)); |
---|
198 | |
---|
199 | if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager_ConfirmMail[3]) and $conf_nbc_UserAdvManager_ConfirmMail[3] == 'true' and !$confirm) |
---|
200 | { |
---|
201 | if (function_exists('get_user_language_desc')) |
---|
202 | { |
---|
203 | $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n"; |
---|
204 | } |
---|
205 | else $infos1 = l10n($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n"; |
---|
206 | } |
---|
207 | |
---|
208 | /* Set reminder true */ |
---|
209 | $query = " |
---|
210 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
211 | SET reminder = 'true' |
---|
212 | WHERE user_id = '".$user_id."' |
---|
213 | ;"; |
---|
214 | pwg_query($query); |
---|
215 | |
---|
216 | break; |
---|
217 | } |
---|
218 | |
---|
219 | pwg_mail($email, array( |
---|
220 | 'subject' => $subject, |
---|
221 | 'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), |
---|
222 | )); |
---|
223 | |
---|
224 | /* ********************** */ |
---|
225 | /* Email sending debugger */ |
---|
226 | /* This is only to trace */ |
---|
227 | /* the send of emails for */ |
---|
228 | /* debugging */ |
---|
229 | /* ********************** */ |
---|
230 | //$content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); |
---|
231 | //MailLog($email,$subject,$content,$language); |
---|
232 | /* ********************** */ |
---|
233 | |
---|
234 | /* Switching back to default language */ |
---|
235 | /* ****************************************************************** */ |
---|
236 | /* Delete this after new Piwigo release (bug in switch_lang function) */ |
---|
237 | $user=$save_user ; |
---|
238 | /* ****************************************************************** */ |
---|
239 | switch_lang_back(); |
---|
240 | } |
---|
241 | |
---|
242 | |
---|
243 | /* Function called from UserAdvManager_admin.php to send a reminder mail for ghost users */ |
---|
244 | function ghostreminder($user_id, $username, $email) |
---|
245 | { |
---|
246 | /* Only available for next Piwigo release (bug in switch_lang function) */ |
---|
247 | //global $conf; |
---|
248 | |
---|
249 | /* ****************************************************************** */ |
---|
250 | /* Delete this after new Piwigo release (bug in switch_lang function) */ |
---|
251 | global $conf, $user; |
---|
252 | $save_user = $user; |
---|
253 | /* ****************************************************************** */ |
---|
254 | |
---|
255 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
256 | |
---|
257 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
258 | |
---|
259 | $infos1_perso = ""; |
---|
260 | |
---|
261 | /* We have to get the user's language in database */ |
---|
262 | $query =' |
---|
263 | SELECT user_id, language |
---|
264 | FROM '.USER_INFOS_TABLE.' |
---|
265 | WHERE user_id = '.$user_id.' |
---|
266 | ;'; |
---|
267 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
268 | $language = $data['language']; |
---|
269 | |
---|
270 | /* And switch gallery to this language before using personalized and multilangual contents */ |
---|
271 | switch_lang_to($data['language']); |
---|
272 | |
---|
273 | load_language('plugin.lang', NBC_UAM_PATH); |
---|
274 | |
---|
275 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_reminder_of_%s', $username)); |
---|
276 | |
---|
277 | if (isset($conf_nbc_UserAdvManager[19]) and $conf_nbc_UserAdvManager[19] <> '' and isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17] == 'true') |
---|
278 | { |
---|
279 | if (function_exists('get_user_language_desc')) |
---|
280 | { |
---|
281 | $infos1 = get_user_language_desc($conf_nbc_UserAdvManager[19])."\n\n"; |
---|
282 | } |
---|
283 | else |
---|
284 | { |
---|
285 | $infos1 = l10n($conf_nbc_UserAdvManager[19])."\n\n"; |
---|
286 | } |
---|
287 | |
---|
288 | resetlastvisit($user_id); |
---|
289 | } |
---|
290 | |
---|
291 | pwg_mail($email, array( |
---|
292 | 'subject' => $subject, |
---|
293 | 'content' => $infos1.get_absolute_root_url(), |
---|
294 | )); |
---|
295 | |
---|
296 | /* ********************** */ |
---|
297 | /* Email sending debugger */ |
---|
298 | /* This is only to trace */ |
---|
299 | /* the send of emails for */ |
---|
300 | /* debugging */ |
---|
301 | /* ********************** */ |
---|
302 | //$content = get_user_language_desc($conf_nbc_UserAdvManager[19])."\n\n"; |
---|
303 | //MailLog($email,$subject,$content,$language); |
---|
304 | /* ********************** */ |
---|
305 | |
---|
306 | /* Switching back to default language */ |
---|
307 | /* ****************************************************************** */ |
---|
308 | /* Delete this after new Piwigo release (bug in switch_lang function) */ |
---|
309 | $user=$save_user ; |
---|
310 | /* ****************************************************************** */ |
---|
311 | switch_lang_back(); |
---|
312 | } |
---|
313 | |
---|
314 | |
---|
315 | /* Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation */ |
---|
316 | function FindAvailableConfirmMailID() |
---|
317 | { |
---|
318 | while (true) |
---|
319 | { |
---|
320 | $id = generate_key(16); |
---|
321 | $query = " |
---|
322 | SELECT COUNT(*) |
---|
323 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
324 | WHERE id = '".$id."' |
---|
325 | ;"; |
---|
326 | list($count) = mysql_fetch_row(pwg_query($query)); |
---|
327 | |
---|
328 | if ($count == 0) |
---|
329 | return $id; |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | |
---|
334 | /* Function called from functions SendMail2User to process unvalidated users and generate validation key link */ |
---|
335 | function AddConfirmMail($user_id, $email) |
---|
336 | { |
---|
337 | global $conf; |
---|
338 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
339 | $Confirm_Mail_ID = FindAvailableConfirmMailID(); |
---|
340 | |
---|
341 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
342 | |
---|
343 | if (isset($Confirm_Mail_ID)) |
---|
344 | { |
---|
345 | $query = " |
---|
346 | SELECT status |
---|
347 | FROM ".USER_INFOS_TABLE." |
---|
348 | WHERE user_id = '".$user_id."' |
---|
349 | ;"; |
---|
350 | list($status) = mysql_fetch_row(pwg_query($query)); |
---|
351 | |
---|
352 | $query = " |
---|
353 | INSERT INTO ".USER_CONFIRM_MAIL_TABLE." |
---|
354 | (id, user_id, mail_address, status, date_check) |
---|
355 | VALUES |
---|
356 | ('".$Confirm_Mail_ID."', '".$user_id."', '".$email."', '".$status."', null) |
---|
357 | ;"; |
---|
358 | pwg_query($query); |
---|
359 | |
---|
360 | $query = " |
---|
361 | DELETE FROM ".USER_GROUP_TABLE." |
---|
362 | WHERE user_id = '".$user_id."' |
---|
363 | AND ( |
---|
364 | group_id = '".$conf_nbc_UserAdvManager[3]."' |
---|
365 | OR |
---|
366 | group_id = '".$conf_nbc_UserAdvManager[4]."' |
---|
367 | ) |
---|
368 | ;"; |
---|
369 | pwg_query($query); |
---|
370 | |
---|
371 | if (!is_admin() and $conf_nbc_UserAdvManager[9] <> -1) |
---|
372 | { |
---|
373 | $query = " |
---|
374 | UPDATE ".USER_INFOS_TABLE." |
---|
375 | SET status = '".$conf_nbc_UserAdvManager[9]."' |
---|
376 | WHERE user_id = '".$user_id."' |
---|
377 | ;"; |
---|
378 | pwg_query($query); |
---|
379 | } |
---|
380 | |
---|
381 | if ( $conf_nbc_UserAdvManager[3] <> -1 ) |
---|
382 | { |
---|
383 | $query = " |
---|
384 | INSERT INTO ".USER_GROUP_TABLE." |
---|
385 | (user_id, group_id) |
---|
386 | VALUES |
---|
387 | ('".$user_id."', '".$conf_nbc_UserAdvManager[3]."') |
---|
388 | ;"; |
---|
389 | pwg_query($query); |
---|
390 | } |
---|
391 | |
---|
392 | return get_absolute_root_url().NBC_UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID; |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | |
---|
397 | /* Function called from UserAdvManager_admin.php to reset validation key */ |
---|
398 | function ResetConfirmMail($user_id) |
---|
399 | { |
---|
400 | global $conf; |
---|
401 | |
---|
402 | $Confirm_Mail_ID = FindAvailableConfirmMailID(); |
---|
403 | |
---|
404 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
405 | |
---|
406 | if (isset($Confirm_Mail_ID)) |
---|
407 | { |
---|
408 | $query = " |
---|
409 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
410 | SET id = '".$Confirm_Mail_ID."' |
---|
411 | WHERE user_id = '".$user_id."' |
---|
412 | ;"; |
---|
413 | pwg_query($query); |
---|
414 | |
---|
415 | $query = " |
---|
416 | UPDATE ".USER_INFOS_TABLE." |
---|
417 | SET registration_date = '".$dbnow."' |
---|
418 | WHERE user_id = '".$user_id."' |
---|
419 | ;"; |
---|
420 | pwg_query($query); |
---|
421 | |
---|
422 | return get_absolute_root_url().NBC_UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID; |
---|
423 | } |
---|
424 | } |
---|
425 | |
---|
426 | |
---|
427 | /* Function called from function_UserAdvManager.inc.php to reset last visit date after sending a reminder */ |
---|
428 | function resetlastvisit($user_id) |
---|
429 | { |
---|
430 | global $conf; |
---|
431 | |
---|
432 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
433 | |
---|
434 | $query = " |
---|
435 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
436 | SET lastvisit = '".$dbnow."', reminder = 'true' |
---|
437 | WHERE user_id = '".$user_id."' |
---|
438 | ;"; |
---|
439 | pwg_query($query); |
---|
440 | } |
---|
441 | |
---|
442 | |
---|
443 | /* Function called from main.inc.php - Triggered on user deletion */ |
---|
444 | function DeleteConfirmMail($user_id) |
---|
445 | { |
---|
446 | $query = " |
---|
447 | DELETE FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
448 | WHERE user_id = '".$user_id."' |
---|
449 | ;"; |
---|
450 | pwg_query($query); |
---|
451 | } |
---|
452 | |
---|
453 | /* Function called from main.inc.php - Triggered on user deletion */ |
---|
454 | function DeleteLastVisit($user_id) |
---|
455 | { |
---|
456 | $query = " |
---|
457 | DELETE FROM ".USER_LASTVISIT_TABLE." |
---|
458 | WHERE user_id = '".$user_id."' |
---|
459 | ;"; |
---|
460 | pwg_query($query); |
---|
461 | } |
---|
462 | |
---|
463 | /* Function called from ConfirmMail.php to verify validation key used by user according time limit */ |
---|
464 | function VerifyConfirmMail($id) |
---|
465 | { |
---|
466 | global $conf; |
---|
467 | |
---|
468 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
469 | |
---|
470 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
471 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
472 | |
---|
473 | $query = " |
---|
474 | SELECT COUNT(*) |
---|
475 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
476 | WHERE id = '".$id."' |
---|
477 | ;"; |
---|
478 | list($count) = mysql_fetch_row(pwg_query($query)); |
---|
479 | |
---|
480 | if ($count == 1) |
---|
481 | { |
---|
482 | $query = " |
---|
483 | SELECT user_id, status, date_check |
---|
484 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
485 | WHERE id = '".$id."' |
---|
486 | ;"; |
---|
487 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
488 | |
---|
489 | if (!empty($data) and isset($data['user_id']) and !isset($data['date_check'])) |
---|
490 | { |
---|
491 | $query = " |
---|
492 | SELECT registration_date |
---|
493 | FROM ".USER_INFOS_TABLE." |
---|
494 | WHERE user_id = '".$data['user_id']."' |
---|
495 | ;"; |
---|
496 | list($registration_date) = mysql_fetch_row(pwg_query($query)); |
---|
497 | |
---|
498 | /* Time limit process */ |
---|
499 | /* ****************** begin ******************* */ |
---|
500 | if (!empty($registration_date)) |
---|
501 | { |
---|
502 | // Verify Confirmmail with time limit ON |
---|
503 | if (isset ($conf_nbc_UserAdvManager_ConfirmMail[1])) |
---|
504 | { |
---|
505 | // dates formating and compare |
---|
506 | $today = date("d-m-Y"); // Get today's date |
---|
507 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
508 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
509 | |
---|
510 | list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date |
---|
511 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
512 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
513 | |
---|
514 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
515 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
516 | |
---|
517 | // Condition with the value set for time limit |
---|
518 | if ($deltadays <= $conf_nbc_UserAdvManager_ConfirmMail[1]) // If Nb of days is less than the limit set |
---|
519 | { |
---|
520 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
521 | |
---|
522 | $query = ' |
---|
523 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
524 | SET date_check="'.$dbnow.'" |
---|
525 | WHERE id = "'.$id.'" |
---|
526 | ;'; |
---|
527 | pwg_query($query); |
---|
528 | |
---|
529 | if ($conf_nbc_UserAdvManager[3] <> -1) // Delete user from unvalidated users group |
---|
530 | { |
---|
531 | $query = " |
---|
532 | DELETE FROM ".USER_GROUP_TABLE." |
---|
533 | WHERE user_id = '".$data['user_id']."' |
---|
534 | AND group_id = '".$conf_nbc_UserAdvManager[3]."' |
---|
535 | ;"; |
---|
536 | pwg_query($query); |
---|
537 | } |
---|
538 | |
---|
539 | if ($conf_nbc_UserAdvManager[4] <> -1) // Add user to validated users group |
---|
540 | { |
---|
541 | $query = " |
---|
542 | INSERT INTO ".USER_GROUP_TABLE." |
---|
543 | (user_id, group_id) |
---|
544 | VALUES |
---|
545 | ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') |
---|
546 | ;"; |
---|
547 | pwg_query($query); |
---|
548 | } |
---|
549 | |
---|
550 | if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) // Change user's status |
---|
551 | { |
---|
552 | $query = " |
---|
553 | UPDATE ".USER_INFOS_TABLE." |
---|
554 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' |
---|
555 | WHERE user_id = '".$data['user_id']."' |
---|
556 | ;"; |
---|
557 | pwg_query($query); |
---|
558 | } |
---|
559 | // Refresh user's category cache |
---|
560 | invalidate_user_cache(); |
---|
561 | |
---|
562 | return true; |
---|
563 | } |
---|
564 | elseif ($deltadays > $conf_nbc_UserAdvManager_ConfirmMail[1]) // If timelimit exeeds |
---|
565 | { |
---|
566 | return false; |
---|
567 | } |
---|
568 | } |
---|
569 | // Verify Confirmmail with time limit OFF |
---|
570 | else |
---|
571 | { |
---|
572 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
573 | |
---|
574 | $query = ' |
---|
575 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
576 | SET date_check="'.$dbnow.'" |
---|
577 | WHERE id = "'.$id.'" |
---|
578 | ;'; |
---|
579 | pwg_query($query); |
---|
580 | |
---|
581 | if ($conf_nbc_UserAdvManager[3] <> -1) |
---|
582 | { |
---|
583 | $query = " |
---|
584 | DELETE FROM ".USER_GROUP_TABLE." |
---|
585 | WHERE user_id = '".$data['user_id']."' |
---|
586 | AND group_id = '".$conf_nbc_UserAdvManager[3]."' |
---|
587 | ;"; |
---|
588 | pwg_query($query); |
---|
589 | } |
---|
590 | |
---|
591 | if ($conf_nbc_UserAdvManager[4] <> -1) |
---|
592 | { |
---|
593 | $query = " |
---|
594 | DELETE FROM ".USER_GROUP_TABLE." |
---|
595 | WHERE user_id = '".$data['user_id']."' |
---|
596 | AND group_id = '".$conf_nbc_UserAdvManager[4]."' |
---|
597 | ;"; |
---|
598 | pwg_query($query); |
---|
599 | |
---|
600 | $query = " |
---|
601 | INSERT INTO ".USER_GROUP_TABLE." |
---|
602 | (user_id, group_id) |
---|
603 | VALUES |
---|
604 | ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') |
---|
605 | ;"; |
---|
606 | pwg_query($query); |
---|
607 | } |
---|
608 | |
---|
609 | if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) |
---|
610 | { |
---|
611 | $query = " |
---|
612 | UPDATE ".USER_INFOS_TABLE." |
---|
613 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' |
---|
614 | WHERE user_id = '".$data['user_id']."' |
---|
615 | ;"; |
---|
616 | pwg_query($query); |
---|
617 | } |
---|
618 | // Refresh user's category cache |
---|
619 | invalidate_user_cache(); |
---|
620 | |
---|
621 | return true; |
---|
622 | } |
---|
623 | } |
---|
624 | } |
---|
625 | } |
---|
626 | else |
---|
627 | return false; |
---|
628 | } |
---|
629 | |
---|
630 | /* Function called from UserAdvManager_admin.php to force users validation by admin */ |
---|
631 | function ForceValidation($id) |
---|
632 | { |
---|
633 | global $conf; |
---|
634 | |
---|
635 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
636 | |
---|
637 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
638 | |
---|
639 | $query = " |
---|
640 | SELECT COUNT(*) |
---|
641 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
642 | WHERE user_id = '".$id."' |
---|
643 | ;"; |
---|
644 | list($count) = mysql_fetch_row(pwg_query($query)); |
---|
645 | |
---|
646 | if ($count == 1) |
---|
647 | { |
---|
648 | $query = " |
---|
649 | SELECT user_id, status, date_check |
---|
650 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
651 | WHERE user_id = '".$id."' |
---|
652 | ;"; |
---|
653 | $data = mysql_fetch_assoc(pwg_query($query)); |
---|
654 | |
---|
655 | if (!empty($data) and isset($data['user_id']) and !isset($data['date_check'])) |
---|
656 | { |
---|
657 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
658 | |
---|
659 | $query = " |
---|
660 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
661 | SET date_check='".$dbnow."' |
---|
662 | WHERE user_id = '".$data['user_id']."' |
---|
663 | ;"; |
---|
664 | pwg_query($query); |
---|
665 | |
---|
666 | if ($conf_nbc_UserAdvManager[3] <> -1) |
---|
667 | { |
---|
668 | $query = " |
---|
669 | DELETE FROM ".USER_GROUP_TABLE." |
---|
670 | WHERE user_id = '".$data['user_id']."' |
---|
671 | AND group_id = '".$conf_nbc_UserAdvManager[3]."' |
---|
672 | ;"; |
---|
673 | pwg_query($query); |
---|
674 | } |
---|
675 | |
---|
676 | if ($conf_nbc_UserAdvManager[4] <> -1) |
---|
677 | { |
---|
678 | $query = " |
---|
679 | DELETE FROM ".USER_GROUP_TABLE." |
---|
680 | WHERE user_id = '".$data['user_id']."' |
---|
681 | AND group_id = '".$conf_nbc_UserAdvManager[4]."' |
---|
682 | ;"; |
---|
683 | pwg_query($query); |
---|
684 | |
---|
685 | $query = " |
---|
686 | INSERT INTO ".USER_GROUP_TABLE." |
---|
687 | (user_id, group_id) |
---|
688 | VALUES |
---|
689 | ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') |
---|
690 | ;"; |
---|
691 | pwg_query($query); |
---|
692 | } |
---|
693 | |
---|
694 | if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) |
---|
695 | { |
---|
696 | $query = " |
---|
697 | UPDATE ".USER_INFOS_TABLE." |
---|
698 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' |
---|
699 | WHERE user_id = '".$data['user_id']."' |
---|
700 | ;"; |
---|
701 | pwg_query($query); |
---|
702 | } |
---|
703 | // Refresh user's category cache |
---|
704 | invalidate_user_cache(); |
---|
705 | return true; |
---|
706 | } |
---|
707 | } |
---|
708 | } |
---|
709 | |
---|
710 | /* Function called from main.inc.php - Get username case insensitive */ |
---|
711 | function NotSensibleSearchUsername($username) |
---|
712 | { |
---|
713 | global $conf; |
---|
714 | |
---|
715 | if (isset($username)) |
---|
716 | { |
---|
717 | $query = " |
---|
718 | SELECT ".$conf['user_fields']['username']." |
---|
719 | FROM ".USERS_TABLE." |
---|
720 | WHERE LOWER(".stripslashes($conf['user_fields']['username']).") = '".strtolower($username)."' |
---|
721 | ;"; |
---|
722 | $users = mysql_num_rows(pwg_query($query)); |
---|
723 | if ($users > 0) |
---|
724 | { |
---|
725 | return true; |
---|
726 | } |
---|
727 | else |
---|
728 | { |
---|
729 | return false; |
---|
730 | } |
---|
731 | } |
---|
732 | } |
---|
733 | |
---|
734 | |
---|
735 | /* Function called from main.inc.php - Check if username matches forbidden caracters */ |
---|
736 | function ValidateUsername($login) |
---|
737 | { |
---|
738 | global $conf; |
---|
739 | |
---|
740 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
741 | |
---|
742 | if (isset($login) and isset($conf_nbc_UserAdvManager[8]) and $conf_nbc_UserAdvManager[8] <> '') |
---|
743 | { |
---|
744 | $conf_nbc_CharExclusion = preg_split("/,/",$conf_nbc_UserAdvManager[8]); |
---|
745 | for ($i = 0 ; $i < count($conf_nbc_CharExclusion) ; $i++) |
---|
746 | { |
---|
747 | $pattern = '/'.$conf_nbc_CharExclusion[$i].'/i'; |
---|
748 | if (preg_match($pattern, $login)) |
---|
749 | { |
---|
750 | return true; |
---|
751 | } |
---|
752 | } |
---|
753 | } |
---|
754 | else |
---|
755 | { |
---|
756 | return false; |
---|
757 | } |
---|
758 | } |
---|
759 | |
---|
760 | |
---|
761 | /* Function called from main.inc.php - Check if user's email is in excluded email providers list */ |
---|
762 | /* Doesn't work on call - Must be copied in main.inc.php to work */ |
---|
763 | function ValidateEmailProvider($email) |
---|
764 | { |
---|
765 | global $conf; |
---|
766 | |
---|
767 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
768 | |
---|
769 | if (isset($email) and isset($conf_nbc_UserAdvManager[13]) and $conf_nbc_UserAdvManager[13] <> '') |
---|
770 | { |
---|
771 | //$ncsemail = strtolower($email); |
---|
772 | $conf_nbc_MailExclusion = preg_split("/[\s,]+/",$conf_nbc_UserAdvManager[13]); |
---|
773 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
---|
774 | { |
---|
775 | $pattern = '/'.$conf_nbc_MailExclusion[$i].'/i'; |
---|
776 | if (preg_match($pattern, $email)) |
---|
777 | { |
---|
778 | return true; |
---|
779 | } |
---|
780 | } |
---|
781 | } |
---|
782 | else |
---|
783 | { |
---|
784 | return false; |
---|
785 | } |
---|
786 | } |
---|
787 | |
---|
788 | |
---|
789 | /* Function called from UserAdvManager.php - Get unvalidated users according time limit */ |
---|
790 | function get_unvalid_user_list() |
---|
791 | { |
---|
792 | global $conf, $page; |
---|
793 | |
---|
794 | /* Get ConfirmMail configuration */ |
---|
795 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
796 | |
---|
797 | /* Get UserAdvManager configuration */ |
---|
798 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
799 | |
---|
800 | $users = array(); |
---|
801 | |
---|
802 | /* search users depending expiration date */ |
---|
803 | $query = ' |
---|
804 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
805 | u.'.$conf['user_fields']['username'].' AS username, |
---|
806 | u.'.$conf['user_fields']['email'].' AS email, |
---|
807 | ui.status, |
---|
808 | ui.adviser, |
---|
809 | ui.enabled_high, |
---|
810 | ui.level, |
---|
811 | ui.registration_date |
---|
812 | FROM '.USERS_TABLE.' AS u |
---|
813 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
814 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
815 | LEFT JOIN '.USER_GROUP_TABLE.' AS ug |
---|
816 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
817 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
818 | AND (TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'" |
---|
819 | OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'")'; |
---|
820 | |
---|
821 | if ($conf_nbc_UserAdvManager[3] <> '-1' and $conf_nbc_UserAdvManager[9] == '-1') |
---|
822 | { |
---|
823 | $query.= ' |
---|
824 | AND ug.group_id = '.$conf_nbc_UserAdvManager[3]; |
---|
825 | } |
---|
826 | if ($conf_nbc_UserAdvManager[3] == '-1' and $conf_nbc_UserAdvManager[9] <> '-1') |
---|
827 | { |
---|
828 | $query.= ' |
---|
829 | AND ui.status = \''.$conf_nbc_UserAdvManager[9]."'"; |
---|
830 | } |
---|
831 | if ($conf_nbc_UserAdvManager[3] <> '-1' and $conf_nbc_UserAdvManager[9] <> '-1') |
---|
832 | { |
---|
833 | $query.= ' |
---|
834 | AND ug.group_id = \''.$conf_nbc_UserAdvManager[3]."'"; |
---|
835 | } |
---|
836 | $query.= ' |
---|
837 | ORDER BY id ASC |
---|
838 | ;'; |
---|
839 | |
---|
840 | $result = pwg_query($query); |
---|
841 | |
---|
842 | while ($row = mysql_fetch_assoc($result)) |
---|
843 | { |
---|
844 | $user = $row; |
---|
845 | $user['groups'] = array(); |
---|
846 | |
---|
847 | array_push($users, $user); |
---|
848 | } |
---|
849 | |
---|
850 | /* add group lists */ |
---|
851 | $user_ids = array(); |
---|
852 | foreach ($users as $i => $user) |
---|
853 | { |
---|
854 | $user_ids[$i] = $user['id']; |
---|
855 | } |
---|
856 | |
---|
857 | $user_nums = array_flip($user_ids); |
---|
858 | |
---|
859 | if (count($user_ids) > 0) |
---|
860 | { |
---|
861 | $query = ' |
---|
862 | SELECT user_id, group_id |
---|
863 | FROM '.USER_GROUP_TABLE.' |
---|
864 | WHERE user_id IN ('.implode(',', $user_ids).') |
---|
865 | ;'; |
---|
866 | |
---|
867 | $result = pwg_query($query); |
---|
868 | |
---|
869 | while ($row = mysql_fetch_assoc($result)) |
---|
870 | { |
---|
871 | array_push( |
---|
872 | $users[$user_nums[$row['user_id']]]['groups'], |
---|
873 | $row['group_id'] |
---|
874 | ); |
---|
875 | } |
---|
876 | } |
---|
877 | |
---|
878 | return $users; |
---|
879 | } |
---|
880 | |
---|
881 | |
---|
882 | /* Function called from UserAdvManager.php - Get ghost users */ |
---|
883 | function get_ghost_user_list() |
---|
884 | { |
---|
885 | global $conf, $page; |
---|
886 | |
---|
887 | /* Get UserAdvManager configuration */ |
---|
888 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
889 | |
---|
890 | $users = array(); |
---|
891 | |
---|
892 | /* search users depending expiration date */ |
---|
893 | $query = ' |
---|
894 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
895 | u.'.$conf['user_fields']['username'].' AS username, |
---|
896 | u.'.$conf['user_fields']['email'].' AS email, |
---|
897 | lv.lastvisit, |
---|
898 | lv.reminder |
---|
899 | FROM '.USERS_TABLE.' AS u |
---|
900 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv |
---|
901 | ON u.'.$conf['user_fields']['id'].' = lv.user_id |
---|
902 | WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_nbc_UserAdvManager[18].'") |
---|
903 | ORDER BY id ASC;'; |
---|
904 | |
---|
905 | $result = pwg_query($query); |
---|
906 | |
---|
907 | while ($row = mysql_fetch_assoc($result)) |
---|
908 | { |
---|
909 | $user = $row; |
---|
910 | $user['groups'] = array(); |
---|
911 | |
---|
912 | array_push($users, $user); |
---|
913 | } |
---|
914 | |
---|
915 | /* add group lists */ |
---|
916 | $user_ids = array(); |
---|
917 | foreach ($users as $i => $user) |
---|
918 | { |
---|
919 | $user_ids[$i] = $user['id']; |
---|
920 | } |
---|
921 | |
---|
922 | return $users; |
---|
923 | } |
---|
924 | |
---|
925 | |
---|
926 | /* Function called from UserAdvManager.php - Get all users to display the number of days since their last visit */ |
---|
927 | function get_user_list() |
---|
928 | { |
---|
929 | global $conf, $page; |
---|
930 | |
---|
931 | $users = array(); |
---|
932 | |
---|
933 | /* search users depending expiration date */ |
---|
934 | $query = ' |
---|
935 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
936 | u.'.$conf['user_fields']['username'].' AS username, |
---|
937 | u.'.$conf['user_fields']['email'].' AS email, |
---|
938 | ug.lastvisit |
---|
939 | FROM '.USERS_TABLE.' AS u |
---|
940 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS ug |
---|
941 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
942 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
943 | ORDER BY lastvisit DESC |
---|
944 | ;'; |
---|
945 | |
---|
946 | $result = pwg_query($query); |
---|
947 | |
---|
948 | while ($row = mysql_fetch_assoc($result)) |
---|
949 | { |
---|
950 | $user = $row; |
---|
951 | $user['groups'] = array(); |
---|
952 | |
---|
953 | array_push($users, $user); |
---|
954 | } |
---|
955 | |
---|
956 | /* add group lists */ |
---|
957 | $user_ids = array(); |
---|
958 | foreach ($users as $i => $user) |
---|
959 | { |
---|
960 | $user_ids[$i] = $user['id']; |
---|
961 | } |
---|
962 | |
---|
963 | return $users; |
---|
964 | } |
---|
965 | |
---|
966 | |
---|
967 | /* Function called from UserAdvManager.php - to determine who is expired or not and giving a different display color */ |
---|
968 | function expiration($id) |
---|
969 | { |
---|
970 | global $conf, $page; |
---|
971 | |
---|
972 | /* Get ConfirmMail configuration */ |
---|
973 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
974 | |
---|
975 | /* Get UserAdvManager configuration */ |
---|
976 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
977 | |
---|
978 | $query = " |
---|
979 | SELECT registration_date |
---|
980 | FROM ".USER_INFOS_TABLE." |
---|
981 | WHERE user_id = '".$id."' |
---|
982 | ;"; |
---|
983 | list($registration_date) = mysql_fetch_row(pwg_query($query)); |
---|
984 | |
---|
985 | /* Time limit process */ |
---|
986 | /* ****************** begin ******************* */ |
---|
987 | if (!empty($registration_date)) |
---|
988 | { |
---|
989 | // dates formating and compare |
---|
990 | $today = date("d-m-Y"); // Get today's date |
---|
991 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
992 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
993 | |
---|
994 | list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date |
---|
995 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
996 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
997 | |
---|
998 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
999 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
1000 | |
---|
1001 | // Condition with the value set for time limit |
---|
1002 | if ($deltadays <= $conf_nbc_UserAdvManager_ConfirmMail[1]) // If Nb of days is less than the limit set |
---|
1003 | { |
---|
1004 | return false; |
---|
1005 | } |
---|
1006 | else |
---|
1007 | { |
---|
1008 | return True; |
---|
1009 | } |
---|
1010 | } |
---|
1011 | } |
---|
1012 | |
---|
1013 | |
---|
1014 | /** |
---|
1015 | * Returns a password's score for password complexity check |
---|
1016 | * |
---|
1017 | * @param password filled by user |
---|
1018 | * |
---|
1019 | * Thanx to MathieuGut from http://m-gut.developpez.com |
---|
1020 | */ |
---|
1021 | function testpassword($password) // Le mot de passe passé en paramètre - $password given by user |
---|
1022 | { |
---|
1023 | |
---|
1024 | // Initialisation des variables - Variables initiation |
---|
1025 | $points = 0; |
---|
1026 | $point_lowercase = 0; |
---|
1027 | $point_uppercase = 0; |
---|
1028 | $point_numbers = 0; |
---|
1029 | $point_characters = 0; |
---|
1030 | |
---|
1031 | // On récupère la longueur du mot de passe - Getting password lengh |
---|
1032 | $length = strlen($password); |
---|
1033 | |
---|
1034 | // On fait une boucle pour lire chaque lettre - Loop to read password characters |
---|
1035 | for($i = 0; $i < $length; $i++) |
---|
1036 | { |
---|
1037 | // On sélectionne une à une chaque lettre - Select each letters |
---|
1038 | // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn |
---|
1039 | $letters = $password[$i]; |
---|
1040 | |
---|
1041 | if ($letters>='a' && $letters<='z') |
---|
1042 | { |
---|
1043 | // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase |
---|
1044 | $points = $points + 1; |
---|
1045 | |
---|
1046 | // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase |
---|
1047 | $point_lowercase = 1; |
---|
1048 | } |
---|
1049 | else if ($letters>='A' && $letters <='Z') |
---|
1050 | { |
---|
1051 | // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase |
---|
1052 | $points = $points + 2; |
---|
1053 | |
---|
1054 | // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase |
---|
1055 | $point_uppercase = 2; |
---|
1056 | } |
---|
1057 | else if ($letters>='0' && $letters<='9') |
---|
1058 | { |
---|
1059 | // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers |
---|
1060 | $points = $points + 3; |
---|
1061 | |
---|
1062 | // On rajoute le bonus pour un chiffre - Adding bonus points for numbers |
---|
1063 | $point_numbers = 3; |
---|
1064 | } |
---|
1065 | else |
---|
1066 | { |
---|
1067 | // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters |
---|
1068 | $points = $points + 5; |
---|
1069 | |
---|
1070 | // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters |
---|
1071 | $point_characters = 5; |
---|
1072 | } |
---|
1073 | } |
---|
1074 | |
---|
1075 | // Calcul du coefficient points/longueur - calculating the coefficient points/length |
---|
1076 | $step1 = $points / $length; |
---|
1077 | |
---|
1078 | // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types... |
---|
1079 | $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters; |
---|
1080 | |
---|
1081 | // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length |
---|
1082 | $score = $step1 * $step2; |
---|
1083 | |
---|
1084 | // Multiplication du résultat par la longueur de la chaîne - Multiplying the result by the length of the chain |
---|
1085 | $finalscore = $score * $length; |
---|
1086 | |
---|
1087 | return $finalscore; |
---|
1088 | } |
---|
1089 | |
---|
1090 | /* Function called from maintain.inc.php - to check if database upgrade is needed */ |
---|
1091 | function table_exist($table) |
---|
1092 | { |
---|
1093 | $query = 'DESC '.$table.';'; |
---|
1094 | return (bool)($res=mysql_query($query)); |
---|
1095 | } |
---|
1096 | |
---|
1097 | /* Email sending debugger function */ |
---|
1098 | function MailLog ($to, $subject, $content, $language) |
---|
1099 | { |
---|
1100 | $fo=fopen (NBC_UAM_PATH.'admin/maillog.txt','a') ; |
---|
1101 | fwrite($fo,"======================\n") ; |
---|
1102 | fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n"); |
---|
1103 | fwrite($fo,$to . "\n" . $subject . "\r\n") ; |
---|
1104 | fwrite($fo, "\n" . $content . "\r\n") ; |
---|
1105 | fwrite($fo, 'Langue : '."\n" . $language . "\r\n") ; |
---|
1106 | fclose($fo) ; |
---|
1107 | //return mail ($to,$subject) ; |
---|
1108 | } |
---|
1109 | |
---|
1110 | |
---|
1111 | /* Function called from UserAdvManager_admin.php to get the plugin version */ |
---|
1112 | function PluginVer($dir) |
---|
1113 | { |
---|
1114 | $path = $dir; |
---|
1115 | |
---|
1116 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
1117 | if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) |
---|
1118 | { |
---|
1119 | $plugin['name'] = trim( $val[1] ); |
---|
1120 | } |
---|
1121 | if (preg_match("|Version: (.*)|", $plg_data, $val)) |
---|
1122 | { |
---|
1123 | $plugin['version'] = trim($val[1]); |
---|
1124 | } |
---|
1125 | if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) |
---|
1126 | { |
---|
1127 | $plugin['uri'] = trim($val[1]); |
---|
1128 | } |
---|
1129 | if ($desc = load_language('description.txt', $path.'/', array('return' => true))) |
---|
1130 | { |
---|
1131 | $plugin['description'] = trim($desc); |
---|
1132 | } |
---|
1133 | elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) |
---|
1134 | { |
---|
1135 | $plugin['description'] = trim($val[1]); |
---|
1136 | } |
---|
1137 | if ( preg_match("|Author: (.*)|", $plg_data, $val) ) |
---|
1138 | { |
---|
1139 | $plugin['author'] = trim($val[1]); |
---|
1140 | } |
---|
1141 | if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) |
---|
1142 | { |
---|
1143 | $plugin['author uri'] = trim($val[1]); |
---|
1144 | } |
---|
1145 | if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) |
---|
1146 | { |
---|
1147 | list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); |
---|
1148 | if (is_numeric($extension)) $plugin['extension'] = $extension; |
---|
1149 | } |
---|
1150 | // IMPORTANT SECURITY ! |
---|
1151 | $plugin = array_map('htmlspecialchars', $plugin); |
---|
1152 | |
---|
1153 | return $plugin ; |
---|
1154 | } |
---|
1155 | |
---|
1156 | /* Funtion called in maintain.inc.php to clean obsolete files */ |
---|
1157 | function clean_obsolete_files($obsolete_file_list) |
---|
1158 | { |
---|
1159 | if (!file_exists(NBC_UAM_PATH.$obsolete_file_list)) |
---|
1160 | { |
---|
1161 | return TRUE; |
---|
1162 | } |
---|
1163 | $obsolete = file(NBC_UAM_PATH.$obsolete_file_list); |
---|
1164 | array_push($obsolete, $obsolete_file_list); |
---|
1165 | return clean_obsolete_list($obsolete); |
---|
1166 | } |
---|
1167 | |
---|
1168 | function clean_obsolete_list($file_list = array(), &$errors = array()) |
---|
1169 | { |
---|
1170 | if (!function_exists('unlink')) |
---|
1171 | { |
---|
1172 | // No unlink available... |
---|
1173 | array_push($errors, l10n('uam_no_unlink')); |
---|
1174 | return FALSE; |
---|
1175 | } |
---|
1176 | $success = TRUE; |
---|
1177 | foreach ($file_list as $file) |
---|
1178 | { |
---|
1179 | $file = NBC_UAM_PATH . $file; |
---|
1180 | if (file_exists($file)) |
---|
1181 | { |
---|
1182 | // Remove obsolete file |
---|
1183 | $success &= unlink($file); |
---|
1184 | } |
---|
1185 | } |
---|
1186 | if (!$success) |
---|
1187 | { |
---|
1188 | array_push($errors, l10n('uam_unlink_errors')); |
---|
1189 | } |
---|
1190 | return $success; |
---|
1191 | } |
---|
1192 | ?> |
---|