PageRenderTime 55ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/kuaileshike/upload
PHP | 159 lines | 124 code | 29 blank | 6 comment | 45 complexity | 055c75d7ada00bbe149dd59f50d93c47 MD5 | raw file
  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: connect_config.php 29265 2012-03-31 06:03:26Z yexinhao $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(empty($_G['uid'])) {
  12. showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
  13. }
  14. $op = !empty($_GET['op']) ? $_GET['op'] : '';
  15. $referer = dreferer();
  16. if(submitcheck('connectsubmit')) {
  17. if($op == 'config') { // debug 修改QQ绑定设置
  18. $ispublishfeed = !empty($_GET['ispublishfeed']) ? 1 : 0;
  19. $ispublisht = !empty($_GET['ispublisht']) ? 1 : 0;
  20. C::t('#qqconnect#common_member_connect')->update($_G['uid'],
  21. array(
  22. 'conispublishfeed' => $ispublishfeed,
  23. 'conispublisht' => $ispublisht,
  24. )
  25. );
  26. if (!$ispublishfeed || !$ispublisht) {
  27. dsetcookie('connect_synpost_tip');
  28. }
  29. showmessage('qqconnect:connect_config_success', $referer);
  30. } elseif($op == 'unbind') {
  31. $connect_member = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
  32. $_G['member'] = array_merge($_G['member'], $connect_member);
  33. if ($connect_member['conuinsecret']) {
  34. if($_G['member']['conisregister']) {
  35. if($_G['setting']['strongpw']) {
  36. $strongpw_str = array();
  37. if(in_array(1, $_G['setting']['strongpw']) && !preg_match("/\d+/", $_GET['newpassword1'])) {
  38. $strongpw_str[] = lang('member/template', 'strongpw_1');
  39. }
  40. if(in_array(2, $_G['setting']['strongpw']) && !preg_match("/[a-z]+/", $_GET['newpassword1'])) {
  41. $strongpw_str[] = lang('member/template', 'strongpw_2');
  42. }
  43. if(in_array(3, $_G['setting']['strongpw']) && !preg_match("/[A-Z]+/", $_GET['newpassword1'])) {
  44. $strongpw_str[] = lang('member/template', 'strongpw_3');
  45. }
  46. if(in_array(4, $_G['setting']['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['newpassword1'])) {
  47. $strongpw_str[] = lang('member/template', 'strongpw_4');
  48. }
  49. if($strongpw_str) {
  50. showmessage(lang('member/template', 'password_weak').implode(',', $strongpw_str));
  51. }
  52. }
  53. if($_GET['newpassword1'] !== $_GET['newpassword2']) {
  54. showmessage('profile_passwd_notmatch', $referer);
  55. }
  56. if(!$_GET['newpassword1'] || $_GET['newpassword1'] != addslashes($_GET['newpassword1'])) {
  57. showmessage('profile_passwd_illegal', $referer);
  58. }
  59. }
  60. $connectService->connectUserUnbind();
  61. } else { // debug 因为老用户access token等信息,所以没法通知connect,所以直接在本地解绑就行了,不fopen connect
  62. if($_G['member']['conisregister']) {
  63. if($_GET['newpassword1'] !== $_GET['newpassword2']) {
  64. showmessage('profile_passwd_notmatch', $referer);
  65. }
  66. if(!$_GET['newpassword1'] || $_GET['newpassword1'] != addslashes($_GET['newpassword1'])) {
  67. showmessage('profile_passwd_illegal', $referer);
  68. }
  69. }
  70. }
  71. C::t('#qqconnect#common_member_connect')->delete($_G['uid']);
  72. C::t('common_member')->update($_G['uid'], array('conisbind' => 0));
  73. C::t('#qqconnect#connect_memberbindlog')->insert(
  74. array(
  75. 'uid' => $_G['uid'],
  76. 'uin' => $_G['member']['conopenid'],
  77. 'type' => 2,
  78. 'dateline' => $_G['timestamp'],
  79. )
  80. );
  81. if($_G['member']['conisregister']) {
  82. loaducenter();
  83. uc_user_edit(addslashes($_G['member']['username']), null, $_GET['newpassword1'], null, 1);
  84. }
  85. foreach($_G['cookie'] as $k => $v) {
  86. dsetcookie($k);
  87. }
  88. $_G['uid'] = $_G['adminid'] = 0;
  89. $_G['username'] = $_G['member']['password'] = '';
  90. showmessage('qqconnect:connect_config_unbind_success', 'member.php?mod=logging&action=login');
  91. }
  92. } else {
  93. if($_G[inajax] && $op == 'synconfig') {
  94. C::t('#qqconnect#common_member_connect')->update($_G['uid'],
  95. array(
  96. 'conispublishfeed' => 0,
  97. 'conispublisht' => 0,
  98. )
  99. );
  100. dsetcookie('connect_synpost_tip');
  101. } elseif($op == 'weibosign') {
  102. if($_GET['hash'] != formhash()) {
  103. showmessage('submit_invalid');
  104. }
  105. $connectService = Cloud::loadClass('Service_Connect');
  106. $connectService->connectMergeMember();
  107. if($_G['member']['conuin'] && $_G['member']['conuinsecret']) {
  108. $arr = array();
  109. $arr['oauth_consumer_key'] = $_G['setting']['connectappid'];
  110. $arr['oauth_nonce'] = mt_rand();
  111. $arr['oauth_timestamp'] = TIMESTAMP;
  112. $arr['oauth_signature_method'] = 'HMAC_SHA1';
  113. $arr['oauth_token'] = $_G['member']['conuin'];
  114. ksort($arr);
  115. $arr['oauth_signature'] = $connectService->connectGetOauthSignature('http://api.discuz.qq.com/connect/getSignature', $arr, 'GET', $_G['member']['conuinsecret']);
  116. $arr['version'] = 'qzone1.0';
  117. $utilService = Cloud::loadClass('Service_Util');
  118. $result = $connectService->connectOutputPhp('http://api.discuz.qq.com/connect/getSignature?' . $utilService->httpBuildQuery($arr, '', '&'));
  119. if ($result['status'] == 0) {
  120. $connectService->connectAjaxOuputMessage('[wb=' . $result['result']['username'] . ']' . $result['result']['signature_url'] . '[/wb]', 0);
  121. } else {
  122. $connectService->connectAjaxOuputMessage('connect_wbsign_no_account', $result['status']);
  123. }
  124. } else {
  125. $connectService->connectAjaxOuputMessage('connect_wbsign_no_bind', -1);
  126. }
  127. } else {
  128. dheader('location: home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp');
  129. }
  130. }