2020-01-26 15:54:21 +01:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
2023-01-01 15:36:24 +01:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2020-02-09 15:45:36 +01:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
namespace Friendica\Module\Profile;
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\App;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Content\Feature;
|
|
|
|
use Friendica\Content\ForumManager;
|
|
|
|
use Friendica\Content\Nav;
|
|
|
|
use Friendica\Content\Text\BBCode;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Core\Hook;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Core\L10n;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Core\Protocol;
|
|
|
|
use Friendica\Core\Renderer;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Core\System;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Database\Database;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Database\DBA;
|
|
|
|
use Friendica\Model\Contact;
|
|
|
|
use Friendica\Model\Profile as ProfileModel;
|
2020-04-26 17:24:58 +02:00
|
|
|
use Friendica\Model\Tag;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Model\User;
|
|
|
|
use Friendica\Module\BaseProfile;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Module\Response;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Module\Security\Login;
|
|
|
|
use Friendica\Network\HTTPException;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Profile\ProfileField\Repository\ProfileField;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Protocol\ActivityPub;
|
|
|
|
use Friendica\Util\DateTimeFormat;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Friendica\Util\Profiler;
|
2022-12-19 05:24:59 +01:00
|
|
|
use Friendica\Util\Strings;
|
2020-01-26 15:54:21 +01:00
|
|
|
use Friendica\Util\Temporal;
|
2022-12-19 04:49:18 +01:00
|
|
|
use Psr\Log\LoggerInterface;
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
class Profile extends BaseProfile
|
|
|
|
{
|
2022-12-19 04:49:18 +01:00
|
|
|
/** @var Database */
|
|
|
|
private $database;
|
|
|
|
/** @var App */
|
|
|
|
private $app;
|
|
|
|
/** @var IHandleUserSessions */
|
|
|
|
private $session;
|
|
|
|
/** @var IManageConfigValues */
|
|
|
|
private $config;
|
|
|
|
/** @var App\Page */
|
|
|
|
private $page;
|
|
|
|
/** @var ProfileField */
|
|
|
|
private $profileField;
|
|
|
|
|
|
|
|
public function __construct(ProfileField $profileField, App\Page $page, IManageConfigValues $config, IHandleUserSessions $session, App $app, Database $database, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
|
|
|
{
|
|
|
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
|
|
|
|
|
|
|
$this->database = $database;
|
|
|
|
$this->app = $app;
|
|
|
|
$this->session = $session;
|
|
|
|
$this->config = $config;
|
|
|
|
$this->page = $page;
|
|
|
|
$this->profileField = $profileField;
|
|
|
|
}
|
|
|
|
|
2021-11-20 15:38:03 +01:00
|
|
|
protected function rawContent(array $request = [])
|
2020-01-26 15:54:21 +01:00
|
|
|
{
|
|
|
|
if (ActivityPub::isRequest()) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$user = $this->database->selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'] ?? '', 'account_removed' => false]);
|
|
|
|
if ($user) {
|
2021-07-20 19:04:25 +02:00
|
|
|
try {
|
|
|
|
$data = ActivityPub\Transmitter::getProfile($user['uid']);
|
2020-04-06 00:02:38 +02:00
|
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
|
2020-01-26 15:54:21 +01:00
|
|
|
System::jsonExit($data, 'application/activity+json');
|
2021-07-20 19:04:25 +02:00
|
|
|
} catch (HTTPException\NotFoundException $e) {
|
|
|
|
System::jsonError(404, ['error' => 'Record not found']);
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
if ($this->database->exists('userd', ['username' => $this->parameters['nickname']])) {
|
2020-01-26 15:54:21 +01:00
|
|
|
// Known deleted user
|
2021-11-14 23:19:25 +01:00
|
|
|
$data = ActivityPub\Transmitter::getDeletedUser($this->parameters['nickname']);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
System::jsonError(410, $data);
|
|
|
|
} else {
|
|
|
|
// Any other case (unknown, blocked, nverified, expired, no profile, no self contact)
|
|
|
|
System::jsonError(404, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-20 15:38:03 +01:00
|
|
|
protected function content(array $request = []): string
|
2020-01-26 15:54:21 +01:00
|
|
|
{
|
2022-12-19 04:49:18 +01:00
|
|
|
$profile = ProfileModel::load($this->app, $this->parameters['nickname'] ?? '');
|
2021-07-24 12:09:39 +02:00
|
|
|
if (!$profile) {
|
2022-12-19 04:49:18 +01:00
|
|
|
throw new HTTPException\NotFoundException($this->t('Profile not found.'));
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$remote_contact_id = $this->session->getRemoteContactID($profile['uid']);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
if ($this->config->get('system', 'block_public') && !$this->session->isAuthenticated()) {
|
2020-01-26 15:54:21 +01:00
|
|
|
return Login::form();
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
if (!empty($profile['hidewall']) && !$this->session->isAuthenticated()) {
|
2022-11-30 19:50:52 +01:00
|
|
|
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$this->page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$this->page['htmlhead'] .= $this->buildHtmlHead($profile, $this->parameters['nickname']);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
Nav::setSelected('home');
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$is_owner = $this->session->getLocalUserId() == $profile['uid'];
|
|
|
|
$o = self::getTabsHTML('profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$view_as_contacts = [];
|
|
|
|
$view_as_contact_id = 0;
|
2020-07-28 17:40:14 +02:00
|
|
|
$view_as_contact_alert = '';
|
2020-01-26 15:54:21 +01:00
|
|
|
if ($is_owner) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$view_as_contact_id = intval($request['viewas'] ?? 0);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
|
2022-12-19 04:49:18 +01:00
|
|
|
'uid' => $this->session->getLocalUserId(),
|
|
|
|
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
|
2020-01-26 15:54:21 +01:00
|
|
|
'network' => Protocol::DFRN,
|
|
|
|
'blocked' => false,
|
|
|
|
]);
|
|
|
|
|
2020-07-28 17:40:14 +02:00
|
|
|
$view_as_contact_ids = array_column($view_as_contacts, 'id');
|
|
|
|
|
2020-01-26 15:54:21 +01:00
|
|
|
// User manually provided a contact ID they aren't privy to, silently defaulting to their own view
|
2020-07-28 17:40:14 +02:00
|
|
|
if (!in_array($view_as_contact_id, $view_as_contact_ids)) {
|
2020-01-26 15:54:21 +01:00
|
|
|
$view_as_contact_id = 0;
|
|
|
|
}
|
2020-07-28 17:40:14 +02:00
|
|
|
|
|
|
|
if (($key = array_search($view_as_contact_id, $view_as_contact_ids)) !== false) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$view_as_contact_alert = $this->t(
|
2020-07-28 17:40:14 +02:00
|
|
|
'You\'re currently viewing your profile as <b>%s</b> <a href="%s" class="btn btn-sm pull-right">Cancel</a>',
|
|
|
|
htmlentities($view_as_contacts[$key]['name'], ENT_COMPAT, 'UTF-8'),
|
2021-11-14 23:19:25 +01:00
|
|
|
'profile/' . $this->parameters['nickname'] . '/profile'
|
2020-07-28 17:40:14 +02:00
|
|
|
);
|
|
|
|
}
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$basic_fields = [];
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('fullname', $this->t('Full Name:'), $profile['name']);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if (Feature::isEnabled($profile['uid'], 'profile_membersince')) {
|
2020-01-26 15:54:21 +01:00
|
|
|
$basic_fields += self::buildField(
|
|
|
|
'membersince',
|
2022-12-19 04:49:18 +01:00
|
|
|
$this->t('Member since:'),
|
2021-07-24 12:09:39 +02:00
|
|
|
DateTimeFormat::local($profile['register_date'])
|
2020-01-26 15:54:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if (!empty($profile['dob']) && $profile['dob'] > DBA::NULL_DATE) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$year_bd_format = $this->t('j F, Y');
|
|
|
|
$short_bd_format = $this->t('j F');
|
2020-01-26 15:54:21 +01:00
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$dob = $this->l10n->getDay(
|
2021-07-24 12:09:39 +02:00
|
|
|
intval($profile['dob']) ?
|
|
|
|
DateTimeFormat::utc($profile['dob'] . ' 00:00 +00:00', $year_bd_format)
|
|
|
|
: DateTimeFormat::utc('2001-' . substr($profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
|
2020-01-26 15:54:21 +01:00
|
|
|
);
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('dob', $this->t('Birthday:'), $dob);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if ($age = Temporal::getAgeByTimezone($profile['dob'], $profile['timezone'])) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('age', $this->t('Age: '), $this->tt('%d year old', '%d years old', $age));
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if ($profile['about']) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('about', $this->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if ($profile['xmpp']) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('xmpp', $this->t('XMPP:'), $profile['xmpp']);
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
2021-08-09 03:39:09 +02:00
|
|
|
if ($profile['matrix']) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('matrix', $this->t('Matrix:'), $profile['matrix']);
|
2021-08-09 03:39:09 +02:00
|
|
|
}
|
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if ($profile['homepage']) {
|
2022-12-19 05:24:59 +01:00
|
|
|
$basic_fields += self::buildField(
|
|
|
|
'homepage',
|
|
|
|
$this->t('Homepage:'),
|
|
|
|
$this->tryRelMe($profile['homepage']) ?: $profile['homepage']
|
|
|
|
);
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
2021-07-24 12:09:39 +02:00
|
|
|
$profile['address']
|
|
|
|
|| $profile['locality']
|
|
|
|
|| $profile['postal-code']
|
|
|
|
|| $profile['region']
|
|
|
|
|| $profile['country-name']
|
2020-01-26 15:54:21 +01:00
|
|
|
) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('location', $this->t('Location:'), ProfileModel::formatLocation($profile));
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
2021-07-24 12:09:39 +02:00
|
|
|
if ($profile['pub_keywords']) {
|
2020-01-26 15:54:21 +01:00
|
|
|
$tags = [];
|
2021-01-23 21:55:21 +01:00
|
|
|
// Separator is defined in Module\Settings\Profile\Index::cleanKeywords
|
2021-07-24 12:09:39 +02:00
|
|
|
foreach (explode(', ', $profile['pub_keywords']) as $tag_label) {
|
2020-01-26 15:54:21 +01:00
|
|
|
$tags[] = [
|
2022-12-19 04:49:18 +01:00
|
|
|
'url' => '/search?tag=' . $tag_label,
|
2020-04-26 17:24:58 +02:00
|
|
|
'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label,
|
2020-01-26 15:54:21 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$basic_fields += self::buildField('pub_keywords', $this->t('Tags:'), $tags);
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$custom_fields = [];
|
|
|
|
|
|
|
|
// Defaults to the current logged in user self contact id to show self-only fields
|
|
|
|
$contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0;
|
|
|
|
|
|
|
|
if ($is_owner && $contact_id === 0) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$profile_fields = $this->profileField->selectByUserId($profile['uid']);
|
2020-01-26 15:54:21 +01:00
|
|
|
} else {
|
2022-12-19 04:49:18 +01:00
|
|
|
$profile_fields = $this->profileField->selectByContactId($contact_id, $profile['uid']);
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($profile_fields as $profile_field) {
|
|
|
|
$custom_fields += self::buildField(
|
|
|
|
'custom_' . $profile_field->order,
|
|
|
|
$profile_field->label,
|
2022-12-19 05:24:59 +01:00
|
|
|
$this->tryRelMe($profile_field->value) ?: BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
|
2020-01-26 15:54:21 +01:00
|
|
|
'aprofile custom'
|
|
|
|
);
|
2022-12-19 04:49:18 +01:00
|
|
|
}
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
//show subcribed forum if it is enabled in the usersettings
|
2021-07-24 12:09:39 +02:00
|
|
|
if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
|
2020-01-26 15:54:21 +01:00
|
|
|
$custom_fields += self::buildField(
|
|
|
|
'forumlist',
|
2022-12-19 04:49:18 +01:00
|
|
|
$this->t('Forums:'),
|
2021-07-24 12:09:39 +02:00
|
|
|
ForumManager::profileAdvanced($profile['uid'])
|
2020-01-26 15:54:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-12-20 04:52:03 +01:00
|
|
|
$tpl = Renderer::getMarkupTemplate('profile/profile.tpl');
|
2022-12-19 04:49:18 +01:00
|
|
|
$o .= Renderer::replaceMacros($tpl, [
|
|
|
|
'$title' => $this->t('Profile'),
|
|
|
|
'$yourself' => $this->t('Yourself'),
|
|
|
|
'$view_as_contacts' => $view_as_contacts,
|
|
|
|
'$view_as_contact_id' => $view_as_contact_id,
|
2020-07-28 17:40:14 +02:00
|
|
|
'$view_as_contact_alert' => $view_as_contact_alert,
|
2022-12-19 04:49:18 +01:00
|
|
|
'$view_as' => $this->t('View profile as:'),
|
|
|
|
'$submit' => $this->t('Submit'),
|
|
|
|
'$basic' => $this->t('Basic'),
|
|
|
|
'$advanced' => $this->t('Advanced'),
|
|
|
|
'$is_owner' => $profile['uid'] == $this->session->getLocalUserId(),
|
|
|
|
'$query_string' => $this->args->getQueryString(),
|
|
|
|
'$basic_fields' => $basic_fields,
|
|
|
|
'$custom_fields' => $custom_fields,
|
|
|
|
'$profile' => $profile,
|
|
|
|
'$edit_link' => [
|
|
|
|
'url' => 'settings/profile', $this->t('Edit profile'),
|
2020-01-26 15:54:21 +01:00
|
|
|
'title' => '',
|
2022-12-19 04:49:18 +01:00
|
|
|
'label' => $this->t('Edit profile')
|
2020-01-26 15:54:21 +01:00
|
|
|
],
|
2022-12-19 04:49:18 +01:00
|
|
|
'$viewas_link' => [
|
|
|
|
'url' => $this->args->getQueryString() . '#viewas',
|
2020-07-28 17:40:14 +02:00
|
|
|
'title' => '',
|
2022-12-19 04:49:18 +01:00
|
|
|
'label' => $this->t('View as')
|
2020-07-28 17:40:14 +02:00
|
|
|
],
|
2020-01-26 15:54:21 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
Hook::callAll('profile_advanced', $o);
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a profile field structure to be used in the profile template
|
|
|
|
*
|
|
|
|
* @param string $name Arbitrary name of the field
|
|
|
|
* @param string $label Display label of the field
|
|
|
|
* @param mixed $value Display value of the field
|
|
|
|
* @param string $class Optional CSS class to apply to the field
|
|
|
|
* @return array
|
|
|
|
*/
|
2022-12-19 04:49:18 +01:00
|
|
|
private static function buildField(string $name, string $label, $value, string $class = 'aprofile'): array
|
2020-01-26 15:54:21 +01:00
|
|
|
{
|
|
|
|
return [$name => [
|
2022-12-19 04:49:18 +01:00
|
|
|
'id' => 'aprofile-' . $name,
|
2020-01-26 15:54:21 +01:00
|
|
|
'class' => $class,
|
|
|
|
'label' => $label,
|
|
|
|
'value' => $value,
|
|
|
|
]];
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
private function buildHtmlHead(array $profile, string $nickname): string
|
2020-01-26 15:54:21 +01:00
|
|
|
{
|
|
|
|
$htmlhead = "\n";
|
|
|
|
|
|
|
|
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
|
|
|
$htmlhead .= '<meta name="friendica.community" content="true" />' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($profile['openidserver'])) {
|
|
|
|
$htmlhead .= '<link rel="openid.server" href="' . $profile['openidserver'] . '" />' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($profile['openid'])) {
|
|
|
|
$delegate = strstr($profile['openid'], '://') ? $profile['openid'] : 'https://' . $profile['openid'];
|
|
|
|
$htmlhead .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// site block
|
2022-12-19 04:49:18 +01:00
|
|
|
$blocked = !$this->session->isAuthenticated() && $this->config->get('system', 'block_public');
|
|
|
|
$userblock = !$this->session->isAuthenticated() && $profile['hidewall'];
|
2020-01-26 15:54:21 +01:00
|
|
|
if (!$blocked && !$userblock) {
|
|
|
|
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
|
|
|
|
if (strlen($keywords)) {
|
|
|
|
$htmlhead .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$htmlhead .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
|
|
|
|
|
2020-02-16 16:39:44 +01:00
|
|
|
if (!$profile['net-publish']) {
|
2020-01-26 15:54:21 +01:00
|
|
|
$htmlhead .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:49:18 +01:00
|
|
|
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
|
|
|
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
|
|
|
|
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
|
|
|
|
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
|
|
|
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : ''));
|
|
|
|
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $this->baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
|
|
|
|
header('Link: <' . $this->baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
2020-01-26 15:54:21 +01:00
|
|
|
|
|
|
|
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
|
|
|
|
foreach ($dfrn_pages as $dfrn) {
|
2022-12-19 04:49:18 +01:00
|
|
|
$htmlhead .= '<link rel="dfrn-' . $dfrn . '" href="' . $this->baseUrl . '/dfrn_' . $dfrn . '/' . $nickname . '" />' . "\n";
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $htmlhead;
|
|
|
|
}
|
2022-12-19 05:24:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the input is an HTTP(S) link and returns a rel="me" link if yes, empty string if not
|
|
|
|
*
|
|
|
|
* @param string $input
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function tryRelMe(string $input): string
|
|
|
|
{
|
|
|
|
if (preg_match(Strings::onlyLinkRegEx(), trim($input))) {
|
|
|
|
return '<a href="' . trim($input) . '" target="_blank" rel="noopener noreferrer me">' . trim($input) . '</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
2020-01-26 15:54:21 +01:00
|
|
|
}
|