forget.ctrl.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('utility');
  8. $openid = $_W['openid'];
  9. $dos = array('reset', 'forget');
  10. $do = in_array($do, $dos) ? $do : 'forget';
  11. $setting = uni_setting($_W['uniacid'], array('uc', 'passport'));
  12. $uc_setting = $setting['uc'] ? $setting['uc'] : array();
  13. $register_mode = is_array($setting['passport']) && !empty($setting['passport']['item']) ? $setting['passport']['item'] : 'random';
  14. $forward = url('mc');
  15. if(!empty($_GPC['forward'])) {
  16. $forward = './index.php?' . base64_decode($_GPC['forward']) . '#wechat_redirect';
  17. }
  18. if(!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) {
  19. header('location: ' . $forward);
  20. exit;
  21. }
  22. if($do == 'reset') {
  23. if($_W['ispost'] && $_W['isajax']) {
  24. $code = safe_gpc_string($_GPC['code']);
  25. $username = safe_gpc_string($_GPC['username']);
  26. $member_table = table('mc_members');
  27. switch ($register_mode) {
  28. case 'mobile':
  29. $member_table->searchWithMobile($username);
  30. break;
  31. case 'email':
  32. $member_table->searchWithEmail($username);
  33. break;
  34. default:
  35. $member_table->searchWithMobileOrEmail($username);
  36. break;
  37. }
  38. $member_table->searchWithUniacid($_W['uniacid']);
  39. $member_info = $member_table->get();
  40. if (empty($member_info)) {
  41. message('用户不存在', referer(), 'error');
  42. }
  43. if(!code_verify($_W['uniacid'], $username, $code)) {
  44. message('验证码错误', referer(), 'error');
  45. }
  46. $password = safe_gpc_string($_GPC['password']);
  47. $repassword = safe_gpc_string($_GPC['repassword']);
  48. if ($repassword != $password) {
  49. message('密码输入不一致', referer(), 'error');
  50. }
  51. $password = md5($password . $member_info['salt'] . $_W['config']['setting']['authkey']);
  52. mc_update($member_info['uid'], array('password' => $password));
  53. pdo_delete('uni_verifycode', array('receiver' => $username));
  54. message('找回成功', referer(), 'success');
  55. }
  56. }
  57. template('auth/forget');