人人商城

find-password.ctrl.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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('user');
  8. load()->model('setting');
  9. load()->model('utility');
  10. $dos = array('find_password', 'valid_mobile', 'valid_code', 'set_password', 'success');
  11. $do = in_array($do, $dos) ? $do : 'find_password';
  12. $setting_sms_sign = setting_load('site_sms_sign');
  13. $find_password_sign = !empty($setting_sms_sign['site_sms_sign']['find_password']) ? $setting_sms_sign['site_sms_sign']['find_password'] : '';
  14. $mobile = safe_gpc_string($_GPC['receiver']);
  15. if (in_array($do, array('valid_code', 'set_password'))) {
  16. $check_res = user_check_mobile($mobile);
  17. if (is_error($check_res)) {
  18. iajax($check_res['errno'], $check_res['message']);
  19. }
  20. }
  21. if ($do == 'valid_mobile') {
  22. $check_res = user_check_mobile($mobile);
  23. iajax($check_res['errno'], $check_res['message']);
  24. }
  25. if ($do == 'valid_code') {
  26. if ($_W['isajax'] && $_W['ispost']) {
  27. $code = trim($_GPC['code']);
  28. if (empty($code)) {
  29. iajax(-1, '短信验证码不能为空');
  30. }
  31. $verify_res = utility_smscode_verify(0, $mobile, $code);
  32. if (is_error($verify_res)) {
  33. iajax($verify_res['errno'], $verify_res['message']);
  34. }
  35. iajax(0, '');
  36. } else {
  37. iajax(-1, '非法请求');
  38. }
  39. }
  40. if ($do == 'set_password') {
  41. if ($_W['isajax'] && $_W['ispost']) {
  42. $password = $_GPC['password'];
  43. $repassword = $_GPC['repassword'];
  44. if (empty($password) || empty($repassword)) {
  45. iajax(-1, '密码不能为空');
  46. }
  47. if ($password != $repassword) {
  48. iajax(-1, '两次密码不一致');
  49. }
  50. $user_info = user_single($find_mobile['uid']);
  51. $password = user_hash($password, $user_info['salt']);
  52. if ($password == $user_info['password']) {
  53. iajax(-2, '不能使用最近使用的密码');
  54. }
  55. $result = pdo_update('users', array('password' => $password), array('uid' => $user_info['uid']));
  56. if (empty($result)) {
  57. iajax(0, '设置密码成功');
  58. }
  59. iajax(0);
  60. }
  61. }
  62. template('user/find-password');