示例#1
0
 function prepare($args)
 {
     parent::prepare($args);
     $this->uri = $this->trimmed('uri');
     $this->uri = self::normalize($this->uri);
     if (self::isWebfinger($this->uri)) {
         $parts = explode('@', substr(urldecode($this->uri), 5));
         if (count($parts) == 2) {
             list($nick, $domain) = $parts;
             // @fixme confirm the domain too
             // @fixme if domain checking is added, ensure that it will not
             //        cause problems with sites that have changed domains!
             $nick = common_canonical_nickname($nick);
             $this->user = User::staticGet('nickname', $nick);
         }
     } else {
         $this->user = User::staticGet('uri', $this->uri);
         if (empty($this->user)) {
             // try and get it by profile url
             $profile = Profile::staticGet('profileurl', $this->uri);
             if (!empty($profile)) {
                 $this->user = User::staticGet('id', $profile->id);
             }
         }
     }
     if (!$this->user) {
         $this->clientError(_('No such user.'), 404);
         return false;
     }
     return true;
 }
示例#2
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     // throws exception if resource is empty
     $this->resource = Discovery::normalize($this->trimmed('resource'));
     try {
         if (Event::handle('StartGetWebFingerResource', array($this->resource, &$this->target, $this->args))) {
             Event::handle('EndGetWebFingerResource', array($this->resource, &$this->target, $this->args));
         }
     } catch (NoSuchUserException $e) {
         throw new ServerException($e->getMessage(), 404);
     }
     if (!$this->target instanceof WebFingerResource) {
         // TRANS: Error message when an object URI which we cannot find was requested
         throw new ServerException(_m('Resource not found in local database.'), 404);
     }
     return true;
 }
示例#3
0
文件: userxrd.php 项目: himmelex/NTW
 function prepare($args)
 {
     parent::prepare($args);
     $this->uri = $this->trimmed('uri');
     $this->uri = Discovery::normalize($this->uri);
     if (Discovery::isWebfinger($this->uri)) {
         $parts = explode('@', substr(urldecode($this->uri), 5));
         if (count($parts) == 2) {
             list($nick, $domain) = $parts;
             // @fixme confirm the domain too
             $nick = common_canonical_nickname($nick);
             $this->user = User::staticGet('nickname', $nick);
         }
     } else {
         $this->user = User::staticGet('uri', $this->uri);
     }
     if (!$this->user) {
         $this->clientError(_('用户不存在'), 404);
         return false;
     }
     return true;
 }