connect.class.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. <?php
  2. /**
  3. * [Discuz! X] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: connect.class.php 34497 2014-05-09 09:05:09Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class plugin_qqconnect_base {
  12. public $retryInterval = 60;
  13. public $retryMax = 5;
  14. public $retryAvaiableTime = 1800;
  15. function init() {
  16. global $_G;
  17. include_once template('qqconnect:module');
  18. if(!$_G['setting']['connect']['allow'] || $_G['setting']['bbclosed']) {
  19. return;
  20. }
  21. $this->allow = true;
  22. }
  23. function common_base() {
  24. global $_G;
  25. if(!isset($_G['connect'])) {
  26. $_G['connect']['url'] = 'http://connect.discuz.qq.com';
  27. $_G['connect']['api_url'] = 'http://api.discuz.qq.com';
  28. $_G['connect']['avatar_url'] = 'http://avatar.connect.discuz.qq.com';
  29. $_G['connect']['qzone_public_share_url'] = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey';
  30. $_G['connect']['referer'] = !$_G['inajax'] && CURSCRIPT != 'member' ? $_G['basefilename'].($_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : '') : dreferer();
  31. $_G['connect']['weibo_public_appkey'] = 'ce7fb946290e4109bdc9175108b6db3a';
  32. $_G['connect']['login_url'] = $_G['siteurl'].'connect.php?mod=login&op=init&referer='.urlencode($_G['connect']['referer'] ? $_G['connect']['referer'] : 'index.php');
  33. $_G['connect']['callback_url'] = $_G['siteurl'].'connect.php?mod=login&op=callback';
  34. $_G['connect']['discuz_new_feed_url'] = $_G['siteurl'].'connect.php?mod=feed&op=new&formhash=' . formhash();
  35. $_G['connect']['discuz_new_post_feed_url'] = $_G['siteurl'].'connect.php?mod=feed&op=new&action=post&formhash=' . formhash();
  36. $_G['connect']['discuz_new_share_url'] = $_G['siteurl'].'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=new';
  37. $_G['connect']['discuz_sync_tthread_url'] = $_G['siteurl'].'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=sync_tthread&formhash=' . formhash();
  38. $_G['connect']['discuz_change_qq_url'] = $_G['siteurl'].'connect.php?mod=login&op=change';
  39. $_G['connect']['auth_fields'] = array(
  40. 'is_user_info' => 1,
  41. 'is_feed' => 2,
  42. );
  43. if($_G['uid']) {
  44. dsetcookie('connect_is_bind', $_G['member']['conisbind'], 31536000);
  45. if(!$_G['member']['conisbind'] && $_G['cookie']['connect_login']) {
  46. $_G['cookie']['connect_login'] = 0;
  47. dsetcookie('connect_login');
  48. }
  49. }
  50. if (!$_G['uid'] && $_G['connectguest']) {
  51. if ($_G['cookie']['connect_qq_nick']) {
  52. $_G['member']['username'] = $_G['cookie']['connect_qq_nick'];
  53. } else {
  54. $connectGuest = C::t('#qqconnect#common_connect_guest')->fetch($conopenid);
  55. if ($connectGuest['conqqnick']) {
  56. $_G['member']['username'] = $connectGuest['conqqnick'];
  57. }
  58. }
  59. }
  60. if($this->allow && !$_G['uid'] && !defined('IN_MOBILE')) {
  61. $_G['setting']['pluginhooks']['global_login_text'] = tpl_login_bar();
  62. }
  63. }
  64. }
  65. }
  66. class plugin_qqconnect extends plugin_qqconnect_base {
  67. var $allow = false;
  68. function plugin_qqconnect() {
  69. $this->init();
  70. }
  71. function common() {
  72. $this->common_base();
  73. }
  74. function discuzcode($param) {
  75. global $_G;
  76. if($param['caller'] == 'discuzcode') {
  77. $_G['discuzcodemessage'] = preg_replace('/\[wb=(.+?)\](.+?)\[\/wb\]/', '<a href="http://t.qq.com/\\1" target="_blank"><img src="\\2" /></a>', $_G['discuzcodemessage']);
  78. }
  79. if($param['caller'] == 'messagecutstr') {
  80. $_G['discuzcodemessage'] = preg_replace('/\[tthread=(.+?)\](.*?)\[\/tthread\]/', '', $_G['discuzcodemessage']);
  81. }
  82. }
  83. function global_login_extra() {
  84. global $_G;
  85. if(!$this->allow || $_G['inshowmessage']) {
  86. return;
  87. }
  88. return tpl_global_login_extra();
  89. }
  90. function global_usernav_extra1() {
  91. global $_G;
  92. if(!$this->allow) {
  93. return;
  94. }
  95. if (!$_G['uid'] && !$_G['connectguest']) {
  96. return;
  97. }
  98. if(!$_G['member']['conisbind']) {
  99. return tpl_global_usernav_extra1();
  100. }
  101. }
  102. function global_footer() {
  103. global $_G;
  104. if(!$this->allow || !empty($_G['inshowmessage'])) {
  105. return;
  106. }
  107. $loadJs = array();
  108. $connectService = Cloud::loadClass('Service_Connect');
  109. if(defined('CURSCRIPT') && CURSCRIPT == 'forum' && defined('CURMODULE') && CURMODULE == 'viewthread'
  110. && $_G['setting']['connect']['allow'] && $_G['setting']['connect']['qshare_allow']) {
  111. $appkey = $_G['setting']['connect']['qshare_appkey'] ? $_G['setting']['connect']['qshare_appkey'] : $_G['connect']['weibo_public_appkey'];
  112. $qsharejsurl = $_G['siteurl'] . 'static/js/qshare.js';
  113. $sitename = isset($_G['setting']['bbname']) ? $_G['setting']['bbname'] : '';
  114. $loadJs['qsharejs'] = array('jsurl' => $qsharejsurl, 'appkey' => $appkey, 'sitename' => $sitename, 'func' => '$C');
  115. }
  116. if(!empty($_G['cookie']['connect_js_name'])) {
  117. if($_G['cookie']['connect_js_name'] == 'feed_resend') {
  118. $jsurl = $connectService->connectFeedResendJs();
  119. $loadJs['feedjs'] = array('jsurl' => $jsurl);
  120. }
  121. dsetcookie('connect_js_name');
  122. dsetcookie('connect_js_params');
  123. }
  124. loadcache('connect_login_report_date');
  125. if (dgmdate(TIMESTAMP, 'Y-m-d') != $_G['cache']['connect_login_report_date']) {
  126. $jsurl = $connectService->connectCookieLoginJs();
  127. $loadJs['cookieloginjs'] = array('jsurl' => $jsurl);
  128. }
  129. if ($_G['member']['conisbind']) {
  130. $connectService->connectMergeMember();
  131. if($_G['member']['conuinsecret'] && ($_G['cookie']['connect_last_report_time'] != dgmdate(TIMESTAMP, 'Y-m-d'))) {
  132. $connectService->connectAddCookieLogins();
  133. }
  134. }
  135. if ($_G['cookie']['connect_sync_post']) {
  136. $params = array();
  137. list($params['thread_id'], $params['post_id']) = explode('|', $_G['cookie']['connect_sync_post']);
  138. $params['ts'] = TIMESTAMP;
  139. $params['sig'] = $connectService->connectGetSig($params, $connectService->connectGetSigKey());
  140. $utilService = Cloud::loadClass('Service_Util');
  141. $jsurl = $_G['connect']['discuz_new_post_feed_url'].'&'.$utilService->httpBuildQuery($params, '', '&');
  142. $loadJs['syncpostjs'] = array('jsurl' => $jsurl);
  143. }
  144. return tpl_global_footer($loadJs);
  145. }
  146. function _allowconnectfeed() {
  147. if(!$this->allow) {
  148. return;
  149. }
  150. global $_G;
  151. return $_G['uid'] && $_G['setting']['connect']['allow'] && $_G['setting']['connect']['feed']['allow'] && ($_G['forum']['status'] == 3 && $_G['setting']['connect']['feed']['group'] || $_G['forum']['status'] != 3 && (!$_G['setting']['connect']['feed']['fids'] || in_array($_G['fid'], $_G['setting']['connect']['feed']['fids'])));
  152. }
  153. function _allowconnectt() {
  154. if(!$this->allow) {
  155. return;
  156. }
  157. global $_G;
  158. return $_G['uid'] && $_G['setting']['connect']['allow'] && $_G['setting']['connect']['t']['allow'] && ($_G['forum']['status'] == 3 && $_G['setting']['connect']['t']['group'] || $_G['forum']['status'] != 3 && (!$_G['setting']['connect']['t']['fids'] || in_array($_G['fid'], $_G['setting']['connect']['t']['fids'])));
  159. }
  160. function _forumdisplay_fastpost_sync_method_output() {
  161. if(!$this->allow) {
  162. return;
  163. }
  164. global $_G;
  165. $allowconnectfeed = $this->_allowconnectfeed();
  166. $allowconnectt = $this->_allowconnectt();
  167. if($GLOBALS['fastpost'] && ($allowconnectfeed || $allowconnectt)) {
  168. $connectService = Cloud::loadClass('Service_Connect');
  169. $connectService->connectMergeMember();
  170. if ($_G['member']['is_feed']) {
  171. return tpl_sync_method($allowconnectfeed, $allowconnectt);
  172. }
  173. }
  174. }
  175. function _post_sync_method_output() {
  176. if(!$this->allow) {
  177. return;
  178. }
  179. global $_G;
  180. $allowconnectfeed = $this->_allowconnectfeed();
  181. $allowconnectt = $this->_allowconnectt();
  182. if(!$_G['inajax'] && ($allowconnectfeed || $allowconnectt) && ($_GET['action'] == 'newthread' || $_GET['action'] == 'edit' && $GLOBALS['isfirstpost'] && $GLOBALS['thread']['displayorder'] == -4)) {
  183. $connectService = Cloud::loadClass('Service_Connect');
  184. $connectService->connectMergeMember();
  185. if ($_G['member']['is_feed']) {
  186. return tpl_sync_method($allowconnectfeed, $allowconnectt);
  187. }
  188. }
  189. if(!$_G['inajax'] && ($allowconnectfeed || $allowconnectt) && $_GET['action'] == 'reply') {
  190. $connectService = Cloud::loadClass('Service_Connect');
  191. $connectService->connectMergeMember();
  192. if ($_G['member']['is_feed']) {
  193. return tpl_sync_method(false, $allowconnectt);
  194. }
  195. }
  196. }
  197. function _post_infloat_btn_extra_output() {
  198. if(!$this->allow) {
  199. return;
  200. }
  201. global $_G;
  202. $allowconnectfeed = $this->_allowconnectfeed();
  203. $allowconnectt = $this->_allowconnectt();
  204. if($_G['inajax'] && ($allowconnectfeed || $allowconnectt) && $_GET['action'] == 'newthread') {
  205. $connectService = Cloud::loadClass('Service_Connect');
  206. $connectService->connectMergeMember();
  207. if ($_G['member']['is_feed']) {
  208. return tpl_infloat_sync_method($allowconnectfeed, $allowconnectt, ' z');
  209. }
  210. }
  211. if($_G['inajax'] && ($allowconnectfeed || $allowconnectt) && $_GET['action'] == 'reply') {
  212. $connectService = Cloud::loadClass('Service_Connect');
  213. $connectService->connectMergeMember();
  214. if ($_G['member']['is_feed']) {
  215. return tpl_infloat_sync_method(false, $allowconnectt, ' z');
  216. }
  217. }
  218. }
  219. function _post_feedlog_message($param) {
  220. if(!$this->allow) {
  221. return;
  222. }
  223. global $_G;
  224. $condition1 = substr($param['param'][0], -8) != '_succeed';
  225. $condition2 = $_GET['action'] == 'edit' && !$GLOBALS['isfirstpost'];
  226. $condition3 = !$this->_allowconnectfeed() && !$this->_allowconnectt();
  227. $condition4 = empty($_GET['connect_publish_feed']) && empty($_GET['connect_publish_t']);
  228. if (empty($_GET['connect_publish_feed']) && $_GET['action'] != 'reply') {
  229. dsetcookie('connect_not_sync_feed', 1);
  230. } else {
  231. dsetcookie('connect_not_sync_feed', 0);
  232. }
  233. if (empty($_GET['connect_publish_t'])) {
  234. dsetcookie('connect_not_sync_t', 1);
  235. } else {
  236. dsetcookie('connect_not_sync_t', 0);
  237. }
  238. if ($condition1 || $condition2 || $condition3 || $condition4) {
  239. return false;
  240. }
  241. if ($_GET['action'] == 'reply') {
  242. $tid = $param['param'][2]['tid'];
  243. $pid = $param['param'][2]['pid'];
  244. if ($_GET['connect_publish_t']) {
  245. dsetcookie('connect_sync_post', $tid .'|'. $pid);
  246. $data = array(
  247. 'pid' => $pid,
  248. 'uid' => $_G['uid'],
  249. 'lastpublished' => 0,
  250. 'dateline' => $_G['timestamp'],
  251. 'status' => 0,
  252. );
  253. C::t('#qqconnect#connect_postfeedlog')->insert($data, 0, 1);
  254. }
  255. } else {
  256. $tid = $param['param'][2]['tid'];
  257. $thread = C::t('forum_thread')->fetch($tid);
  258. if ($_GET['connect_publish_feed']) {
  259. $thread['status'] = setstatus(7, 1, $thread['status']);
  260. }
  261. if ($_GET['connect_publish_t']) {
  262. $thread['status'] = setstatus(8, 1, $thread['status']);
  263. }
  264. C::t('forum_thread')->update($tid, array('status' => $thread['status']));
  265. $data = array(
  266. 'tid' => $tid,
  267. 'uid' => $_G['uid'],
  268. 'lastpublished' => 0,
  269. 'dateline' => $_G['timestamp'],
  270. 'status' => 0,
  271. );
  272. C::t('#qqconnect#connect_feedlog')->insert($data, 0, 1);
  273. }
  274. }
  275. function _viewthread_share_method_output() {
  276. global $_G, $postlist, $canonical;
  277. $needFeedStatus = getstatus($_G['forum_thread']['status'], 7);
  278. $needWeiboStatus = getstatus($_G['forum_thread']['status'], 8);
  279. $_G['connect']['thread_url'] = $_G['siteurl'] . $canonical;
  280. $connectService = Cloud::loadClass('Service_Connect');
  281. $_G['connect']['qzone_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=1&thread_id=' . $_G['tid'];
  282. $_G['connect']['weibo_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=2&thread_id=' . $_G['tid'];
  283. $_G['connect']['pengyou_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=3&thread_id=' . $_G['tid'];
  284. $_G['connect']['qq_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=4&thread_id=' . $_G['tid'];
  285. $_G['connect']['first_post'] = $postlist[$_G['forum_firstpid']];
  286. if ($_G['connect']['first_post']['anonymous']) {
  287. $_G['connect']['first_post']['authorid'] = 0;
  288. $_G['connect']['first_post']['author'] = '';
  289. }
  290. $_GET['connect_autoshare'] = !empty($_GET['connect_autoshare']) ? 1 : 0;
  291. $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey'];
  292. if($this->allow && $_G['setting']['connect']['qshare_appkey']) {
  293. $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['qshare_appkey'];
  294. }
  295. $condition1 = $_G['uid'] != $_G['forum_thread']['authorid'] || !$_G['member']['conopenid'];
  296. $condition2 = $_G['forum_thread']['displayorder'] < 0;
  297. $condition3 = $_G['timestamp'] - $_G['forum_thread']['dateline'] > $this->retryAvaiableTime;
  298. if ($condition1 || $condition2 || $condition3) {
  299. $needFeedStatus = $needWeiboStatus = false;
  300. }
  301. if ($_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) {
  302. if (trim($_G['forum']['viewperm'])) {
  303. $allowViewPermGroupIds = explode("\t", trim($_G['forum']['viewperm']));
  304. }
  305. if (trim($_G['forum']['getattachperm'])) {
  306. $allowViewAttachGroupIds = explode("\t", trim($_G['forum']['getattachperm']));
  307. }
  308. $bigWidth = '400';
  309. $bigHeight = '400';
  310. $share_images = array();
  311. foreach ($_G['connect']['first_post']['attachments'] as $attachment) {
  312. if ($attachment['isimage'] == 0 || $attachment['price'] > 0
  313. || $attachment['readperm'] > $_G['group']['readaccess']
  314. || ($allowViewPermGroupIds && !in_array($_G['groupid'], $allowViewPermGroupIds))
  315. || ($allowViewAttachGroupIds && !in_array($_G['groupid'], $allowViewAttachGroupIds))) {
  316. continue;
  317. }
  318. $bigImageURL = $_G['siteurl'] . getforumimg($attachment['aid'], 1, $bigWidth, $bigHeight, 'fixnone');
  319. $share_images[] = urlencode($bigImageURL);
  320. }
  321. $_G['connect']['share_images'] = implode('|', $share_images);
  322. }
  323. if (!$needFeedStatus && !$needWeiboStatus) {
  324. return tpl_viewthread_share_method($jsurl);
  325. }
  326. if ($_G['page'] == 1 && $_G['forum_firstpid'] && $postlist[$_G['forum_firstpid']]['invisible'] == 0) {
  327. $feedLog = C::t('#qqconnect#connect_feedlog')->fetch_by_tid($_G['tid']);
  328. if ($feedLog['publishtimes'] >= $this->retryMax) {
  329. return tpl_viewthread_share_method($jsurl);
  330. }
  331. $hadFeedStatus = getstatus($feedLog['status'], 2);
  332. $hadWeiboStatus = getstatus($feedLog['status'], 4);
  333. if (!$hadFeedStatus || !$hadWeiboStatus) {
  334. if ($needFeedStatus && !$hadFeedStatus) {
  335. if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) {
  336. $needFeedStatus = false;
  337. }
  338. } else {
  339. $needFeedStatus = false;
  340. }
  341. if($needWeiboStatus && !$hadWeiboStatus) {
  342. if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) {
  343. $needWeiboStatus = false;
  344. }
  345. } else {
  346. $needWeiboStatus = false;
  347. }
  348. }
  349. $jsurl = '';
  350. if($needFeedStatus || $needWeiboStatus) {
  351. $params = array();
  352. $params['thread_id'] = $_G['tid'];
  353. $params['ts'] = TIMESTAMP;
  354. $params['type'] = bindec(($needWeiboStatus ? '1' : '0').($needFeedStatus ? '1' : '0'));
  355. $params['sig'] = $connectService->connectGetSig($params, $connectService->connectGetSigKey());
  356. $utilService = Cloud::loadClass('Service_Util');
  357. $jsurl = $_G['connect']['discuz_new_feed_url'].'&'.$utilService->httpBuildQuery($params, '', '&');
  358. }
  359. $connectService->connectMergeMember();
  360. return tpl_viewthread_share_method($jsurl);
  361. }
  362. }
  363. function _viewthread_bottom_output() {
  364. if(!$this->allow) {
  365. return;
  366. }
  367. global $_G, $thread, $rushreply, $postlist, $page;
  368. $uids = $openids = array();
  369. foreach($postlist as $pid => $post) {
  370. if($post['anonymous']) {
  371. continue;
  372. }
  373. if($post['authorid']) {
  374. $uids[$post['authorid']] = $post['authorid'];
  375. }
  376. }
  377. foreach(C::t('#qqconnect#common_member_connect')->fetch_all($uids) as $connect) {
  378. if($connect['conisqqshow'] && $connect['conopenid']) {
  379. $openids[$connect['uid']] = $connect['conopenid'];
  380. }
  381. }
  382. foreach($postlist as $pid => $post) {
  383. if(getstatus($post['status'], 5)) {
  384. $matches = array();
  385. preg_match('/\[tthread=(.+?),(.+?)\](.*?)\[\/tthread\]/', $post['message'], $matches);
  386. if($matches[1] && $matches[2]) {
  387. $post['message'] = preg_replace('/\[tthread=(.+?)\](.*?)\[\/tthread\]/', lang('plugin/qqconnect', 'connect_tthread_message', array('username' => $matches[1], 'nick' => $matches[2])), $post['message']);
  388. }
  389. $post['authorid'] = 0;
  390. $post['author'] = lang('plugin/qqconnect', 'connect_tthread_comment');
  391. $post['avatar'] = $matches[3] ? '<img src="'.$matches[3].'/120'.'">' : '<img src="'.$_G['siteurl'].'/static/image/common/tavatar.gif">';
  392. $post['groupid'] = '7';
  393. $postlist[$pid] = $post;
  394. continue;
  395. }
  396. if($post['anonymous']) {
  397. continue;
  398. }
  399. }
  400. if($page == 1 && $postlist[$_G['forum_firstpid']]['invisible'] == 0) {
  401. $jsurl = '';
  402. if(!$_G['cookie']['connect_last_sync_t'] && $_G['uid'] && $_G['setting']['connect']['t']['reply'] && !$thread['closed'] && !$rushreply && getstatus($_G['forum_thread']['status'], 14)) {
  403. $jsurl = $_G['connect']['discuz_sync_tthread_url'].'&tid='.$thread['tid'];
  404. dsetcookie('connect_last_sync_t', 1, 600);
  405. }
  406. return tpl_viewthread_bottom($jsurl);
  407. }
  408. }
  409. function _viewthread_postbottom_output() {
  410. global $_G, $postlist;
  411. $return = array();
  412. if ($postlist[$_G['forum_firstpid']]['invisible'] == 0 && $_G['inajax']) {
  413. $jsurl = '';
  414. $viewpid = intval($_GET['viewpid']);
  415. if ($viewpid && $_G['tid']) {
  416. $data = C::t('#qqconnect#connect_postfeedlog')->fetch_by_pid($viewpid);
  417. if (!$data['status'] && $data) {
  418. $params = array();
  419. $params['thread_id'] = $_G['tid'];
  420. $params['post_id'] = $viewpid;
  421. $params['ts'] = TIMESTAMP;
  422. $connectService = Cloud::loadClass('Service_Connect');
  423. $params['sig'] = $connectService->connectGetSig($params, $connectService->connectGetSigKey());
  424. $utilService = Cloud::loadClass('Service_Util');
  425. $jsurl = $_G['connect']['discuz_new_post_feed_url'].'&'.$utilService->httpBuildQuery($params, '', '&');
  426. $return[] = tpl_sync_post_viewthread_bottom($jsurl);
  427. }
  428. }
  429. }
  430. return $return;
  431. }
  432. function _viewthread_fastpost_btn_extra_output() {
  433. if(!$this->allow) {
  434. return;
  435. }
  436. global $_G;
  437. $allowconnectt = $this->_allowconnectt();
  438. if($GLOBALS['fastpost'] && $allowconnectt) {
  439. $connectService = Cloud::loadClass('Service_Connect');
  440. $connectService->connectMergeMember();
  441. if ($_G['member']['is_feed']) {
  442. return lang('plugin/qqconnect', 'connect_post_sync_method') . tpl_sync_method(false, $allowconnectt) . ' | ';
  443. }
  444. }
  445. }
  446. }
  447. class plugin_qqconnect_member extends plugin_qqconnect {
  448. function connect_member() {
  449. global $_G, $seccodecheck, $secqaacheck, $connect_guest;
  450. if($this->allow) {
  451. if($_G['uid'] && $_G['member']['conisbind']) {
  452. dheader('location: '.$_G['siteurl'].'index.php');
  453. }
  454. $connect_guest = array();
  455. if($_G['connectguest'] && (submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck) || submitcheck('loginsubmit', 1, $seccodestatus))) {
  456. if(!$_GET['auth_hash']) {
  457. $_GET['auth_hash'] = $_G['cookie']['con_auth_hash'];
  458. }
  459. $conopenid = authcode($_GET['auth_hash']);
  460. $connect_guest = C::t('#qqconnect#common_connect_guest')->fetch($conopenid);
  461. if(!$connect_guest) {
  462. dsetcookie('con_auth_hash');
  463. showmessage('qqconnect:connect_login_first');
  464. }
  465. }
  466. }
  467. }
  468. function logging_member() {
  469. global $_G;
  470. if($this->allow && $_G['connectguest'] && $_GET['action'] == 'login') {
  471. if ($_G['inajax']) {
  472. showmessage('qqconnect:connectguest_message_complete_or_bind');
  473. } else {
  474. dheader('location: '.$_G['siteurl'].'member.php?mod=connect&ac=bind');
  475. }
  476. }
  477. }
  478. function register_member() {
  479. global $_G;
  480. if($this->allow && $_G['connectguest']) {
  481. if ($_G['inajax']) {
  482. showmessage('qqconnect:connectguest_message_complete_or_bind');
  483. } else {
  484. dheader('location: '.$_G['siteurl'].'member.php?mod=connect');
  485. }
  486. }
  487. }
  488. function logging_method() {
  489. if(!$this->allow) {
  490. return;
  491. }
  492. return tpl_login_bar();
  493. }
  494. function register_logging_method() {
  495. if(!$this->allow) {
  496. return;
  497. }
  498. return tpl_login_bar();
  499. }
  500. function connect_input_output() {
  501. if(!$this->allow) {
  502. return;
  503. }
  504. global $_G;
  505. $_G['setting']['pluginhooks']['register_input'] = tpl_register_input();
  506. }
  507. function connect_bottom_output() {
  508. if(!$this->allow) {
  509. return;
  510. }
  511. global $_G;
  512. $_G['setting']['pluginhooks']['register_bottom'] = tpl_register_bottom();
  513. }
  514. }
  515. class plugin_qqconnect_forum extends plugin_qqconnect {
  516. function index_status_extra() {
  517. global $_G;
  518. if(!$this->allow) {
  519. return;
  520. }
  521. if($_G['setting']['connect']['like_allow'] && $_G['setting']['connect']['like_url'] || $_G['setting']['connect']['turl_allow'] && $_G['setting']['connect']['turl_code']) {
  522. return tpl_index_status_extra();
  523. }
  524. }
  525. function forumdisplay_fastpost_sync_method_output() {
  526. return $this->_forumdisplay_fastpost_sync_method_output();
  527. }
  528. function post_sync_method_output() {
  529. return $this->_post_sync_method_output();
  530. }
  531. function post_infloat_btn_extra_output() {
  532. return $this->_post_infloat_btn_extra_output();
  533. }
  534. function post_feedlog_message($param) {
  535. return $this->_post_feedlog_message($param);
  536. }
  537. function viewthread_share_method_output() {
  538. return $this->_viewthread_share_method_output();
  539. }
  540. function viewthread_bottom_output() {
  541. return $this->_viewthread_bottom_output();
  542. }
  543. function viewthread_fastpost_btn_extra_output() {
  544. return $this->_viewthread_fastpost_btn_extra_output();
  545. }
  546. function viewthread_postbottom_output() {
  547. return $this->_viewthread_postbottom_output();
  548. }
  549. }
  550. class plugin_qqconnect_group extends plugin_qqconnect {
  551. function forumdisplay_fastpost_sync_method_output() {
  552. return $this->_forumdisplay_fastpost_sync_method_output();
  553. }
  554. function post_sync_method_output() {
  555. return $this->_post_sync_method_output();
  556. }
  557. function post_infloat_btn_extra_output() {
  558. return $this->_post_infloat_btn_extra_output();
  559. }
  560. function post_feedlog_message($param) {
  561. return $this->_post_feedlog_message($param);
  562. }
  563. function viewthread_share_method_output() {
  564. return $this->_viewthread_share_method_output();
  565. }
  566. function viewthread_bottom_output() {
  567. return $this->_viewthread_bottom_output();
  568. }
  569. function viewthread_fastpost_btn_extra_output() {
  570. return $this->_viewthread_fastpost_btn_extra_output();
  571. }
  572. }
  573. class plugin_qqconnect_home extends plugin_qqconnect {
  574. function spacecp_profile_bottom() {
  575. global $_G;
  576. if($_G['uid'] && $_G['setting']['connect']['allow']) {
  577. return tpl_spacecp_profile_bottom();
  578. }
  579. }
  580. }
  581. class mobileplugin_qqconnect extends plugin_qqconnect_base {
  582. var $allow = false;
  583. function mobileplugin_qqconnect() {
  584. global $_G;
  585. if(!$_G['setting']['connect']['allow'] || $_G['setting']['bbclosed']) {
  586. return;
  587. }
  588. $this->allow = true;
  589. }
  590. function common() {
  591. $this->common_base();
  592. }
  593. function global_footer_mobile() {
  594. global $_G;
  595. if(!$this->allow || !empty($_G['inshowmessage'])) {
  596. return;
  597. }
  598. }
  599. }