function login($call_back, $url) { global $oauth_verifier, $code, $_K; if (isset($code) && $this->_wb_type == 'sina') { $oauth_verifier = array('code' => $code, 'redirect_uri' => $url); } if ($call_back) { if (isset($code) && $this->_wb_type == 'sina') { if ($oauth_verifier) { oauth_api_factory::create_access_token($oauth_verifier, $this->_wb_type, $this->_app_id, $this->_app_secret); $oauth_user_info = $this->get_login_user_info(); $bind_info = keke_register_class::is_oauth_bind($this->_wb_type, $oauth_user_info['account']); if ($oauth_user_info && $bind_info) { $user_info = kekezu::get_user_info($bind_info['uid']); $login_obj = new keke_user_login_class(); $login_user_info = $login_obj->user_login($user_info['username'], $user_info['password'], null, 1); $login_obj->save_user_info($login_user_info, 1); } else { $_SESSION['wb_type'] = $this->_wb_type; header("Location:{$_K['siteurl']}/index.php?do=index"); die; } } else { header("Location:{$_K['siteurl']}/index.php?do=login"); die; } } else { oauth_api_factory::create_access_token($oauth_verifier, $this->_wb_type, $this->_app_id, $this->_app_secret); $oauth_user_info = $this->get_login_user_info(); $bind_info = keke_register_class::is_oauth_bind($this->_wb_type, $oauth_user_info['account']); if ($oauth_user_info && $bind_info) { $user_info = kekezu::get_user_info($bind_info['uid']); $login_obj = new keke_user_login_class(); $login_user_info = $login_obj->user_login($user_info['username'], $user_info['password'], null, 1); $login_obj->save_user_info($login_user_info, 1); } else { $_SESSION['wb_type'] = $this->_wb_type; header("Location:{$_K['siteurl']}/index.php?do=index"); die; } } } $this->_url = $url; if (oauth_api_factory::get_access_token($this->_wb_type, $this->_app_id, $this->_app_secret)) { return true; } else { $aurl = oauth_api_factory::get_auth_url("{$url}&call_back=1", $this->_wb_type, $this->_app_id, $this->_app_secret); header('Location:' . $aurl); die; } }
} $arrOauthInfo = $_SESSION[$type . '_oauthInfo']; $memberOauthInfo = $arrOauthInfo; if (strtoupper(CHARSET) == 'GBK') { $arrOauthInfo = kekezu::utftogbk($arrOauthInfo); } $objReg = new keke_register_class(); $objLogin = new keke_user_login_class(); $arrBindInfo = keke_register_class::is_oauth_bind($type, $arrOauthInfo['account']); $account = $arrBindInfo['username']; if ($_SESSION[$type . '_oauthInfo'] && $arrBindInfo && !$to_bind) { $_SESSION[$type . '_oauthInfo'] = null; setcookie($type . 'uid', 1, time() - 1); $arrUserInfo = kekezu::get_user_info($arrBindInfo['uid']); $loginUserInfo = $objLogin->oauth_user_login($arrUserInfo['username'], $arrUserInfo['password'], null, 1); $objLogin->save_user_info($loginUserInfo, 1); } elseif ($_SESSION[$type . '_oauthInfo'] && !$arrBindInfo && !$formhash && !$to_bind) { $password = kekezu::randomkeys(6); $account = kekezu::escape($arrOauthInfo['nickname']); $is_nameExist = 1; while ($is_nameExist) { $hasUser = db_factory::get_one("select * from " . TABLEPRE . "witkey_space where username='******'"); if ($hasUser) { $is_nameExist = 1; $code = kekezu::randomkeys(6); $account = $account . $code; } else { $is_nameExist = 0; } } $intRegUid = $objReg->user_register($account, $password, $email, $code, false, $password, 1);
if (in_array($type, array_keys($arrOauthType))) { UserCenter::oauthRoute($type); } kekezu::show_msg('缺少参数', 'index.php?do=login', 3, NULL, 'warning'); } $arrOauthInfo = $_SESSION[$type . '_oauthInfo']; if (strtoupper(CHARSET) == 'GBK') { $arrOauthInfo = kekezu::utftogbk($arrOauthInfo); } $objLogin = new keke_user_login_class(); $arrBindInfo = keke_register_class::is_oauth_bind($type, $arrOauthInfo['account']); if ($_SESSION[$type . '_oauthInfo'] && $arrBindInfo && !$is_binding) { $_SESSION[$type . '_oauthInfo'] = null; $arrUserInfo = kekezu::get_user_info($arrBindInfo['uid']); $loginUserInfo = $objLogin->oauth_user_login($arrUserInfo['username'], $arrUserInfo['password'], null, 1); $objLogin->save_user_info($loginUserInfo, 1); } $inter = $kekezu->_sys_config['user_intergration']; $intLoginTimes = intval($_SESSION['login_times']); if (kekezu::submitcheck(isset($formhash)) || isset($login_type) == 3) { if ($code) { $strCodeCheck = kekezu::check_secode($code); if ($strCodeCheck != 1) { $tips['errors']['code'] = $strCodeCheck; kekezu::show_msg($tips, NULL, NULL, NULL, 'error'); } } $strCode = isset($code) ? $code : ""; $intLoginType = isset($login_type) ? $login_type : ""; $ckb_cookie = isset($ckb_cookie) ? $ckb_cookie : ""; if (strtoupper(CHARSET) == 'GBK') {
$inter = $kekezu->_sys_config['user_intergration']; $intLoginTimes = intval($_SESSION['login_times']); if (kekezu::submitcheck(isset($formhash)) || isset($login_type) == 3) { if ($code) { $strCodeCheck = kekezu::check_secode($code); if ($strCodeCheck != 1) { $tips['errors']['code'] = $strCodeCheck; kekezu::show_msg($tips, NULL, NULL, NULL, 'error'); } } isset($hdn_refer) and $_K['refer'] = $hdn_refer; isset($_COOKIE['kekeloginrefer']) and $_K['refer'] = $_COOKIE['kekeloginrefer']; $refer_do = array('do' => null); $refer = parse_url($_K['refer']); isset($refer['query']) and parse_str($refer['query'], $refer_do); !$refer_do['do'] && ($do = 'logout') and $refer_do['do'] = 'logout'; in_array($refer_do['do'], array('logout', 'register', 'login', 'activating')) and $_K['refer'] = 'index.php' or $_K['refer'] = $_K['refer']; $strCode = isset($code) ? $code : ""; $intLoginType = isset($login_type) ? $login_type : ""; $ckb_cookie = isset($ckb_cookie) ? $ckb_cookie : ""; if (strtoupper(CHARSET) == 'GBK') { $account = kekezu::utftogbk($account); } $account = kekezu::escape($account); $objLogin = new keke_user_login_class(); $arrUserInfo = $objLogin->user_login($account, kekezu::escape($password), $strCode, $intLogin_type); db_factory::execute("update " . TABLEPRE . "witkey_space set is_mail=0 where uid=" . $arrUserInfo[uid]); $objLogin->save_user_info($arrUserInfo, $account, $ckb_cookie, $intLoginType, intval($autoLogin)); die; } $_SESSION['spread'] = 'index.php?do=login';