member_getpasswd.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: member_getpasswd.php 35030 2014-10-23 07:43:23Z laoguozhang $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. define('NOROBOT', TRUE);
  12. if($_GET['uid'] && $_GET['id'] && $_GET['sign'] === make_getpws_sign($_GET['uid'], $_GET['id'])) {
  13. $discuz_action = 141;
  14. $member = getuserbyuid($_GET['uid'], 1);
  15. $table_ext = isset($member['_inarchive']) ? '_archive' : '';
  16. $member = array_merge(C::t('common_member_field_forum'.$table_ext)->fetch($_GET['uid']), $member);
  17. list($dateline, $operation, $idstring) = explode("\t", $member['authstr']);
  18. if($dateline < TIMESTAMP - 86400 * 3 || $operation != 1 || $idstring != $_GET['id']) {
  19. showmessage('getpasswd_illegal', NULL);
  20. }
  21. if(!submitcheck('getpwsubmit') || $_GET['newpasswd1'] != $_GET['newpasswd2']) {
  22. $hashid = $_GET['id'];
  23. $uid = $_GET['uid'];
  24. include template('member/getpasswd');
  25. } else {
  26. if($_GET['newpasswd1'] != addslashes($_GET['newpasswd1'])) {
  27. showmessage('profile_passwd_illegal');
  28. }
  29. if($_G['setting']['pwlength']) {
  30. if(strlen($_GET['newpasswd1']) < $_G['setting']['pwlength']) {
  31. showmessage('profile_password_tooshort', '', array('pwlength' => $_G['setting']['pwlength']));
  32. }
  33. }
  34. if($_G['setting']['strongpw']) {
  35. $strongpw_str = array();
  36. if(in_array(1, $_G['setting']['strongpw']) && !preg_match("/\d+/", $_GET['newpasswd1'])) {
  37. $strongpw_str[] = lang('member/template', 'strongpw_1');
  38. }
  39. if(in_array(2, $_G['setting']['strongpw']) && !preg_match("/[a-z]+/", $_GET['newpasswd1'])) {
  40. $strongpw_str[] = lang('member/template', 'strongpw_2');
  41. }
  42. if(in_array(3, $_G['setting']['strongpw']) && !preg_match("/[A-Z]+/", $_GET['newpasswd1'])) {
  43. $strongpw_str[] = lang('member/template', 'strongpw_3');
  44. }
  45. if(in_array(4, $_G['setting']['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['newpasswd1'])) {
  46. $strongpw_str[] = lang('member/template', 'strongpw_4');
  47. }
  48. if($strongpw_str) {
  49. showmessage(lang('member/template', 'password_weak').implode(',', $strongpw_str));
  50. }
  51. }
  52. loaducenter();
  53. uc_user_edit(addslashes($member['username']), $_GET['newpasswd1'], $_GET['newpasswd1'], addslashes($member['email']), 1, 0);
  54. $password = md5(random(10));
  55. if(isset($member['_inarchive'])) {
  56. C::t('common_member_archive')->move_to_master($member['uid']);
  57. }
  58. C::t('common_member')->update($_GET['uid'], array('password' => $password));
  59. C::t('common_member_field_forum')->update($_GET['uid'], array('authstr' => ''));
  60. showmessage('getpasswd_succeed', 'index.php', array(), array('login' => 1));
  61. }
  62. } else {
  63. showmessage('parameters_error');
  64. }
  65. ?>