예제 #1
0
 protected function _setPreHook($m, $mc, $mca)
 {
     $prehook = Wekit::V('prehook');
     PwHook::preset($prehook['ALL']);
     PwHook::preset($prehook[$this->loginUser->isExists() ? 'LOGIN' : 'UNLOGIN']);
     if (isset($prehook[$m])) {
         PwHook::preset($prehook[$m]);
     }
     if (isset($prehook[$mc])) {
         PwHook::preset($prehook[$mc]);
     }
     if (isset($prehook[$mca])) {
         PwHook::preset($prehook[$mca]);
     }
 }
 public function beforeLogout(PwUserBo $bo)
 {
     if (!$bo->isExists()) {
         return true;
     }
     $srv = Wekit::load('online.srv.PwOnlineService');
     $srv->logoutOnline($bo->uid);
     return true;
 }
 /**
  * 
  * 获取用户对应的对话框列表
  * 
  * @param int $uid
  * @param int $start
  * @param int $limit
  * @return array 
  */
 public function getMessageByUid($uid, $offset, $limit)
 {
     $user = new PwUserBo($uid);
     if (!$user->isExists()) {
         return $this->buildResponse(MESSAGE_UID_ERROR);
     }
     $result = $this->getPwMessageService()->getDialogs($uid, $offset, $limit);
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
예제 #4
0
 public function synLogin($uid)
 {
     Wind::import('SRC:service.user.bo.PwUserBo');
     Wind::import('SRC:service.user.srv.PwLoginService');
     $userBo = new PwUserBo($uid);
     if ($userBo->isExists() && !Pw::getstatus($userBo->info['status'], PwUser::STATUS_UNACTIVE)) {
         $srv = new PwLoginService();
         $ip = Wind::getApp()->getRequest()->getClientIp();
         $srv->setLoginCookie($userBo, $ip, 1);
     }
     exit;
     //return true;
 }
 /**
  * 检查用户登录及应用马甲绑定的状况
  *
  * @return PwError|boolean
  */
 private function _check($ifCheck = true)
 {
     if (!Wekit::C('app_majia', 'isopen')) {
         return new PwError('马甲切换应用没有开启');
     }
     if (!$this->loginBo->isExists()) {
         return new PwError('用户没有登录');
     }
     if ($ifCheck && !in_array($this->loginBo->gid, Wekit::C('app_majia', 'band.allow.groups'))) {
         return new PwError('您所在的用户组不能使用马甲绑定功能');
     }
     return true;
 }
예제 #6
0
 protected function _getUser()
 {
     $authkey = 'winduser';
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($authkey = $pre . '_' . $authkey);
     $winduser = $this->getInput($authkey, 'post');
     list($uid, $password) = explode("\t", Pw::decrypt(urldecode($winduser)));
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return null;
     }
     unset($user->info['password']);
     return $user;
 }
 /**
  * Enter description here ...
  *
  * @param unknown_type $uid
  * @return Ambigous <multitype:unknown , multitype:unknown NULL >
  */
 public function isUserBanned($uid)
 {
     $user = new PwUserBo($uid);
     if (!$user->isExists()) {
         return $this->buildResponse(PERMISSIONS_USER_NOT_EXISTS);
     }
     // $result = $this->getUserBanService ()->getBanInfoByUid ( $uid, 1 );
     Wind::import('SRV:user.srv.PwBanBp');
     $banBp = new PwBanBp($uid);
     $result = $banBp->checkIfBanSpeak();
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse($result ? 500 : 0);
 }
 public function beforeLogout(PwUserBo $bo)
 {
     if (!$bo->isExists()) {
         return true;
     }
     $onlineTime = intval(Wekit::C('site', 'onlinetime'));
     if ($onlineTime <= 0) {
         return true;
     }
     $newLastVisit = $bo->info['lastvisit'] - $onlineTime * 60;
     Wind::import('SRV:user.dm.PwUserInfoDm');
     $dm = new PwUserInfoDm($bo->uid);
     $dm->setLastvisit($newLastVisit);
     /* @var $userDs PwUser */
     $userDs = Wekit::load('user.PwUser');
     $userDs->editUser($dm, PwUser::FETCH_DATA);
     return true;
 }
예제 #9
0
 /**
  * 发送回复
  * @param int $tid
  * @param int $uid
  * @param string $title
  * @param string $content
  * return bool
  */
 public function sendPost($tid, $uid, $title, $content)
 {
     $userBo = new PwUserBo($uid);
     if (!$userBo->isExists()) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST);
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwReplyPost');
     $postAction = new PwReplyPost($tid);
     $pwPost = new PwPost($postAction);
     $info = $pwPost->getInfo();
     $title == 'Re:' . $info['subject'] && ($title = '');
     $postDm = $pwPost->getDm();
     $postDm->setTitle($title)->setContent($content)->setAuthor($uid, $userBo->username, $userBo->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
 public function getLatestThreadByFavoritesForum($uid, $offset, $limit)
 {
     list($uid, $offset, $limit) = array(intval($uid), intval($offset), intval($limit));
     if ($uid <= 0) {
         return $this->buildResponse(THREAD_INVALID_PARAMS, "参数错误");
     }
     $userBo = new PwUserBo($uid);
     if (!$userBo->isExists()) {
         return $this->buildResponse(USER_NOT_EXISTS, "用户不存在");
     }
     $fids = array_keys($this->_getForumUser()->getFroumByUid($uid));
     if (!$fids) {
         return $this->buildResponse(0, array());
     }
     return $this->getLatestThreadsByFids($fids, $offset, $limit);
 }
예제 #11
0
 /**
  * 获得大概年前登录用户对象
  *
  * @return PwUserBo
  */
 protected function _getLoginUser()
 {
     if (!($userCookie = Pw::getCookie('winduser'))) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($userCookie));
     }
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         $user->reset();
     } else {
         unset($user->info['password']);
     }
     return $user;
 }
예제 #12
0
 /** 
  * 编辑email
  *
  * @param int $uid 用户id
  * @param int $email email
  * @return boolean|PwError
  */
 public function updateEmail($uid, $email)
 {
     $userBo = new PwUserBo(intval($uid));
     if (!$userBo->isExists()) {
         return $this->buildResponse(USER_NOT_EXISTS);
     }
     if (!$email || WindValidator::isEmail($email) !== true) {
         return $this->buildResponse(USER_INVALID_PARAMS);
     }
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm($uid);
     $userDm->setEmail($email);
     $result = $this->getUser()->editUser($userDm, PwUser::FETCH_MAIN);
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
 public function checkCookie($cookie)
 {
     if (empty($cookie)) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($cookie));
     }
     Wind::import('SRV:user.bo.PwUserBo');
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return $this->buildResponse(-1, 'cookie非法');
     } else {
         return $this->buildResponse(0, array('uid' => $uid, 'username' => $user->username));
     }
 }
예제 #14
0
 /**
  * 发表帖子
  * @param int $tid
  * @param int $fid
  * @param string $subject
  * @param string $content
  * return bool
  */
 public function postThread($uid, $fid, $subject, $content)
 {
     $userBo = new PwUserBo($uid);
     if (!$userBo->isExists()) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST);
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwTopicPost');
     $postAction = new PwTopicPost($fid);
     $pwPost = new PwPost($postAction);
     $postDm = $pwPost->getDm();
     $postDm->setFid($fid)->setTitle($subject)->setContent($content)->setAuthor($uid, $userBo->username, $userBo->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }