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