DiscuzX /source/plugin/qqconnect/connect/connect_config.php

Language PHP Lines 156
MD5 Hash 3f730ee75fb1ee32b5d3cd2345f9c4d1
Repository https://github.com/jinbo51/DiscuzX.git View Raw File
  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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: connect_config.php 32901 2013-03-21 08:54:21Z liulanbo $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

if(empty($_G['uid'])) {
	showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
}

$op = !empty($_GET['op']) ? $_GET['op'] : '';
$referer = dreferer();

if(submitcheck('connectsubmit')) {

	if($op == 'config') { // debug 修改QQ绑定设置

		$ispublisht = !empty($_GET['ispublisht']) ? 1 : 0;
		C::t('#qqconnect#common_member_connect')->update($_G['uid'],
			array(
				'conispublisht' => $ispublisht,
			)
		);
		if (!$ispublisht) {
			dsetcookie('connect_synpost_tip');
		}
		showmessage('qqconnect:connect_config_success', $referer);

	} elseif($op == 'unbind') {

		$connect_member = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
		$_G['member'] = array_merge($_G['member'], $connect_member);

		if ($connect_member['conuinsecret']) {

			if($_G['member']['conisregister']) {
				if($_G['setting']['strongpw']) {
					$strongpw_str = array();
					if(in_array(1, $_G['setting']['strongpw']) && !preg_match("/\d+/", $_GET['newpassword1'])) {
						$strongpw_str[] = lang('member/template', 'strongpw_1');
					}
					if(in_array(2, $_G['setting']['strongpw']) && !preg_match("/[a-z]+/", $_GET['newpassword1'])) {
						$strongpw_str[] = lang('member/template', 'strongpw_2');
					}
					if(in_array(3, $_G['setting']['strongpw']) && !preg_match("/[A-Z]+/", $_GET['newpassword1'])) {
						$strongpw_str[] = lang('member/template', 'strongpw_3');
					}
					if(in_array(4, $_G['setting']['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['newpassword1'])) {
						$strongpw_str[] = lang('member/template', 'strongpw_4');
					}
					if($strongpw_str) {
						showmessage(lang('member/template', 'password_weak').implode(',', $strongpw_str));
					}
				}
				if($_GET['newpassword1'] !== $_GET['newpassword2']) {
					showmessage('profile_passwd_notmatch', $referer);
				}
				if(!$_GET['newpassword1'] || $_GET['newpassword1'] != addslashes($_GET['newpassword1'])) {
					showmessage('profile_passwd_illegal', $referer);
				}
			}

			$connectService->connectUserUnbind();

		} else { // debug 因为老用户access token等信息,所以没法通知connect,所以直接在本地解绑就行了,不fopen connect

			if($_G['member']['conisregister']) {
				if($_GET['newpassword1'] !== $_GET['newpassword2']) {
					showmessage('profile_passwd_notmatch', $referer);
				}
				if(!$_GET['newpassword1'] || $_GET['newpassword1'] != addslashes($_GET['newpassword1'])) {
					showmessage('profile_passwd_illegal', $referer);
				}
			}
		}

		C::t('#qqconnect#common_member_connect')->delete($_G['uid']);

		C::t('common_member')->update($_G['uid'], array('conisbind' => 0));
		C::t('#qqconnect#connect_memberbindlog')->insert(
			array(
				'uid' => $_G['uid'],
				'uin' => $_G['member']['conopenid'],
				'type' => 2,
				'dateline' => $_G['timestamp'],
			)
		);

		if($_G['member']['conisregister']) {
			loaducenter();
			uc_user_edit(addslashes($_G['member']['username']), null, $_GET['newpassword1'], null, 1);
		}

		foreach($_G['cookie'] as $k => $v) {
			dsetcookie($k);
		}

		$_G['uid'] = $_G['adminid'] = 0;
		$_G['username'] = $_G['member']['password'] = '';

		showmessage('qqconnect:connect_config_unbind_success', 'member.php?mod=logging&action=login');
	}

} else {

	if($_G[inajax] && $op == 'synconfig') {
		C::t('#qqconnect#common_member_connect')->update($_G['uid'],
			array(
				'conispublisht' => 0,
			)
		);
		dsetcookie('connect_synpost_tip');

	} elseif($op == 'weibosign') {
		if($_GET['hash'] != formhash()) {
			showmessage('submit_invalid');
		}

		$connectService = Cloud::loadClass('Service_Connect');
		$connectService->connectMergeMember();

		if($_G['member']['conuin'] && $_G['member']['conuinsecret']) {

			$arr = array();
			$arr['oauth_consumer_key'] = $_G['setting']['connectappid'];
			$arr['oauth_nonce'] = mt_rand();
			$arr['oauth_timestamp'] = TIMESTAMP;
			$arr['oauth_signature_method'] = 'HMAC_SHA1';
			$arr['oauth_token'] = $_G['member']['conuin'];
			ksort($arr);
			$arr['oauth_signature'] = $connectService->connectGetOauthSignature('http://api.discuz.qq.com/connect/getSignature', $arr, 'GET', $_G['member']['conuinsecret']);

			$arr['version'] = 'qzone1.0';

			$utilService = Cloud::loadClass('Service_Util');
			$result = $connectService->connectOutputPhp('http://api.discuz.qq.com/connect/getSignature?' . $utilService->httpBuildQuery($arr, '', '&'));
			if ($result['status'] == 0) {
				$connectService->connectAjaxOuputMessage('[wb=' . $result['result']['username'] . ']' . $result['result']['signature_url'] . '[/wb]', 0);
			} else {
				$connectService->connectAjaxOuputMessage('connect_wbsign_no_account', $result['status']);
			}
		} else {
			$connectService->connectAjaxOuputMessage('connect_wbsign_no_bind', -1);
		}

	} else {
		dheader('location: home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp');
	}
}
Back to Top