iothk 發表於 2020-9-6 15:33:44

Discuz X Facebook Connect

本文章最後由 iothk 於 2020-9-6 04:57 PM 編輯

forum.php

'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum'),
替換成
'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum', 'plugin'),

'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum'),
替換成
'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum', 'plugin'),

'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum'),
      'redirect'      => array('threadtableids', 'threadtable_info', 'posttable_info'),
替換成
'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum', 'plugin'),
      'redirect'      => array('threadtableids', 'threadtable_info', 'posttable_info', 'plugin'),

'domainwhitelist'),
      'space'                => array('fields_required', 'fields_optional', 'custominfo'),
      'group'                => array('grouptype', 'diytemplatenamegroup'),
替換成
'domainwhitelist', 'plugin'),
      'space'                => array('fields_required', 'fields_optional', 'custominfo', 'plugin'),
      'group'                => array('grouptype', 'diytemplatenamegroup', 'plugin'),

group.php

$cachelist = array('grouptype', 'groupindex', 'diytemplatenamegroup');
替換成
$cachelist = array('grouptype', 'groupindex', 'diytemplatenamegroup', 'plugin');
home.php

$cachelist = array('magic','userapp','usergroups', 'diytemplatenamehome');
替換成
$cachelist = array('magic','userapp','usergroups', 'diytemplatenamehome', 'plugin');
misc.php

'ranklist' => array('forums', 'diytemplatename'),
替換成
'ranklist' => array('forums', 'diytemplatename', 'plugin'),
portal.php

$cachelist = array('userapp', 'portalcategory', 'diytemplatenameportal');
替換成
$cachelist = array('userapp', 'portalcategory', 'diytemplatenameportal', 'plugin');
./source/class 下的文件
class_core.php

$_G['PHP_SELF'] = htmlspecialchars($this->_get_script_url());
替換成
$_G['PHP_SELF'] = htmlspecialchars($_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['PHP_SELF']);

$this->var['config']['cookie']['cookiepre'] = $this->var['config']['cookie']['cookiepre'].substr(md5($this->var['config']['cookie']['cookiepath'].'|'.$this->var['config']['cookie']['cookiedomain']), 0, 4).'_';
下面加上
$this->var['authkey'] = md5($_config['security']['authkey'].$_SERVER['HTTP_USER_AGENT']);

} elseif((!defined('ALLOWGUEST') || !ALLOWGUEST) && !in_array(CURSCRIPT, array('member', 'api')) && !$this->var['inajax']) {
替換成
} elseif((!defined('ALLOWGUEST') || !ALLOWGUEST) && !in_array(CURSCRIPT, array('member', 'api')) && !$this->var['inajax'] && !$_GET['act']) {
class_member.php

function logging_ctl() {
下面加上
loadcache(array('plugin'));

loadcache(array('modreasons', 'stamptypeid', 'fields_required', 'fields_optional', 'fields_register', 'ipctrl'));

替換成
loadcache(array('modreasons', 'stamptypeid', 'fields_required', 'fields_optional', 'fields_register', 'ipctrl', 'plugin'));
./source/function/ 下的文件
function_delete.php

DB::query("DELETE FROM ".DB::table('common_mailcron').", ".DB::table('common_mailqueue')." USING ".DB::table('common_mailcron').", ".DB::table('common_mailqueue')." WHERE ".DB::table('common_mailcron').".touid IN ($uids) AND ".DB::table('common_mailcron').".cid=".DB::table('common_mailqueue').".cid", 'UNBUFFERED');

下面加上
DB::query("DELETE FROM ".DB::table('facebook_connect')." WHERE uid IN ($uids)", 'UNBUFFERED');
function_space.php

global $_G, $space;
替換成
global $_G, $space, $sfb, $isfriend;


$html .= "<li class='ul_pm'><a href=\"home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_$space&touid=$space&pmid=0&daterange=2\" id=\"a_sendpm_$space\" onclick=\"showWindow('showMsgBox', this.href, 'get', 0)\">".lang('space', 'block_profile_sendmessage')."</a></li>";
下面加上
if(($sfb && $_G['adminid'] > 0) || ($sfb && $sfb == 0) || ($sfb && $sfb == 1 && $isfriend)) {
                                        $html .= "<li><a href=\"http://www.facebook.com/profile.php?id=$sfb\" target=\"_blank\" style=\"background-image:url(static/image/facebook_icon.png);\">".lang('space', 'facebook_profile')."</a></li>";
                                        $html .= "<li><a href=\"http://www.facebook.com/addfriend.php?id=$sfb\" target=\"_blank\" style=\"background-image:url(static/image/facebook_icon.png);\">".lang('space', 'add_facebook_friend')."</a></li>";}


https://iothk.co/static/image/facebook_icon3.png
https://iothk.co/static/image/facebook_iconb.png

                              
./source/language/ 下面文件
lang_message.php

'post_hide_nopermission' => '抱歉,您沒有權限使用 代碼',
下面加上
'post_like_nopermission' => '對不起,你沒有權限使用 代碼,請返回修改。',
'post_like_dontinreply' => '對不起,回帖不可使用 代碼,請返回修改。',
'facebook_not_yet_like' => '您還未點讚,請返回。',
'facebook_not_yet_comm' => '您還未於本帖的Facebook留言版上留言 (請使用FB帳戶進行留言),請返回。',
lang_space.php

'facebook_profile' => '看FB檔案',
      'add_facebook_friend' => '加FB好友',

./source/language/forum/ 下的文件
lang_template.php

'post_hide_reply_hidden' => ',如果您要查看本帖隱藏內容請<a href="forum.php?mod=post&action=reply&fid=$_G&tid=$_G">回復</a>',
換成
'post_hide_reply_hidden' => ',如果您要查看本帖隱藏內容請<a href="forum.php?mod=post&action=reply&fid=$_G&tid=$_G">回覆</a>',
'post_hide_reply_like_hidden' => ',如果你要查看本帖隱藏內容請 <a href="forum.php?mod=post&action=reply&fid=$_G&tid=$_G">回覆</a> 或 <b>點讚</b>:',
'post_hide_like_hidden' => ',如果你要查看本帖隱藏內容請<b>點讚</b>:',
'first_login' => '請先登入會員:',
'facebook_profile' => '查看FB檔案',
'add_facebook_friend' => '加入FB好友',
'facebook_send' => '傳送',
'facebook_invite_friend_add' => '邀請朋友加入',
'facebook_invite_friend_addmsg' => '我在 [ {$_G} ] 加入會員了!誠摯邀請您一同加入!',
'facebook_already_like' => '[ 若您已點過讚,請點此重新檢查 ]',
'facebook_already_comm' => '[ 已在FB版留言?請點此重新檢查 ]',
'facebook_already_like_t' => '因為您目前並無登入本論壇,所以必須手動檢查您是否已點過讚。',
'facebook_already_comm_t' => '因為您目前並無登入本論壇,所以必須手動檢查您是否已在本帖的Facebook留言版上留言 (請使用FB帳戶進行留言)。',

'facebook_profile' => '看FB檔案',
'add_facebook_friend' => '加FB好友',
./source/module/forum/ 下的文件
forum_viewthread.php

LEFT JOIN ".DB::table('facebook_connect')." fc USING(uid)


require_once libfile('function/friend');

$postlist[$pid] = viewthread_procpost($post, $_G['member']['lastvisit'], $ordertype);
下面加上
if($postlist[$pid]['first'] == 1) {
                        $getmsgi = $postlist[$pid]['message'];
                }
      }
      preg_match_all('/<img.+file=[\'"]([^\'"]+)[\'"].*>/i', $getmsgi, $iattrsA);
      preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $getmsgi, $iattrsB);
      if($iattrsA) {
                $iattrs = $_G.$iattrsA;
      } elseif($iattrsB) {
                if(stristr($iattrsB, "http://")) {
                        $iattrs = $iattrsB;
                } else {
                        $iattrs = $_G.$iattrsB;
                }
      } else {
                $iattrs = $_G['cache']['plugin']['facebook_connect']['dfimg'];
./source/module/home/ 下的文件
home_space.php

<meta http-equiv="MSThemeCompatible" content="Yes" />
下面加上

<!--{if $_G}-->
      <meta property="og:type" content="discuz:thread"/>
      <meta property="og:site_name" content="$_G['setting']['bbname']"/>
      <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
      <meta property="og:url" content="$_Gthread-{$_G}-1-1.html"/>
      <!--{else}-->
      <meta property="og:url" content="$_Gforum.php?mod=viewthread&tid=$_G"/>
      <!--{/if}-->
      <meta property="og:title" content="$_G - $_G['setting']['bbname']"/>
      <meta property="og:description" content="{if !empty($metadescription)}{echo htmlspecialchars($metadescription)}{/if}"/>
      <!--{if $iattrs}-->
      <meta property="og:image" content="$iattrs"/>
      <!--{/if}-->
      <meta property="fb:app_id" content="$_G['cache']['plugin']['facebook_connect']['appid']"/>
      <!--{/if}-->
./template/default/common/ 下的文件
footer.htm

<!--{eval userappprompt();}-->
<!--{if $_G['basescript'] != 'userapp'}-->
<span id="scrolltop">{lang scrolltop}</span>
<script type="text/javascript">_attachEvent(window, 'scroll', function(){showTopLink();});</script>
<!--{/if}-->
下面加上
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
      FB.init({appId:'$_G['cache']['plugin']['facebook_connect']['appid']', status:true, cookie:true, xfbml:true, channelUrl:'{$_G}channel.html'});
<!--{if $_G}-->
      <!--{if $_G['like'] == 'no'}-->
      FB.Event.subscribe('edge.create', function() {
                location.replace('forum.php?mod=viewthread&tid={$_G}&page={$_G}&todo=like');
      });
      <!--{if $_G['fbc'] && $_G['cache']['plugin']['facebook_ltv']['fctv']}-->
      FB.Event.subscribe('comment.create', function() {
                location.replace('forum.php?mod=viewthread&tid={$_G}&page={$_G}&todo=fcomm');
      });
      <!--{/if}-->
      <!--{/if}-->
      FB.Event.subscribe('edge.remove', function() {
                fbshare();
      });
      <!--{if $_G['like'] && $_G['fbc'] && $_G['cache']['plugin']['facebook_ltv']['fctv']}-->
      FB.Event.subscribe('comment.remove', function() {
                location.replace('forum.php?mod=viewthread&tid={$_G}&page={$_G}&todo=unfcomm');
      });
      <!--{/if}-->
<!--{/if}-->
};
(function() {
      var e = document.createElement('script');
      e.src = document.location.protocol + '//connect.facebook.net/zh_TW/all.js';
      e.async = true;
      document.getElementById('fb-root').appendChild(e);
}());
<!--{if $_G}-->
function fbshare() {
      FB.ui({
                method: 'feed',
                name: '$_G',
                <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
                link: '$_Gthread-{$_G}-1-1.html',
                <!--{else}-->
                link: '$_Gforum.php?mod=viewthread&tid=$_G',
                <!--{/if}-->
                <!--{if $iattrs}-->
                picture: '$iattrs',
                <!--{/if}-->
                caption: '$_G['setting']['bbname']',
                description: '{if !empty($metadescription)}{echo htmlspecialchars($metadescription)}{/if}',
                message: ''
      }, function(response) {
                <!--{if $_G['like']}-->
                if (response && response.post_id) {
                        location.replace('forum.php?mod=viewthread&tid={$_G}&page={$_G}&todo=unlike');
                } else {
                        location.replace('forum.php?mod=viewthread&tid={$_G}&page={$_G}&todo=unlike');
                }
                <!--{/if}-->
      });
}
function fbsend() {
      FB.ui({
                method: 'send',
                app_id: '$_G['cache']['plugin']['facebook_connect']['appid']',
                name: '$_G',
                <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
                link: '$_Gthread-{$_G}-1-1.html',
                <!--{else}-->
                link: '$_Gforum.php?mod=viewthread&tid=$_G',
                <!--{/if}-->
                <!--{if $iattrs}-->
                picture: '$iattrs',
                <!--{/if}-->
                description: '{if !empty($metadescription)}{echo htmlspecialchars($metadescription)}{/if}'
      });
}
function fbinvite() {
      FB.ui({
                method: 'apprequests',
                message: '{lang facebook_invite_friend_addmsg}',
                filters: "['app_non_users']",
                title: '{lang facebook_invite_friend_add} {$_G['setting']['bbname']}'
      });
}
<!--{/if}-->
function fblogin() {
      FB.login(function(response) {
                if (response.session) {
                        if (response.perms) {
                              location.replace('fblogin.php?act=logging&rf='+urlencode(location.href));
                        } else {
                              location.replace('index.php');
                        }
                } else {
                        location.replace('index.php');
                }
      }, {perms:'email,user_likes,publish_stream'});
}
function urlencode(str) {
      var output = '', x = 0, regex = /(^*)/;
      str = str.toString();
      while (x < str.length) {
                var match = regex.exec(str.substr(x));
                if (match != null && match.length > 1 && match != '') {
                        output += match;
                        x += match.length;
                } else {
                        if (str == ' ') {
                              output += '+';
                        } else {
                              var charCode = str.charCodeAt(x), hexVal = charCode.toString(16);
                              output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
                        }
                        x++;
                }
      }
      return output;
}
</script>

header_common.htm

<html xmlns="http://www.w3.org/1999/xhtml">
替換成
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml" xmlns:discuz="http://www.discuz.net/ns#">

<meta http-equiv="MSThemeCompatible" content="Yes" />
下面加上
<!--{if $_G}-->
      <meta property="og:type" content="discuz:thread"/>
      <meta property="og:site_name" content="$_G['setting']['bbname']"/>
      <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
      <meta property="og:url" content="$_Gthread-{$_G}-1-1.html"/>
      <!--{else}-->
      <meta property="og:url" content="$_Gforum.php?mod=viewthread&tid=$_G"/>
      <!--{/if}-->
      <meta property="og:title" content="$_G - $_G['setting']['bbname']"/>
      <meta property="og:description" content="{if !empty($metadescription)}{echo htmlspecialchars($metadescription)}{/if}"/>
      <!--{if $iattrs}-->
      <meta property="og:image" content="$iattrs"/>
      <!--{/if}-->
      <meta property="fb:app_id" content="$_G['cache']['plugin']['facebook_connect']['appid']"/>
      <!--{/if}-->
./template/default/forum/ 下的文件
forumdisplay_fastpost.htm

<div class="pt hm">{lang login_to_post} <a href="member.php?mod=logging&action=login" class="xi2">{lang login}</a> | <a href="member.php?mod={$_G}" class="xi2">$_G['setting']['reglinkname']</a> <!--{hook/global_login_text}--></div>
換成

<div class="pt hm">{lang login_to_post} <a href="member.php?mod=logging&action=login" class="xi2">{lang login}</a> | <a href="member.php?mod={$_G}" class="xi2">$_G['setting']['reglinkname']</a> | <a href="javascript:;"><img src="static/image/facebook_icon3.png" style="margin-bottom:-5px;"></a> <!--{hook/global_login_text}--></div>
viewthread.htm

<div id="post_$post">
                              <!--{subtemplate forum/viewthread_node}-->
                        </div>
下面加入
<!--{if $post['first'] && $_G['fbc']}-->
                              <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
                                        <div id="fbcomm_$post" style="text-align:right;"><fb:comments href="{$_G}thread-{$_G}-1-1.html" num_posts="10" width="960"></fb:comments>
                                        <div style="line-height:5px;background:{$_G};"> </div></div>
                              <!--{else}-->
                                        <div id="fbcomm_$post" style="text-align:right;"><fb:comments href="{$_G}forum.php?mod=viewthread&tid={$_G}" num_posts="10" width="960"></fb:comments>
                                        <div style="line-height:5px;background:{$_G};"> </div></div>
                              <!--{/if}-->
                        <!--{/if}-->
viewthread_fastpost.htm

<div class="pt hm">{lang login_to_reply} <a href="member.php?mod=logging&action=login" class="xi2">{lang login}</a> | <a href="member.php?mod={$_G}" class="xi2">$_G['setting']['reglinkname']</a> <!--{hook/global_login_text}--></div>
換成

<div class="pt hm">{lang login_to_reply} <a href="member.php?mod=logging&action=login" class="xi2">{lang login}</a> | <a href="member.php?mod={$_G}" class="xi2">$_G['setting']['reglinkname']</a> | <a href="javascript:;"><img src="static/image/facebook_icon3.png" style="margin-bottom:-5px;"></a> <!--{hook/global_login_text}--></div>
viewthread_node.htm

<li class="pm2"><a href="home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_$post&touid=$post&pmid=0&daterange=2&pid=$post&tid=$post" title="{lang viewthread_left_sendpm}" class="xi2">{lang viewthread_left_sendpm}</a></li>
下面加上
<!--{if ($post && $_G['forum']['ismoderator']) || ($post && $post == 0) || ($post && $post == 1 && $isfriend[$post])}-->
                                                <li style="background-image:url(static/image/facebook_icon.png);"><a href="http://www.facebook.com/profile.php?id=$post" target="_blank">{lang facebook_profile}</a></li>
                                                <li style="background-image:url(static/image/facebook_icon.png);"><a href="http://www.facebook.com/addfriend.php?id=$post" target="_blank">{lang add_facebook_friend}</a></li>
                                        <!--{/if}-->

<tr><td class="plc plm">
下面加上

<!--{if $post['first']}--><div style="line-height:40px;"><!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}--><fb:like href="$_Gthread-{$_G}-1-1.html" show_faces="false" send="true" width="450"></fb:like><!--{else}--><fb:like href="$_Gforum.php?mod=viewthread&tid=$_G" show_faces="false" send="true" width="450"></fb:like><!--{/if}--></div><!--{/if}-->

<!--{if $post['first'] && $_G && $_G == $post}-->
                              <a href="misc.php?mod=invite&action=thread&id=$_G"><i><img src="{IMGDIR}/activitysmall.gif" alt="{lang invite}" />{lang invite}</i></a>
                        <!--{/if}-->
下面加上
<a href="javascript:;"><i><img src="static/image/facebook_icon2.png" style="margin-right:5px;">{lang thread_share}</i></a>
                        <a href="javascript:;"><i><img src="static/image/facebook_icon2.png" style="margin-right:5px;">{lang facebook_send}</i></a>
                        <a href="javascript:;"><i><img src="static/image/facebook_icon2.png" style="margin-right:5px;">{lang invite}</i></a>
viewthread_node_body.htm

<div class="{if !$_G}t_fsz{else}pcbs{/if}">
                <!--{if $post['first']}-->
下面加上
<div style="line-height:40px;"><!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}--><fb:like href="$_Gthread-{$_G}-1-1.html" show_faces="false" send="true" width="450"></fb:like><!--{else}--><fb:like href="$_Gforum.php?mod=viewthread&tid=$_G" show_faces="false" send="true" width="450"></fb:like><!--{/if}--></div>
./template/default/home/ 下的文件
space_userabout.htm

<li class="ul_pm"><a href="home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_$space&touid=$space&pmid=0&daterange=2" id="a_sendpm_$space">{lang send_pm}</a></li>
下面加入

<!--{if ($sfb && $_G['adminid'] > 0) || ($sfb && $sfb == 0) || ($sfb && $sfb == 1 && $isfriend)}-->
                                        <li><a href="http://www.facebook.com/profile.php?id=$sfb" target="_blank" style="background-image:url(static/image/facebook_icon.png);">{lang facebook_profile}</a></li>
                                        <li><a href="http://www.facebook.com/addfriend.php?id=$sfb" target="_blank" style="background-image:url(static/image/facebook_icon.png);">{lang add_facebook_friend}</a></li>
                              <!--{/if}-->
./template/default/member/ 下的檔案
login.htm

<td>
                                                                <button class="pn pnc" type="submit" name="loginsubmit" value="true" tabindex="1"><strong>{lang login}</strong></button>
                                                      </td>
下面加上
<td><b>Facebook</b> <a href="javascript:;"><img src="static/image/facebook_icon3.png" style="margin-bottom:-5px;"></a></td>
login_simple.htm

<td class="fastlg_l"><label for="ls_cookietime"><input type="checkbox" name="cookietime" id="ls_cookietime" class="pc" value="2592000" tabindex="903" />{lang login_permanent}</label></td>
下面加上
<td class="fastlg_l" rowspan="2"><a href="javascript:;"><img src="static/image/facebook_iconb.png"></a></td>
register.htm

<td><!--{if $this->setting['sitemessage']}--><a href="javascript:;" id="custominfo_register" class="y"><img src="{IMGDIR}/info_small.gif" alt="{lang faq}" /></a><!--{/if}--></td>
下面加入
<td><b>Facebook</b> <a href="javascript:;"><img src="static/image/facebook_icon3.png" style="margin-bottom:-5px;"></a></td>
1. 修改風格檔 footer.htm:

找到FB.init({appId:'$_G['cache']['plugin']['facebook_connect']['appid']', status:true, cookie:true, xfbml:true, channelUrl:'{$_G}channel.html'});替換為FB.init({appId:'$_G',channelURL:'{$_G}channel.html',status:true,cookie:true,oauth:true,xfbml:true});找到function fblogin() {
      FB.login(function(response) {
                if (response.session) {
                        if (response.perms) {
                              location.replace('fblogin.php?act=logging&rf='+urlencode(location.href));
                        } else {
                              location.replace('index.php');
                        }
                } else {
                        location.replace('index.php');
                }
      }, {perms:'email,user_likes,publish_stream'});
}
替換為function fblogin() {
      FB.login(function(response) {
                if (response.authResponse) {
                        location.replace('fblogin.php?act=logging&rf='+urlencode(location.href));
                } else {
                        location.replace('index.php');
                }
      }, {scope:'email,user_likes,publish_stream'});
}最後儲存上傳覆蓋,後台更新緩存即可,此修改可以暫時解決FB無法正常登入問題,其餘請等待下次完整更新插件發佈。
頁: [1]
檢視完整版本: Discuz X Facebook Connect