當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XWB_plugin::addBindUser方法代碼示例

本文整理匯總了PHP中XWB_plugin::addBindUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP XWB_plugin::addBindUser方法的具體用法?PHP XWB_plugin::addBindUser怎麽用?PHP XWB_plugin::addBindUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XWB_plugin的用法示例。


在下文中一共展示了XWB_plugin::addBindUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doBindAtNotLog

 /**
  * 在未登錄論壇帳號,但已登錄新浪微博帳號的綁定頁麵進行用戶賬戶驗證和綁定
  */
 function doBindAtNotLog()
 {
     if (!XWB_plugin::pCfg('is_account_binding') || !XWB_plugin::isRequestBy('POST')) {
         XWB_plugin::showError('網站管理員關閉了插件功能“新浪微博綁定”。請稍後再試。');
     }
     $this->_chkIsWaitingForReg();
     $usernameS = trim((string) XWB_plugin::V('p:siteBindName'));
     $password = trim((string) XWB_plugin::V('p:bindPwd'));
     $questionid = (int) XWB_plugin::V('p:questionid');
     $questionanswerS = trim((string) XWB_plugin::V('p:questionanswer'));
     $username = XWB_plugin::convertEncoding($usernameS, "UTF8", XWB_S_CHARSET);
     if (!empty($questionanswerS)) {
         $questionanswer = XWB_plugin::convertEncoding($questionanswerS, "UTF8", XWB_S_CHARSET);
     } else {
         $questionanswer = '';
     }
     $uid = 0;
     //第1關:數據輸入驗證關
     if (empty($username)) {
         $uid = -102;
     }
     if (empty($password)) {
         $uid = -103;
     }
     $msg = '';
     //第2關:用戶身份驗證關
     if ($uid == 0) {
         $verify = XWB_plugin::O('siteUserVerifier');
         $verifyresult = $verify->verify($username, $password, $questionid, $questionanswer);
         $uid = $verifyresult[0];
     }
     if ($uid > 0) {
         $wbApi = XWB_plugin::getWB();
         $uInfo = $wbApi->verifyCredentials();
         //第3關:驗證微博帳號是否已經在當前站點中綁定,防止用戶通過多個瀏覽器惡意注冊用戶
         $bInfo = XWB_plugin::getBUById($uid, $uInfo['id']);
         //遠程API
         if (!empty($bInfo) && is_array($bInfo)) {
             $uid = -201;
         } else {
             $sess = XWB_plugin::getUser();
             $sess->setInfo('sina_uid', $uInfo['id']);
             $last_key = $sess->getOAuthKey(true);
             $rst = XWB_plugin::addBindUser($uid, $uInfo['id'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
             //遠程API
             require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
             xwb_setSiteUserLogin($uid);
             dsetcookie($this->_getBindCookiesName($uid), (string) $uInfo['id'], 604800);
             dsetcookie('xwb_tips_type', '', 0);
             $sess->setInfo('waiting_site_reg', '0');
             $msg = "綁定論壇帳號成功。下次你可以繼續使用新浪微博帳號登錄使用" . XWB_S_TITLE . "論壇。";
             $msg .= "<br>綁定帳號:  <em>" . htmlspecialchars($usernameS) . "</em>  ";
             //正向綁定(在未登錄論壇帳號已登錄新浪微博帳號的綁定頁麵)統計上報
             $sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
             //輸出UCenter同步JS
             global $_G;
             loaducenter();
             $ucsynlogin = $_G['setting']['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
             $this->_outputUJ($ucsynlogin);
         }
     }
     if ($uid <= 0) {
         $msg = $this->_getBindTip($uid);
     }
     $displayWindow = 0;
     $this->_oScript('xwbSetTips', array($uid, $msg, $displayWindow));
 }
開發者ID:chibimiku,項目名稱:xweibo_for_discuz_x2_php7,代碼行數:70,代碼來源:xwbSiteInterface.mod.php

示例2: authCallBack

 function authCallBack()
 {
     if (!XWB_plugin::pCfg('is_account_binding')) {
         XWB_plugin::showError('網站管理員關閉了插件功能“新浪微博綁定”。請稍後再試。');
     }
     //--------------------------------------------------------------------
     global $_G;
     $sess = XWB_plugin::getUser();
     $waiting_site_bind = $sess->getInfo('waiting_site_bind');
     if (empty($waiting_site_bind)) {
         //XWB_plugin::deny();
         $siteUrl = XWB_plugin::siteUrl(0);
         XWB_plugin::redirect($siteUrl, 3);
     }
     $sess->setOAuthKey(array(), true);
     //--------------------------------------------------------------------
     $wbApi = XWB_plugin::getWB();
     $db = XWB_plugin::getDB();
     $last_key = $wbApi->getAccessToken(XWB_plugin::V('r:oauth_verifier'));
     //print_r($last_key);
     if (!isset($last_key['oauth_token']) || !isset($last_key['oauth_token_secret'])) {
         $api_error_origin = isset($last_key['error']) ? $last_key['error'] : 'UNKNOWN ERROR. MAYBE SERVER CAN NOT CONNECT TO SINA API SERVER';
         $api_error = isset($last_key['error_CN']) && !empty($last_key['error_CN']) && 'null' != $last_key['error_CN'] ? $last_key['error_CN'] : '';
         XWB_plugin::LOG("[WEIBO CLASS]\t[ERROR]\t#{$wbApi->req_error_count}\t{$api_error}\t{$wbApi->last_req_url}\tERROR ARRAY:\r\n" . print_r($last_key, 1));
         XWB_plugin::showError("服務器獲取Access Token失敗;請稍候再試。<br />錯誤原因:{$api_error}[{$api_error_origin}]");
     }
     $sess->setOAuthKey($last_key, true);
     $wbApi->setConfig();
     $uInfo = $wbApi->verifyCredentials();
     $sess->setInfo('sina_uid', $uInfo['id']);
     $sess->setInfo('sina_name', $uInfo['screen_name']);
     //print_r($uInfo);
     //--------------------------------------------------------------------
     /// 此帳號是否已經在當前站點中綁定
     $sinaHasBinded = false;
     $stat_is_bind_type = 0;
     if (defined('XWB_S_UID') && XWB_S_UID > 0) {
         $bInfo = XWB_plugin::getBUById(XWB_S_UID, $uInfo['id']);
     } else {
         $bInfo = XWB_plugin::getBindUser($uInfo['id'], 'sina_uid');
         //遠程API
     }
     if (!is_array($bInfo) && (defined('XWB_S_UID') && XWB_S_UID > 0)) {
         $bInfo = XWB_plugin::getBindUser(XWB_S_UID, 'site_uid');
         //登錄狀態下再查一次API,確保沒有綁定
     }
     if (!empty($bInfo) && is_array($bInfo)) {
         $sinaHasBinded = true;
         dsetcookie($this->_getBindCookiesName($bInfo['uid']), (string) $bInfo['sina_uid'], 604800);
         //核查存儲的access token是否有更新,有更新則進行自動更新
         if ($bInfo['sina_uid'] == $uInfo['id'] && ($bInfo['token'] != $last_key['oauth_token'] || $bInfo['tsecret'] != $last_key['oauth_token_secret'])) {
             XWB_plugin::updateBindUser($bInfo['uid'], $bInfo['sina_uid'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
             //遠程API
         }
     }
     //--------------------------------------------------------------------
     /// 決定在首頁中顯示什麽浮層
     $tipsType = '';
     //xwb_tips_type
     //已在論壇登錄
     if (defined('XWB_S_UID') && XWB_S_UID) {
         if ($sinaHasBinded) {
             //$sinaHasBinded為true時,$bInfo必定存在
             if (XWB_S_UID != $bInfo['uid'] || $bInfo['sina_uid'] != $uInfo['id']) {
                 $tipsType = 'hasBinded';
                 $sess->clearToken();
             } else {
                 $tipsType = 'autoLogin';
             }
         } else {
             //遠程API
             $rst = XWB_plugin::addBindUser(XWB_S_UID, $uInfo['id'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
             if (!$rst) {
                 echo "DB ERROR";
                 exit;
                 return false;
             }
             $tipsType = 'bind';
             dsetcookie($this->_getBindCookiesName(XWB_S_UID), (string) $uInfo['id'], 604800);
             //正向綁定統計上報
             $sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
         }
     } else {
         //從 wb 登錄後 檢查用戶是否綁定,如果綁定了 則在附屬站點自
         if ($sinaHasBinded) {
             require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
             $result = xwb_setSiteUserLogin((int) $bInfo['uid']);
             if (false == $result) {
                 dsetcookie($this->_getBindCookiesName($bInfo['uid']), -1, 604800);
                 XWB_plugin::delBindUser($bInfo['uid']);
                 //遠程API
                 $tipsType = 'siteuserNotExist';
             } else {
                 $stat_is_bind_type = 1;
                 $tipsType = 'autoLogin';
             }
         } else {
             //已登錄WB,沒有附屬站點的帳號 引導注冊
             $sess->setInfo('waiting_site_reg', '1');
             $tipsType = 'reg';
//.........這裏部分代碼省略.........
開發者ID:Jaedeok-seol,項目名稱:discuz_template,代碼行數:101,代碼來源:xwbAuth.mod.php


注:本文中的XWB_plugin::addBindUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。