TShopping

 找回密碼
 註冊
搜索
查看: 2618|回復: 0
打印 上一主題 下一主題

[X2.0] facebook connect 2.3 詳解

  [複製鏈接]
跳轉到指定樓層
1#
發表於 2012-3-25 23:23:27 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook
source\class\class_core.php
找到

  1. 'mobile' => '',
複製代碼
下面加入

  1. 'fbcon' => '',
  2. 'fbsup' => '',
  3. 'fblgl' => '',
複製代碼
  1. $this->var['group'] = array_merge($this->var['group'], $this->var['cache']['admingroup_'.$this->var['member']['adminid']]);
  2. }
複製代碼
下面加上

  1. loadcache('plugin');
  2.   $_G['fbcon'] = $this->var['cache']['plugin']['facebook_connect'];
  3.   $_G['fbsup'] = 'ctY2YubmV0IiB0YXJnZXQ9Il9ibGFuayI+JiMyMTgzOTsmIzM4OTg4OyYjMjIyMzg7JiMyMjU3NzsmIzI1MTEwOyYjMjU1NTI7JiMyMDM3OTsmIzI0MzE0OyYjMzU2OTY7PC9hPg==';
  4. }
  5. function _request_uri() {
  6.   if (isset($_SERVER['REQUEST_URI'])) {
  7.    $uri = $_SERVER['REQUEST_URI'];
  8.   } else {
  9.    if (isset($_SERVER['argv'])) {
  10.     $uri = htmlentities($_SERVER['PHP_SELF']) .'?'. $_SERVER['argv'][0];
  11.    } else {
  12.     $uri = htmlentities($_SERVER['PHP_SELF']) .'?'. $_SERVER['QUERY_STRING'];
  13.    }
  14.   }
  15.   return $uri;
複製代碼
  1. define('TEMPLATEID', $this->var['style']['templateid']);
複製代碼
下面加上
  1. if(!$_G['fbcon']['appid'] || !$_G['fbcon']['secret']) {
  2. $_G['fblgl'] = "javascript:alert('請先到後台設定Facebook Connect插件,輸入正確的FB應用程式ID與密鑰。');";
  3. } else {
  4. require_once './fblib/facebook.php';
  5. $facebook = new Facebook(array('appId'=>$_G['fbcon']['appid'], 'secret'=>$_G['fbcon']['secret']));
  6. $_G['fblgl'] = $facebook->getLoginUrl(array('scope'=>'email,user_likes,publish_stream,offline_access', 'redirect_uri'=>$_G[siteurl].'fblogin.php?act=login&rf='.urlencode('http://'.$_SERVER['HTTP_HOST'].$this->_request_uri())));
  7. }
複製代碼
source\function\function_delete.php
找到
  1. manyoulog('user', $uids, 'delete');
  2. return $numdeleted;
複製代碼
上面加上
  1. DB::query("DELETE FROM ".DB::table('facebook_connect')." WHERE uid IN ($uids)", 'UNBUFFERED');
複製代碼
source\function\function_space.php
找到
  1. global $_G, $space;
複製代碼
換成
  1. global $_G, $space, $sfb, $isfriend;
複製代碼
  1. $html .= "<li class='ul_pm'><a href=\"home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_$space[uid]&touid=$space[uid]&pmid=0&daterange=2\" id=\"a_sendpm_$space[uid]\" onclick=\"showWindow('showMsgBox', this.href, 'get', 0)\">".lang('space', 'block_profile_sendmessage')."</a></li>";
複製代碼
下面加上
  1. if(($sfb['fbid'] && $_G['adminid'] > 0) || ($sfb['fbid'] && $sfb['showfblink'] == 0) || ($sfb['fbid'] && $sfb['showfblink'] == 1 && $isfriend)) {
  2. $html .= "<li><a href=\"http://www.facebook.com/profile.php?id=$sfb[fbid]\" target=\"_blank\" style=\"background-image:url(static/image/facebook_icon.png);\">".lang('space', 'facebook_profile')."</a></li>";
  3. $html .= "<li><a href=\"http://www.facebook.com/addfriend.php?id=$sfb[fbid]\" target=\"_blank\" style=\"background-image:url(static/image/facebook_icon.png);\">".lang('space', 'add_facebook_friend')."</a></li>";
  4. }
複製代碼
source\language\lang_space.php
找到
  1. 'feed_view_only' => '只看此類動態',
複製代碼
下面加上
  1. 'facebook_profile' => '看FB檔案',
  2. 'add_facebook_friend' => '加FB好友',
複製代碼
source\language\lang_template.php
找到

  1. };

  2. ?>
複製代碼
上面加上
  1. 'flogin_title' => '使用Facebook帳戶登入',
複製代碼
source\language\forum\lang_template.php
找到
  1. 'set_cover' => '設為封面',
複製代碼
上面加上
  1. 'facebook_profile' => '查看FB檔案',
  2.   'add_facebook_friend' => '加入FB好友',
  3.   'facebook_send' => '傳送',
  4.   'flogin_title' => '使用Facebook帳戶登入',
複製代碼
source\language\home\lang_template.php
找到
  1. 'view_blog' => '查看日誌',
複製代碼
下面加上
  1. 'facebook_profile' => '看FB檔案',
  2.   'add_facebook_friend' => '加FB好友',
複製代碼
source\module\forum\forum_viewthread.php
找到
  1. mf.medals, mf.sightml AS signature, mf.customstatus, mh.privacy $fieldsadd
複製代碼
換成
  1. mf.medals, mf.sightml AS signature, mf.customstatus, mh.privacy, fc.fbid, fc.showfblink $fieldsadd
複製代碼
找到
  1. LEFT JOIN ".DB::table('common_member_field_home')." mh USING(uid)
複製代碼
下面加上
  1. LEFT JOIN ".DB::table('facebook_connect')." fc USING(uid)
複製代碼
找到
  1. }
  2. }

  3. if($savepostposition && $positionlist) {
複製代碼
上面加上
  1. $ofbcfarr = explode(',', $_G['fbcon']['ofbcfid']);
  2.         if($_G['fbcon']['ofbc'] && !in_array($_G['fid'], $ofbcfarr)) {
  3.                 $_G['hfbcm'] = true;
複製代碼
找到
  1. if(empty($postlist)) {
  2.         showmessage('post_not_found');
  3. } else {
  4.         foreach($postlist as $pid => $post) {
  5.                 $postlist[$pid]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $postlist[$pid]['message']);
  6.         }
  7. }
複製代碼
換成
  1. if(empty($postlist)) {
  2.         showmessage('post_not_found');
  3. } else {
  4.         foreach($postlist as $pid => $post) {
  5.                 $postlist[$pid]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $postlist[$pid]['message']);
  6.                 if($postlist[$pid]['first'] == 1) {
  7.                         $getmsgi = $postlist[$pid]['message'];
  8.                 }
  9.         }
  10.         preg_match_all('/<img.+file=[\'"]([^\'"]+)[\'"].*>/isU', $getmsgi, $iattrsA);
  11.         preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/isU', $getmsgi, $iattrsB);
  12.         if(strpos($iattrsB[1][0], 'fbshare.png') !== FALSE) {
  13.                 $iattrs = $_G['fbcon']['dfimg'];
  14.         } elseif($iattrsA[1][0]) {
  15.                 if(strpos($iattrsA[1][0], "http://") !== FALSE || strpos($iattrsA[1][0], "https://") !== FALSE) {
  16.                         $iattrs = $iattrsA[1][0];
  17.                 } else {
  18.                         $iattrs = $_G['siteurl'].$iattrsA[1][0];
  19.                 }
  20.         } elseif($iattrsB[1][0]) {
  21.                 if(strpos($iattrsB[1][0], "http://") !== FALSE || strpos($iattrsB[1][0], "https://") !== FALSE) {
  22.                         $iattrs = $iattrsB[1][0];
  23.                 } else {
  24.                         $iattrs = $_G['siteurl'].$iattrsB[1][0];
  25.                 }
  26.         } else {
  27.                 $iattrs = $_G['fbcon']['dfimg'];
  28.         }
  29. }
複製代碼
source\module\home\home_space.php
找到
  1. if(empty($space)) {
  2.                 showmessage('space_does_not_exist');
  3.         }
複製代碼
下面加上
  1. $sfb = DB::fetch_first("SELECT fbid,showfblink FROM ".DB::table('facebook_connect')." WHERE uid='$uid' LIMIT 1");
  2.         require_once libfile('function/friend');
  3.         $isfriend = friend_check($uid);
複製代碼
找到
  1. if(empty($space)) {
複製代碼
下面加上
  1. $sfb = DB::fetch_first("SELECT fbid,showfblink FROM ".DB::table('facebook_connect')." WHERE uid='$uid' LIMIT 1");
  2.         require_once libfile('function/friend');
  3.         $isfriend = friend_check($uid);
複製代碼
templates/default/headers_common.htm
  1. <html xmlns="http://www.w3.org/1999/xhtml">
複製代碼
替換成
  1. <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#">
複製代碼
找到
  1. <meta http-equiv="MSThemeCompatible" content="Yes" />
複製代碼
下面加上
  1.         <!--{if $_G['tid']}-->
  2.         <meta property="og:type" content="discuz:thread"/>
  3.         <meta property="og:site_name" content="$_G[setting][bbname]"/>
  4.         <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
  5.         <meta property="og:url" content="$_G[siteurl]thread-{$_G[tid]}-1-1.html"/>
  6.         <!--{else}-->
  7.         <meta property="og:url" content="$_G[siteurl]forum.php?mod=viewthread&tid=$_G[tid]"/>
  8.         <!--{/if}-->
  9.         <meta property="og:title" content="$_G[forum_thread][subject] - $_G[setting][bbname]"/>
  10.         <meta property="og:description" content="{if !empty($metadescription)}{echo htmlspecialchars($metadescription, ENT_QUOTES)}{/if}"/>
  11.         <!--{if $iattrs}-->
  12.         <meta property="og:image" content="$iattrs"/>
  13.         <!--{/if}-->
複製代碼
./template/default/common/ 下的文件
footer.htm
  1. <!--{eval output();}-->
複製代碼
上面加上[code]<div id="fb-root"></div>
<script type="text/javascript">
<!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
var sc=0,scc=0,surl='{$_G[siteurl]}thread-{$_G[tid]}-1-1.html',uqstr='https://api.facebook.com/method/fql.query?format=json&callback=?&query='+encodeURIComponent('SELECT url,share_count FROM link_stat WHERE url="'+surl+'"');
<!--{else}-->
var sc=0,scc=0,surl='{$_G[siteurl]}forum.php?mod=viewthread&tid={$_G[tid]}',uqstr='https://api.facebook.com/method/fql.query?format=json&callback=?&query='+encodeURIComponent('SELECT url,share_count FROM link_stat WHERE url="'+surl+'"');
<!--{/if}-->
window.fbAsyncInit = function() {
        FB.init({appId:'$_G[fbcon][appid]', status:true, cookie:true, xfbml:true, channelUrl:'{$_G[siteurl]}channel.html'});
};
(function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/zh_CN/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
        <!--{if $_G['tid']}-->
        var f = document.createElement('script');
        f.src = 'prikey.php?i='+HASH+'&j={$_G[hlike]}&k={$_G

 

臉書網友討論
*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-4-26 03:21 , Processed in 0.085769 second(s), 18 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表