spacecp.inc.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: spacecp.inc.php 34575 2014-06-04 02:12:08Z nemohou $
  7. */
  8. if (!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. define('QRCODE_EXPIRE', 1800);
  12. $inspacecp = true;
  13. if(submitcheck('resetpwsubmit') && $_G['wechatuser']['isregister']) {
  14. if($_G['setting']['strongpw']) {
  15. $strongpw_str = array();
  16. if(in_array(1, $_G['setting']['strongpw']) && !preg_match("/\d+/", $_GET['newpassword1'])) {
  17. $strongpw_str[] = lang('member/template', 'strongpw_1');
  18. }
  19. if(in_array(2, $_G['setting']['strongpw']) && !preg_match("/[a-z]+/", $_GET['newpassword1'])) {
  20. $strongpw_str[] = lang('member/template', 'strongpw_2');
  21. }
  22. if(in_array(3, $_G['setting']['strongpw']) && !preg_match("/[A-Z]+/", $_GET['newpassword1'])) {
  23. $strongpw_str[] = lang('member/template', 'strongpw_3');
  24. }
  25. if(in_array(4, $_G['setting']['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['newpassword1'])) {
  26. $strongpw_str[] = lang('member/template', 'strongpw_4');
  27. }
  28. if($strongpw_str) {
  29. showmessage(lang('member/template', 'password_weak').implode(',', $strongpw_str));
  30. }
  31. }
  32. if($_GET['newpassword1'] !== $_GET['newpassword2']) {
  33. showmessage('profile_passwd_notmatch');
  34. }
  35. if(!$_GET['newpassword1'] || $_GET['newpassword1'] != addslashes($_GET['newpassword1'])) {
  36. showmessage('profile_passwd_illegal');
  37. }
  38. loaducenter();
  39. uc_user_edit(addslashes($_G['member']['username']), null, $_GET['newpassword1'], null, 1);
  40. C::t('common_member')->update($_G['uid'], array('password' => md5(random(10))));
  41. if($_G['wechat']['setting']['wechat_qrtype']) {
  42. C::t('#wechat#common_member_wechatmp')->update($_G['uid'], array('status' => 1));
  43. } else {
  44. C::t('#wechat#common_member_wechat')->update($_G['uid'], array('isregister' => 0));
  45. }
  46. showmessage('wechat:wsq_password_reset', dreferer());
  47. } elseif(submitcheck('unbindsubmit')) {
  48. require_once libfile('function/member');
  49. if($_G['wechat']['setting']['wechat_qrtype']) {
  50. require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
  51. $member = C::t('#wechat#common_member_wechatmp')->fetch($_G['uid']);
  52. if(!$member || !wsq::userunbind($_G['uid'], $member['openid'])) {
  53. showmessage('wechat:wechat_message_unbind_fail');
  54. }
  55. C::t('#wechat#common_member_wechatmp')->delete($_G['uid']);
  56. } else {
  57. C::t('#wechat#common_member_wechat')->delete($_G['uid']);
  58. require_once DISCUZ_ROOT.'./source/plugin/wechat/wsq.class.php';
  59. wsq::report('unbind');
  60. }
  61. clearcookies();
  62. showmessage('wechat:wechat_message_unbinded', $_G['siteurl']);
  63. }