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