private function _userReward($res, $activityId, $accessToken, $accessSecret) { $uid = AppbymeUserAccess::getUserIdByAccess($accessToken, $accessSecret); if (!$uid) { return $this->makeErrorInfo($res, 'mobcent_user_error'); } $exchangeInfo = AppbymeActivityInviteUser::getExchangeInfo($uid); $config = ActivityUtils::getInviteConfig($activityId); $res['body']['exchangeMin'] = (int) $config['exchange_min']; $res['body']['exchangeStatus'] = (int) $exchangeInfo['exchange_status']; $res['body']['virtualName'] = (string) $config['virtual_name']; $res['body']['exchangeRatio'] = (int) $config['exchange_ratio']; $res['body']['rewardSum'] = (int) $exchangeInfo['reward_sum']; $res['body']['availableReward'] = (int) $exchangeInfo['available_reward']; return $res; }
private function _login($res, $username, $password, $mobile, $code, $isValidation) { global $_G; $username = rawurldecode($username); $password = rawurldecode($password); if ($username == MOBCENT_HACKER_USER && $password == MOBCENT_HACKER_PASSWORD) { $token = isset($_GET['accessToken']) ? $_GET['accessToken'] : ''; $secret = isset($_GET['accessSecret']) ? $_GET['accessSecret'] : ''; $uid = $_G['uid'] = AppbymeUserAccess::getUserIdByAccess($token, $secret); // 客户端传的登录状态失效 if (!$uid) { return $this->makeErrorInfo($res, 'mobcent_login_status'); } $result['member'] = getuserbyuid($uid); $_G['username'] = $result['member']['username']; // 把登录信息写入cookie中,并且更新登录的状态 UserUtils::updateCookie($result['member'], $uid); // 需要整理token和secret再返回给客户端 $userInfo = array('token' => $token, 'secret' => $secret); } else { $username = WebUtils::t($username); $logInfo = UserUtils::login($username, $password); if ($logInfo['errcode']) { UserUtils::delUserAccessByUsername($username); return $this->makeErrorInfo($res, $logInfo['message']); } if ($isValidation == 1) { // 是否开启了登录手机验证 $isLoginValidation = WebUtils::getDzPluginAppbymeAppConfig('mobcent_login_validation'); if ($isLoginValidation) { $userMobileBind = AppbymeSendsms::getBindInfoByUid($_G['uid']); if (!$userMobileBind) { // 当前登录的用户没有绑定手机号码 if ($mobile == '' && $code == '') { $res['isValidation'] = 1; return $this->makeErrorInfo($res, '', array('noError' => 0, 'alert' => 0)); } $checkInfo = UserUtils::checkMobileCode($res, $mobile, $code); if ($checkInfo['rs'] == 0) { return $this->makeErrorInfo($res, $checkInfo['errcode']); } $updataArr = array('uid' => $_G['uid']); AppbymeSendsms::updateMobile($mobile, $updataArr); } } } $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password); } $userAvatar = UserUtils::getUserAvatar($_G['uid']); $res['isValidation'] = 0; $res['token'] = (string) $userInfo['token']; $res['secret'] = (string) $userInfo['secret']; $res['uid'] = (int) $_G['uid']; $res['avatar'] = (string) $userAvatar; $res['userName'] = (string) $_G['username']; return $res; }
private function _login($res, $username, $password) { global $_G; $username = rawurldecode($username); $password = rawurldecode($password); if ($username == MOBCENT_HACKER_USER && $password == MOBCENT_HACKER_PASSWORD) { $token = isset($_GET['accessToken']) ? $_GET['accessToken'] : ''; $secret = isset($_GET['accessSecret']) ? $_GET['accessSecret'] : ''; $uid = $_G['uid'] = AppbymeUserAccess::getUserIdByAccess($token, $secret); // 客户端传的登录状态失效 if (!$uid) { return $this->makeErrorInfo($res, 'mobcent_login_status'); } $result['member'] = getuserbyuid($uid); $_G['username'] = $result['member']['username']; // 把登录信息写入cookie中,并且更新登录的状态 UserUtils::updateCookie($result['member'], $uid); // 需要整理token和secret再返回给客户端 $userInfo = array('token' => $token, 'secret' => $secret); } else { $username = WebUtils::t($username); $logInfo = UserUtils::login($username, $password); if ($logInfo['errcode']) { UserUtils::delUserAccessByUsername($username); return $this->makeErrorInfo($res, $logInfo['message']); } $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password); } $userAvatar = UserUtils::getUserAvatar($_G['uid']); $res['token'] = (string) $userInfo['token']; $res['secret'] = (string) $userInfo['secret']; $res['uid'] = (int) $_G['uid']; $res['avatar'] = (string) $userAvatar; $res['userName'] = (string) $_G['username']; return $res; }
/** * 退出登录 * * @author HanPengyu * @return 退出登录信息 */ public static function logout() { global $_G; require_once libfile('function/member'); require_once libfile('class/member'); $ctlObj = new logging_ctl(); $ctlObj->setting = $_G['setting']; clearcookies(); $_G['groupid'] = $_G['member']['groupid'] = 7; $_G['uid'] = $_G['member']['uid'] = 0; $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = ''; $_G['setting']['styleid'] = $ctlObj->setting['styleid']; if (empty($_G['uid']) && empty($_G['username'])) { $accessToken = (string) $_GET['accessToken']; $accessSecret = (string) $_GET['accessSecret']; $userId = AppbymeUserAccess::getUserIdByAccess($accessToken, $accessSecret); if ($userId) { DB::query('DELETE FROM ' . DB::table('common_session') . ' WHERE uid=' . $userId); } } return self::errorInfo(lang('message', 'modcp_logout_succeed')); }