bind.inc.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: bind.inc.php 34850 2014-08-14 07:03:18Z nemohou $
  7. */
  8. if (!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if($_GET['unbind'] && $_GET['unbind'] == FORMHASH) {
  12. require_once libfile('function/member');
  13. C::t('#mobile#common_member_wechat')->delete($_G['uid']);
  14. clearcookies();
  15. showmessage('wechat:wechat_message_unbinded', dreferer());
  16. }
  17. if($_G['uid'] && submitcheck('confirmsubmit')) {
  18. loaducenter();
  19. list($result) = uc_user_login($_G['uid'], $_GET['passwordconfirm'], 1, 0);
  20. if($result >= 0) {
  21. dsetcookie('qrauth', base64_encode(authcode($result, 'ENCODE', $_G['config']['security']['authkey'], 300)));
  22. showmessage('', dreferer());
  23. }
  24. showmessage('login_password_invalid');
  25. }
  26. if(isset($_GET['check'])) {
  27. $code = authcode(base64_decode($_GET['check']), 'DECODE', $_G['config']['security']['authkey']);
  28. if($code) {
  29. $authcode = C::t('#wechat#mobile_wechat_authcode')->fetch_by_code($code);
  30. if($authcode['status']) {
  31. require_once libfile('function/member');
  32. $member = getuserbyuid($authcode['uid'], 1);
  33. setloginstatus($member, 1296000);
  34. dsetcookie('wechat_ticket', '', -1);
  35. $echostr = 'done';
  36. } else {
  37. $echostr = '1';//json_encode($authcode);
  38. }
  39. } else {
  40. $echostr = '-1';
  41. }
  42. if(!ob_start($_G['gzipcompress'] ? 'ob_gzhandler' : null)) {
  43. ob_start();
  44. }
  45. if($echostr === 'done'){
  46. C::t('#wechat#mobile_wechat_authcode')->delete($authcode['sid']);
  47. }
  48. include template('common/header_ajax');
  49. echo $echostr;
  50. include template('common/footer_ajax');
  51. exit;
  52. }
  53. if($_G['cookie']['qrauth']) {
  54. $qrauth = authcode(base64_decode($_G['cookie']['qrauth']), 'DECODE', $_G['config']['security']['authkey']);
  55. }
  56. if(!$_G['wechat']['setting']['wechat_qrtype']) {
  57. require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.lib.class.php';
  58. require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
  59. list($isqrapi, $qrcodeurl, $codeenc, $code) = WeChat::getqrcode();
  60. wsq::report('siteqrshow');
  61. }
  62. if($_G['uid'] && !$qrauth && in_array('qqconnect', $_G['setting']['plugins']['available'])) {
  63. $connect = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
  64. if($connect['conisregister']) {
  65. if(!$_G['wechat']['setting']['wechat_qrtype']) {
  66. $qrauth = true;
  67. } else {
  68. showmessage('', 'plugin.php?id=wechat:login', array(), array('redirectmsg' => 1, 'location' => 1));
  69. }
  70. }
  71. }
  72. include_once template('wechat:wechat_qrcode');