本文整理汇总了PHP中XWB_plugin::getBindUser方法的典型用法代码示例。如果您正苦于以下问题:PHP XWB_plugin::getBindUser方法的具体用法?PHP XWB_plugin::getBindUser怎么用?PHP XWB_plugin::getBindUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XWB_plugin
的用法示例。
在下文中一共展示了XWB_plugin::getBindUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBindInfo
/**
* 获取当前登录用户状态的绑定信息
* 若当前没有用户登录,则返回false
*
* @param mixed $key 键值。若传入false,则表示返回所有绑定信息
* @param mixed $def 默认值。若没有值返回,则返回该默认值
* @param bool $apiUpdate
* @param bool $turn
*/
function getBindInfo($key = false, $def = null, $apiUpdate = false, $turn = false)
{
static $rst = '-1';
//由于服务器可能返回false或者null,故只能用这个作标识
if (!XWB_S_UID) {
return false;
}
if ($rst === '-1') {
$rst = XWB_plugin::getBindUser(XWB_S_UID, 'site_uid', $apiUpdate, $turn);
//远程API
}
if ($key === false) {
return empty($rst) ? array() : $rst;
} else {
return isset($rst[$key]) ? $rst[$key] : $def;
}
}
示例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';
//.........这里部分代码省略.........
示例3: doReg
function doReg()
{
global $_G;
if (!XWB_plugin::pCfg('is_account_binding') || !XWB_plugin::isRequestBy('POST')) {
XWB_plugin::showError('网站管理员关闭了插件功能“新浪微博绑定”。请稍后再试。');
}
$this->_chkIsWaitingForReg();
$usernameS = trim((string) XWB_plugin::V('p:siteRegName'));
$emailS = trim((string) XWB_plugin::V('p:siteRegEmail'));
$regPwdS = trim((string) XWB_plugin::V('p:regPwd'));
//转换成论坛编码,方便进行UC和论坛的注册数据库操作
$username = XWB_plugin::convertEncoding($usernameS, "UTF8", XWB_S_CHARSET);
$email = XWB_plugin::convertEncoding($emailS, "UTF8", XWB_S_CHARSET);
$password = $regPwdS;
$uid = 0;
if (empty($username)) {
$uid = -102;
}
if (empty($email)) {
$uid = -101;
}
if (empty($password)) {
$uid = -103;
}
if (empty($uid)) {
$wbApi = XWB_plugin::getWB();
$uInfo = $wbApi->verifyCredentials();
//验证微博帐号是否已经在当前站点中绑定,防止用户通过多个浏览器恶意注册用户
$bInfo = XWB_plugin::getBindUser($uInfo['id'], 'sina_uid');
//远程API
if (!empty($bInfo) && is_array($bInfo)) {
$uid = -201;
} else {
$regInstance = XWB_plugin::O('xwbSiteUserRegister');
$uid = $regInstance->reg($username, $email, $password);
}
unset($bInfo);
}
$msg = '';
if ($uid < 1) {
$msg = $this->_getRegTip($uid);
} 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);
if (XWB_plugin::pCfg('is_sync_face')) {
//同步新浪头像(放到脚本结束时进行)
$faceSync = XWB_plugin::N('sinaFaceSync');
register_shutdown_function(array(&$faceSync, 'sync4DX'), $uid);
}
dsetcookie($this->_getBindCookiesName($uid), (string) $uInfo['id'], 604800);
dsetcookie('xwb_tips_type', '', 0);
$sess->setInfo('waiting_site_reg', '0');
$displayWindow = 0;
$msg = "已为你创建了" . XWB_S_TITLE . "论坛的帐号,并与你的新浪微博帐号进行绑定。下次你可以继续使用新浪微博帐号登录使用" . XWB_S_TITLE . "论坛。";
if ($_G['setting']['regverify'] == 1) {
$displayWindow = 1;
$msg .= '<br /><em>你的帐号 ' . htmlspecialchars($usernameS) . ' 处于非激活状态,请收取邮件激活你的帐号</em>' . '<br />如果你没有收到我们发送的系统邮件,请进入个人中心点击“重新验证 Email”或在“密码和安全问题”中更换另外一个 Email 地址。注意:在完成激活之前,根据管理员设置,你将只能以待验证会员的身份访问论坛。';
$msg .= "<br />邮箱: <em>" . htmlspecialchars($emailS) . "</em> ";
} elseif ($_G['setting']['regverify'] == 2 || $_G['setting']['regverify'] == 3) {
$displayWindow = 1;
$msg .= '<br /><em>请等待管理员审核你的帐号 ' . htmlspecialchars($usernameS) . '</em><br />在完成审核之前,根据管理员设置,你将只能以待验证会员的身份访问论坛,你可能不能进行发帖等操作。审核成功后,上述限制将自动取消。';
} else {
$msg .= "<br />帐号: <em>" . htmlspecialchars($usernameS) . "</em> ";
}
//反向绑定统计上报
$sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 2));
//输出UCenter同步JS
loaducenter();
$ucsynlogin = $_G['setting']['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
$this->_outputUJ($ucsynlogin);
}
$this->_oScript('xwbSetTips', array($uid, $msg, $displayWindow));
}
示例4: get_bind_sina_uid_by_cookie_cache
/**
* 用cookies缓存进行当前登录uid的绑定用户查询
* 没有绑定状态cookies,查询后就发送一个cookies
* @return bigint
*/
function get_bind_sina_uid_by_cookie_cache()
{
global $_G;
if (is_numeric($this->_bind_sina_uid)) {
return $this->_bind_sina_uid;
}
$this->_bind_sina_uid = -1;
if ($_G['uid'] < 1) {
return $this->_bind_sina_uid;
}
$bind_status_cookiename = core_sina_xweibo_x2::getBindCookiesName($_G['uid']);
if (!isset($_G['cookie'][$bind_status_cookiename])) {
//echo 'running db check'; //@todo 用于检测cookies是否起作用
if (true === $this->start_xweibo()) {
$bInfo = XWB_plugin::getBindUser($_G['uid'], 'site_uid');
//远程API
if (isset($bInfo['sina_uid']) && $bInfo['sina_uid'] > 0) {
$this->_bind_sina_uid = (string) $bInfo['sina_uid'];
}
} else {
$sina_uid = DB::result_first('SELECT `sina_uid` FROM ' . DB::table('xwb_bind_info') . ' WHERE `uid` = ' . $_G['uid']);
if (is_numeric($sina_uid) && $sina_uid > 0) {
$this->_bind_sina_uid = (string) $sina_uid;
}
}
dsetcookie($bind_status_cookiename, $this->_bind_sina_uid, 604800);
} elseif (is_numeric($_G['cookie'][$bind_status_cookiename]) && $_G['cookie'][$bind_status_cookiename] > 0) {
$this->_bind_sina_uid = (string) $_G['cookie'][$bind_status_cookiename];
}
return $this->_bind_sina_uid;
}