member_connect_register.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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: member_connect_register.php 33538 2013-07-02 05:01:37Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $from_connect = $_G['setting']['connect']['allow'] ? 1 : 0;
  12. $regname = 'connect';
  13. if(empty($_POST)) {
  14. $_G['qc']['connect_auth_hash'] = $_GET['con_auth_hash'];
  15. $_G['qc']['dreferer'] = dreferer();
  16. if(!$_G['qc']['connect_auth_hash']) {
  17. $_G['qc']['connect_auth_hash'] = $_G['cookie']['con_auth_hash'];
  18. }
  19. $conopenid = authcode($_G['qc']['connect_auth_hash']);
  20. if (empty($conopenid)) {
  21. showmessage('qqconnect:connect_login_first', $referer);
  22. }
  23. $_G['qc']['connect_is_feed'] = true;
  24. $_G['qc']['connect_app_id'] = $_G['setting']['connectappid'];
  25. $_G['qc']['connect_openid'] = $conopenid;
  26. unset($auth_code, $conopenid);
  27. $_G['qc']['connect_is_notify'] = true;
  28. foreach($_G['cache']['fields_register'] as $field) {
  29. $fieldid = $field['fieldid'];
  30. $html = profile_setting($fieldid, $connectdefault);
  31. if($html) {
  32. $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
  33. $htmls[$fieldid] = $html;
  34. }
  35. }
  36. } else {
  37. if(!empty($_G['setting']['checkuinlimit']) && !empty($_GET['uin'])) {
  38. if($_G['qc']['uinlimit']) {
  39. showmessage('qqconnect:connect_register_uinlimit', '', array('limit' => $this->setting['connect']['register_uinlimit']));
  40. }
  41. if(!$_G['setting']['regconnect']) {
  42. showmessage('qqconnect:connect_register_closed');
  43. }
  44. }
  45. $conuin = $this->connect_guest['conuin'];
  46. $conuinsecret = $this->connect_guest['conuinsecret'];
  47. $conuintoken = $this->connect_guest['conuintoken'];
  48. $conopenid = $this->connect_guest['conopenid'];
  49. $cookie_expires = 2592000;
  50. dsetcookie('client_created', TIMESTAMP, $cookie_expires);
  51. dsetcookie('client_token', 1, $cookie_expires);
  52. if(!$_G['setting']['connect']['oauth2']) {
  53. if (!$conuin || !$conuinsecret || !$conopenid) {
  54. showmessage('qqconnect:connect_get_request_token_failed');
  55. }
  56. } else {
  57. if (!$conuintoken || !$conopenid) {
  58. showmessage('qqconnect:connect_get_request_token_failed');
  59. }
  60. }
  61. if(C::t('#qqconnect#common_member_connect')->fetch_fields_by_openid($conopenid, 'uid')) {
  62. showmessage('qqconnect:connect_register_bind_uin_already');
  63. }
  64. $conispublishfeed = 0;
  65. $conispublisht = 0;
  66. $is_qzone_avatar = !empty($_GET['use_qzone_avatar']) ? 1 : 0;
  67. $is_use_qqshow = !empty($_GET['use_qqshow']) ? 1 : 0;
  68. if(!empty($_GET['use_qzone_avatar_qqshow'])) {
  69. $is_qzone_avatar = $is_use_qqshow = 1;
  70. }
  71. $userdata = array();
  72. $userdata['avatarstatus'] = $is_qzone_avatar;
  73. $userdata['conisbind'] = 1;
  74. C::t('#qqconnect#common_member_connect')->insert(array(
  75. 'uid' => $uid,
  76. 'conuin' => $conuin,
  77. 'conuinsecret' => $conuinsecret,
  78. 'conuintoken' => $conuintoken,
  79. 'conopenid' => $conopenid,
  80. 'conispublishfeed' => $conispublishfeed,
  81. 'conispublisht' => $conispublisht,
  82. 'conisregister' => '1',
  83. 'conisqzoneavatar' => $is_qzone_avatar,
  84. 'conisfeed' => '1',
  85. 'conisqqshow' => $is_use_qqshow,
  86. ));
  87. dsetcookie('connect_js_name', 'user_bind', 86400);
  88. dsetcookie('connect_js_params', base64_encode(serialize(array('type' => 'register'))), 86400);
  89. dsetcookie('connect_login', 1, 31536000);
  90. dsetcookie('connect_is_bind', '1', 31536000);
  91. dsetcookie('connect_uin', $conopenid, 31536000);
  92. dsetcookie('stats_qc_reg', 1, 86400);
  93. if ($_GET['is_feed']) {
  94. dsetcookie('connect_synpost_tip', 1, 31536000);
  95. }
  96. C::t('#qqconnect#connect_memberbindlog')->insert(array('uid' => $uid, 'uin' => $conopenid, 'type' => '1', 'dateline' => $_G['timestamp']));
  97. dsetcookie('con_auth_hash');
  98. C::t('#qqconnect#common_connect_guest')->delete($conopenid);
  99. if(!function_exists('build_cache_userstats')) {
  100. require_once libfile('cache/userstats', 'function');
  101. }
  102. build_cache_userstats();
  103. if($_G['setting']['connect']['register_groupid']) {
  104. $userdata['groupid'] = $groupinfo['groupid'] = $_G['setting']['connect']['register_groupid'];
  105. }
  106. C::t('common_member')->update($uid, $userdata);
  107. if($_G['setting']['connect']['register_addcredit']) {
  108. $addcredit = array('extcredits'.$_G['setting']['connect']['register_rewardcredit'] => $_G['setting']['connect']['register_addcredit']);
  109. }
  110. C::t('common_member_count')->increase($uid, $addcredit);
  111. }
  112. function connect_filter_username($username) {
  113. $username = str_replace(' ', '_', trim($username));
  114. return cutstr($username, 15, '');
  115. }
  116. ?>