Ejemplo n.º 1
0
 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
             // @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(_m('No such user.'), 404);
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public function discover($uri)
 {
     if (Discovery::isWebfinger($uri)) {
         // We have a webfinger acct: - start with host-meta
         list($name, $domain) = explode('@', $uri);
     } else {
         $domain = parse_url($uri, PHP_URL_HOST);
     }
     $url = 'http://' . $domain . '/.well-known/host-meta';
     $xrd = Discovery::fetchXrd($url);
     if ($xrd) {
         if ($xrd->host != $domain) {
             return false;
         }
         return $xrd->links;
     }
 }