connect_user.php
1.7 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: connect_user.php 29265 2012-03-31 06:03:26Z yexinhao $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
include template('common/header');
$op = !empty($_GET['op']) ? trim($_GET['op'], '/') : '';
if(!in_array($op, array('get'))) {
connect_error_output('undefined_action');
}
if($_GET['hash'] != formhash()) {
connect_error_output('submit_invalid');
}
if($op == 'get') {
$conopenid = authcode($_G['cookie']['con_auth_hash']);
$connect_guest = C::t('#qqconnect#common_connect_guest')->fetch($conopenid);
if(!$connect_guest) {
dsetcookie('con_auth_hash');
connect_error_output('qqconnect:connect_login_first');
}
$conuin = $connect_guest['conuin'];
$conuinsecret = $connect_guest['conuinsecret'];
if($conuin && $conuinsecret && $conopenid) {
try {
$connectOAuthClient = Cloud::loadClass('Service_Client_ConnectOAuth');
$connect_user_info = $connectOAuthClient->connectGetUserInfo($conopenid, $conuin, $conuinsecret);
} catch(Exception $e) {
connect_error_output();
}
if ($connect_user_info['nickname']) {
$qq_nick = $connect_user_info['nickname'];
$connect_nickname = $connectService->connectFilterUsername($qq_nick);
}
loaducenter();
$ucresult = uc_user_checkname($connect_nickname);
$first_available_username = '';
if($ucresult >= 0) {
$first_available_username = $connect_nickname;
}
echo $first_available_username;
}
}
include template('common/footer');
function connect_error_output($error = '') {
include template('common/footer');
exit;
}