function _viewthread_share_method_output() { global $_G; require_once libfile('function/connect'); if ($GLOBALS['page'] == 1 && $_G['forum_firstpid'] && $GLOBALS['postlist'][$_G['forum_firstpid']]['invisible'] == 0) { $_G['connect']['feed_js'] = $_G['connect']['t_js'] = false; if (!getstatus($_G['forum_thread']['status'], 7) && $_G['forum_thread']['displayorder'] >= 0) { $feedlogstatus = false; $_G['connect']['feed_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_feedlog') . " WHERE tid='{$_G['tid']}'"); if ($_G['connect']['feed_log']) { $_G['connect']['feed_interval'] = 300; $_G['connect']['feed_publish_max'] = 1000; if ($_G['connect']['feed_log'] && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) { if ($_G['connect']['feed_log']['status'] == 1 || $_G['connect']['feed_log']['status'] == 2 && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) { DB::query("UPDATE " . DB::table('connect_feedlog') . " SET status='2', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}' AND status!=4"); $_G['connect']['feed_js'] = $feedlogstatus = true; } } } else { $feedlogstatus = true; } } if (!getstatus($_G['forum_thread']['status'], 8) && $_G['forum_thread']['displayorder'] >= 0) { $_G['connect']['t_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_tlog') . " WHERE tid='{$_G['tid']}'"); if ($_G['connect']['t_log']) { $_G['connect']['t_interval'] = 300; $_G['connect']['t_publish_max'] = 1000; if ($_G['connect']['t_log'] && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) { if ($_G['connect']['t_log']['status'] == 1 || $_G['connect']['t_log']['status'] == 2 && TIMESTAMP - $_G['connect']['t_log']['lastpublished'] > $_G['connect']['t_interval'] && $_G['connect']['t_log']['publishtimes'] < $_G['connect']['t_publish_max']) { DB::query("UPDATE " . DB::table('connect_tlog') . " SET status='2', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}' AND status!=4"); $_G['connect']['t_js'] = $tlogstatus = true; } } } else { $tlogstatus = true; } } if ($feedlogstatus || $tlogstatus) { $newstatus = $_G['forum_thread']['status']; $newstatus = $feedlogstatus ? setstatus(7, 1, $newstatus) : $newstatus; $newstatus = $tlogstatus ? setstatus(8, 1, $newstatus) : $newstatus; DB::query("UPDATE " . DB::table('forum_thread') . " SET status='{$newstatus}' WHERE tid='{$_G['tid']}'"); } $_G['connect']['thread_url'] = $_G['siteurl'] . $GLOBALS['canonical']; $_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']; $_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']; $_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']; $_G['connect']['qzone_share_api'] = $_G['connect']['qzone_public_share_url'] . '?url=' . urlencode($_G['connect']['thread_url']); $_G['connect']['pengyou_share_api'] = $_G['connect']['qzone_public_share_url'] . '?to=pengyou&url=' . urlencode($_G['connect']['thread_url']); $params = array('oauth_consumer_key' => $_G['setting']['connectappid'], 'title' => $GLOBALS['postlist'][$_G['forum_firstpid']]['subject'], 'url' => $_G['connect']['thread_url']); $params['sig'] = connect_get_sig($params, connect_get_sig_key()); $_G['connect']['t_share_api'] = $_G['connect']['url'] . '/mblog/redirect?' . cloud_http_build_query($params, '', '&'); $_G['connect']['first_post'] = daddslashes($GLOBALS['postlist'][$_G['forum_firstpid']]); $_G['gp_connect_autoshare'] = !empty($_G['gp_connect_autoshare']) ? 1 : 0; $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey']; if ($this->allow && $_G['setting']['connect']['mblog_app_key']) { $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['mblog_app_key']; } $extrajs = ''; if ($_G['connect']['feed_js'] || $_G['connect']['t_js']) { $params = array(); $params['thread_id'] = $_G['tid']; $params['ts'] = TIMESTAMP; $params['type'] = bindec(($_G['connect']['t_js'] ? '1' : '0') . ($_G['connect']['feed_js'] ? '1' : '0')); $params['sig'] = connect_get_sig($params, connect_get_sig_key()); $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . cloud_http_build_query($params, '', '&'); $extrajs = connect_output_javascript($jsurl); } if (!$_G['member']['conisbind'] && $_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) { if ($_G['connect']['first_post']['message']) { require_once libfile('function/connect'); $post['html_content'] = connect_parse_bbcode($_G['connect']['first_post']['message'], $_G['connect']['first_post']['fid'], $_G['connect']['first_post']['pid'], $_G['connect']['first_post']['htmlon'], $attach_images); if ($attach_images && is_array($attach_images)) { $attach_images = array_slice($attach_images, 0, 3); $share_images = array(); foreach ($attach_images as $attach_image) { $share_images[] = urlencode($attach_image['big']); } $_G['connect']['share_images'] = implode('|', $share_images); unset($share_images); } } } connect_merge_member(); return tpl_viewthread_share_method() . $extrajs; } }
function _viewthread_share_method_output() { global $_G, $postlist, $canonical; // 判断是否需要推送到空间或者微博,判断条件:需要发+主题表无发过标志 $needFeedStatus = getstatus($_G['forum_thread']['status'], 7); $needWeiboStatus = getstatus($_G['forum_thread']['status'], 8); // 主题地址 $_G['connect']['thread_url'] = $_G['siteurl'] . $canonical; // 本地三个分享表单请求地址 $connectService = Cloud::loadClass('Service_Connect'); $_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']; $_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']; $_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']; // 楼主pid $_G['connect']['first_post'] = $postlist[$_G['forum_firstpid']]; // 匿名帖用户信息 if ($_G['connect']['first_post']['anonymous']) { $_G['connect']['first_post']['authorid'] = 0; $_G['connect']['first_post']['author'] = ''; } $_GET['connect_autoshare'] = !empty($_GET['connect_autoshare']) ? 1 : 0; // 设置微薄appkey $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey']; if ($this->allow && $_G['setting']['connect']['qshare_appkey']) { $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['qshare_appkey']; } // 如果看帖的不是作者本人或者没有绑定关系直接结束 $condition1 = $_G['uid'] != $_G['forum_thread']['authorid'] || !$_G['member']['conopenid']; // 判断是否是正常主题 $condition2 = $_G['forum_thread']['displayorder'] < 0; // 发帖超过半个小时,不继续执行,减少查询 $condition3 = $_G['timestamp'] - $_G['forum_thread']['dateline'] > $this->retryAvaiableTime; // 满足以上任意一个条件 if ($condition1 || $condition2 || $condition3) { $needFeedStatus = $needWeiboStatus = false; } // 站外分享图片权限:未绑定QC和有权限查看图片的用户 if (!$_G['member']['conisbind'] && $_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) { // debug 站外分享附件图片权限判断 if (trim($_G['forum']['viewperm'])) { $allowViewPermGroupIds = explode("\t", trim($_G['forum']['viewperm'])); } if (trim($_G['forum']['getattachperm'])) { $allowViewAttachGroupIds = explode("\t", trim($_G['forum']['getattachperm'])); } $bigWidth = '400'; $bigHeight = '400'; $share_images = array(); foreach ($_G['connect']['first_post']['attachments'] as $attachment) { if ($attachment['isimage'] == 0 || $attachment['price'] > 0 || $attachment['readperm'] > $_G['group']['readaccess'] || $allowViewPermGroupIds && !in_array($_G['groupid'], $allowViewPermGroupIds) || $allowViewAttachGroupIds && !in_array($_G['groupid'], $allowViewAttachGroupIds)) { continue; } $key = md5($attachment['aid'] . '|' . $bigWidth . '|' . $bigHeight); $bigImageURL = $_G['siteurl'] . 'forum.php?mod=image&aid=' . $attachment['aid'] . '&size=' . $bigWidth . 'x' . $bigHeight . '&key=' . rawurlencode($key) . '&type=fixnone&nocache=1'; $share_images[] = urlencode($bigImageURL); } $_G['connect']['share_images'] = implode('|', $share_images); } // 如果不需要推送到空间也不需要推送到微博 if (!$needFeedStatus && !$needWeiboStatus) { return tpl_viewthread_share_method($jsurl); } // 如果在第一页,而且有楼主层,并且楼主层的帖子可见,进入推送判断流程 if ($_G['page'] == 1 && $_G['forum_firstpid'] && $postlist[$_G['forum_firstpid']]['invisible'] == 0) { $feedLog = C::t('#qqconnect#connect_feedlog')->fetch_by_tid($_G['tid']); // 发送次数达到最大,取消 if ($feedLog['publishtimes'] >= $this->retryMax) { return tpl_viewthread_share_method($jsurl); } // 已经推送到空间 $hadFeedStatus = getstatus($feedLog['status'], 2); // 已经推送到微博 $hadWeiboStatus = getstatus($feedLog['status'], 4); if (!$hadFeedStatus || !$hadWeiboStatus) { // 暂时去除重试机制 // 如果需要推送且未推送过 if ($needFeedStatus && !$hadFeedStatus) { // 上次发送时间距离当前时间小于1分钟,不发送 if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) { $needFeedStatus = false; } } else { // 不满足条件,不输出JS $needFeedStatus = false; } // 暂时去除重试机制 // 如果需要推送且未推送过 if ($needWeiboStatus && !$hadWeiboStatus) { // 上次发送时间距离当前时间小于1分钟,不发送 if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) { $needWeiboStatus = false; } } else { // 不满足条件,不输出JS $needWeiboStatus = false; } } // 发feed通知到本地 $jsurl = ''; if ($needFeedStatus || $needWeiboStatus) { $params = array(); $params['thread_id'] = $_G['tid']; $params['ts'] = TIMESTAMP; $params['type'] = bindec(($needWeiboStatus ? '1' : '0') . ($needFeedStatus ? '1' : '0')); $params['sig'] = $connectService->connectGetSig($params, $connectService->connectGetSigKey()); $utilService = Cloud::loadClass('Service_Util'); $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . $utilService->httpBuildQuery($params, '', '&'); } $connectService->connectMergeMember(); return tpl_viewthread_share_method($jsurl); } }
function _viewthread_share_method_output() { global $_G, $postlist, $canonical; $needFeedStatus = getstatus($_G['forum_thread']['status'], 7); $needWeiboStatus = getstatus($_G['forum_thread']['status'], 8); $_G['connect']['thread_url'] = $_G['siteurl'] . $canonical; $connectService = Cloud::loadClass('Service_Connect'); $_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']; $_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']; $_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']; $_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']; $_G['connect']['first_post'] = $postlist[$_G['forum_firstpid']]; if ($_G['connect']['first_post']['anonymous']) { $_G['connect']['first_post']['authorid'] = 0; $_G['connect']['first_post']['author'] = ''; } $_GET['connect_autoshare'] = !empty($_GET['connect_autoshare']) ? 1 : 0; $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey']; if ($this->allow && $_G['setting']['connect']['qshare_appkey']) { $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['qshare_appkey']; } $condition1 = $_G['uid'] != $_G['forum_thread']['authorid'] || !$_G['member']['conopenid']; $condition2 = $_G['forum_thread']['displayorder'] < 0; $condition3 = $_G['timestamp'] - $_G['forum_thread']['dateline'] > $this->retryAvaiableTime; if ($condition1 || $condition2 || $condition3) { $needFeedStatus = $needWeiboStatus = false; } if ($_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) { if (trim($_G['forum']['viewperm'])) { $allowViewPermGroupIds = explode("\t", trim($_G['forum']['viewperm'])); } if (trim($_G['forum']['getattachperm'])) { $allowViewAttachGroupIds = explode("\t", trim($_G['forum']['getattachperm'])); } $bigWidth = '400'; $bigHeight = '400'; $share_images = array(); foreach ($_G['connect']['first_post']['attachments'] as $attachment) { if ($attachment['isimage'] == 0 || $attachment['price'] > 0 || $attachment['readperm'] > $_G['group']['readaccess'] || $allowViewPermGroupIds && !in_array($_G['groupid'], $allowViewPermGroupIds) || $allowViewAttachGroupIds && !in_array($_G['groupid'], $allowViewAttachGroupIds)) { continue; } $bigImageURL = $_G['siteurl'] . getforumimg($attachment['aid'], 1, $bigWidth, $bigHeight, 'fixnone'); $share_images[] = urlencode($bigImageURL); } $_G['connect']['share_images'] = implode('|', $share_images); } if (!$needFeedStatus && !$needWeiboStatus) { return tpl_viewthread_share_method($jsurl); } if ($_G['page'] == 1 && $_G['forum_firstpid'] && $postlist[$_G['forum_firstpid']]['invisible'] == 0) { $feedLog = C::t('#qqconnect#connect_feedlog')->fetch_by_tid($_G['tid']); if ($feedLog['publishtimes'] >= $this->retryMax) { return tpl_viewthread_share_method($jsurl); } $hadFeedStatus = getstatus($feedLog['status'], 2); $hadWeiboStatus = getstatus($feedLog['status'], 4); if (!$hadFeedStatus || !$hadWeiboStatus) { if ($needFeedStatus && !$hadFeedStatus) { if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) { $needFeedStatus = false; } } else { $needFeedStatus = false; } if ($needWeiboStatus && !$hadWeiboStatus) { if ($_G['timestamp'] - $feedLog['lastpublished'] < 60) { $needWeiboStatus = false; } } else { $needWeiboStatus = false; } } $jsurl = ''; if ($needFeedStatus || $needWeiboStatus) { $params = array(); $params['thread_id'] = $_G['tid']; $params['ts'] = TIMESTAMP; $params['type'] = bindec(($needWeiboStatus ? '1' : '0') . ($needFeedStatus ? '1' : '0')); $params['sig'] = $connectService->connectGetSig($params, $connectService->connectGetSigKey()); $utilService = Cloud::loadClass('Service_Util'); $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . $utilService->httpBuildQuery($params, '', '&'); } $connectService->connectMergeMember(); return tpl_viewthread_share_method($jsurl); } }
function _viewthread_share_method_output() { global $_G, $postlist; require_once libfile('function/connect'); $extrajs = ''; if ($GLOBALS['page'] == 1 && $_G['forum_firstpid'] && $GLOBALS['postlist'][$_G['forum_firstpid']]['invisible'] == 0 && TIMESTAMP - $_G['forum_thread']['dateline'] < 43200) { $_G['connect']['feed_js'] = $_G['connect']['t_js'] = $feedlogstatus = $tlogstatus = false; if ((!getstatus($_G['forum_thread']['status'], 7) || !getstatus($_G['forum_thread']['status'], 8)) && $_G['forum_thread']['displayorder'] >= 0 && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) { $_G['connect']['feed_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_feedlog') . " WHERE tid='{$_G['tid']}'"); if ($_G['connect']['feed_log']) { $_G['connect']['feed_interval'] = 300; $_G['connect']['feed_publish_max'] = 1000; if (getstatus($_G['connect']['feed_log']['status'], 1) || getstatus($_G['connect']['feed_log']['status'], 2) && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) { $_G['connect']['feed_js'] = $feedlogstatus = true; } if (getstatus($_G['connect']['feed_log']['status'], 3) || getstatus($_G['connect']['feed_log']['status'], 4) && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) { $_G['connect']['t_js'] = $tlogstatus = true; } if ($feedlogstatus || $tlogstatus) { $status = $feedlogstatus ? setstatus(2, 1, $status) : $status; $status = $tlogstatus ? setstatus(4, 1, $status) : $status; DB::query("UPDATE " . DB::table('connect_feedlog') . " SET status='{$status}', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}'"); } } } if ($feedlogstatus || $tlogstatus) { $newstatus = $_G['forum_thread']['status']; $newstatus = $feedlogstatus ? setstatus(7, 1, $newstatus) : $newstatus; $newstatus = $tlogstatus ? setstatus(8, 1, $newstatus) : $newstatus; DB::query("UPDATE " . DB::table('forum_thread') . " SET status='{$newstatus}' WHERE tid='{$_G['tid']}'"); } if ($_G['connect']['feed_js'] || $_G['connect']['t_js']) { $params = array(); $params['thread_id'] = $_G['tid']; $params['ts'] = TIMESTAMP; $params['type'] = bindec(($_G['connect']['t_js'] ? '1' : '0') . ($_G['connect']['feed_js'] ? '1' : '0')); $params['sig'] = connect_get_sig($params, connect_get_sig_key()); $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . cloud_http_build_query($params, '', '&'); $extrajs = connect_output_javascript($jsurl); } } $_G['connect']['thread_url'] = $_G['siteurl'] . $GLOBALS['canonical']; $_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']; $_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']; $_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']; $_G['connect']['qzone_share_api'] = $_G['connect']['qzone_public_share_url'] . '?url=' . urlencode($_G['connect']['thread_url']); $_G['connect']['pengyou_share_api'] = $_G['connect']['qzone_public_share_url'] . '?to=pengyou&url=' . urlencode($_G['connect']['thread_url']); $params = array('oauth_consumer_key' => $_G['setting']['connectappid'], 'title' => $GLOBALS['postlist'][$_G['forum_firstpid']]['subject'], 'url' => $_G['connect']['thread_url']); $params['sig'] = connect_get_sig($params, connect_get_sig_key()); $_G['connect']['t_share_api'] = $_G['connect']['url'] . '/mblog/redirect?' . cloud_http_build_query($params, '', '&'); $_G['connect']['first_post'] = daddslashes($GLOBALS['postlist'][$_G['forum_firstpid']]); if ($_G['connect']['first_post']['anonymous']) { $_G['connect']['first_post']['authorid'] = 0; $_G['connect']['first_post']['author'] = ''; } $_G['gp_connect_autoshare'] = !empty($_G['gp_connect_autoshare']) ? 1 : 0; $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey']; if ($this->allow && $_G['setting']['connect']['mblog_app_key']) { $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['mblog_app_key']; } if (trim($_G['forum']['viewperm'])) { $allowViewPermGroupIds = explode("\t", trim($_G['forum']['viewperm'])); } if (trim($_G['forum']['getattachperm'])) { $allowViewAttachGroupIds = explode("\t", trim($_G['forum']['getattachperm'])); } $bigWidth = '400'; $bigHeight = '400'; $share_images = array(); foreach ($postlist[$_G['connect']['first_post']['pid']]['attachments'] as $attachment) { if ($attachment['isimage'] == 0 || $attachment['price'] > 0 || $attachment['readperm'] > $_G['group']['readaccess'] || $allowViewPermGroupIds && !in_array($_G['groupid'], $allowViewPermGroupIds) || $allowViewAttachGroupIds && !in_array($_G['groupid'], $allowViewAttachGroupIds)) { continue; } $key = md5($attachment['aid'] . '|' . $bigWidth . '|' . $bigHeight); $bigImageURL = $_G['siteurl'] . 'forum.php?mod=image&aid=' . $attachment['aid'] . '&size=' . $bigWidth . 'x' . $bigHeight . '&key=' . rawurlencode($key) . '&type=fixnone&nocache=1'; $share_images[] = urlencode($bigImageURL); } $_G['connect']['share_images'] = implode('|', $share_images); connect_merge_member(); return tpl_viewthread_share_method() . $extrajs; }