- Timestamp:
- Aug 18, 2010, 10:56:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/branches/2.15/include/functions.inc.php
r5634 r6776 45 45 $password = $password <> '' ? $password : l10n('UAM_empty_pwd'); 46 46 47 if (isset($conf_UAM[ 10]) and $conf_UAM[10] <> '')47 if (isset($conf_UAM[9]) and $conf_UAM[9] <> '') 48 48 { 49 49 if (function_exists('get_user_language_desc')) 50 50 { 51 $infos1_perso = get_user_language_desc($conf_UAM[ 10])."\n\n";51 $infos1_perso = get_user_language_desc($conf_UAM[9])."\n\n"; 52 52 } 53 else $infos1_perso = l10n($conf_UAM[ 10])."\n\n";53 else $infos1_perso = l10n($conf_UAM[9])."\n\n"; 54 54 } 55 55 … … 81 81 82 82 83 if ( isset($conf_UAM[ 2]) and $conf_UAM[2] == 'true' and $confirm)83 if ( isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and $confirm) 84 84 { 85 85 $infos2 = array … … 89 89 ); 90 90 91 if (isset($conf_UAM[1 1]) and $conf_UAM[11] <> '')91 if (isset($conf_UAM[10]) and $conf_UAM[10] <> '') 92 92 { 93 93 if (function_exists('get_user_language_desc')) 94 94 { 95 $infos2_perso = get_user_language_desc($conf_UAM[1 1])."\n\n";95 $infos2_perso = get_user_language_desc($conf_UAM[10])."\n\n"; 96 96 } 97 else $infos2_perso = l10n($conf_UAM[1 1])."\n\n";97 else $infos2_perso = l10n($conf_UAM[10])."\n\n"; 98 98 } 99 99 } … … 275 275 $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_reminder_of_%s', $username)); 276 276 277 if (isset($conf_UAM[1 9]) and $conf_UAM[19] <> '' and isset($conf_UAM[17]) and $conf_UAM[17] == 'true')277 if (isset($conf_UAM[18]) and $conf_UAM[18] <> '' and isset($conf_UAM[16]) and $conf_UAM[16] == 'true') 278 278 { 279 279 if (function_exists('get_user_language_desc')) 280 280 { 281 $infos1 = get_user_language_desc($conf_UAM[1 9])."\n\n";281 $infos1 = get_user_language_desc($conf_UAM[18])."\n\n"; 282 282 } 283 283 else 284 284 { 285 $infos1 = l10n($conf_UAM[1 9])."\n\n";285 $infos1 = l10n($conf_UAM[18])."\n\n"; 286 286 } 287 287 … … 359 359 WHERE user_id = '".$user_id."' 360 360 AND ( 361 group_id = '".$conf_UAM[2]."' 362 OR 361 363 group_id = '".$conf_UAM[3]."' 362 OR363 group_id = '".$conf_UAM[4]."'364 364 ) 365 365 ;"; 366 366 pwg_query($query); 367 367 368 if (!is_admin() and $conf_UAM[ 9] <> -1)368 if (!is_admin() and $conf_UAM[8] <> -1) 369 369 { 370 370 $query = " 371 371 UPDATE ".USER_INFOS_TABLE." 372 SET status = '".$conf_UAM[ 9]."'372 SET status = '".$conf_UAM[8]."' 373 373 WHERE user_id = '".$user_id."' 374 374 ;"; … … 376 376 } 377 377 378 if ( $conf_UAM[ 3] <> -1 )378 if ( $conf_UAM[2] <> -1 ) 379 379 { 380 380 $query = " … … 382 382 (user_id, group_id) 383 383 VALUES 384 ('".$user_id."', '".$conf_UAM[ 3]."')384 ('".$user_id."', '".$conf_UAM[2]."') 385 385 ;"; 386 386 pwg_query($query); … … 388 388 389 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); 390 431 } 391 432 } … … 457 498 pwg_query($query); 458 499 } 500 501 502 /* Function called from main.inc.php - Triggered on user deletion */ 503 function DeleteRedir($user_id) 504 { 505 $tab = array(); 506 507 $query = " 508 SELECT value 509 FROM ".CONFIG_TABLE." 510 WHERE param = 'UserAdvManager_Redir' 511 ;"; 512 513 $tab = pwg_db_fetch_row(pwg_query($query)); 514 515 $values = explode(',', $tab[0]); 516 517 unset($values[array_search($user_id, $values)]); 518 519 $query = " 520 UPDATE ".CONFIG_TABLE." 521 SET value = \"".implode(',', $values)."\" 522 WHERE param = 'UserAdvManager_Redir';"; 523 524 pwg_query($query); 525 } 526 459 527 460 528 /* Function called from ConfirmMail.php to verify validation key used by user according time limit */ … … 525 593 pwg_query($query); 526 594 527 if ($conf_UAM[ 3] <> -1) // Delete user from unvalidated users group595 if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group 528 596 { 529 597 $query = " 530 598 DELETE FROM ".USER_GROUP_TABLE." 531 599 WHERE user_id = '".$data['user_id']."' 532 AND group_id = '".$conf_UAM[ 3]."'600 AND group_id = '".$conf_UAM[2]."' 533 601 ;"; 534 602 pwg_query($query); 535 603 } 536 604 537 if ($conf_UAM[ 4] <> -1) // Add user to validated users group605 if ($conf_UAM[3] <> -1) // Add user to validated users group 538 606 { 539 607 $query = " … … 541 609 (user_id, group_id) 542 610 VALUES 543 ('".$data['user_id']."', '".$conf_UAM[ 4]."')611 ('".$data['user_id']."', '".$conf_UAM[3]."') 544 612 ;"; 545 613 pwg_query($query); 546 614 } 547 615 548 if (($conf_UAM[ 5] <> -1 or isset($data['status']))) // Change user's status616 if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status 549 617 { 550 618 $query = " 551 619 UPDATE ".USER_INFOS_TABLE." 552 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[ 5])."'620 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' 553 621 WHERE user_id = '".$data['user_id']."' 554 622 ;"; … … 577 645 pwg_query($query); 578 646 647 if ($conf_UAM[2] <> -1) 648 { 649 $query = " 650 DELETE FROM ".USER_GROUP_TABLE." 651 WHERE user_id = '".$data['user_id']."' 652 AND group_id = '".$conf_UAM[2]."' 653 ;"; 654 pwg_query($query); 655 } 656 579 657 if ($conf_UAM[3] <> -1) 580 658 { … … 585 663 ;"; 586 664 pwg_query($query); 587 }588 589 if ($conf_UAM[4] <> -1)590 {591 $query = "592 DELETE FROM ".USER_GROUP_TABLE."593 WHERE user_id = '".$data['user_id']."'594 AND group_id = '".$conf_UAM[4]."'595 ;";596 pwg_query($query);597 665 598 666 $query = " … … 600 668 (user_id, group_id) 601 669 VALUES 602 ('".$data['user_id']."', '".$conf_UAM[ 4]."')670 ('".$data['user_id']."', '".$conf_UAM[3]."') 603 671 ;"; 604 672 pwg_query($query); 605 673 } 606 674 607 if (($conf_UAM[ 5] <> -1 or isset($data['status'])))675 if (($conf_UAM[4] <> -1 or isset($data['status']))) 608 676 { 609 677 $query = " 610 678 UPDATE ".USER_INFOS_TABLE." 611 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[ 5])."'679 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' 612 680 WHERE user_id = '".$data['user_id']."' 613 681 ;"; … … 662 730 pwg_query($query); 663 731 732 if ($conf_UAM[2] <> -1) 733 { 734 $query = " 735 DELETE FROM ".USER_GROUP_TABLE." 736 WHERE user_id = '".$data['user_id']."' 737 AND group_id = '".$conf_UAM[2]."' 738 ;"; 739 pwg_query($query); 740 } 741 664 742 if ($conf_UAM[3] <> -1) 665 743 { … … 668 746 WHERE user_id = '".$data['user_id']."' 669 747 AND group_id = '".$conf_UAM[3]."' 670 ;";671 pwg_query($query);672 }673 674 if ($conf_UAM[4] <> -1)675 {676 $query = "677 DELETE FROM ".USER_GROUP_TABLE."678 WHERE user_id = '".$data['user_id']."'679 AND group_id = '".$conf_UAM[4]."'680 748 ;"; 681 749 pwg_query($query); … … 685 753 (user_id, group_id) 686 754 VALUES 687 ('".$data['user_id']."', '".$conf_UAM[ 4]."')755 ('".$data['user_id']."', '".$conf_UAM[3]."') 688 756 ;"; 689 757 pwg_query($query); 690 758 } 691 759 692 if (($conf_UAM[ 5] <> -1 or isset($data['status'])))760 if (($conf_UAM[4] <> -1 or isset($data['status']))) 693 761 { 694 762 $query = " 695 763 UPDATE ".USER_INFOS_TABLE." 696 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[ 5])."'764 SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' 697 765 WHERE user_id = '".$data['user_id']."' 698 766 ;"; … … 706 774 } 707 775 708 /* Function called from main.inc.php - Get username case insensitive */709 function NotSensibleSearchUsername($username)710 {711 global $conf;712 713 if (isset($username))714 {715 $query = "716 SELECT ".$conf['user_fields']['username']."717 FROM ".USERS_TABLE."718 WHERE LOWER(".stripslashes($conf['user_fields']['username']).") = '".strtolower($username)."'719 ;";720 $users = pwg_db_num_rows(pwg_query($query));721 if ($users > 0)722 {723 return true;724 }725 else726 {727 return false;728 }729 }730 }731 732 776 733 777 /* Function called from main.inc.php - Check if username matches forbidden caracters */ … … 738 782 $conf_UAM = unserialize($conf['UserAdvManager']); 739 783 740 if (isset($login) and isset($conf_UAM[ 8]) and $conf_UAM[8] <> '')741 { 742 $conf_CharExclusion = preg_split("/,/",$conf_UAM[ 8]);784 if (isset($login) and isset($conf_UAM[7]) and $conf_UAM[7] <> '') 785 { 786 $conf_CharExclusion = preg_split("/,/",$conf_UAM[7]); 743 787 for ($i = 0 ; $i < count($conf_CharExclusion) ; $i++) 744 788 { … … 765 809 $conf_UAM = unserialize($conf['UserAdvManager']); 766 810 767 if (isset($email) and isset($conf_UAM[1 3]) and $conf_UAM[13] <> '')811 if (isset($email) and isset($conf_UAM[12]) and $conf_UAM[12] <> '') 768 812 { 769 813 //$ncsemail = strtolower($email); 770 $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[1 3]);814 $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[12]); 771 815 for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++) 772 816 { … … 816 860 OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_UAM_ConfirmMail[1].'")'; 817 861 818 if ($conf_UAM[ 3] <> '-1' and $conf_UAM[9] == '-1')862 if ($conf_UAM[2] <> '-1' and $conf_UAM[8] == '-1') 819 863 { 820 864 $query.= ' 821 AND ug.group_id = '.$conf_UAM[ 3];822 } 823 if ($conf_UAM[ 3] == '-1' and $conf_UAM[9] <> '-1')865 AND ug.group_id = '.$conf_UAM[2]; 866 } 867 if ($conf_UAM[2] == '-1' and $conf_UAM[8] <> '-1') 824 868 { 825 869 $query.= ' 826 AND ui.status = \''.$conf_UAM[ 9]."'";827 } 828 if ($conf_UAM[ 3] <> '-1' and $conf_UAM[9] <> '-1')870 AND ui.status = \''.$conf_UAM[8]."'"; 871 } 872 if ($conf_UAM[2] <> '-1' and $conf_UAM[8] <> '-1') 829 873 { 830 874 $query.= ' 831 AND ug.group_id = \''.$conf_UAM[ 3]."'";875 AND ug.group_id = \''.$conf_UAM[2]."'"; 832 876 } 833 877 $query.= ' 834 ORDER BY idASC878 ORDER BY ui.registration_date ASC 835 879 ;'; 836 880 … … 896 940 INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv 897 941 ON u.'.$conf['user_fields']['id'].' = lv.user_id 898 WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[1 8].'")899 ORDER BY idASC;';942 WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[17].'") 943 ORDER BY lv.lastvisit ASC;'; 900 944 901 945 $result = pwg_query($query); … … 937 981 ON u.'.$conf['user_fields']['id'].' = ug.user_id 938 982 WHERE u.'.$conf['user_fields']['id'].' >= 3 939 ORDER BY lastvisit DESC983 ORDER BY ug.lastvisit DESC 940 984 ;'; 941 985 … … 1002 1046 else 1003 1047 { 1004 return True;1048 return true; 1005 1049 } 1006 1050 } … … 1168 1212 } 1169 1213 } 1214 1215 1216 // check_consult - Thx to LucMorizur 1217 // checks if a user id is registered as having already 1218 // visited his profile.php page. 1219 // @uid : the user id 1220 // @user_idsOK : (returned) array of all users ids having already visited 1221 // their profile.php pages 1222 // 1223 // @returns : true or false whether the users has already visited his 1224 // profile.php page or not 1225 function check_consult($uid, &$user_idsOK) 1226 { 1227 $t = array(); 1228 $v = false; 1229 1230 $query = " 1231 SELECT value 1232 FROM ".CONFIG_TABLE." 1233 WHERE param = 'UserAdvManager_Redir' 1234 ;"; 1235 1236 if ($v = (($t = pwg_db_fetch_row(pwg_query($query))) !== false)) 1237 { 1238 $user_idsOK = explode(',', $t[0]); 1239 $v = (in_array($uid, $user_idsOK)); 1240 } 1241 return $v; 1242 } 1170 1243 ?>
Note: See TracChangeset
for help on using the changeset viewer.