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 if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['profile_uid'])) {
53 ProfileModel::load($a, $parameters['nickname']);
55 DI::page()['htmlhead'] .= "\n";
57 $blocked = !local_user() && !Session::getRemoteContactID($a->profile['profile_uid']) && DI::config()->get('system', 'block_public');
58 $userblock = !local_user() && !Session::getRemoteContactID($a->profile['profile_uid']) && $a->profile['hidewall'];
60 if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
61 DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
64 if (!empty($a->profile['openidserver'])) {
65 DI::page()['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";
68 if (!empty($a->profile['openid'])) {
69 $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
70 DI::page()['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
74 if (!$blocked && !$userblock) {
75 $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
76 if (strlen($keywords)) {
77 DI::page()['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
81 DI::page()['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
83 if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
84 DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
87 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";
88 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";
89 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";
90 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";
91 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . DI::baseUrl()->getHostname() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''));
92 DI::page()['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . DI::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";
93 header('Link: <' . DI::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
95 $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
96 foreach ($dfrn_pages as $dfrn) {
97 DI::page()['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . DI::baseUrl() . '/dfrn_' . $dfrn . '/' . $parameters['nickname'] . '" />' . "\n";
99 DI::page()['htmlhead'] .= '<link rel="dfrn-poco" href="' . DI::baseUrl() . '/poco/' . $parameters['nickname'] . '" />' . "\n";
103 Nav::setSelected('home');
105 $remote_contact = Session::getRemoteContactID($a->profile['profile_uid']);
106 $is_owner = local_user() == $a->profile['profile_uid'];
108 if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
109 notice(DI::l10n()->t('Access to this profile has been restricted.'));
113 $o .= ProfileModel::getTabs($a, 'profile', $is_owner, $a->profile['nickname']);
115 $o .= ProfileModel::getAdvanced($a);
117 Hook::callAll('profile_advanced', $o);