PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/source/module/member/member_lostpasswd.php

https://github.com/kuaileshike/upload
PHP | 73 lines | 59 code | 8 blank | 6 comment | 15 complexity | 8bbe02b016638d6e355dbd28dedad6d0 MD5 | raw file
  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_lostpasswd.php 31164 2012-07-20 07:50:57Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. define('NOROBOT', TRUE);
  12. $discuz_action = 141;
  13. if(submitcheck('lostpwsubmit')) {
  14. loaducenter();
  15. $_GET['email'] = strtolower(trim($_GET['email']));
  16. if($_GET['username']) {
  17. list($tmp['uid'], , $tmp['email']) = uc_get_user(addslashes($_GET['username']));
  18. $tmp['email'] = strtolower(trim($tmp['email']));
  19. if($_GET['email'] != $tmp['email']) {
  20. showmessage('getpasswd_account_notmatch');
  21. }
  22. $member = getuserbyuid($tmp['uid'], 1);
  23. } else {
  24. $emailcount = C::t('common_member')->count_by_email($_GET['email'], 1);
  25. if(!$emailcount) {
  26. showmessage('lostpasswd_email_not_exist');
  27. }
  28. if($emailcount > 1) {
  29. showmessage('lostpasswd_many_users_use_email');
  30. }
  31. $member = C::t('common_member')->fetch_by_email($_GET['email'], 1);
  32. list($tmp['uid'], , $tmp['email']) = uc_get_user(addslashes($member['username']));
  33. $tmp['email'] = strtolower(trim($tmp['email']));
  34. }
  35. if(!$member) {
  36. showmessage('getpasswd_account_notmatch');
  37. } elseif($member['adminid'] == 1 || $member['adminid'] == 2) {
  38. showmessage('getpasswd_account_invalid');
  39. }
  40. $table_ext = $member['_inarchive'] ? '_archive' : '';
  41. if($member['email'] != $tmp['email']) {
  42. C::t('common_member'.$table_ext)->update($tmp['uid'], array('email' => $tmp['email']));
  43. }
  44. $idstring = random(6);
  45. C::t('common_member_field_forum'.$table_ext)->update($member['uid'], array('authstr' => "$_G[timestamp]\t1\t$idstring"));
  46. require_once libfile('function/mail');
  47. $get_passwd_subject = lang('email', 'get_passwd_subject');
  48. $get_passwd_message = lang(
  49. 'email',
  50. 'get_passwd_message',
  51. array(
  52. 'username' => $member['username'],
  53. 'bbname' => $_G['setting']['bbname'],
  54. 'siteurl' => $_G['siteurl'],
  55. 'uid' => $member['uid'],
  56. 'idstring' => $idstring,
  57. 'clientip' => $_G['clientip'],
  58. )
  59. );
  60. if(!sendmail("$_GET[username] <$tmp[email]>", $get_passwd_subject, $get_passwd_message)) {
  61. runlog('sendmail', "$tmp[email] sendmail failed.");
  62. }
  63. showmessage('getpasswd_send_succeed', $_G['siteurl'], array(), array('showdialog' => 1, 'locationtime' => true));
  64. }
  65. ?>