Example #1
2
 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;
 }
Example #2
0
 private function _register($res, $username, $password, $email, $mobile, $code, $isValidation)
 {
     if ($isValidation) {
         // 是否开启注册手机验证
         $isRegisterValidation = WebUtils::getDzPluginAppbymeAppConfig('mobcent_register_validation');
         if ($isRegisterValidation) {
             $checkInfo = UserUtils::checkMobileCode($res, $mobile, $code);
             if ($checkInfo['rs'] == 0) {
                 return $this->makeErrorInfo($res, $checkInfo['errcode']);
             }
         }
     }
     $regInfo = UserUtils::register($username, $password, $email);
     if ($regInfo['errcode']) {
         return $this->makeErrorInfo($res, $regInfo['message']);
     }
     if ($isValidation) {
         if ($isRegisterValidation) {
             // 注册完毕之后更新手机验证信息
             $updataArr = array('uid' => $regInfo['info']['uid']);
             AppbymeSendsms::updateMobile($mobile, $updataArr);
         }
     }
     $userInfo = AppbymeUserAccess::registerProcess($regInfo['info']['uid'], $password);
     $res['token'] = (string) $userInfo['token'];
     $res['secret'] = (string) $userInfo['secret'];
     $res['uid'] = (int) $regInfo['info']['uid'];
     return $res;
 }
 private function _updatePass($res, $oldpassword, $newpassword)
 {
     global $_G;
     $oldpassword = $oldpassword ? urldecode($oldpassword) : '';
     $newpassword = $newpassword ? urldecode($newpassword) : '';
     if (!empty($newpassword) && $newpassword != addslashes($newpassword)) {
         // 抱歉,密码空或包含非法字符:新密码
         return $this->makeErrorInfo($res, lang('message', 'profile_passwd_illegal'));
     }
     loaducenter();
     $ucresult = uc_user_edit(addslashes($_G['username']), $oldpassword, $newpassword);
     if ($ucresult == -1) {
         // 原密码不正确,您不能修改密码或 Email 或安全提问
         return $this->makeErrorInfo($res, lang('message', 'profile_passwd_wrong'));
     }
     $setarr['password'] = md5(random(10));
     C::t('common_member')->update($_G['uid'], $setarr);
     $secretStr = AppbymeUserAccess::getSecretStr($_G['uid'], $newpassword);
     $newAccessSecret = $secretStr['accessSecret'];
     $data = array('user_access_secret' => $newAccessSecret);
     $result = AppbymeUserAccess::updateUserAccess($data, $_G['uid']);
     // if (!$result) {
     //     return $this->makeErrorInfo($res, 'user_info_edit_error');
     // }
     $res['token'] = $secretStr['accessToken'];
     $res['secret'] = $newAccessSecret;
     return $res;
 }
Example #4
0
 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 _register($res, $username, $password, $email)
 {
     $regInfo = UserUtils::register($username, $password, $email);
     if ($regInfo['errcode']) {
         return $this->makeErrorInfo($res, $regInfo['message']);
     }
     $userInfo = AppbymeUserAccess::registerProcess($regInfo['info']['uid'], $password);
     $res['token'] = (string) $userInfo['token'];
     $res['secret'] = (string) $userInfo['secret'];
     $res['uid'] = (int) $regInfo['info']['uid'];
     return $res;
 }
Example #6
0
 private function _switchVest($res, $username)
 {
     global $_G;
     $username = WebUtils::t(rawurldecode($username));
     $_GET['username'] = $username;
     $myrepeatsusergroups = (array) dunserialize($_G['cache']['plugin']['myrepeats']['usergroups']);
     if (!in_array($_G['groupid'], $myrepeatsusergroups)) {
         $users = C::t('#myrepeats#myrepeats')->fetch_all_by_username($_G['username']);
         if (!$users) {
             return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'usergroup_disabled'));
         } else {
             $permusers = array();
             foreach ($users as $user) {
                 $permusers[] = $user['uid'];
             }
             $member = C::t('common_member')->fetch_by_username($_GET['username']);
             if (!$member || !in_array($member['uid'], $permusers)) {
                 return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'usergroup_disabled'));
             }
         }
     }
     $user = C::t('#myrepeats#myrepeats')->fetch_all_by_uid_username($_G['uid'], $_GET['username']);
     $user = current($user);
     $olddiscuz_uid = $_G['uid'];
     $olddiscuz_user = $_G['username'];
     $olddiscuz_userss = $_G['member']['username'];
     if (!$user) {
         $newuid = C::t('common_member')->fetch_uid_by_username($_GET['username']);
         if (C::t('#myrepeats#myrepeats')->count_by_uid_username($newuid, $olddiscuz_userss)) {
             // 第一次登录,需要输入密码
         }
         //return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'user_nonexistence'));
     } elseif ($user['locked']) {
         return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'user_locked', array('user' => $_GET['username'])));
     }
     list($password, $questionid, $answer) = explode("\t", authcode($user['logindata'], 'DECODE', $_G['config']['security']['authkey']));
     $logInfo = UserUtils::login($username, $password);
     if ($logInfo['errcode']) {
         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;
 }
 private function _qqInfo($res, $openId, $oauthToken, $platformId)
 {
     global $_G;
     $password = MOBCENT_HACKER_PASSWORD;
     require_once libfile('function/member');
     if (!empty($platformId) && $platformId == 20) {
         $qqUserInfo = $this->_getQQinfoByOpenId($openId);
         if (isset($qqUserInfo) && !empty($qqUserInfo)) {
             $userInfo = UserUtils::getUserInfo($qqUserInfo['uid']);
             setloginstatus($userInfo, $_GET['cookietime'] ? 2592000 : 0);
             C::t('common_member_status')->update($userInfo['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
             $ipArray = explode('.', $_G['clientip']);
             $sid = FileUtils::getRandomFileName('', 6);
             $data = array('sid' => $sid, 'ip1' => $ipArray[0], 'ip2' => $ipArray[1], 'ip3' => $ipArray[2], 'ip4' => $ipArray[3], 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'groupid' => $userInfo['groupid'], 'invisible' => '0', 'action' => '', 'lastactivity' => time(), 'fid' => '0', 'tid' => '0', 'lastolupdate' => '0');
             $comSess = DzCommonSession::getComSessByUid($userInfo['uid']);
             if (!empty($comSess)) {
                 DzCommonSession::delComSess($userInfo['uid']);
             }
             DzCommonSession::insertComSess($data);
             $userAccess = AppbymeUserAccess::loginProcess($userInfo['uid'], $password);
             $res['body']['register'] = 0;
             $res['body']['uid'] = (int) $userInfo['uid'];
             $res['body']['userName'] = (string) $userInfo['username'];
             $res['body']['avatar'] = (string) UserUtils::getUserAvatar($userInfo['uid']);
             $res['body']['token'] = (string) $userAccess['token'];
             $res['body']['secret'] = (string) $userAccess['secret'];
             return $res;
         } else {
             $res['body']['register'] = 1;
             $res['body']['openId'] = (string) $openId;
             $res['body']['oauthToken'] = (string) $oauthToken;
             $res['body']['platformId'] = (int) $platformId;
             return $res;
         }
     }
     // 客户端参数不正确
     return $this->makeErrorInfo($res, 'mobcent_error_params');
 }
 private function _saveInfo($res, $username, $email, $oauthToken, $openId, $gender, $platformId)
 {
     $username = WebUtils::t(rawurldecode($username));
     $email = WebUtils::t(rawurldecode($email));
     $password = MOBCENT_HACKER_PASSWORD;
     $regInfo = UserUtils::register($username, $password, $email, 'qq');
     if ($regInfo['errcode']) {
         return $this->makeErrorInfo($res, $regInfo['message']);
     }
     $uid = $regInfo['info']['uid'];
     $userInfo = UserUtils::getUserInfo($uid);
     $userAccess = AppbymeUserAccess::registerProcess($uid, $password);
     if (!empty($platformId) && $platformId == 20) {
         $qqdata = array('uid' => $uid, 'conuin' => $oauthToken, 'conuinsecret' => '', 'conopenid' => $openId, 'conisfeed' => 1, 'conispublishfeed' => 1, 'conispublisht' => 1, 'conisregister' => 1, 'conisqzoneavatar' => 1, 'conisqqshow' => 1);
         $qqbind = array('mblid' => '', 'uid' => $uid, 'uin' => $openId, 'type' => 1, 'dateline' => time());
         $this->_inserBindlog($qqbind);
         $this->_inserConnect($qqdata);
         $updateInfo = array('avatarstatus' => 1, 'conisbind' => 1);
         // 用户是否绑定QQ
         DzCommonMember::updateMember($updateInfo, array('uid' => $uid));
         $setarr['gender'] = intval($gender);
         C::t('common_member_profile')->update($uid, $setarr);
         $ipArray = explode('.', $_G['clientip']);
         $sid = FileUtils::getRandomFileName('', 6);
         $data = array('sid' => $sid, 'ip1' => $ipArray[0], 'ip2' => $ipArray[1], 'ip3' => $ipArray[2], 'ip4' => $ipArray[3], 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'groupid' => $userInfo['groupid'], 'invisible' => '0', 'action' => '', 'lastactivity' => time(), 'fid' => '0', 'tid' => '0', 'lastolupdate' => '0');
         DzCommonSession::insertComSess($data);
         require_once libfile('cache/userstats', 'function');
         build_cache_userstats();
         $res['token'] = (string) $userAccess['token'];
         $res['secret'] = (string) $userAccess['secret'];
         $res['uid'] = (int) $regInfo['info']['uid'];
         return $res;
     }
     // 客户端参数不正确
     return $this->makeErrorInfo($res, 'mobcent_error_params');
 }
Example #9
0
 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;
 }
Example #10
0
 /**
  * 通过username删除用户的accessToken、accessSecret
  * 
  * @param string $username Description.
  * @static
  *
  */
 public static function delUserAccessByUsername($username)
 {
     $userInfo = DzCommonMember::getUidByUsername($username);
     $delUid = $userInfo['uid'];
     AppbymeUserAccess::delUserAccess($delUid);
 }
 private function _saveWxInfo($res, $username, $oauthToken, $password, $openId, $email, $gender, $act, $platformId)
 {
     if ($act == 'register') {
         $regInfo = UserUtils::register($username, $password, $email);
         if ($regInfo['errcode']) {
             return $this->makeErrorInfo($res, $regInfo['message']);
         }
         $uid = $regInfo['info']['uid'];
         $member = UserUtils::getUserInfo($uid);
         $userInfo = AppbymeUserAccess::registerProcess($regInfo['info']['uid'], $password);
         $data = array('uid' => $uid, 'openid' => $openId, 'status' => 1, 'type' => 1);
         AppbymeConnection::insertMobcentWx($data);
         $res['body']['uid'] = (int) $uid;
         $res['body']['token'] = (string) $userInfo['token'];
         $res['body']['secret'] = (string) $userInfo['secret'];
     } elseif ($act == 'bind') {
         global $_G;
         $logInfo = UserUtils::login($username, $password);
         if ($logInfo['errcode']) {
             UserUtils::delUserAccessByUsername($username);
             return $this->makeErrorInfo($res, 'mobcent_bind_error');
         }
         $isBind = AppbymeConnection::getUserBindInfo($_G['uid']);
         if ($isBind) {
             return $this->makeErrorInfo($res, 'mobcent_bind_error_repeat');
         }
         $data = array('uid' => $_G['uid'], 'openid' => $openId, 'status' => 1, 'type' => 1);
         AppbymeConnection::insertMobcentWx($data);
         $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password);
         $userAvatar = UserUtils::getUserAvatar($_G['uid']);
         $res['body']['token'] = (string) $userInfo['token'];
         $res['body']['secret'] = (string) $userInfo['secret'];
         $res['body']['uid'] = (int) $_G['uid'];
         $res['body']['avatar'] = (string) $userAvatar;
         $res['body']['userName'] = (string) $_G['username'];
     }
     return $res;
 }
 private function _wxInfo($res, $openId, $oauthToken, $platformId)
 {
     $wxLogin = AppbymeConnection::getMobcentWxinfoByOpenId($openId);
     if ($wxLogin) {
         $member = getuserbyuid($wxLogin['uid']);
         UserUtils::updateCookie($member, $member['uid']);
         $userAccess = AppbymeUserAccess::loginProcess($member['uid'], $this->password);
         $res['body']['register'] = 0;
         $res['body']['uid'] = (int) $member['uid'];
         $res['body']['userName'] = (string) $member['username'];
         $res['body']['avatar'] = (string) UserUtils::getUserAvatar($member['uid']);
         $res['body']['token'] = (string) $userAccess['token'];
         $res['body']['secret'] = (string) $userAccess['secret'];
     } else {
         // 检查是否有微信登陆的插件
         $isWechat = AppbymeConnection::isWechat();
         if ($isWechat) {
             $dzWxLogin = AppbymeConnection::getWXinfoByOpenId($openId);
             if (!empty($dzWxLogin)) {
                 $member = getuserbyuid($dzWxLogin['uid']);
                 UserUtils::updateCookie($member, $member['uid']);
                 $data = array('uid' => $uid, 'openid' => $openId, 'status' => 1, 'type' => 1);
                 AppbymeConnection::insertMobcentWx($data);
                 $userAccess = AppbymeUserAccess::loginProcess($member['uid'], $this->password);
                 $res['body']['register'] = 0;
                 $res['body']['uid'] = (int) $member['uid'];
                 $res['body']['userName'] = (string) $member['username'];
                 $res['body']['avatar'] = (string) UserUtils::getUserAvatar($member['uid']);
                 $res['body']['token'] = (string) $userAccess['token'];
                 $res['body']['secret'] = (string) $userAccess['secret'];
             } else {
                 $res['body']['register'] = 1;
                 $res['body']['openId'] = (string) $openId;
                 $res['body']['oauthToken'] = (string) $oauthToken;
                 $res['body']['platformId'] = (int) $platformId;
             }
         } else {
             // 低版本的discuz!或者是没有装微信插件
             $res['body']['register'] = 1;
             $res['body']['openId'] = (string) $openId;
             $res['body']['oauthToken'] = (string) $oauthToken;
             $res['body']['platformId'] = (int) $platformId;
         }
     }
     return $res;
 }