是否在线
@param $uid
@return bool
974208
public function isOnline($uid)
    {
        if (empty($uid)) return false;
        foreach ($this->map as $node_name => $set) {
            if ($set->contains($uid)) {
                return true;
            }
            return false;
        }
    }
282227
public static function gentoken($uid = '')
    {
        $str = microtime() . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'unknow') . 
            $uid . '7200';

        $md5 = md5($str);

        $crypt = crypt($md5, 'CRYPT_SHA256');

        $md5 = md5($crypt);

        return substr(strrev($md5), 1);
    }
1121671
public function userIdToFid($uid) {
        $value = Cache::redis()->hGet('user_id_#_fid', $uid);
        Cache::release();
        return $value;
    }
901098
public function searchByUid($uid) {
		$results = $this->ldap->search($this->basedn,
			$this->search_username . '=' . $uid);
		return $results;
	}
1123623
public function checkIndex(IndexUUID $indexUUID): bool
    {
        return array_key_exists($this->getIndexKey($indexUUID), $this->indices);
    }
141436
public function getUserInfo($uid) {

        $userinfo = [];

        if (empty($this->userInfo)){

            $userinfo = $this->config['auth_cache'] ? Session::get($this->getUserKey($uid)) : [];

            if (empty($userinfo) || !is_array($userinfo)){
                $user = Db::name($this->config['users']);
                // 获取用户表主键
                $_pk = is_string($user->getPk()) ? $user->getPk() : 'id';

                $userinfo = $user->field($this->config['users_auth_fields'])->where($_pk, $uid)->find();

                if ($this->config['auth_cache'])
                    Session::set($this->getUserKey($uid),$userinfo);
            }


            $this->userInfo = $userinfo;
        }

        return $this->userInfo;
    }
323103
protected function getUserInfo($uid) {
        static $userinfo=array();
        if(!isset($userinfo[$uid])){
             $userinfo[$uid] = Db::table($this->prefix.$this->_config['auth_user'])->where(array('uid'=>$uid))->find();
        }
        return $userinfo[$uid];
    }
191148
public function getRoleUser($uid) {

        if (empty($this->roleUser)){

            $role_user_data = $this->config['auth_cache'] ? Session::get($this->getRoleUserKey()) : [];

            if (empty($role_user_data) || !is_array($role_user_data)){

                $where = [];
                $where['user_id'] = $uid;
                $role_user_list = Db::name($this->config['role_user'])
                    ->field('role_id')
                    ->where($where)
                    ->select();

                $role_user_data = array_column($role_user_list,'role_id');

                //dump($role_user_data);

                if (empty($role_user_data)) return false;

                if ($this->config['auth_cache'])
                    Session::set($this->getRoleUserKey(),$role_user_data);
            }

            $this->roleUser = $role_user_data;

        }

        return $this->roleUser;
    }
1344117
protected function getUserInfo($uid) {
        static $userinfo=array();
        if(!isset($userinfo[$uid])){
             $userinfo[$uid]=M()->where(array('uid'=>$uid))->table($this->_config['AUTH_USER'])->find();
        }
        return $userinfo[$uid];
    }
1282756
protected function bindUid($uid, $isKick = true)
    {
        if (!empty($this->uid)) {
            throw new \Exception("已经绑定过uid");
        }
        if (Start::$testUnity) {
            $this->testUnitSendStack[] = ['action' => 'bindUid', 'fd' => $this->fd, 'uid' => $uid];
        } else {
            get_instance()->bindUid($this->fd, $uid, $isKick);
        }
        $this->uid = $uid;
    }
1133004
public function serverGetByUid($uid)
  {
    foreach($this->serverList() as $server)
    {
      if($server["virtualserver_unique_identifier"] == $uid) return $server;
    }

    throw new Exception("invalid serverID", 0x400);
  }
117199
protected function getUserInfo($uid)
    {
        static $userinfo = [];

        $user = Db::name($this->config['auth_user']);
        // 获取用户表主键
        $_pk = is_string($user->getPk()) ? $user->getPk() : 'uid';
        if (!isset($userinfo[$uid])) {
            $userinfo[$uid] = $user->where($_pk, $uid)->find();
        }

        return $userinfo[$uid];
    }
191644
public function getUidInfo($uid)
    {
        $fd = $this->getFdFromUid($uid);
        if (empty($fd)) {
            if (!$this->isCluster()) {
                return [];
            } else {
                $fdInfo = ProcessManager::getInstance()->getRpcCall(ClusterProcess::class)->my_getUidInfo($uid);

                return $fdInfo;
            }
        } else {
            $fdInfo = $this->getFdInfo($fd);
            $fdInfo['node'] = getNodeName();

            return $fdInfo;
        }
    }
1254759
public function newSession($uid, $options = array()) {
		BLog::addToLog('[Users.Session]: SessionStart()');
		//Checking options...
		if (!isset($options['interval'])) {
			$options['interval'] = 10800;
		}
		//Conncting to the database
		$db = BFactory::getDBO();
		if (empty($db)) {
			return false;
		}
		//-------------------------------------------
		// PHP porn :-(
		//-------------------------------------------
		$DTI_GENERAL = (int)$options['interval'];
		$DTI_D = (int)($DTI_GENERAL / 86400);
		$DTI_GENERAL -= $DTI_D * 86400;
		$DTI_H = (int)($DTI_GENERAL / 3600);
		$DTI_GENERAL -= $DTI_H * 3600;
		$DTI_M = (int)($DTI_GENERAL / 60);
		$DTI_GENERAL -= $DTI_M * 60;
		$DTI_S = $DTI_GENERAL;
		$DTI_STRING = 'P0Y0M' . $DTI_D . 'DT' . $DTI_H . 'H' . $DTI_M . 'M' . $DTI_S . 'S';
		$DTI = new \DateInterval($DTI_STRING);
		//-------------------------------------------
		// Variables
		//-------------------------------------------
		$sessid = sha1(uniqid(rand(), 1));
		$nowdate = new \DateTime();
		$enddate = new \DateTime();
		$enddate->add($DTI);

		if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
			$ip = $_SERVER['HTTP_CLIENT_IP'];
		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
			$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
		} else {
			$ip = $_SERVER['REMOTE_ADDR'];
		}
		$ipv4 = ip2long($ip);
		//Object for cache.
		$obj = array();
		$obj['sessionid'] = $sessid;
		$obj['start'] = $nowdate->format('Y-m-d H:i:s');
		$obj['end'] = $enddate->format('Y-m-d H:i:s');
		$obj['lastaction'] = $nowdate->format('Y-m-d H:i:s');
		$obj['interval'] = (int)$options['interval'];
		$obj['updatestep'] = $options['updatestep'];
		$obj['userid'] = $uid;
		$obj['data'] = '{}';
		$obj['ipv4'] = $ipv4;
		//-------------------------------------------
		//Forming query...
		//-------------------------------------------
		$qr = 'insert into `sessions` (`sessionid`,`ipv4`,`start`,`end`,' . 'lastaction,userid,`data`,updatestep,`interval`) values (' . $db->escapeString($obj['sessionid']) . ', ' . sprintf('%u', $obj['ipv4']) . ', ' . $db->escapeString($obj['start']) . ', ' . $db->escapeString($obj['end']) . ', ' . $db->escapeString($obj['lastaction']) . ', ' . $obj['userid'] . ',' . $db->escapeString($obj['data']) . ', ' . $obj['updatestep'] . ',' . $obj['interval'] . ')';
		$q = $db->Query($qr);
		if (empty($q)) {
			return false;
		}
		//-------------------------------------------
		// Updating last action
		//-------------------------------------------
		$qr = 'update users set last_action=NOW() where id=' . $obj['userid'];
		$q = $db->Query($qr);
		if (empty($q)) {
			return false;
		}
		//-------------------------------------------
		// Inserting into log...
		//-------------------------------------------
		$qr = 'insert into `users_iplog` (`user`,`dt`,`IPv4`,`UserAgent`) values (' . $obj['userid'] . ',' . $db->escapeString($obj['start']) . ', ' . sprintf('%u', $obj['ipv4']) . ', ' . $db->escapeString($_SERVER['HTTP_USER_AGENT']) . ')';
		$q = $db->Query($qr);
		if (empty($q)) {
			return false;
		}
		$busers = BUsers::getInstance();
		$me = $busers->itemGet($obj['userid']);
		$me->updatecache();
		//-------------------------------------------
		// Set cache...
		//-------------------------------------------
		$bCache = BFactory::getCache();
		if ($bCache) {
			$bCache->set('session:' . $obj['sessionid'], $obj, 600);
		}
		//Set cookie
		$expire = time() + $options['interval'] + 3600;//+1 hour
		//$expire=0;
		if (DEBUG_MODE) {
			BLog::addToLog('[Users.Session]: SessionStart() enddate=' . $enddate->format('Y-m-d H:i:s'));
			BLog::addToLog('[Users.Session]: SessionStart() nowdate=' . $nowdate->format('Y-m-d H:i:s'));
			BLog::addToLog('[Users.Session]: Interval: ' . $options['interval']);
			BLog::addToLog('[Users.Session]: Set cookie. Expire=' . $expire);
		}
		//BDebug::print_html();die('SetCookie!');
		setcookie('brillsecret', $uid . ':' . $sessid, $expire, '/', BHOSTNAME);
		return true;
	}
920171
public function show($uid)
    {
        $options = $this->getParams('includes');

        $user = Subbly::api('subbly.user')->find($uid, $options);

        return $this->jsonResponse(array(
            'user' => $this->presenter->single($user),
        ));
    }
318366
public function find($uid, array $options = array())
    {
        $query = $this->newQuery($options);
        $query->where('uid', '=', $uid);

        return $query->firstOrFail();
    }
69238
public function getGroup($uid){
        
        $groupIds = $this->getGroupIds($uid);
        
        $groups = DB::table($this->dbTablePrefix . $this->tableGroup)
                    ->where('id' , 'in' , $groupIds)
                    ->where('status' , '1')
                    ->order('sort asc')
                    ->select();
        
        return $groups;
        
    }