forgetpass.inc.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. require_once MYMPS_ROOT . '/include/sms.fun.php';
  3. if ($action == 'sendmail') {
  4. $email = isset($email) ? mhtmlspecialchars($email) : '';
  5. if ($authcodesettings['forgetpass'] == 1 && !($randcode = mymps_chk_randcode($checkcode))) {
  6. write_msg('验证码输入错误,请返回重新输入');
  7. }
  8. empty($email) && write_msg('请填写电子邮箱地址!');
  9. $user_info = $db->getRow('SELECT * FROM `' . $db_mymps . 'member` WHERE email = \'' . $email . '\'');
  10. if ($user_info['userid']) {
  11. require MYMPS_INC . '/email.fun.php';
  12. $code = base64_encode($user_info['id'] . '.' . md5($user_info['id'] . '+' . $user_info['userpwd']) . '.' . $timestamp);
  13. globalassign();
  14. if (send_pwd_email($user_info['id'], $user_info['userid'], $email, $code)) {
  15. include mymps_tpl($mod . '_2');
  16. }
  17. else {
  18. $status = 'error2';
  19. $msg = '发送邮件失败,请联系客服:' . $mymps_global['SiteTel'] . '重设密码!';
  20. include mymps_tpl($mod . '_4');
  21. }
  22. }
  23. else {
  24. $status = 'error2';
  25. $msg = '该电子邮箱或用户名不存在!请联系客服:' . $mymps_global['SiteTel'] . '!';
  26. globalassign();
  27. include mymps_tpl($mod . '_4');
  28. }
  29. }
  30. else if ($action == 'sendsms') {
  31. $mobile = isset($mobile) ? mhtmlspecialchars($mobile) : '';
  32. if ($authcodesettings['forgetpass'] == 1 && !($randcode = mymps_chk_randcode($checkcode))) {
  33. write_msg('验证码输入错误,请返回重新输入');
  34. }
  35. empty($mobile) && write_msg('请填写您的手机号码!');
  36. $user_info = $db->getRow('SELECT * FROM `' . $db_mymps . 'member` WHERE mobile = \'' . $mobile . '\'');
  37. if ($user_info['userid']) {
  38. $smsconfig = get_sms_config();
  39. $smsconfig['sms_service'] && include MYMPS_ROOT . '/include/' . $smsconfig['sms_service'] . '/mymps.php';
  40. if (!send_pwdsms($smsconfig['sms_user'], $smsconfig['sms_pwd'], $mobile, $smsconfig['sms_pwdtpl'])) {
  41. $status = 'error2';
  42. $msg = '验证码发送失败!请联系客服:' . $mymps_global['SiteTel'] . '!';
  43. globalassign();
  44. include mymps_tpl($mod . '_4');
  45. }
  46. else {
  47. $uid = $user_info['id'];
  48. $userid = $user_info['userid'];
  49. include mymps_tpl($mod . '_2');
  50. }
  51. }
  52. else {
  53. $status = 'error2';
  54. $msg = '该手机号尚未注册用户!请联系客服:' . $mymps_global['SiteTel'] . '!';
  55. globalassign();
  56. include mymps_tpl($mod . '_4');
  57. }
  58. }
  59. else if ($action == 'resetpage') {
  60. globalassign();
  61. include mymps_tpl($mod . '_3');
  62. }
  63. else if ($action == 'resetpwd') {
  64. $uid = $uid ? intval($uid) : '';
  65. $userid = $userid ? mhtmlspecialchars($userid) : '';
  66. $userpwd = $userpwd ? mhtmlspecialchars($userpwd) : '';
  67. $email = $email ? mhtmlspecialchars($email) : '';
  68. $mobile = $mobile ? mhtmlspecialchars($mobile) : '';
  69. $smscheckcode = $smscheckcode ? intval($smscheckcode) : '';
  70. if ($mymps_global['cfg_member_verify'] == 4) {
  71. if (!mymps_chk_smsrandcode($smscheckcode, $mobile)) {
  72. write_msg('密码修改失败,手机验证码输入不正确或与手机号不匹配!', '?mod=forgetpass');
  73. }
  74. }
  75. if (empty($userpwd)) {
  76. write_msg('请输入你的新密码!');
  77. }
  78. if (PASSPORT_TYPE == 'phpwind') {
  79. require MYMPS_ROOT . '/pw_client/uc_client.php';
  80. $pw_user = uc_user_get($userid);
  81. $result = uc_user_edit($pw_user['uid'], $pw_user['username'], '', md5($userpwd), '');
  82. }
  83. else if (PASSPORT_TYPE == 'ucenter') {
  84. require MYMPS_ROOT . '/uc_client/client.php';
  85. $result = uc_user_edit($userid, $userpwd, $userpwd, $email, 1);
  86. }
  87. if (!empty($userpwd)) {
  88. $db->query('UPDATE `' . $db_mymps . 'member` SET userpwd=\'' . md5($userpwd) . ('\' WHERE id = \'' . $uid . '\''));
  89. $status = 'success';
  90. }
  91. else {
  92. $status = 'error';
  93. $msg = '未定义错误,密码修改失败!';
  94. }
  95. globalassign();
  96. include mymps_tpl($mod . '_4');
  97. }
  98. ?>