3 namespace Friendica\Module\Profile;
5 use Friendica\BaseModule;
6 use Friendica\Content\Nav;
7 use Friendica\Core\Hook;
8 use Friendica\Core\Session;
9 use Friendica\Core\System;
10 use Friendica\Database\DBA;
12 use Friendica\Model\Profile as ProfileModel;
13 use Friendica\Model\User;
14 use Friendica\Module\Security\Login;
15 use Friendica\Protocol\ActivityPub;
17 require_once 'boot.php';
19 class Index extends BaseModule
21 public static function rawContent(array $parameters = [])
23 if (ActivityPub::isRequest()) {
24 $user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]);
25 if (DBA::isResult($user)) {
26 // The function returns an empty array when the account is removed, expired or blocked
27 $data = ActivityPub\Transmitter::getProfile($user['uid']);
29 System::jsonExit($data, 'application/activity+json');
33 if (DBA::exists('userd', ['username' => $parameters['nickname']])) {
35 $data = ActivityPub\Transmitter::getDeletedUser($parameters['nickname']);
37 System::jsonError(410, $data);
39 // Any other case (unknown, blocked, nverified, expired, no profile, no self contact)
40 System::jsonError(404, []);
45 public static function content(array $parameters = [])
49 ProfileModel::load($a, $parameters['nickname']);
51 $remote_contact_id = Session::getRemoteContactID($a->profile['uid']);
53 if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) {
57 DI::page()['htmlhead'] .= "\n";
59 $blocked = !local_user() && !$remote_contact_id && DI::config()->get('system', 'block_public');
60 $userblock = !local_user() && !$remote_contact_id && $a->profile['hidewall'];
62 if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
63 DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
66 if (!empty($a->profile['openidserver'])) {
67 DI::page()['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";
70 if (!empty($a->profile['openid'])) {
71 $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
72 DI::page()['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
76 if (!$blocked && !$userblock) {
77 $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
78 if (strlen($keywords)) {
79 DI::page()['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
83 DI::page()['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
85 if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
86 DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
89 DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
90 DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";
91 DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";
92 DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
93 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . DI::baseUrl()->getHostname() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''));
94 DI::page()['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . DI::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";
95 header('Link: <' . DI::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
97 $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
98 foreach ($dfrn_pages as $dfrn) {
99 DI::page()['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . DI::baseUrl() . '/dfrn_' . $dfrn . '/' . $parameters['nickname'] . '" />' . "\n";
101 DI::page()['htmlhead'] .= '<link rel="dfrn-poco" href="' . DI::baseUrl() . '/poco/' . $parameters['nickname'] . '" />' . "\n";
105 Nav::setSelected('home');
107 $is_owner = local_user() == $a->profile['uid'];
109 if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) {
110 notice(DI::l10n()->t('Access to this profile has been restricted.'));
114 $o .= ProfileModel::getTabs($a, 'profile', $is_owner, $a->profile['nickname']);
116 $o .= ProfileModel::getAdvanced($a);
118 Hook::callAll('profile_advanced', $o);