12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- defined('GNUSOCIAL') || die();
- function pullRemoteProfile(string $uri): ?Ostatus_profile
- {
- $validate = new Validate();
- try {
- $uri = Discovery::normalize($uri);
- } catch (Exception $e) {
- return null;
- }
- try {
- if (Discovery::isAcct($uri) && $validate->email(mb_substr($uri, 5))) {
- $profile = Ostatus_profile::ensureWebfinger($uri);
- } else if ($validate->uri($uri)) {
- $profile = Ostatus_profile::ensureProfileURL($uri);
- } else {
- common_log(LOG_ERR, 'Invalid address format.');
- return null;
- }
- return $profile;
- } catch (FeedSubBadURLException $e) {
- common_log(LOG_ERR, 'Invalid URL or could not reach server.');
- } catch (FeedSubBadResponseException $e) {
- common_log(LOG_ERR, 'Cannot read feed; server returned error.');
- } catch (FeedSubEmptyException $e) {
- common_log(LOG_ERR, 'Cannot read feed; server returned an empty page.');
- } catch (FeedSubBadHTMLException $e) {
- common_log(LOG_ERR, 'Bad HTML, could not find feed link.');
- } catch (FeedSubNoFeedException $e) {
- common_log(LOG_ERR, 'Could not find a feed linked from this URL.');
- } catch (FeedSubUnrecognizedTypeException $e) {
- common_log(LOG_ERR, 'Not a recognized feed type.');
- } catch (FeedSubNoHubException $e) {
- common_log(LOG_ERR, 'No hub found.');
- } catch (Exception $e) {
- common_log(LOG_ERR, sprintf('Bad feed URL: %s %s', get_class($e), $e->getMessage()));
- }
- return null;
- }
|