Merge branch 'develop' into notifications-summary

This commit is contained in:
Hank Grabowski 2023-02-20 10:06:59 -05:00
commit 843502badc
140 changed files with 1030 additions and 1508 deletions

View file

@ -36,7 +36,6 @@ return [
'sitename' => 'Friendica Social Network', 'sitename' => 'Friendica Social Network',
'register_policy' => \Friendica\Module\Register::OPEN, 'register_policy' => \Friendica\Module\Register::OPEN,
'register_text' => '', 'register_text' => '',
'hostname' => 'friendica.local',
], ],
'system' => [ 'system' => [
'default_timezone' => 'UTC', 'default_timezone' => 'UTC',

View file

@ -48,5 +48,6 @@ $a->runFrontend(
$dice->create(\Friendica\Content\Nav::class), $dice->create(\Friendica\Content\Nav::class),
$dice->create(Friendica\Module\Special\HTTPException::class), $dice->create(Friendica\Module\Special\HTTPException::class),
new \Friendica\Util\HTTPInputData($_SERVER), new \Friendica\Util\HTTPInputData($_SERVER),
$start_time $start_time,
$_SERVER
); );

View file

@ -58,7 +58,6 @@ function message_init(App $a)
$head_tpl = Renderer::getMarkupTemplate('message-head.tpl'); $head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
'$baseurl' => DI::baseUrl()->get(true),
'$base' => $base '$base' => $base
]); ]);
} }
@ -178,7 +177,6 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('msg-header.tpl'); $tpl = Renderer::getMarkupTemplate('msg-header.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => DI::baseUrl()->get(true),
'$nickname' => $a->getLoggedInUserNickname(), '$nickname' => $a->getLoggedInUserNickname(),
'$linkurl' => DI::l10n()->t('Please enter a link URL:') '$linkurl' => DI::l10n()->t('Please enter a link URL:')
]); ]);
@ -284,7 +282,6 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('msg-header.tpl'); $tpl = Renderer::getMarkupTemplate('msg-header.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => DI::baseUrl()->get(true),
'$nickname' => $a->getLoggedInUserNickname(), '$nickname' => $a->getLoggedInUserNickname(),
'$linkurl' => DI::l10n()->t('Please enter a link URL:') '$linkurl' => DI::l10n()->t('Please enter a link URL:')
]); ]);

View file

@ -35,7 +35,6 @@ return [
// **************************************************************** // ****************************************************************
'config' => [ 'config' => [
'hostname' => 'friendica.local',
'admin_email' => 'admin@friendica.local', 'admin_email' => 'admin@friendica.local',
'sitename' => 'Friendica Social Network', 'sitename' => 'Friendica Social Network',
'register_policy' => \Friendica\Module\Register::OPEN, 'register_policy' => \Friendica\Module\Register::OPEN,
@ -44,9 +43,7 @@ return [
'system' => [ 'system' => [
'default_timezone' => 'UTC', 'default_timezone' => 'UTC',
'language' => 'en', 'language' => 'en',
'ssl_policy' => \Friendica\App\BaseURL::SSL_POLICY_SELFSIGN,
'url' => 'https://friendica.local', 'url' => 'https://friendica.local',
'urlpath' => '',
// don't start unexpected worker.php processes during test! // don't start unexpected worker.php processes during test!
'worker_dont_fork' => true, 'worker_dont_fork' => true,
], ],

View file

@ -29,7 +29,6 @@ return [
// **************************************************************** // ****************************************************************
'config' => [ 'config' => [
'hostname' => '192.168.56.10',
'admin_email' => 'admin@friendica.local', 'admin_email' => 'admin@friendica.local',
'sitename' => 'Friendica Social Network', 'sitename' => 'Friendica Social Network',
'register_policy' => \Friendica\Module\Register::OPEN, 'register_policy' => \Friendica\Module\Register::OPEN,
@ -39,8 +38,6 @@ return [
'default_timezone' => 'UTC', 'default_timezone' => 'UTC',
'language' => 'en', 'language' => 'en',
'basepath' => '/vagrant', 'basepath' => '/vagrant',
'ssl_policy' => \Friendica\App\BaseURL::SSL_POLICY_SELFSIGN,
'url' => 'https://192.168.56.10', 'url' => 'https://192.168.56.10',
'urlpath' => '',
], ],
]; ];

View file

@ -555,11 +555,12 @@ class App
* @param ModuleHTTPException $httpException The possible HTTP Exception container * @param ModuleHTTPException $httpException The possible HTTP Exception container
* @param HTTPInputData $httpInput A library for processing PHP input streams * @param HTTPInputData $httpInput A library for processing PHP input streams
* @param float $start_time The start time of the overall script execution * @param float $start_time The start time of the overall script execution
* @param array $server The $_SERVER array
* *
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public function runFrontend(App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, Nav $nav, ModuleHTTPException $httpException, HTTPInputData $httpInput, float $start_time) public function runFrontend(App\Router $router, IManagePersonalConfigValues $pconfig, Authentication $auth, App\Page $page, Nav $nav, ModuleHTTPException $httpException, HTTPInputData $httpInput, float $start_time, array $server)
{ {
$this->profiler->set($start_time, 'start'); $this->profiler->set($start_time, 'start');
$this->profiler->set(microtime(true), 'classinit'); $this->profiler->set(microtime(true), 'classinit');
@ -575,10 +576,12 @@ class App
if (!$this->mode->isInstall()) { if (!$this->mode->isInstall()) {
// Force SSL redirection // Force SSL redirection
if ($this->baseURL->checkRedirectHttps()) { if ($this->config->get('system', 'force_ssl') &&
System::externalRedirect($this->baseURL->get() . '/' . $this->args->getQueryString()); (empty($server['HTTPS']) || $server['HTTPS'] === 'off') &&
!empty($server['REQUEST_METHOD']) &&
$server['REQUEST_METHOD'] === 'GET') {
System::externalRedirect($this->baseURL . '/' . $this->args->getQueryString());
} }
Core\Hook::callAll('init_1'); Core\Hook::callAll('init_1');
} }

View file

@ -23,284 +23,64 @@ namespace Friendica\App;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Psr\Log\LoggerInterface;
/** /**
* A class which checks and contains the basic * A class which checks and contains the basic
* environment for the BaseURL (url, urlpath, ssl_policy, hostname, scheme) * environment for the BaseURL (url, urlpath, ssl_policy, hostname, scheme)
*/ */
class BaseURL class BaseURL extends Uri implements UriInterface
{ {
/** public function __construct(IManageConfigValues $config, LoggerInterface $logger, array $server = [])
* No SSL necessary
*/
const SSL_POLICY_NONE = 0;
/**
* SSL is necessary
*/
const SSL_POLICY_FULL = 1;
/**
* SSL is optional, but preferred
*/
const SSL_POLICY_SELFSIGN = 2;
/**
* Define the Default SSL scheme
*/
const DEFAULT_SSL_SCHEME = self::SSL_POLICY_SELFSIGN;
/**
* The Friendica Config
*
* @var IManageConfigValues
*/
private $config;
/**
* The server side variables
*
* @var array
*/
private $server;
/**
* The hostname of the Base URL
*
* @var string
*/
private $hostname;
/**
* The SSL_POLICY of the Base URL
*
* @var int
*/
private $sslPolicy;
/**
* The URL sub-path of the Base URL
*
* @var string
*/
private $urlPath;
/**
* The full URL
*
* @var string
*/
private $url;
/**
* The current scheme of this call
*
* @var string
*/
private $scheme;
/**
* Returns the hostname of this node
*
* @return string
*/
public function getHostname(): string
{ {
return $this->hostname; $url = $config->get('system', 'url');
if (empty($url)) {
$logger->critical('Invalid config - Missing system.url');
$url = ServerRequest::getUriFromGlobals()
->withQuery('')
->withPath($this->determineURLPath($server));
}
parent::__construct($url);
} }
/** /**
* Returns the current scheme of this call * Figure out if we are running at the top of a domain or in a subdirectory
*
* @return string
*/ */
public function getScheme(): string private function determineURLPath(array $server): string
{ {
return $this->scheme; /* Relative script path to the web server root
} * Not all of those $_SERVER properties can be present, so we do by inverse priority order
*/
$relativeScriptPath =
($server['REDIRECT_URL'] ?? '') ?:
($server['REDIRECT_URI'] ?? '') ?:
($server['REDIRECT_SCRIPT_URL'] ?? '') ?:
($server['SCRIPT_URL'] ?? '') ?:
$server['REQUEST_URI'] ?? '';
/** /* $relativeScriptPath gives /relative/path/to/friendica/module/parameter
* Returns the SSL policy of this node * QUERY_STRING gives pagename=module/parameter
* *
* @return int * To get /relative/path/to/friendica we perform dirname() for as many levels as there are slashes in the QUERY_STRING
*/ */
public function getSSLPolicy(): int if (!empty($relativeScriptPath)) {
{ // Module
return $this->sslPolicy; if (!empty($server['QUERY_STRING'])) {
} return trim(dirname($relativeScriptPath, substr_count(trim($server['QUERY_STRING'], '/'), '/') + 1), '/');
} else {
/** // Root page
* Returns the sub-path of this URL $scriptPathParts = explode('?', $relativeScriptPath, 2);
* return trim($scriptPathParts[0], '/');
* @return string
*/
public function getUrlPath(): string
{
return $this->urlPath;
}
/**
* Returns the full URL of this call
*
* Note: $ssl parameter value doesn't directly correlate with the resulting protocol
*
* @param bool $ssl True, if ssl should get used
*
* @return string
*/
public function get(bool $ssl = false): string
{
if ($this->sslPolicy === self::SSL_POLICY_SELFSIGN && $ssl) {
return Network::switchScheme($this->url);
}
return $this->url;
}
/**
* Save current parts of the base Url
*
* @param string? $hostname
* @param int? $sslPolicy
* @param string? $urlPath
*
* @return bool true, if successful
* @TODO Find proper types
*/
public function save($hostname = null, $sslPolicy = null, $urlPath = null): bool
{
$currUrl = $this->url;
$configTransaction = $this->config->beginTransaction();
if (!empty($hostname) && $hostname !== $this->hostname) {
$configTransaction->set('config', 'hostname', $hostname);
$this->hostname = $hostname;
}
if (isset($sslPolicy) && $sslPolicy !== $this->sslPolicy) {
$configTransaction->set('system', 'ssl_policy', $sslPolicy);
$this->sslPolicy = $sslPolicy;
}
if (isset($urlPath) && $urlPath !== $this->urlPath) {
$configTransaction->set('system', 'urlpath', $urlPath);
$this->urlPath = $urlPath;
}
$this->determineBaseUrl();
if ($this->url !== $currUrl) {
$configTransaction->set('system', 'url', $this->url);
}
$configTransaction->commit();
return true;
}
/**
* Save the current url as base URL
*
* @param string $url
*
* @return bool true, if the save was successful
*/
public function saveByURL(string $url): bool
{
$parsed = @parse_url($url);
if (empty($parsed) || empty($parsed['host'])) {
return false;
}
$hostname = $parsed['host'];
if (!empty($hostname) && !empty($parsed['port'])) {
$hostname .= ':' . $parsed['port'];
}
$urlPath = null;
if (!empty($parsed['path'])) {
$urlPath = trim($parsed['path'], '\\/');
}
$sslPolicy = null;
if (!empty($parsed['scheme'])) {
if ($parsed['scheme'] == 'https') {
$sslPolicy = BaseURL::SSL_POLICY_FULL;
} }
} }
return $this->save($hostname, $sslPolicy, $urlPath); return '';
}
/**
* Checks, if a redirect to the HTTPS site would be necessary
*
* @return bool
*/
public function checkRedirectHttps()
{
return $this->config->get('system', 'force_ssl') &&
($this->getScheme() == "http") &&
intval($this->getSSLPolicy()) == BaseURL::SSL_POLICY_FULL &&
strpos($this->get(), 'https://') === 0 &&
!empty($this->server['REQUEST_METHOD']) &&
$this->server['REQUEST_METHOD'] === 'GET';
}
/**
* @param IManageConfigValues $config The Friendica IConfiguration
* @param array $server The $_SERVER array
*/
public function __construct(IManageConfigValues $config, array $server)
{
$this->config = $config;
$this->server = $server;
$this->hostname = $this->config->get('config', 'hostname');
$this->urlPath = $this->config->get('system', 'urlpath') ?? '';
$this->sslPolicy = $this->config->get('system', 'ssl_policy') ?? static::DEFAULT_SSL_SCHEME;
$this->url = $this->config->get('system', 'url');
if (empty($this->hostname) || empty($this->url)) {
throw new \Exception('Invalid config - Missing system.url or config.hostname');
}
$this->determineSchema();
}
/**
* Determine the full URL based on all parts
*/
private function determineBaseUrl()
{
$scheme = 'http';
if ($this->sslPolicy == self::SSL_POLICY_FULL) {
$scheme = 'https';
}
$this->url = $scheme . '://' . $this->hostname . (!empty($this->urlPath) ? '/' . $this->urlPath : '');
}
/**
* Determine the scheme of the current used link
*/
private function determineSchema()
{
$this->scheme = 'http';
if (!empty($this->server['HTTPS']) ||
!empty($this->server['HTTP_FORWARDED']) && preg_match('/proto=https/', $this->server['HTTP_FORWARDED']) ||
!empty($this->server['HTTP_X_FORWARDED_PROTO']) && $this->server['HTTP_X_FORWARDED_PROTO'] == 'https' ||
!empty($this->server['HTTP_X_FORWARDED_SSL']) && $this->server['HTTP_X_FORWARDED_SSL'] == 'on' ||
!empty($this->server['FRONT_END_HTTPS']) && $this->server['FRONT_END_HTTPS'] == 'on' ||
!empty($this->server['SERVER_PORT']) && (intval($this->server['SERVER_PORT']) == 443) // XXX: reasonable assumption, but isn't this hardcoding too much?
) {
$this->scheme = 'https';
}
} }
/** /**
@ -314,11 +94,11 @@ class BaseURL
{ {
// Remove the hostname from the url if it is an internal link // Remove the hostname from the url if it is an internal link
$nurl = Strings::normaliseLink($origURL); $nurl = Strings::normaliseLink($origURL);
$base = Strings::normaliseLink($this->get()); $base = Strings::normaliseLink($this->__toString());
$url = str_replace($base . '/', '', $nurl); $url = str_replace($base . '/', '', $nurl);
// if it is an external link return the orignal value // if it is an external link return the original value
if ($url == Strings::normaliseLink($origURL)) { if ($url === $nurl) {
return $origURL; return $origURL;
} else { } else {
return $url; return $url;
@ -344,15 +124,7 @@ class BaseURL
throw new HTTPException\InternalServerErrorException("$toUrl is not a relative path, please use System::externalRedirectTo"); throw new HTTPException\InternalServerErrorException("$toUrl is not a relative path, please use System::externalRedirectTo");
} }
$redirectTo = $this->get($ssl) . '/' . ltrim($toUrl, '/'); $redirectTo = $this->__toString() . '/' . ltrim($toUrl, '/');
System::externalRedirect($redirectTo); System::externalRedirect($redirectTo);
} }
/**
* Returns the base url as string
*/
public function __toString(): string
{
return (string) $this->get();
}
} }

View file

@ -523,7 +523,7 @@ class Page implements ArrayAccess
header("X-Friendica-Version: " . App::VERSION); header("X-Friendica-Version: " . App::VERSION);
header("Content-type: text/html; charset=utf-8"); header("Content-type: text/html; charset=utf-8");
if ($config->get('system', 'hsts') && ($baseURL->getSSLPolicy() == BaseURL::SSL_POLICY_FULL)) { if ($config->get('system', 'hsts') && ($baseURL->getScheme() === 'https')) {
header("Strict-Transport-Security: max-age=31536000"); header("Strict-Transport-Security: max-age=31536000");
} }

View file

@ -199,8 +199,7 @@ HELP;
$this->out('The Friendica URL has to be set during CLI installation.'); $this->out('The Friendica URL has to be set during CLI installation.');
return 1; return 1;
} else { } else {
$baseUrl = new BaseURL($this->config, []); $configCache->set('system', 'url', $url);
$baseUrl->saveByURL($url);
} }
$installer->createConfig($configCache); $installer->createConfig($configCache);

View file

@ -94,7 +94,7 @@ HELP;
$fields = ['id', 'avatar', 'photo', 'thumb', 'micro', 'uri-id', 'url', 'avatar', 'network']; $fields = ['id', 'avatar', 'photo', 'thumb', 'micro', 'uri-id', 'url', 'avatar', 'network'];
$condition = ["NOT `self` AND `avatar` != ? AND `photo` LIKE ? AND `uid` = ? AND `uri-id` != ? AND NOT `uri-id` IS NULL AND NOT `network` IN (?, ?)", $condition = ["NOT `self` AND `avatar` != ? AND `photo` LIKE ? AND `uid` = ? AND `uri-id` != ? AND NOT `uri-id` IS NULL AND NOT `network` IN (?, ?)",
'', $this->baseUrl->get() . '/photo/%', 0, 0, Protocol::MAIL, Protocol::FEED]; '', $this->baseUrl . '/photo/%', 0, 0, Protocol::MAIL, Protocol::FEED];
$count = 0; $count = 0;
$total = $this->dba->count('contact', $condition); $total = $this->dba->count('contact', $condition);

View file

@ -92,9 +92,9 @@ HELP;
throw new \InvalidArgumentException('Can not parse new base URL. Must have at least <scheme>://<domain>'); throw new \InvalidArgumentException('Can not parse new base URL. Must have at least <scheme>://<domain>');
} }
$this->out(sprintf('Relocation started from %s to %s. Could take a while to complete.', $this->baseUrl->get(true), $this->getArgument(0))); $this->out(sprintf('Relocation started from %s to %s. Could take a while to complete.', $this->baseUrl, $this->getArgument(0)));
$old_url = $this->baseUrl->get(true); $old_url = $this->baseUrl;
// Generate host names for relocation the addresses in the format user@address.tld // Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace('http://', '@', Strings::normaliseLink($new_url)); $new_host = str_replace('http://', '@', Strings::normaliseLink($new_url));
@ -179,7 +179,6 @@ HELP;
// update config // update config
$this->out('Updating config values'); $this->out('Updating config values');
$this->config->set('system', 'url', $new_url); $this->config->set('system', 'url', $new_url);
$this->baseUrl->saveByURL($new_url);
$this->database->commit(); $this->database->commit();
} catch (\Throwable $e) { } catch (\Throwable $e) {

View file

@ -314,7 +314,7 @@ class Conversation
$tpl = Renderer::getMarkupTemplate('jot-header.tpl'); $tpl = Renderer::getMarkupTemplate('jot-header.tpl');
$this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$newpost' => 'true', '$newpost' => 'true',
'$baseurl' => $this->baseURL->get(true), '$baseurl' => $this->baseURL,
'$geotag' => $geotag, '$geotag' => $geotag,
'$nickname' => $x['nickname'], '$nickname' => $x['nickname'],
'$ispublic' => $this->l10n->t('Visible to <strong>everybody</strong>'), '$ispublic' => $this->l10n->t('Visible to <strong>everybody</strong>'),
@ -385,7 +385,7 @@ class Conversation
'$posttype' => $notes_cid ? ItemModel::PT_PERSONAL_NOTE : ItemModel::PT_ARTICLE, '$posttype' => $notes_cid ? ItemModel::PT_PERSONAL_NOTE : ItemModel::PT_ARTICLE,
'$content' => $x['content'] ?? '', '$content' => $x['content'] ?? '',
'$post_id' => $x['post_id'] ?? '', '$post_id' => $x['post_id'] ?? '',
'$baseurl' => $this->baseURL->get(true), '$baseurl' => $this->baseURL,
'$defloc' => $x['default_location'], '$defloc' => $x['default_location'],
'$visitor' => $x['visitor'], '$visitor' => $x['visitor'],
'$pvisit' => $notes_cid ? 'none' : $x['visitor'], '$pvisit' => $notes_cid ? 'none' : $x['visitor'],
@ -446,8 +446,6 @@ class Conversation
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); $this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
$ssl_state = (bool)$this->session->getLocalUserId();
$live_update_div = ''; $live_update_div = '';
$blocklist = $this->getBlocklist(); $blocklist = $this->getBlocklist();
@ -784,7 +782,7 @@ class Conversation
} }
$o = Renderer::replaceMacros($page_template, [ $o = Renderer::replaceMacros($page_template, [
'$baseurl' => $this->baseURL->get($ssl_state), '$baseurl' => $this->baseURL,
'$return_path' => $this->args->getQueryString(), '$return_path' => $this->args->getQueryString(),
'$live_update' => $live_update_div, '$live_update' => $live_update_div,
'$remove' => $this->l10n->t('remove'), '$remove' => $this->l10n->t('remove'),

View file

@ -903,7 +903,7 @@ class Item
if ($post['attach']) { if ($post['attach']) {
$post['attach'] .= ','; $post['attach'] .= ',';
} }
$post['attach'] .= Post\Media::getAttachElement($this->baseURL->get() . '/attach/' . $attachment['id'], $post['attach'] .= Post\Media::getAttachElement($this->baseURL . '/attach/' . $attachment['id'],
$attachment['filesize'], $attachment['filetype'], $attachment['filename'] ?? ''); $attachment['filesize'], $attachment['filetype'], $attachment['filename'] ?? '');
$fields = ['allow_cid' => $post['allow_cid'], 'allow_gid' => $post['allow_gid'], $fields = ['allow_cid' => $post['allow_cid'], 'allow_gid' => $post['allow_gid'],

View file

@ -184,8 +184,6 @@ class Nav
*/ */
private function getInfo(): array private function getInfo(): array
{ {
$ssl_state = (bool) $this->session->getLocalUserId();
/* /*
* Our network is distributed, and as you visit friends some * Our network is distributed, and as you visit friends some
* sites look exactly the same - it isn't always easy to know where you are. * sites look exactly the same - it isn't always easy to know where you are.
@ -194,7 +192,7 @@ class Nav
$myident = !empty($this->session->getLocalUserNickname()) ? $this->session->getLocalUserNickname() . '@' : ''; $myident = !empty($this->session->getLocalUserNickname()) ? $this->session->getLocalUserNickname() . '@' : '';
$sitelocation = $myident . substr($this->baseUrl->get($ssl_state), strpos($this->baseUrl->get($ssl_state), '//') + 2); $sitelocation = $myident . substr($this->baseUrl, strpos($this->baseUrl, '//') + 2);
$nav = [ $nav = [
'admin' => null, 'admin' => null,

View file

@ -1274,7 +1274,7 @@ class BBCode
private static function cleanPictureLinksCallback(array $match): string private static function cleanPictureLinksCallback(array $match): string
{ {
// When the picture link is the own photo path then we can avoid fetching the link // When the picture link is the own photo path then we can avoid fetching the link
$own_photo_url = preg_quote(Strings::normaliseLink(DI::baseUrl()->get()) . '/photos/'); $own_photo_url = preg_quote(Strings::normaliseLink(DI::baseUrl()) . '/photos/');
if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) { if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) {
if (!empty($match[3])) { if (!empty($match[3])) {
$text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]'; $text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]';
@ -2099,8 +2099,8 @@ class BBCode
// Default iframe allowed domains/path // Default iframe allowed domains/path
$allowedIframeDomains = [ $allowedIframeDomains = [
DI::baseUrl()->getHostname() DI::baseUrl()->getHost()
. (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : '') . (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : '')
. '/oembed/', # The path part has to change with the source in Content\Oembed::iframe . '/oembed/', # The path part has to change with the source in Content\Oembed::iframe
'www.youtube.com/embed/', 'www.youtube.com/embed/',
'player.vimeo.com/video/', 'player.vimeo.com/video/',

View file

@ -73,7 +73,7 @@ class Cache
public function __construct(BaseURL $baseURL, IManageConfigValues $config, Database $dba, Profiler $profiler, LoggerInterface $logger) public function __construct(BaseURL $baseURL, IManageConfigValues $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
{ {
$this->hostname = $baseURL->getHostname(); $this->hostname = $baseURL->getHost();
$this->config = $config; $this->config = $config;
$this->dba = $dba; $this->dba = $dba;
$this->profiler = $profiler; $this->profiler = $profiler;

View file

@ -158,23 +158,20 @@ class Installer
{ {
$basepath = $configCache->get('system', 'basepath'); $basepath = $configCache->get('system', 'basepath');
$tpl = Renderer::getMarkupTemplate('local.config.tpl'); $tpl = Renderer::getMarkupTemplate('install/local.config.tpl');
$txt = Renderer::replaceMacros($tpl, [ $txt = Renderer::replaceMacros($tpl, [
'$dbhost' => $configCache->get('database', 'hostname'), '$dbhost' => $configCache->get('database', 'hostname'),
'$dbuser' => $configCache->get('database', 'username'), '$dbuser' => $configCache->get('database', 'username'),
'$dbpass' => $configCache->get('database', 'password'), '$dbpass' => $configCache->get('database', 'password'),
'$dbdata' => $configCache->get('database', 'database'), '$dbdata' => $configCache->get('database', 'database'),
'$phpath' => $configCache->get('config', 'php_path'), '$phpath' => $configCache->get('config', 'php_path'),
'$adminmail' => $configCache->get('config', 'admin_email'), '$adminmail' => $configCache->get('config', 'admin_email'),
'$hostname' => $configCache->get('config', 'hostname'),
'$urlpath' => $configCache->get('system', 'urlpath'), '$system_url' => $configCache->get('system', 'url'),
'$baseurl' => $configCache->get('system', 'url'), '$basepath' => $basepath,
'$sslpolicy' => $configCache->get('system', 'ssl_policy'), '$timezone' => $configCache->get('system', 'default_timezone'),
'$basepath' => $basepath, '$language' => $configCache->get('system', 'language'),
'$timezone' => $configCache->get('system', 'default_timezone'),
'$language' => $configCache->get('system', 'language'),
]); ]);
$result = file_put_contents($basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php', $txt); $result = file_put_contents($basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php', $txt);

View file

@ -76,7 +76,7 @@ class Renderer
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
// pass $baseurl to all templates if it isn't set // pass $baseurl to all templates if it isn't set
$vars = array_merge(['$baseurl' => DI::baseUrl()->get(), '$APP' => DI::app()], $vars); $vars = array_merge(['$baseurl' => DI::baseUrl(), '$APP' => DI::app()], $vars);
$t = self::getTemplateEngine(); $t = self::getTemplateEngine();

View file

@ -37,7 +37,7 @@ class Native extends AbstractSession implements IHandleSessions
ini_set('session.use_only_cookies', 1); ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', (int)Cookie::HTTPONLY); ini_set('session.cookie_httponly', (int)Cookie::HTTPONLY);
if ($baseURL->getSSLPolicy() == App\BaseURL::SSL_POLICY_FULL) { if ($baseURL->getScheme() === 'https') {
ini_set('session.cookie_secure', 1); ini_set('session.cookie_secure', 1);
} }

View file

@ -401,7 +401,7 @@ class System
if (is_bool($prefix) && !$prefix) { if (is_bool($prefix) && !$prefix) {
$prefix = ''; $prefix = '';
} elseif (empty($prefix)) { } elseif (empty($prefix)) {
$prefix = hash('crc32', DI::baseUrl()->getHostname()); $prefix = hash('crc32', DI::baseUrl()->getHost());
} }
while (strlen($prefix) < ($size - 13)) { while (strlen($prefix) < ($size - 13)) {
@ -604,7 +604,7 @@ class System
$temppath = BasePath::getRealPath($temppath); $temppath = BasePath::getRealPath($temppath);
// To avoid any interferences with other systems we create our own directory // To avoid any interferences with other systems we create our own directory
$new_temppath = $temppath . "/" . DI::baseUrl()->getHostname(); $new_temppath = $temppath . "/" . DI::baseUrl()->getHost();
if (!is_dir($new_temppath)) { if (!is_dir($new_temppath)) {
/// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method? /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
mkdir($new_temppath); mkdir($new_temppath);

View file

@ -126,10 +126,7 @@ abstract class DI
return self::$dice->create(App\Arguments::class); return self::$dice->create(App\Arguments::class);
} }
/** public static function baseUrl(): App\BaseURL
* @return App\BaseURL
*/
public static function baseUrl()
{ {
return self::$dice->create(App\BaseURL::class); return self::$dice->create(App\BaseURL::class);
} }

View file

@ -90,7 +90,7 @@ class Photo extends BaseFactory
} }
foreach ($photos as $id => $photo) { foreach ($photos as $id => $photo) {
$link = $this->baseUrl->get() . '/photo/' . $data['resource-id'] . '-' . $photo['scale'] . Images::getExtensionByMimeType($data['type']); $link = $this->baseUrl . '/photo/' . $data['resource-id'] . '-' . $photo['scale'] . Images::getExtensionByMimeType($data['type']);
if ($type == 'xml') { if ($type == 'xml') {
$data['links'][$photo['scale'] . ':link']['@attributes'] = [ $data['links'][$photo['scale'] . ':link']['@attributes'] = [
'type' => $data['type'], 'type' => $data['type'],

View file

@ -570,7 +570,7 @@ class Contact
{ {
if (!parse_url($url, PHP_URL_SCHEME)) { if (!parse_url($url, PHP_URL_SCHEME)) {
$addr_parts = explode('@', $url); $addr_parts = explode('@', $url);
return (count($addr_parts) == 2) && ($addr_parts[1] == DI::baseUrl()->getHostname()); return (count($addr_parts) == 2) && ($addr_parts[1] == DI::baseUrl()->getHost());
} }
return Strings::compareLink(self::getBasepath($url, true), DI::baseUrl()); return Strings::compareLink(self::getBasepath($url, true), DI::baseUrl());

View file

@ -408,7 +408,7 @@ class Item
if ($notify) { if ($notify) {
// We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri. // We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri.
// We add the hash of our own host because our host is the original creator of the post. // We add the hash of our own host because our host is the original creator of the post.
$prefix_host = DI::baseUrl()->getHostname(); $prefix_host = DI::baseUrl()->getHost();
} else { } else {
$prefix_host = ''; $prefix_host = '';
@ -2048,7 +2048,7 @@ class Item
$guid = System::createUUID(); $guid = System::createUUID();
} }
return DI::baseUrl()->get() . '/objects/' . $guid; return DI::baseUrl() . '/objects/' . $guid;
} }
/** /**
@ -2288,7 +2288,7 @@ class Item
} }
// Prevent to forward already forwarded posts // Prevent to forward already forwarded posts
if ($datarray['app'] == DI::baseUrl()->getHostname()) { if ($datarray['app'] == DI::baseUrl()->getHost()) {
Logger::info('Already forwarded (second test)'); Logger::info('Already forwarded (second test)');
return false; return false;
} }

View file

@ -171,7 +171,7 @@ class Nodeinfo
return [ return [
'name' => $administrator['username'] ?? null, 'name' => $administrator['username'] ?? null,
'contact' => $administrator['email'] ?? null, 'contact' => $administrator['email'] ?? null,
'account' => $administrator['nickname'] ?? '' ? DI::baseUrl()->get() . '/profile/' . $administrator['nickname'] : null, 'account' => $administrator['nickname'] ?? '' ? DI::baseUrl() . '/profile/' . $administrator['nickname'] : null,
]; ];
} }
} }

View file

@ -918,7 +918,7 @@ class Photo
*/ */
public static function getResourceData(string $name): array public static function getResourceData(string $name): array
{ {
$base = DI::baseUrl()->get(); $base = DI::baseUrl();
$guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name)); $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
@ -982,7 +982,7 @@ class Photo
*/ */
public static function isLocalPage(string $name): bool public static function isLocalPage(string $name): bool
{ {
$base = DI::baseUrl()->get(); $base = DI::baseUrl();
$guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name)); $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
$guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid); $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);

View file

@ -334,7 +334,7 @@ class Profile
if (!$local_user_is_self) { if (!$local_user_is_self) {
if (!$visitor_is_authenticated) { if (!$visitor_is_authenticated) {
// Remote follow is only available for local profiles // Remote follow is only available for local profiles
if (!empty($profile['nickname']) && strpos($profile_url, DI::baseUrl()->get()) === 0) { if (!empty($profile['nickname']) && strpos($profile_url, DI::baseUrl()) === 0) {
$follow_link = 'profile/' . $profile['nickname'] . '/remote_follow'; $follow_link = 'profile/' . $profile['nickname'] . '/remote_follow';
} }
} else { } else {
@ -756,13 +756,13 @@ class Profile
$query = rtrim(str_replace($addr_request, '', DI::args()->getQueryString()), '?&'); $query = rtrim(str_replace($addr_request, '', DI::args()->getQueryString()), '?&');
// The other instance needs to know where to redirect. // The other instance needs to know where to redirect.
$dest = urlencode(DI::baseUrl()->get() . '/' . $query); $dest = urlencode(DI::baseUrl() . '/' . $query);
// We need to extract the basebath from the profile url // We need to extract the basebath from the profile url
// to redirect the visitors '/magic' module. // to redirect the visitors '/magic' module.
$basepath = Contact::getBasepath($contact['url']); $basepath = Contact::getBasepath($contact['url']);
if ($basepath != DI::baseUrl()->get() && !strstr($dest, '/magic')) { if ($basepath != DI::baseUrl() && !strstr($dest, '/magic')) {
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request; $magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
// We have to check if the remote server does understand /magic without invoking something // We have to check if the remote server does understand /magic without invoking something
@ -870,7 +870,7 @@ class Profile
$a->setContactId($arr['visitor']['id']); $a->setContactId($arr['visitor']['id']);
DI::sysmsg()->addInfo(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name'])); DI::sysmsg()->addInfo(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHost(), $visitor['name']));
Logger::info('OpenWebAuth: auth success from ' . $visitor['addr']); Logger::info('OpenWebAuth: auth success from ' . $visitor['addr']);
} }

View file

@ -534,8 +534,11 @@ class Tag
$searchpath = DI::baseUrl() . '/search?tag='; $searchpath = DI::baseUrl() . '/search?tag=';
$taglist = DBA::select('tag-view', ['type', 'name', 'url', 'cid'], $taglist = DBA::select(
['uri-id' => $item['uri-id'], 'type' => [self::HASHTAG, self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION]]); 'tag-view',
['type', 'name', 'url', 'cid'],
['uri-id' => $item['uri-id'], 'type' => [self::HASHTAG, self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION]]
);
while ($tag = DBA::fetch($taglist)) { while ($tag = DBA::fetch($taglist)) {
if ($tag['url'] == '') { if ($tag['url'] == '') {
$tag['url'] = $searchpath . rawurlencode($tag['name']); $tag['url'] = $searchpath . rawurlencode($tag['name']);
@ -544,7 +547,7 @@ class Tag
$orig_tag = $tag['url']; $orig_tag = $tag['url'];
$prefix = self::TAG_CHARACTER[$tag['type']]; $prefix = self::TAG_CHARACTER[$tag['type']];
switch($tag['type']) { switch ($tag['type']) {
case self::HASHTAG: case self::HASHTAG:
if ($orig_tag != $tag['url']) { if ($orig_tag != $tag['url']) {
$item['body'] = str_replace($orig_tag, $tag['url'], $item['body']); $item['body'] = str_replace($orig_tag, $tag['url'], $item['body']);
@ -639,17 +642,17 @@ class Tag
* *
* @param int $period Period in hours to consider posts * @param int $period Period in hours to consider posts
* @param int $limit Number of returned tags * @param int $limit Number of returned tags
* @param int $offset Page offset in results
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function getGlobalTrendingHashtags(int $period, $limit = 10): array public static function getGlobalTrendingHashtags(int $period, int $limit = 10, int $offset = 0): array
{ {
$tags = DI::cache()->get('global_trending_tags-' . $period . '-' . $limit); $tags = DI::cache()->get("global_trending_tags-$period");
if (!empty($tags)) { if (empty($tags)) {
return $tags; $tags = self::setGlobalTrendingHashtags($period, 1000);
} else {
return self::setGlobalTrendingHashtags($period, $limit);
} }
return array_slice($tags, $offset, $limit);
} }
/** /**
@ -665,7 +668,9 @@ class Tag
} }
$blocked = explode(',', $blocked_txt); $blocked = explode(',', $blocked_txt);
array_walk($blocked, function(&$value) { $value = "'" . DBA::escape(trim($value)) . "'";}); array_walk($blocked, function (&$value) {
$value = "'" . DBA::escape(trim($value)) . "'";
});
return ' AND NOT `name` IN (' . implode(',', $blocked) . ')'; return ' AND NOT `name` IN (' . implode(',', $blocked) . ')';
} }
@ -683,8 +688,11 @@ class Tag
* Get a uri-id that is at least X hours old. * Get a uri-id that is at least X hours old.
* We use the uri-id in the query for the hash tags since this is much faster * We use the uri-id in the query for the hash tags since this is much faster
*/ */
$post = Post::selectFirstThread(['uri-id'], ["`uid` = ? AND `received` < ?", 0, DateTimeFormat::utc('now - ' . $period . ' hour')], $post = Post::selectFirstThread(
['order' => ['received' => true]]); ['uri-id'],
["`uid` = ? AND `received` < ?", 0, DateTimeFormat::utc('now - ' . $period . ' hour')],
['order' => ['received' => true]]
);
if (empty($post['uri-id'])) { if (empty($post['uri-id'])) {
return []; return [];
@ -692,17 +700,20 @@ class Tag
$block_sql = self::getBlockedSQL(); $block_sql = self::getBlockedSQL();
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`, COUNT(DISTINCT(`author-id`)) as `authors` $tagsStmt = DBA::p(
"SELECT `name` AS `term`, COUNT(*) AS `score`, COUNT(DISTINCT(`author-id`)) as `authors`
FROM `tag-search-view` FROM `tag-search-view`
WHERE `private` = ? AND `uid` = ? AND `uri-id` > ? $block_sql WHERE `private` = ? AND `uid` = ? AND `uri-id` > ? $block_sql
GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?", GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?",
Item::PUBLIC, 0, $post['uri-id'], Item::PUBLIC,
0,
$post['uri-id'],
$limit $limit
); );
if (DBA::isResult($tagsStmt)) { if (DBA::isResult($tagsStmt)) {
$tags = DBA::toArray($tagsStmt); $tags = DBA::toArray($tagsStmt);
DI::cache()->set('global_trending_tags-' . $period . '-' . $limit, $tags, Duration::DAY); DI::cache()->set("global_trending_tags-$period", $tags, Duration::HOUR);
return $tags; return $tags;
} }
@ -714,17 +725,17 @@ class Tag
* *
* @param int $period Period in hours to consider posts * @param int $period Period in hours to consider posts
* @param int $limit Number of returned tags * @param int $limit Number of returned tags
* @param int $offset Page offset in results
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function getLocalTrendingHashtags(int $period, $limit = 10): array public static function getLocalTrendingHashtags(int $period, $limit = 10, int $offset = 0): array
{ {
$tags = DI::cache()->get('local_trending_tags-' . $period . '-' . $limit); $tags = DI::cache()->get("local_trending_tags-$period");
if (!empty($tags)) { if (empty($tags)) {
return $tags; $tags = self::setLocalTrendingHashtags($period, 1000);
} else {
return self::setLocalTrendingHashtags($period, $limit);
} }
return array_slice($tags, $offset, $limit);
} }
/** /**
@ -739,25 +750,30 @@ class Tag
{ {
// Get a uri-id that is at least X hours old. // Get a uri-id that is at least X hours old.
// We use the uri-id in the query for the hash tags since this is much faster // We use the uri-id in the query for the hash tags since this is much faster
$post = Post::selectFirstThread(['uri-id'], ["`uid` = ? AND `received` < ?", 0, DateTimeFormat::utc('now - ' . $period . ' hour')], $post = Post::selectFirstThread(
['order' => ['received' => true]]); ['uri-id'],
["`uid` = ? AND `received` < ?", 0, DateTimeFormat::utc('now - ' . $period . ' hour')],
['order' => ['received' => true]]
);
if (empty($post['uri-id'])) { if (empty($post['uri-id'])) {
return []; return [];
} }
$block_sql = self::getBlockedSQL(); $block_sql = self::getBlockedSQL();
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`, COUNT(DISTINCT(`author-id`)) as `authors` $tagsStmt = DBA::p(
"SELECT `name` AS `term`, COUNT(*) AS `score`, COUNT(DISTINCT(`author-id`)) as `authors`
FROM `tag-search-view` FROM `tag-search-view`
WHERE `private` = ? AND `wall` AND `origin` AND `uri-id` > ? $block_sql WHERE `private` = ? AND `wall` AND `origin` AND `uri-id` > ? $block_sql
GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?", GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?",
Item::PUBLIC, $post['uri-id'], Item::PUBLIC,
$post['uri-id'],
$limit $limit
); );
if (DBA::isResult($tagsStmt)) { if (DBA::isResult($tagsStmt)) {
$tags = DBA::toArray($tagsStmt); $tags = DBA::toArray($tagsStmt);
DI::cache()->set('local_trending_tags-' . $period . '-' . $limit, $tags, Duration::DAY); DI::cache()->set("local_trending_tags-$period", $tags, Duration::HOUR);
return $tags; return $tags;
} }

View file

@ -166,7 +166,7 @@ class User
$system['region'] = ''; $system['region'] = '';
$system['postal-code'] = ''; $system['postal-code'] = '';
$system['country-name'] = ''; $system['country-name'] = '';
$system['homepage'] = DI::baseUrl()->get(); $system['homepage'] = DI::baseUrl();
$system['dob'] = '0000-00-00'; $system['dob'] = '0000-00-00';
// Ensure that the user contains data // Ensure that the user contains data
@ -219,7 +219,7 @@ class User
'self' => true, 'self' => true,
'network' => Protocol::ACTIVITYPUB, 'network' => Protocol::ACTIVITYPUB,
'name' => 'System Account', 'name' => 'System Account',
'addr' => $system_actor_name . '@' . DI::baseUrl()->getHostname(), 'addr' => $system_actor_name . '@' . DI::baseUrl()->getHost(),
'nick' => $system_actor_name, 'nick' => $system_actor_name,
'url' => DI::baseUrl() . '/friendica', 'url' => DI::baseUrl() . '/friendica',
'pubkey' => $keys['pubkey'], 'pubkey' => $keys['pubkey'],
@ -1023,7 +1023,7 @@ class User
$_SESSION['register'] = 1; $_SESSION['register'] = 1;
$_SESSION['openid'] = $openid_url; $_SESSION['openid'] = $openid_url;
$openid = new LightOpenID(DI::baseUrl()->getHostname()); $openid = new LightOpenID(DI::baseUrl()->getHost());
$openid->identity = $openid_url; $openid->identity = $openid_url;
$openid->returnUrl = DI::baseUrl() . '/openid'; $openid->returnUrl = DI::baseUrl() . '/openid';
$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson']; $openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
@ -1360,7 +1360,7 @@ class User
$l10n, $l10n,
$user, $user,
DI::config()->get('config', 'sitename'), DI::config()->get('config', 'sitename'),
DI::baseUrl()->get(), DI::baseUrl(),
($register['password'] ?? '') ?: 'Sent in a previous email' ($register['password'] ?? '') ?: 'Sent in a previous email'
); );
} }
@ -1457,7 +1457,7 @@ class User
Thank you and welcome to %4$s.')); Thank you and welcome to %4$s.'));
$preamble = sprintf($preamble, $user['username'], DI::config()->get('config', 'sitename')); $preamble = sprintf($preamble, $user['username'], DI::config()->get('config', 'sitename'));
$body = sprintf($body, DI::baseUrl()->get(), $user['nickname'], $result['password'], DI::config()->get('config', 'sitename')); $body = sprintf($body, DI::baseUrl(), $user['nickname'], $result['password'], DI::config()->get('config', 'sitename'));
$email = DI::emailer() $email = DI::emailer()
->newSystemMail() ->newSystemMail()

View file

@ -59,7 +59,7 @@ class Cookie
*/ */
public function __construct(App\Request $request, IManageConfigValues $config, App\BaseURL $baseURL, array $COOKIE = []) public function __construct(App\Request $request, IManageConfigValues $config, App\BaseURL $baseURL, array $COOKIE = [])
{ {
$this->sslEnabled = $baseURL->getSSLPolicy() === App\BaseURL::SSL_POLICY_FULL; $this->sslEnabled = $baseURL->getScheme() === 'https';
$this->sitePrivateKey = $config->get('system', 'site_prvkey'); $this->sitePrivateKey = $config->get('system', 'site_prvkey');
$authCookieDays = $config->get('system', 'auth_cookie_lifetime', $authCookieDays = $config->get('system', 'auth_cookie_lifetime',

View file

@ -56,7 +56,7 @@ class Objects extends BaseModule
Logger::info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]); Logger::info('Provided GUID found.', ['guid' => $this->parameters['guid'], 'uri-id' => $itemuri['id']]);
} else { } else {
// The item URI does not always contain the GUID. This means that we have to search the URL instead // The item URI does not always contain the GUID. This means that we have to search the URL instead
$url = DI::baseUrl()->get() . '/' . DI::args()->getQueryString(); $url = DI::baseUrl() . '/' . DI::args()->getQueryString();
$nurl = Strings::normaliseLink($url); $nurl = Strings::normaliseLink($url);
$ssl_url = str_replace('http://', 'https://', $nurl); $ssl_url = str_replace('http://', 'https://', $nurl);

View file

@ -112,7 +112,6 @@ class Details extends BaseAdmin
'$page' => DI::l10n()->t('Addons'), '$page' => DI::l10n()->t('Addons'),
'$toggle' => DI::l10n()->t('Toggle'), '$toggle' => DI::l10n()->t('Toggle'),
'$settings' => DI::l10n()->t('Settings'), '$settings' => DI::l10n()->t('Settings'),
'$baseurl' => DI::baseUrl()->get(true),
'$addon' => $addon, '$addon' => $addon,
'$status' => $status, '$status' => $status,

View file

@ -68,7 +68,6 @@ class Index extends BaseAdmin
'$page' => DI::l10n()->t('Addons'), '$page' => DI::l10n()->t('Addons'),
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$reload' => DI::l10n()->t('Reload active addons'), '$reload' => DI::l10n()->t('Reload active addons'),
'$baseurl' => DI::baseUrl()->get(true),
'$function' => 'addons', '$function' => 'addons',
'$addons' => $addons, '$addons' => $addons,
'$pcount' => count($addons), '$pcount' => count($addons),

View file

@ -102,13 +102,11 @@ class DBSync extends BaseAdmin
if (!count($failed)) { if (!count($failed)) {
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [
'$base' => DI::baseUrl()->get(true),
'$banner' => DI::l10n()->t('No failed updates.'), '$banner' => DI::l10n()->t('No failed updates.'),
'$check' => DI::l10n()->t('Check database structure'), '$check' => DI::l10n()->t('Check database structure'),
]); ]);
} else { } else {
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [
'$base' => DI::baseUrl()->get(true),
'$banner' => DI::l10n()->t('Failed Updates'), '$banner' => DI::l10n()->t('Failed Updates'),
'$desc' => DI::l10n()->t('This does not include updates prior to 1139, which did not return a status.'), '$desc' => DI::l10n()->t('This does not include updates prior to 1139, which did not return a status.'),
'$mark' => DI::l10n()->t("Mark success \x28if update was manually applied\x29"), '$mark' => DI::l10n()->t("Mark success \x28if update was manually applied\x29"),

View file

@ -81,7 +81,6 @@ class Features extends BaseAdmin
$tpl = Renderer::getMarkupTemplate('admin/features.tpl'); $tpl = Renderer::getMarkupTemplate('admin/features.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$form_security_token' => self::getFormSecurityToken("admin_manage_features"), '$form_security_token' => self::getFormSecurityToken("admin_manage_features"),
'$baseurl' => DI::baseUrl()->get(true),
'$title' => DI::l10n()->t('Manage Additional Features'), '$title' => DI::l10n()->t('Manage Additional Features'),
'$features' => $features, '$features' => $features,
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),

View file

@ -80,7 +80,6 @@ class Settings extends BaseAdmin
'$page' => DI::l10n()->t('Logs'), '$page' => DI::l10n()->t('Logs'),
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$clear' => DI::l10n()->t('Clear'), '$clear' => DI::l10n()->t('Clear'),
'$baseurl' => DI::baseUrl()->get(true),
'$logname' => DI::config()->get('system', 'logfile'), '$logname' => DI::config()->get('system', 'logfile'),
// see /help/smarty3-templates#1_1 on any Friendica node // see /help/smarty3-templates#1_1 on any Friendica node
'$debugging' => ['debugging', DI::l10n()->t("Enable Debugging"), DI::config()->get('system', 'debugging'), ""], '$debugging' => ['debugging', DI::l10n()->t("Enable Debugging"), DI::config()->get('system', 'debugging'), ""],

View file

@ -80,7 +80,6 @@ class View extends BaseAdmin
} }
} }
return Renderer::replaceMacros($t, [ return Renderer::replaceMacros($t, [
'$baseurl' => DI::baseUrl()->get(true),
'$title' => DI::l10n()->t('Administration'), '$title' => DI::l10n()->t('Administration'),
'$page' => DI::l10n()->t('View Logs'), '$page' => DI::l10n()->t('View Logs'),
'$l10n' => [ '$l10n' => [

View file

@ -118,7 +118,6 @@ class Site extends BaseAdmin
$mail_enabled = !empty($_POST['mail_enabled']); $mail_enabled = !empty($_POST['mail_enabled']);
$ostatus_enabled = !empty($_POST['ostatus_enabled']); $ostatus_enabled = !empty($_POST['ostatus_enabled']);
$diaspora_enabled = !empty($_POST['diaspora_enabled']); $diaspora_enabled = !empty($_POST['diaspora_enabled']);
$ssl_policy = (!empty($_POST['ssl_policy']) ? intval($_POST['ssl_policy']) : 0);
$force_ssl = !empty($_POST['force_ssl']); $force_ssl = !empty($_POST['force_ssl']);
$show_help = !empty($_POST['show_help']); $show_help = !empty($_POST['show_help']);
$dbclean = !empty($_POST['dbclean']); $dbclean = !empty($_POST['dbclean']);
@ -152,49 +151,10 @@ class Site extends BaseAdmin
Worker::add(Worker::PRIORITY_LOW, 'Directory'); Worker::add(Worker::PRIORITY_LOW, 'Directory');
} }
if (DI::baseUrl()->getUrlPath() != "") { if (DI::baseUrl()->getPath() != "") {
$diaspora_enabled = false; $diaspora_enabled = false;
} }
if ($ssl_policy != intval(DI::config()->get('system', 'ssl_policy'))) {
if ($ssl_policy == App\BaseURL::SSL_POLICY_FULL) {
DBA::e("UPDATE `contact` SET
`url` = REPLACE(`url` , 'http:' , 'https:'),
`photo` = REPLACE(`photo` , 'http:' , 'https:'),
`thumb` = REPLACE(`thumb` , 'http:' , 'https:'),
`micro` = REPLACE(`micro` , 'http:' , 'https:'),
`request` = REPLACE(`request`, 'http:' , 'https:'),
`notify` = REPLACE(`notify` , 'http:' , 'https:'),
`poll` = REPLACE(`poll` , 'http:' , 'https:'),
`confirm` = REPLACE(`confirm`, 'http:' , 'https:'),
`poco` = REPLACE(`poco` , 'http:' , 'https:')
WHERE `self` = 1"
);
DBA::e("UPDATE `profile` SET
`photo` = REPLACE(`photo` , 'http:' , 'https:'),
`thumb` = REPLACE(`thumb` , 'http:' , 'https:')
WHERE 1 "
);
} elseif ($ssl_policy == App\BaseURL::SSL_POLICY_SELFSIGN) {
DBA::e("UPDATE `contact` SET
`url` = REPLACE(`url` , 'https:' , 'http:'),
`photo` = REPLACE(`photo` , 'https:' , 'http:'),
`thumb` = REPLACE(`thumb` , 'https:' , 'http:'),
`micro` = REPLACE(`micro` , 'https:' , 'http:'),
`request` = REPLACE(`request`, 'https:' , 'http:'),
`notify` = REPLACE(`notify` , 'https:' , 'http:'),
`poll` = REPLACE(`poll` , 'https:' , 'http:'),
`confirm` = REPLACE(`confirm`, 'https:' , 'http:'),
`poco` = REPLACE(`poco` , 'https:' , 'http:')
WHERE `self` = 1"
);
DBA::e("UPDATE `profile` SET
`photo` = REPLACE(`photo` , 'https:' , 'http:'),
`thumb` = REPLACE(`thumb` , 'https:' , 'http:')
WHERE 1 "
);
}
}
$transactionConfig->set('system', 'ssl_policy' , $ssl_policy);
$transactionConfig->set('system', 'maxloadavg' , $maxloadavg); $transactionConfig->set('system', 'maxloadavg' , $maxloadavg);
$transactionConfig->set('system', 'min_memory' , $min_memory); $transactionConfig->set('system', 'min_memory' , $min_memory);
$transactionConfig->set('system', 'optimize_tables' , $optimize_tables); $transactionConfig->set('system', 'optimize_tables' , $optimize_tables);
@ -408,12 +368,6 @@ class Site extends BaseAdmin
Register::OPEN => DI::l10n()->t('Open') Register::OPEN => DI::l10n()->t('Open')
]; ];
$ssl_choices = [
App\BaseURL::SSL_POLICY_NONE => DI::l10n()->t('No SSL policy, links will track page SSL state'),
App\BaseURL::SSL_POLICY_FULL => DI::l10n()->t('Force all links to use SSL'),
App\BaseURL::SSL_POLICY_SELFSIGN => DI::l10n()->t('Self-signed certificate, use SSL for local links only (discouraged)')
];
$check_git_version_choices = [ $check_git_version_choices = [
'none' => DI::l10n()->t('Don\'t check'), 'none' => DI::l10n()->t('Don\'t check'),
'stable' => DI::l10n()->t('check the stable version'), 'stable' => DI::l10n()->t('check the stable version'),
@ -428,7 +382,7 @@ class Site extends BaseAdmin
// ContactRelation::DISCOVERY_ALL => DI::l10n()->t('All'), // ContactRelation::DISCOVERY_ALL => DI::l10n()->t('All'),
]; ];
$diaspora_able = (DI::baseUrl()->getUrlPath() == ''); $diaspora_able = (DI::baseUrl()->getPath() == '');
$t = Renderer::getMarkupTemplate('admin/site.tpl'); $t = Renderer::getMarkupTemplate('admin/site.tpl');
return Renderer::replaceMacros($t, [ return Renderer::replaceMacros($t, [
@ -452,7 +406,6 @@ class Site extends BaseAdmin
'$relocate' => DI::l10n()->t('Relocate Node'), '$relocate' => DI::l10n()->t('Relocate Node'),
'$relocate_msg' => DI::l10n()->t('Relocating your node enables you to change the DNS domain of this node and keep all the existing users and posts. This process takes a while and can only be started from the relocate console command like this:'), '$relocate_msg' => DI::l10n()->t('Relocating your node enables you to change the DNS domain of this node and keep all the existing users and posts. This process takes a while and can only be started from the relocate console command like this:'),
'$relocate_cmd' => DI::l10n()->t('(Friendica directory)# bin/console relocate https://newdomain.com'), '$relocate_cmd' => DI::l10n()->t('(Friendica directory)# bin/console relocate https://newdomain.com'),
'$baseurl' => DI::baseUrl()->get(true),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), ''], '$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), ''],
@ -464,9 +417,8 @@ class Site extends BaseAdmin
'$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')], '$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')],
'$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())], '$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())],
'$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), '', $lang_choices], '$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), '', $lang_choices],
'$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - <a href="%s" id="cnftheme">Change default theme settings</a>', DI::baseUrl()->get(true) . '/admin/themes'), $theme_choices], '$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - <a href="%s" id="cnftheme">Change default theme settings</a>', DI::baseUrl() . '/admin/themes'), $theme_choices],
'$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile], '$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile],
'$ssl_policy' => ['ssl_policy', DI::l10n()->t('SSL link policy'), DI::config()->get('system', 'ssl_policy'), DI::l10n()->t('Determines whether generated links should be forced to use SSL'), $ssl_choices],
'$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')], '$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')],
'$show_help' => ['show_help', DI::l10n()->t('Show help entry from navigation menu'), !DI::config()->get('system', 'hide_help'), DI::l10n()->t('Displays the menu entry for the Help pages from the navigation menu. It is always accessible by calling /help directly.')], '$show_help' => ['show_help', DI::l10n()->t('Show help entry from navigation menu'), !DI::config()->get('system', 'hide_help'), DI::l10n()->t('Displays the menu entry for the Help pages from the navigation menu. It is always accessible by calling /help directly.')],
'$singleuser' => ['singleuser', DI::l10n()->t('Single user instance'), DI::config()->get('system', 'singleuser', '---'), DI::l10n()->t('Make this instance multi-user or single-user for the named user'), $user_names], '$singleuser' => ['singleuser', DI::l10n()->t('Single user instance'), DI::config()->get('system', 'singleuser', '---'), DI::l10n()->t('Make this instance multi-user or single-user for the named user'), $user_names],

View file

@ -144,7 +144,6 @@ class Storage extends BaseAdmin
'$use' => DI::l10n()->t('Use storage backend'), '$use' => DI::l10n()->t('Use storage backend'),
'$save_reload' => DI::l10n()->t('Save & Reload'), '$save_reload' => DI::l10n()->t('Save & Reload'),
'$noconfig' => DI::l10n()->t('This backend doesn\'t have custom settings'), '$noconfig' => DI::l10n()->t('This backend doesn\'t have custom settings'),
'$baseurl' => DI::baseUrl()->get(true),
'$form_security_token' => self::getFormSecurityToken("admin_storage"), '$form_security_token' => self::getFormSecurityToken("admin_storage"),
'$storagebackend' => $current_storage_backend instanceof ICanWriteToStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'), '$storagebackend' => $current_storage_backend instanceof ICanWriteToStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'),
'$availablestorageforms' => $available_storage_forms, '$availablestorageforms' => $available_storage_forms,

View file

@ -98,6 +98,10 @@ class Summary extends BaseAdmin
$warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)'); $warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
} }
if (empty(DI::config()->get('system', 'url'))) {
$warningtext[] = DI::l10n()->t('The system.url entry is missing. This is a low level setting and can lead to unexpected behavior. Please add a valid entry as soon as possible in the config file or per console command!');
}
$last_worker_call = DI::keyValue()->get('last_worker_execution'); $last_worker_call = DI::keyValue()->get('last_worker_execution');
if (!$last_worker_call) { if (!$last_worker_call) {
$warningtext[] = DI::l10n()->t('The worker was never executed. Please check your database structure!'); $warningtext[] = DI::l10n()->t('The worker was never executed. Please check your database structure!');
@ -107,18 +111,18 @@ class Summary extends BaseAdmin
// Legacy config file warning // Legacy config file warning
if (file_exists('.htconfig.php')) { if (file_exists('.htconfig.php')) {
$warningtext[] = DI::l10n()->t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl()->get() . '/help/Config'); $warningtext[] = DI::l10n()->t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl() . '/help/Config');
} }
if (file_exists('config/local.ini.php')) { if (file_exists('config/local.ini.php')) {
$warningtext[] = DI::l10n()->t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>config/local.ini.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl()->get() . '/help/Config'); $warningtext[] = DI::l10n()->t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>config/local.ini.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl() . '/help/Config');
} }
// Check server vitality // Check server vitality
if (!self::checkSelfHostMeta()) { if (!self::checkSelfHostMeta()) {
$well_known = DI::baseUrl()->get() . Probe::HOST_META; $well_known = DI::baseUrl() . Probe::HOST_META;
$warningtext[] = DI::l10n()->t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.', $warningtext[] = DI::l10n()->t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
$well_known, $well_known, DI::baseUrl()->get() . '/help/Install'); $well_known, $well_known, DI::baseUrl() . '/help/Install');
} }
// Check logfile permission // Check logfile permission
@ -229,7 +233,7 @@ class Summary extends BaseAdmin
private static function checkSelfHostMeta() private static function checkSelfHostMeta()
{ {
// Fetch the host-meta to check if this really is a vital server // Fetch the host-meta to check if this really is a vital server
return DI::httpClient()->get(DI::baseUrl()->get() . Probe::HOST_META, HttpClientAccept::XRD_XML)->isSuccess(); return DI::httpClient()->get(DI::baseUrl() . Probe::HOST_META, HttpClientAccept::XRD_XML)->isSuccess();
} }
} }

View file

@ -76,7 +76,7 @@ class Details extends BaseAdmin
require_once "view/theme/$theme/config.php"; require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin')) { if (function_exists('theme_admin')) {
$admin_form = '<iframe onload="resizeIframe(this);" src="' . DI::baseUrl()->get(true) . '/admin/themes/' . $theme . '/embed?mode=minimal" width="100%" height="600px" frameborder="no"></iframe>'; $admin_form = '<iframe onload="resizeIframe(this);" src="' . DI::baseUrl() . '/admin/themes/' . $theme . '/embed?mode=minimal" width="100%" height="600px" frameborder="no"></iframe>';
} }
} }
@ -91,7 +91,6 @@ class Details extends BaseAdmin
'$page' => DI::l10n()->t('Themes'), '$page' => DI::l10n()->t('Themes'),
'$toggle' => DI::l10n()->t('Toggle'), '$toggle' => DI::l10n()->t('Toggle'),
'$settings' => DI::l10n()->t('Settings'), '$settings' => DI::l10n()->t('Settings'),
'$baseurl' => DI::baseUrl()->get(true),
'$addon' => $theme, '$addon' => $theme,
'$status' => $status, '$status' => $status,
'$action' => $action, '$action' => $action,

View file

@ -95,7 +95,7 @@ class Embed extends BaseAdmin
$t = Renderer::getMarkupTemplate('admin/addons/embed.tpl'); $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');
return Renderer::replaceMacros($t, [ return Renderer::replaceMacros($t, [
'$action' => DI::baseUrl()->get(true) . '/admin/themes/' . $theme . '/embed?mode=minimal', '$action' => 'admin/themes/' . $theme . '/embed?mode=minimal',
'$form' => $admin_form, '$form' => $admin_form,
'$form_security_token' => self::getFormSecurityToken("admin_theme_settings"), '$form_security_token' => self::getFormSecurityToken("admin_theme_settings"),
]); ]);

View file

@ -112,7 +112,6 @@ class Index extends BaseAdmin
'$page' => DI::l10n()->t('Themes'), '$page' => DI::l10n()->t('Themes'),
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$reload' => DI::l10n()->t('Reload active themes'), '$reload' => DI::l10n()->t('Reload active themes'),
'$baseurl' => DI::baseUrl()->get(true),
'$function' => 'themes', '$function' => 'themes',
'$addons' => $addons, '$addons' => $addons,
'$pcount' => count($themes), '$pcount' => count($themes),

View file

@ -37,9 +37,9 @@ class Config extends BaseApi
$config = [ $config = [
'site' => [ 'site' => [
'name' => DI::config()->get('config', 'sitename'), 'name' => DI::config()->get('config', 'sitename'),
'server' => DI::baseUrl()->getHostname(), 'server' => DI::baseUrl()->getHost(),
'theme' => DI::config()->get('system', 'theme'), 'theme' => DI::config()->get('system', 'theme'),
'path' => DI::baseUrl()->getUrlPath(), 'path' => DI::baseUrl()->getPath(),
'logo' => DI::baseUrl() . '/images/friendica-64.png', 'logo' => DI::baseUrl() . '/images/friendica-64.png',
'fancy' => true, 'fancy' => true,
'language' => DI::config()->get('system', 'language'), 'language' => DI::config()->get('system', 'language'),
@ -52,7 +52,7 @@ class Config extends BaseApi
'private' => (bool)DI::config()->get('system', 'block_public'), 'private' => (bool)DI::config()->get('system', 'block_public'),
'textlimit' => (string) DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size')), 'textlimit' => (string) DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size')),
'sslserver' => null, 'sslserver' => null,
'ssl' => DI::config()->get('system', 'ssl_policy') == App\BaseURL::SSL_POLICY_FULL ? 'always' : '0', 'ssl' => DI::baseUrl()->getScheme() === 'https' ? 'always' : '0',
'friendica' => [ 'friendica' => [
'FRIENDICA_PLATFORM' => App::PLATFORM, 'FRIENDICA_PLATFORM' => App::PLATFORM,
'FRIENDICA_VERSION' => App::VERSION, 'FRIENDICA_VERSION' => App::VERSION,

View file

@ -107,6 +107,7 @@ class Statuses extends BaseApi
'visibility' => '', // Visibility of the posted status. One of: "public", "unlisted", "private" or "direct". 'visibility' => '', // Visibility of the posted status. One of: "public", "unlisted", "private" or "direct".
'scheduled_at' => '', // ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future. 'scheduled_at' => '', // ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future.
'language' => '', // ISO 639 language code for this status. 'language' => '', // ISO 639 language code for this status.
'friendica' => [], // Friendica extensions to the standard Mastodon API spec
], $request); ], $request);
$owner = User::getOwnerDataById($uid); $owner = User::getOwnerDataById($uid);
@ -208,8 +209,10 @@ class Statuses extends BaseApi
$item['quote-uri-id'] = $request['quote_id']; $item['quote-uri-id'] = $request['quote_id'];
} }
$item['title'] = $request['friendica']['title'] ?? '';
if (!empty($request['spoiler_text'])) { if (!empty($request['spoiler_text'])) {
if (!$request['in_reply_to_id'] && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) { if (!isset($request['friendica']['title']) && !$request['in_reply_to_id'] && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) {
$item['title'] = $request['spoiler_text']; $item['title'] = $request['spoiler_text'];
} else { } else {
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body']; $item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];

View file

@ -65,6 +65,13 @@ class Direct extends BaseApi
$params['order'] = ['uri-id']; $params['order'] = ['uri-id'];
} }
if (!empty($uid)) {
$condition = DBA::mergeConditions(
$condition,
["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid]
);
}
$mails = DBA::select('mail', ['id', 'uri-id'], $condition, $params); $mails = DBA::select('mail', ['id', 'uri-id'], $condition, $params);
$statuses = []; $statuses = [];

View file

@ -90,11 +90,6 @@ class PublicTimeline extends BaseApi
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]); $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
} }
if (!empty($uid)) {
$condition = DBA::mergeConditions($condition,
["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid]);
}
$items = Post::selectPostsForUser($uid, ['uri-id'], $condition, $params); $items = Post::selectPostsForUser($uid, ['uri-id'], $condition, $params);
$display_quotes = self::appSupportsQuotes(); $display_quotes = self::appSupportsQuotes();

View file

@ -104,6 +104,13 @@ class Tag extends BaseApi
$params['order'] = ['uri-id']; $params['order'] = ['uri-id'];
} }
if (!empty($uid)) {
$condition = DBA::mergeConditions(
$condition,
["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid]
);
}
$items = DBA::select('tag-search-view', ['uri-id'], $condition, $params); $items = DBA::select('tag-search-view', ['uri-id'], $condition, $params);
$display_quotes = self::appSupportsQuotes(); $display_quotes = self::appSupportsQuotes();

View file

@ -41,6 +41,7 @@ class Links extends BaseApi
{ {
$request = $this->getRequest([ $request = $this->getRequest([
'limit' => 10, // Maximum number of results to return. Defaults to 10. 'limit' => 10, // Maximum number of results to return. Defaults to 10.
'offset' => 0, // Offset in set, Defaults to 0.
], $request); ], $request);
$condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?", $condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?",
@ -48,13 +49,17 @@ class Links extends BaseApi
$condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]); $condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]);
$trending = []; $trending = [];
$statuses = Post::selectPostThread(['uri-id', 'total-comments', 'total-actors'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]); $statuses = Post::selectPostThread(['uri-id', 'total-comments', 'total-actors'], $condition, ['limit' => [$request['offset'], $request['limit']], 'offset' => $request['offset'], 'order' => ['total-actors' => true]]);
while ($status = Post::fetch($statuses)) { while ($status = Post::fetch($statuses)) {
$history = [['day' => (string)time(), 'uses' => (string)$status['total-comments'], 'accounts' => (string)$status['total-actors']]]; $history = [['day' => (string)time(), 'uses' => (string)$status['total-comments'], 'accounts' => (string)$status['total-actors']]];
$trending[] = DI::mstdnCard()->createFromUriId($status['uri-id'], $history)->toArray(); $trending[] = DI::mstdnCard()->createFromUriId($status['uri-id'], $history)->toArray();
} }
DBA::close($statuses); DBA::close($statuses);
if (!empty($trending)) {
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
}
System::jsonExit($trending); System::jsonExit($trending);
} }
} }

View file

@ -44,6 +44,7 @@ class Statuses extends BaseApi
$request = $this->getRequest([ $request = $this->getRequest([
'limit' => 10, // Maximum number of results to return. Defaults to 10. 'limit' => 10, // Maximum number of results to return. Defaults to 10.
'offset' => 0, // Offset in set, Defaults to 0.
], $request); ], $request);
$condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')]; $condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')];
@ -52,7 +53,7 @@ class Statuses extends BaseApi
$display_quotes = self::appSupportsQuotes(); $display_quotes = self::appSupportsQuotes();
$trending = []; $trending = [];
$statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]); $statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => [$request['offset'], $request['limit']], 'order' => ['total-actors' => true]]);
while ($status = Post::fetch($statuses)) { while ($status = Post::fetch($statuses)) {
try { try {
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes); $trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
@ -62,6 +63,10 @@ class Statuses extends BaseApi
} }
DBA::close($statuses); DBA::close($statuses);
if (!empty($trending)) {
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
}
System::jsonExit($trending); System::jsonExit($trending);
} }
} }

View file

@ -37,11 +37,18 @@ class Tags extends BaseApi
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$request = $this->getRequest([ $request = $this->getRequest([
'limit' => 20, // Maximum number of results to return. Defaults to 10. 'limit' => 20, // Maximum number of results to return. Defaults to 20.
'offset' => 0, // Offset in set. Defaults to 0.
'friendica_local' => false, // Whether to return local tag trends instead of global, defaults to false
], $request); ], $request);
$trending = []; $trending = [];
$tags = Tag::getGlobalTrendingHashtags(24, 20); if ($request['friendica_local']) {
$tags = Tag::getLocalTrendingHashtags(24, $request['limit'], $request['offset']);
} else {
$tags = Tag::getGlobalTrendingHashtags(24, $request['limit'], $request['offset']);
}
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tag['name'] = $tag['term']; $tag['name'] = $tag['term'];
$history = [['day' => (string)time(), 'uses' => (string)$tag['score'], 'accounts' => (string)$tag['authors']]]; $history = [['day' => (string)time(), 'uses' => (string)$tag['score'], 'accounts' => (string)$tag['authors']]];
@ -49,6 +56,10 @@ class Tags extends BaseApi
$trending[] = $hashtag->toArray(); $trending[] = $hashtag->toArray();
} }
System::jsonExit(array_slice($trending, 0, $request['limit'])); if (!empty($trending)) {
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
}
System::jsonExit($trending);
} }
} }

View file

@ -62,7 +62,7 @@ abstract class ContactEndpoint extends BaseApi
if (!$screen_name) { if (!$screen_name) {
$contact = Contact::getById($contact_id, ['nick', 'url']); $contact = Contact::getById($contact_id, ['nick', 'url']);
// We don't have the followers of remote accounts so we check for locality // We don't have the followers of remote accounts so we check for locality
if (empty($contact) || !Strings::startsWith($contact['url'], DI::baseUrl()->get())) { if (empty($contact) || !Strings::startsWith($contact['url'], DI::baseUrl())) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found')); throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found'));
} }

View file

@ -168,6 +168,34 @@ class BaseApi extends BaseModule
return 'Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"'; return 'Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"';
} }
/**
* Get the "link" header with "next" and "prev" links for an offset/limit type call
* @return string
*/
protected static function getOffsetAndLimitLinkHeader(int $offset, int $limit): string
{
$request = self::$request;
unset($request['offset']);
$request['limit'] = $limit;
$prev_request = $next_request = $request;
$prev_request['offset'] = $offset - $limit;
$next_request['offset'] = $offset + $limit;
$command = DI::baseUrl() . '/' . DI::args()->getCommand();
$prev = $command . '?' . http_build_query($prev_request);
$next = $command . '?' . http_build_query($next_request);
if ($prev_request['offset'] >= 0) {
return 'Link: <' . $next . '>; rel="next", <' . $prev . '>; rel="prev"';
} else {
return 'Link: <' . $next . '>; rel="next"';
}
}
/** /**
* Set the "link" header with "next" and "prev" links * Set the "link" header with "next" and "prev" links
* @return void * @return void
@ -180,6 +208,18 @@ class BaseApi extends BaseModule
} }
} }
/**
* Set the "link" header with "next" and "prev" links
* @return void
*/
protected static function setLinkHeaderByOffsetLimit(int $offset, int $limit)
{
$header = self::getOffsetAndLimitLinkHeader($offset, $limit);
if (!empty($header)) {
header($header);
}
}
/** /**
* Check if the app is known to support quoted posts * Check if the app is known to support quoted posts
* *

View file

@ -59,7 +59,7 @@ class Download extends \Friendica\BaseModule
header('Content-Type: text/csv'); header('Content-Type: text/csv');
header('Content-Transfer-Encoding: Binary'); header('Content-Transfer-Encoding: Binary');
header('Content-disposition: attachment; filename="' . $this->baseUrl->getHostname() . '_domain_blocklist_' . substr($hash, 0, 6) . '.csv"'); header('Content-disposition: attachment; filename="' . $this->baseUrl->getHost() . '_domain_blocklist_' . substr($hash, 0, 6) . '.csv"');
header("Etag: $etag"); header("Etag: $etag");
$this->blocklist->exportToFile('php://output'); $this->blocklist->exportToFile('php://output');

View file

@ -47,7 +47,7 @@ class Bookmarklet extends BaseModule
} }
$referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? ''); $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
$page = Strings::normaliseLink(DI::baseUrl()->get() . "/bookmarklet"); $page = Strings::normaliseLink(DI::baseUrl() . "/bookmarklet");
if (!strstr($referer, $page)) { if (!strstr($referer, $page)) {
if (empty($_REQUEST["url"])) { if (empty($_REQUEST["url"])) {

View file

@ -220,7 +220,6 @@ class Contact extends BaseModule
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl'); $tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => DI::baseUrl()->get(true),
]); ]);
$o = ''; $o = '';

View file

@ -236,7 +236,6 @@ class Profile extends BaseModule
$_SESSION['return_path'] = $this->args->getQueryString(); $_SESSION['return_path'] = $this->args->getQueryString();
$this->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [ $this->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
'$baseurl' => $this->baseUrl->get(true),
]); ]);
switch ($localRelationship->rel) { switch ($localRelationship->rel) {

View file

@ -166,7 +166,7 @@ class Redir extends \Friendica\BaseModule
} }
if ($this->session->getRemoteUserId()) { if ($this->session->getRemoteUserId()) {
$host = substr($this->baseUrl->getUrlPath() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : ''), strpos($this->baseUrl->getUrlPath(), '://') + 3); $host = substr($this->baseUrl->getPath() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : ''), strpos($this->baseUrl->getPath(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1); $remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
// On a local instance we have to check if the local user has already authenticated // On a local instance we have to check if the local user has already authenticated

View file

@ -58,7 +58,7 @@ class Localtime extends BaseModule
$output .= '<p>' . DI::l10n()->t('Converted localtime: %s', self::$mod_localtime) . '</p>'; $output .= '<p>' . DI::l10n()->t('Converted localtime: %s', self::$mod_localtime) . '</p>';
} }
$output .= '<form action ="' . DI::baseUrl()->get() . '/localtime?time=' . $time . '" method="post" >'; $output .= '<form action ="localtime?time=' . $time . '" method="post">';
$output .= '<p>' . DI::l10n()->t('Please select your timezone:') . '</p>'; $output .= '<p>' . DI::l10n()->t('Please select your timezone:') . '</p>';
$output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ); $output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ);
$output .= '<input type="submit" name="submit" value="' . DI::l10n()->t('Submit') . '" /></form>'; $output .= '<input type="submit" name="submit" value="' . DI::l10n()->t('Submit') . '" /></form>';

View file

@ -61,7 +61,7 @@ class Fetch extends BaseModule
} }
$host = $parts["scheme"] . "://" . $parts["host"]; $host = $parts["scheme"] . "://" . $parts["host"];
if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl()->get())) { if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl())) {
$location = $host . "/fetch/" . DI::args()->getArgv()[1] . "/" . urlencode($guid); $location = $host . "/fetch/" . DI::args()->getArgv()[1] . "/" . urlencode($guid);
System::externalRedirect($location, 301); System::externalRedirect($location, 301);
} }

View file

@ -71,7 +71,7 @@ class Friendica extends BaseModule
} }
$tos = ($config->get('system', 'tosdisplay')) ? $tos = ($config->get('system', 'tosdisplay')) ?
DI::l10n()->t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', DI::baseUrl()->get()) : DI::l10n()->t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', DI::baseUrl()) :
''; '';
$blockList = $config->get('system', 'blocklist'); $blockList = $config->get('system', 'blocklist');
@ -99,7 +99,7 @@ class Friendica extends BaseModule
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'about' => DI::l10n()->t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.', 'about' => DI::l10n()->t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.',
'<strong>' . App::VERSION . '</strong>', '<strong>' . App::VERSION . '</strong>',
DI::baseUrl()->get(), DI::baseUrl(),
'<strong>' . $config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>', '<strong>' . $config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>',
'<strong>' . $keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'), '<strong>' . $keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'),
'friendica' => DI::l10n()->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'), 'friendica' => DI::l10n()->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
@ -151,7 +151,7 @@ class Friendica extends BaseModule
if (!empty($administrator)) { if (!empty($administrator)) {
$admin = [ $admin = [
'name' => $administrator['username'], 'name' => $administrator['username'],
'profile' => DI::baseUrl()->get() . '/profile/' . $administrator['nickname'], 'profile' => DI::baseUrl() . '/profile/' . $administrator['nickname'],
]; ];
} }
@ -172,7 +172,7 @@ class Friendica extends BaseModule
$data = [ $data = [
'version' => App::VERSION, 'version' => App::VERSION,
'url' => DI::baseUrl()->get(), 'url' => DI::baseUrl(),
'addons' => $visible_addons, 'addons' => $visible_addons,
'locked_features' => $locked_features, 'locked_features' => $locked_features,
'explicit_content' => intval($config->get('system', 'explicit_content', 0)), 'explicit_content' => intval($config->get('system', 'explicit_content', 0)),
@ -182,7 +182,7 @@ class Friendica extends BaseModule
'site_name' => $config->get('config', 'sitename'), 'site_name' => $config->get('config', 'sitename'),
'platform' => strtolower(App::PLATFORM), 'platform' => strtolower(App::PLATFORM),
'info' => $config->get('config', 'info'), 'info' => $config->get('config', 'info'),
'no_scrape_url' => DI::baseUrl()->get() . '/noscrape', 'no_scrape_url' => DI::baseUrl() . '/noscrape',
]; ];
System::jsonExit($data); System::jsonExit($data);

View file

@ -66,15 +66,15 @@ class HCard extends BaseModule
$baseUrl = DI::baseUrl(); $baseUrl = DI::baseUrl();
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : '')); $uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHost() . ($baseUrl->getPath() ? '/' . $baseUrl->getPath() : ''));
$page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n"; $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl->get() . '/dfrn_poll/' . $nickname . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
$page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl->get() . '/xrd/?uri=' . $uri . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . $baseUrl->get() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . $baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) { foreach (['request', 'confirm', 'notify', 'poll'] as $dfrn) {
$page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n"; $page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";
} }
$block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()); $block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated());

View file

@ -102,7 +102,7 @@ class Help extends BaseModule
$idNum[$level] ++; $idNum[$level] ++;
$href = DI::baseUrl()->get() . "/help/{$filename}#{$anchor}"; $href = "help/{$filename}#{$anchor}";
$toc .= "<li><a href=\"{$href}\">" . strip_tags($line) . "</a></li>"; $toc .= "<li><a href=\"{$href}\">" . strip_tags($line) . "</a></li>";
$id = implode("_", array_slice($idNum, 1, $level)); $id = implode("_", array_slice($idNum, 1, $level));
$line = "<a name=\"{$id}\"></a>" . $line; $line = "<a name=\"{$id}\"></a>" . $line;

View file

@ -69,7 +69,7 @@ class Home extends BaseModule
$customHome = $homeFilePath; $customHome = $homeFilePath;
if (file_exists($cssFilePath)) { if (file_exists($cssFilePath)) {
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/home.css' . '" media="all" />'; DI::page()->registerStylesheet('home.css', 'all');
} }
} }

View file

@ -34,6 +34,7 @@ use Friendica\Util\BasePath;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use GuzzleHttp\Psr7\Uri;
class Install extends BaseModule class Install extends BaseModule
{ {
@ -73,7 +74,7 @@ class Install extends BaseModule
/** @var App\Mode */ /** @var App\Mode */
protected $mode; protected $mode;
public function __construct(App $app, App\Mode $mode, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Core\Installer $installer, array $server, array $parameters = []) public function __construct(App $app, BasePath $basePath, App\Mode $mode, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Core\Installer $installer, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
@ -94,12 +95,11 @@ class Install extends BaseModule
// get basic installation information and save them to the config cache // get basic installation information and save them to the config cache
$configCache = $this->app->getConfigCache(); $configCache = $this->app->getConfigCache();
$basePath = new BasePath($this->app->getBasePath());
$this->installer->setUpCache($configCache, $basePath->getPath()); $this->installer->setUpCache($configCache, $basePath->getPath());
// We overwrite current theme css, because during install we may not have a working mod_rewrite // We overwrite current theme css, because during install we may not have a working mod_rewrite
// so we may not have a css at all. Here we set a static css file for the install procedure pages // so we may not have a css at all. Here we set a static css file for the install procedure pages
Renderer::$theme['stylesheet'] = $this->baseUrl->get() . '/view/install/style.css'; Renderer::$theme['stylesheet'] = $this->baseUrl . '/view/install/style.css';
$this->currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK; $this->currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK;
} }
@ -117,19 +117,15 @@ class Install extends BaseModule
case self::DATABASE_CONFIG: case self::DATABASE_CONFIG:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($configCache, $_POST, 'config', 'php_path');
$this->checkSetting($configCache, $_POST, 'config', 'hostname');
$this->checkSetting($configCache, $_POST, 'system', 'ssl_policy');
$this->checkSetting($configCache, $_POST, 'system', 'basepath'); $this->checkSetting($configCache, $_POST, 'system', 'basepath');
$this->checkSetting($configCache, $_POST, 'system', 'urlpath'); $this->checkSetting($configCache, $_POST, 'system', 'url');
break; break;
case self::SITE_SETTINGS: case self::SITE_SETTINGS:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($configCache, $_POST, 'config', 'php_path');
$this->checkSetting($configCache, $_POST, 'config', 'hostname');
$this->checkSetting($configCache, $_POST, 'system', 'ssl_policy');
$this->checkSetting($configCache, $_POST, 'system', 'basepath'); $this->checkSetting($configCache, $_POST, 'system', 'basepath');
$this->checkSetting($configCache, $_POST, 'system', 'urlpath'); $this->checkSetting($configCache, $_POST, 'system', 'url');
$this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST); $this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
$this->checkSetting($configCache, $_POST, 'database', 'username', ''); $this->checkSetting($configCache, $_POST, 'database', 'username', '');
@ -146,10 +142,8 @@ class Install extends BaseModule
case self::FINISHED: case self::FINISHED:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($configCache, $_POST, 'config', 'php_path');
$this->checkSetting($configCache, $_POST, 'config', 'hostname');
$this->checkSetting($configCache, $_POST, 'system', 'ssl_policy');
$this->checkSetting($configCache, $_POST, 'system', 'basepath'); $this->checkSetting($configCache, $_POST, 'system', 'basepath');
$this->checkSetting($configCache, $_POST, 'system', 'urlpath'); $this->checkSetting($configCache, $_POST, 'system', 'url');
$this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST); $this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
$this->checkSetting($configCache, $_POST, 'database', 'username', ''); $this->checkSetting($configCache, $_POST, 'database', 'username', '');
@ -198,9 +192,9 @@ class Install extends BaseModule
case self::SYSTEM_CHECK: case self::SYSTEM_CHECK:
$php_path = $configCache->get('config', 'php_path'); $php_path = $configCache->get('config', 'php_path');
$status = $this->installer->checkEnvironment($this->baseUrl->get(), $php_path); $status = $this->installer->checkEnvironment($this->baseUrl, $php_path);
$tpl = Renderer::getMarkupTemplate('install_checks.tpl'); $tpl = Renderer::getMarkupTemplate('install/01_checks.tpl');
$output .= Renderer::replaceMacros($tpl, [ $output .= Renderer::replaceMacros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => $this->t('System check'), '$pass' => $this->t('System check'),
@ -218,43 +212,31 @@ class Install extends BaseModule
break; break;
case self::BASE_CONFIG: case self::BASE_CONFIG:
$ssl_choices = [ $baseUrl = $configCache->get('system', 'url') ?
App\BaseURL::SSL_POLICY_NONE => $this->t("No SSL policy, links will track page SSL state"), new Uri($configCache->get('system', 'url')) :
App\BaseURL::SSL_POLICY_FULL => $this->t("Force all links to use SSL"), $this->baseUrl;
App\BaseURL::SSL_POLICY_SELFSIGN => $this->t("Self-signed certificate, use SSL for local links only \x28discouraged\x29")
];
$tpl = Renderer::getMarkupTemplate('install_base.tpl'); $tpl = Renderer::getMarkupTemplate('install/02_base_config.tpl');
$output .= Renderer::replaceMacros($tpl, [ $output .= Renderer::replaceMacros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => $this->t('Base settings'), '$pass' => $this->t('Base settings'),
'$ssl_policy' => ['system-ssl_policy',
$this->t("SSL link policy"),
$configCache->get('system', 'ssl_policy'),
$this->t("Determines whether generated links should be forced to use SSL"),
$ssl_choices],
'$hostname' => ['config-hostname',
$this->t('Host name'),
$configCache->get('config', 'hostname'),
$this->t('Overwrite this field in case the determinated hostname isn\'t right, otherweise leave it as is.'),
$this->t('Required')],
'$basepath' => ['system-basepath', '$basepath' => ['system-basepath',
$this->t("Base path to installation"), $this->t("Base path to installation"),
$configCache->get('system', 'basepath'), $configCache->get('system', 'basepath'),
$this->t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."), $this->t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
$this->t('Required')], $this->t('Required')],
'$urlpath' => ['system-urlpath', '$system_url' => ['system-url',
$this->t('Sub path of the URL'), $this->t('The Friendica system URL'),
$configCache->get('system', 'urlpath'), (string)$baseUrl,
$this->t('Overwrite this field in case the sub path determination isn\'t right, otherwise leave it as is. Leaving this field blank means the installation is at the base URL without sub path.'), $this->t("Overwrite this field in case the system URL determination isn't right, otherwise leave it as is."),
''], $this->t('Required')],
'$php_path' => $configCache->get('config', 'php_path'), '$php_path' => $configCache->get('config', 'php_path'),
'$submit' => $this->t('Submit'), '$submit' => $this->t('Submit'),
]); ]);
break; break;
case self::DATABASE_CONFIG: case self::DATABASE_CONFIG:
$tpl = Renderer::getMarkupTemplate('install_db.tpl'); $tpl = Renderer::getMarkupTemplate('install/03_database_config.tpl');
$output .= Renderer::replaceMacros($tpl, [ $output .= Renderer::replaceMacros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => $this->t('Database connection'), '$pass' => $this->t('Database connection'),
@ -264,10 +246,8 @@ class Install extends BaseModule
'$required' => $this->t('Required'), '$required' => $this->t('Required'),
'$requirement_not_satisfied' => $this->t('Requirement not satisfied'), '$requirement_not_satisfied' => $this->t('Requirement not satisfied'),
'$checks' => $this->installer->getChecks(), '$checks' => $this->installer->getChecks(),
'$hostname' => $configCache->get('config', 'hostname'),
'$ssl_policy' => $configCache->get('system', 'ssl_policy'),
'$basepath' => $configCache->get('system', 'basepath'), '$basepath' => $configCache->get('system', 'basepath'),
'$urlpath' => $configCache->get('system', 'urlpath'), '$system_url' => $configCache->get('system', 'url'),
'$dbhost' => ['database-hostname', '$dbhost' => ['database-hostname',
$this->t('Database Server Name'), $this->t('Database Server Name'),
$configCache->get('database', 'hostname'), $configCache->get('database', 'hostname'),
@ -299,16 +279,14 @@ class Install extends BaseModule
/* Installed langs */ /* Installed langs */
$lang_choices = $this->l10n->getAvailableLanguages(); $lang_choices = $this->l10n->getAvailableLanguages();
$tpl = Renderer::getMarkupTemplate('install_settings.tpl'); $tpl = Renderer::getMarkupTemplate('install/04_site_settings.tpl');
$output .= Renderer::replaceMacros($tpl, [ $output .= Renderer::replaceMacros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$required' => $this->t('Required'), '$required' => $this->t('Required'),
'$checks' => $this->installer->getChecks(), '$checks' => $this->installer->getChecks(),
'$pass' => $this->t('Site settings'), '$pass' => $this->t('Site settings'),
'$hostname' => $configCache->get('config', 'hostname'),
'$ssl_policy' => $configCache->get('system', 'ssl_policy'),
'$basepath' => $configCache->get('system', 'basepath'), '$basepath' => $configCache->get('system', 'basepath'),
'$urlpath' => $configCache->get('system', 'urlpath'), '$system_url' => $configCache->get('system', 'url'),
'$dbhost' => $configCache->get('database', 'hostname'), '$dbhost' => $configCache->get('database', 'hostname'),
'$dbuser' => $configCache->get('database', 'username'), '$dbuser' => $configCache->get('database', 'username'),
'$dbpass' => $configCache->get('database', 'password'), '$dbpass' => $configCache->get('database', 'password'),
@ -341,7 +319,7 @@ class Install extends BaseModule
$db_return_text .= $txt; $db_return_text .= $txt;
} }
$tpl = Renderer::getMarkupTemplate('install_finished.tpl'); $tpl = Renderer::getMarkupTemplate('install/05_finished.tpl');
$output .= Renderer::replaceMacros($tpl, [ $output .= Renderer::replaceMacros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$required' => $this->t('Required'), '$required' => $this->t('Required'),
@ -365,7 +343,7 @@ class Install extends BaseModule
*/ */
private function whatNext(): string private function whatNext(): string
{ {
$baseurl = $this->baseUrl->get(); $baseurl = $this->baseUrl;
return return
$this->t('<h1>What next</h1>') $this->t('<h1>What next</h1>')
. "<p>" . $this->t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.') . "<p>" . $this->t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.')

View file

@ -149,14 +149,14 @@ class Invite extends BaseModule
if ($config->get('config', 'register_policy') === Register::CLOSED) { if ($config->get('config', 'register_policy') === Register::CLOSED) {
$linkTxt = DI::l10n()->t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirLocation . '/servers'); $linkTxt = DI::l10n()->t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirLocation . '/servers');
} else { } else {
$linkTxt = DI::l10n()->t('To accept this invitation, please visit and register at %s or any other public Friendica website.', DI::baseUrl()->get()) $linkTxt = DI::l10n()->t('To accept this invitation, please visit and register at %s or any other public Friendica website.', DI::baseUrl())
. "\r\n" . "\r\n" . DI::l10n()->t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirLocation . '/servers'); . "\r\n" . "\r\n" . DI::l10n()->t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirLocation . '/servers');
} }
} else { // there is no global directory URL defined } else { // there is no global directory URL defined
if ($config->get('config', 'register_policy') === Register::CLOSED) { if ($config->get('config', 'register_policy') === Register::CLOSED) {
return DI::l10n()->t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); return DI::l10n()->t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
} else { } else {
$linkTxt = DI::l10n()->t('To accept this invitation, please visit and register at %s.', DI::baseUrl()->get() $linkTxt = DI::l10n()->t('To accept this invitation, please visit and register at %s.', DI::baseUrl()
. "\r\n" . "\r\n" . DI::l10n()->t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.')); . "\r\n" . "\r\n" . DI::l10n()->t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.'));
} }
} }
@ -172,7 +172,7 @@ class Invite extends BaseModule
DI::l10n()->t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" DI::l10n()->t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linkTxt . $linkTxt
. "\r\n" . "\r\n" . (($inviteOnly) ? DI::l10n()->t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . DI::l10n()->t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . (($inviteOnly) ? DI::l10n()->t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . DI::l10n()->t('Once you have registered, please connect with me via my profile page at:')
. "\r\n" . "\r\n" . DI::baseUrl()->get() . '/profile/' . $app->getLoggedInUserNickname() . "\r\n" . "\r\n" . DI::baseUrl() . '/profile/' . $app->getLoggedInUserNickname()
. "\r\n" . "\r\n" . DI::l10n()->t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n", . "\r\n" . "\r\n" . DI::l10n()->t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n",
], ],
'$submit' => DI::l10n()->t('Submit') '$submit' => DI::l10n()->t('Submit')

View file

@ -88,7 +88,7 @@ class Magic extends BaseModule
$contact = $this->dba->selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); $contact = $this->dba->selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site. // Redirect if the contact is already authenticated on this site.
if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl->get())) !== false) { if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl)) !== false) {
$this->logger->info('Contact is already authenticated'); $this->logger->info('Contact is already authenticated');
System::externalRedirect($dest); System::externalRedirect($dest);
} }
@ -113,7 +113,7 @@ class Magic extends BaseModule
$header = HTTPSignature::createSig( $header = HTTPSignature::createSig(
$header, $header,
$user['prvkey'], $user['prvkey'],
'acct:' . $user['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : '') 'acct:' . $user['nickname'] . '@' . $this->baseUrl->getHost() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : '')
); );
// Try to get an authentication token from the other instance. // Try to get an authentication token from the other instance.

View file

@ -35,7 +35,7 @@ class Manifest extends BaseModule
$manifest = [ $manifest = [
'name' => $config->get('config', 'sitename', 'Friendica'), 'name' => $config->get('config', 'sitename', 'Friendica'),
'start_url' => DI::baseUrl()->get(), 'start_url' => DI::baseUrl(),
'display' => 'standalone', 'display' => 'standalone',
'description' => $config->get('config', 'info', DI::l10n()->t('A Decentralized Social Network')), 'description' => $config->get('config', 'info', DI::l10n()->t('A Decentralized Social Network')),
'short_name' => 'Friendica', 'short_name' => 'Friendica',
@ -74,12 +74,12 @@ class Manifest extends BaseModule
if($touch_icon){ if($touch_icon){
$manifest['icons'] = [ $manifest['icons'] = [
[ [
'src' => DI::baseUrl()->get() . '/' . $touch_icon, 'src' => DI::baseUrl() . '/' . $touch_icon,
'sizes' => '192x192', 'sizes' => '192x192',
'type' => 'image/png', 'type' => 'image/png',
], ],
[ [
'src' => DI::baseUrl()->get() . '/' . $touch_icon, 'src' => DI::baseUrl() . '/' . $touch_icon,
'sizes' => '512x512', 'sizes' => '512x512',
'type' => 'image/png', 'type' => 'image/png',
], ],
@ -87,37 +87,37 @@ class Manifest extends BaseModule
} else { } else {
$manifest['icons'] = [ $manifest['icons'] = [
[ [
'src' => DI::baseUrl()->get() . '/images/friendica.svg', 'src' => DI::baseUrl() . '/images/friendica.svg',
'sizes' => 'any', 'sizes' => 'any',
'type' => 'image/svg+xml', 'type' => 'image/svg+xml',
'purpose' => 'any', 'purpose' => 'any',
], ],
[ [
'src' => DI::baseUrl()->get() . '/images/friendica-192.png', 'src' => DI::baseUrl() . '/images/friendica-192.png',
'sizes' => '192x192', 'sizes' => '192x192',
'type' => 'image/png', 'type' => 'image/png',
'purpose' => 'any', 'purpose' => 'any',
], ],
[ [
'src' => DI::baseUrl()->get() . '/images/friendica-512.png', 'src' => DI::baseUrl() . '/images/friendica-512.png',
'sizes' => '512x512', 'sizes' => '512x512',
'type' => 'image/png', 'type' => 'image/png',
'purpose' => 'any', 'purpose' => 'any',
], ],
[ [
'src' => DI::baseUrl()->get() . '/images/friendica-maskable.svg', 'src' => DI::baseUrl() . '/images/friendica-maskable.svg',
'sizes' => 'any', 'sizes' => 'any',
'type' => 'image/svg+xml', 'type' => 'image/svg+xml',
'purpose' => 'maskable', 'purpose' => 'maskable',
], ],
[ [
'src' => DI::baseUrl()->get() . '/images/friendica-maskable-192.png', 'src' => DI::baseUrl() . '/images/friendica-maskable-192.png',
'sizes' => '192x192', 'sizes' => '192x192',
'type' => 'image/png', 'type' => 'image/png',
'purpose' => 'maskable', 'purpose' => 'maskable',
], ],
[ [
'src' => DI::baseUrl()->get() . '/images/friendica-maskable-512.png', 'src' => DI::baseUrl() . '/images/friendica-maskable-512.png',
'sizes' => '512x512', 'sizes' => '512x512',
'type' => 'image/png', 'type' => 'image/png',
'purpose' => 'maskable', 'purpose' => 'maskable',

View file

@ -124,7 +124,7 @@ class Contact extends BaseModeration
'$form_security_token' => self::getFormSecurityToken('moderation_contactblock'), '$form_security_token' => self::getFormSecurityToken('moderation_contactblock'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true), '$baseurl' => $this->baseUrl,
'$contacts' => $contacts, '$contacts' => $contacts,
'$total_contacts' => $this->tt('%s total blocked contact', '%s total blocked contacts', $total), '$total_contacts' => $this->tt('%s total blocked contact', '%s total blocked contacts', $total),

View file

@ -138,7 +138,7 @@ class Add extends BaseModeration
'$newreason' => ['reason', $this->t('Block reason'), $request['reason'] ?? '', $this->t('The reason why you blocked this server domain pattern. This reason will be shown publicly in the server information page.'), $this->t('Required'), '', ''], '$newreason' => ['reason', $this->t('Block reason'), $request['reason'] ?? '', $this->t('The reason why you blocked this server domain pattern. This reason will be shown publicly in the server information page.'), $this->t('Required'), '', ''],
'$pattern' => $pattern, '$pattern' => $pattern,
'$gservers' => $gservers, '$gservers' => $gservers,
'$baseurl' => $this->baseUrl->get(true), '$baseurl' => $this->baseUrl,
'$form_security_token' => self::getFormSecurityToken('moderation_blocklist_add') '$form_security_token' => self::getFormSecurityToken('moderation_blocklist_add')
]); ]);
} }

View file

@ -130,7 +130,7 @@ class Import extends \Friendica\Module\BaseModeration
'$mode_append' => ['mode', $this->t('Append'), 'append', $this->t('Imports patterns from the file that weren\'t already existing in the current blocklist.'), 'checked="checked"'], '$mode_append' => ['mode', $this->t('Append'), 'append', $this->t('Imports patterns from the file that weren\'t already existing in the current blocklist.'), 'checked="checked"'],
'$mode_replace' => ['mode', $this->t('Replace'), 'replace', $this->t('Replaces the current blocklist by the imported patterns.')], '$mode_replace' => ['mode', $this->t('Replace'), 'replace', $this->t('Replaces the current blocklist by the imported patterns.')],
'$blocklist' => $this->blocklist, '$blocklist' => $this->blocklist,
'$baseurl' => $this->baseUrl->get(true), '$baseurl' => $this->baseUrl,
'$form_security_token' => self::getFormSecurityToken('moderation_blocklist_import') '$form_security_token' => self::getFormSecurityToken('moderation_blocklist_import')
]); ]);
} }

View file

@ -115,7 +115,7 @@ class Index extends BaseModeration
'$listfile' => ['listfile', $this->t('Server domain pattern blocklist CSV file'), '', '', $this->t('Required'), '', 'file'], '$listfile' => ['listfile', $this->t('Server domain pattern blocklist CSV file'), '', '', $this->t('Required'), '', 'file'],
'$newdomain' => ['pattern', $this->t('Server Domain Pattern'), '', $this->t('The domain pattern of the new server to add to the blocklist. Do not include the protocol.'), $this->t('Required'), '', ''], '$newdomain' => ['pattern', $this->t('Server Domain Pattern'), '', $this->t('The domain pattern of the new server to add to the blocklist. Do not include the protocol.'), $this->t('Required'), '', ''],
'$entries' => $blocklistform, '$entries' => $blocklistform,
'$baseurl' => $this->baseUrl->get(true), '$baseurl' => $this->baseUrl,
'$form_security_token' => self::getFormSecurityToken('moderation_blocklist'), '$form_security_token' => self::getFormSecurityToken('moderation_blocklist'),
'$form_security_token_import' => self::getFormSecurityToken('moderation_blocklist_import'), '$form_security_token_import' => self::getFormSecurityToken('moderation_blocklist_import'),

View file

@ -32,7 +32,7 @@ class Active extends BaseUsers
{ {
$this->checkModerationAccess(); $this->checkModerationAccess();
self::checkFormSecurityTokenRedirectOnError($this->baseUrl->get(true), 'moderation_users_active'); self::checkFormSecurityTokenRedirectOnError($this->baseUrl, 'moderation_users_active');
$users = $request['user'] ?? []; $users = $request['user'] ?? [];
@ -150,7 +150,7 @@ class Active extends BaseUsers
'$form_security_token' => self::getFormSecurityToken('moderation_users_active'), '$form_security_token' => self::getFormSecurityToken('moderation_users_active'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true), '$baseurl' => $this->baseUrl,
'$query_string' => $this->args->getQueryString(), '$query_string' => $this->args->getQueryString(),
'$users' => $users, '$users' => $users,

View file

@ -149,7 +149,6 @@ class Blocked extends BaseUsers
'$form_security_token' => self::getFormSecurityToken('moderation_users_blocked'), '$form_security_token' => self::getFormSecurityToken('moderation_users_blocked'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true),
'$query_string' => $this->args->getQueryString(), '$query_string' => $this->args->getQueryString(),
'$users' => $users, '$users' => $users,

View file

@ -65,7 +65,6 @@ class Create extends BaseUsers
'$form_security_token' => self::getFormSecurityToken('admin_users_create'), '$form_security_token' => self::getFormSecurityToken('admin_users_create'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true),
'$query_string' => $this->args->getQueryString(), '$query_string' => $this->args->getQueryString(),
'$newusername' => ['new_user_name', $this->t('Name'), '', $this->t('Name of the new user.')], '$newusername' => ['new_user_name', $this->t('Name'), '', $this->t('Name of the new user.')],

View file

@ -85,7 +85,6 @@ class Deleted extends BaseUsers
'$form_security_token' => self::getFormSecurityToken('moderation_users_deleted'), '$form_security_token' => self::getFormSecurityToken('moderation_users_deleted'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true),
'$query_string' => $this->args->getQueryString(), '$query_string' => $this->args->getQueryString(),
'$users' => $users, '$users' => $users,

View file

@ -83,7 +83,7 @@ class Index extends BaseUsers
switch ($action) { switch ($action) {
case 'delete': case 'delete':
if ($this->session->getLocalUserId() != $uid) { if ($this->session->getLocalUserId() != $uid) {
self::checkFormSecurityTokenRedirectOnError($this->baseUrl->get(true), 'moderation_users', 't'); self::checkFormSecurityTokenRedirectOnError($this->baseUrl, 'moderation_users', 't');
// delete user // delete user
User::remove($uid); User::remove($uid);
@ -168,7 +168,6 @@ class Index extends BaseUsers
'$form_security_token' => self::getFormSecurityToken('moderation_users'), '$form_security_token' => self::getFormSecurityToken('moderation_users'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true),
'$query_string' => $this->args->getQueryString(), '$query_string' => $this->args->getQueryString(),
'$users' => $users, '$users' => $users,

View file

@ -105,7 +105,6 @@ class Pending extends BaseUsers
'$form_security_token' => self::getFormSecurityToken('admin_users_pending'), '$form_security_token' => self::getFormSecurityToken('admin_users_pending'),
// values // // values //
'$baseurl' => $this->baseUrl->get(true),
'$query_string' => $this->args->getQueryString(), '$query_string' => $this->args->getQueryString(),
'$pending' => $pending, '$pending' => $pending,

View file

@ -52,7 +52,6 @@ class NodeInfo210 extends BaseModule
$nodeinfo = [ $nodeinfo = [
'version' => '1.0', 'version' => '1.0',
'server' => [ 'server' => [
'baseUrl' => $this->baseUrl->get(),
'name' => $this->config->get('config', 'sitename'), 'name' => $this->config->get('config', 'sitename'),
'software' => 'friendica', 'software' => 'friendica',
'version' => App::VERSION . '-' . DB_UPDATE_VERSION, 'version' => App::VERSION . '-' . DB_UPDATE_VERSION,

View file

@ -244,7 +244,7 @@ class Ping extends BaseModule
$registration['url'], $registration['url'],
$this->l10n->t('{0} requested registration'), $this->l10n->t('{0} requested registration'),
new \DateTime($registration['created'], new \DateTimeZone('UTC')), new \DateTime($registration['created'], new \DateTimeZone('UTC')),
new Uri($this->baseUrl->get(true) . '/moderation/users/pending') new Uri($this->baseUrl . '/moderation/users/pending')
); );
} }
} else { } else {
@ -253,7 +253,7 @@ class Ping extends BaseModule
$registrations[0]['url'], $registrations[0]['url'],
$this->l10n->t('{0} and %d others requested registration', count($registrations) - 1), $this->l10n->t('{0} and %d others requested registration', count($registrations) - 1),
new \DateTime($registrations[0]['created'], new \DateTimeZone('UTC')), new \DateTime($registrations[0]['created'], new \DateTimeZone('UTC')),
new Uri($this->baseUrl->get(true) . '/moderation/users/pending') new Uri($this->baseUrl . '/moderation/users/pending')
); );
} }

View file

@ -39,8 +39,8 @@ class OpenSearch extends BaseModule
*/ */
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$hostname = DI::baseUrl()->getHostname(); $hostname = DI::baseUrl()->getHost();
$baseUrl = DI::baseUrl()->get(); $baseUrl = DI::baseUrl();
/** @var DOMDocument $xml */ /** @var DOMDocument $xml */
XML::fromArray([ XML::fromArray([

View file

@ -352,7 +352,7 @@ class Profile extends BaseProfile
$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 . '/" 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 . '/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"; $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() : '')); $uri = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHost() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : ''));
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $this->baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n"; $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); header('Link: <' . $this->baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);

View file

@ -78,7 +78,6 @@ class Schedule extends BaseProfile
$tpl = Renderer::getMarkupTemplate('profile/schedule.tpl'); $tpl = Renderer::getMarkupTemplate('profile/schedule.tpl');
$o .= Renderer::replaceMacros($tpl, [ $o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("profile_schedule"), '$form_security_token' => BaseModule::getFormSecurityToken("profile_schedule"),
'$baseurl' => DI::baseUrl()->get(true),
'$title' => DI::l10n()->t('Scheduled Posts'), '$title' => DI::l10n()->t('Scheduled Posts'),
'$nickname' => $this->parameters['nickname'] ?? '', '$nickname' => $this->parameters['nickname'] ?? '',
'$scheduled_at' => DI::l10n()->t('Scheduled'), '$scheduled_at' => DI::l10n()->t('Scheduled'),

View file

@ -141,7 +141,6 @@ class UnkMail extends \Friendica\BaseModule
$tpl = Renderer::getMarkupTemplate('profile/unkmail-header.tpl'); $tpl = Renderer::getMarkupTemplate('profile/unkmail-header.tpl');
$this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ $this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => $this->baseUrl->get(true),
'$nickname' => $user['nickname'], '$nickname' => $user['nickname'],
'$linkurl' => $this->l10n->t('Please enter a link URL:') '$linkurl' => $this->l10n->t('Please enter a link URL:')
]); ]);

View file

@ -48,7 +48,7 @@ class ReallySimpleDiscovery extends BaseModule
'@attributes' => [ '@attributes' => [
'name' => 'Twitter', 'name' => 'Twitter',
'preferred' => 'true', 'preferred' => 'true',
'apiLink' => DI::baseUrl()->get(), 'apiLink' => DI::baseUrl(),
'blogID' => '', 'blogID' => '',
], ],
'settings' => [ 'settings' => [

View file

@ -161,7 +161,7 @@ class Register extends BaseModule
'$ask_password' => $ask_password, '$ask_password' => $ask_password,
'$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')], '$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')],
'$password2' => ['confirm', DI::l10n()->t('Confirm:'), '', ''], '$password2' => ['confirm', DI::l10n()->t('Confirm:'), '', ''],
'$nickdesc' => DI::l10n()->t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "<strong>nickname@%s</strong>".', DI::baseUrl()->getHostname()), '$nickdesc' => DI::l10n()->t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "<strong>nickname@%s</strong>".', DI::baseUrl()->getHost()),
'$nicklabel' => DI::l10n()->t('Choose a nickname: '), '$nicklabel' => DI::l10n()->t('Choose a nickname: '),
'$photo' => $photo, '$photo' => $photo,
'$publish' => $profile_publish, '$publish' => $profile_publish,
@ -169,7 +169,7 @@ class Register extends BaseModule
'$username' => $username, '$username' => $username,
'$email' => $email, '$email' => $email,
'$nickname' => $nickname, '$nickname' => $nickname,
'$sitename' => DI::baseUrl()->getHostname(), '$sitename' => DI::baseUrl()->getHost(),
'$importh' => DI::l10n()->t('Import'), '$importh' => DI::l10n()->t('Import'),
'$importt' => DI::l10n()->t('Import your profile to this friendica instance'), '$importt' => DI::l10n()->t('Import your profile to this friendica instance'),
'$showtoslink' => DI::config()->get('system', 'tosdisplay'), '$showtoslink' => DI::config()->get('system', 'tosdisplay'),
@ -298,7 +298,7 @@ class Register extends BaseModule
$user = $result['user']; $user = $result['user'];
$base_url = DI::baseUrl()->get(); $base_url = DI::baseUrl();
if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) { if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname']; $url = $base_url . '/profile/' . $user['nickname'];
@ -404,11 +404,11 @@ class Register extends BaseModule
'type' => Model\Notification\Type::SYSTEM, 'type' => Model\Notification\Type::SYSTEM,
'event' => $event, 'event' => $event,
'uid' => $admin['uid'], 'uid' => $admin['uid'],
'link' => DI::baseUrl()->get(true) . '/moderation/users/', 'link' => DI::baseUrl() . '/moderation/users/',
'source_name' => $user['username'], 'source_name' => $user['username'],
'source_mail' => $user['email'], 'source_mail' => $user['email'],
'source_nick' => $user['nickname'], 'source_nick' => $user['nickname'],
'source_link' => DI::baseUrl()->get(true) . '/moderation/users/', 'source_link' => DI::baseUrl() . '/moderation/users/',
'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB), 'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
'show_in_notification_page' => false 'show_in_notification_page' => false
]); ]);

View file

@ -132,7 +132,6 @@ class Login extends BaseModule
DI::page()['htmlhead'] .= Renderer::replaceMacros( DI::page()['htmlhead'] .= Renderer::replaceMacros(
Renderer::getMarkupTemplate('login_head.tpl'), Renderer::getMarkupTemplate('login_head.tpl'),
[ [
'$baseurl' => DI::baseUrl()->get(true)
] ]
); );
@ -154,7 +153,7 @@ class Login extends BaseModule
$o = Renderer::replaceMacros( $o = Renderer::replaceMacros(
$tpl, $tpl,
[ [
'$dest_url' => DI::baseUrl()->get(true) . '/login', '$dest_url' => DI::baseUrl() . '/login',
'$logout' => DI::l10n()->t('Logout'), '$logout' => DI::l10n()->t('Logout'),
'$login' => DI::l10n()->t('Login'), '$login' => DI::l10n()->t('Login'),

View file

@ -43,7 +43,7 @@ class OpenID extends BaseModule
if (!empty($_GET['openid_mode']) && !empty($session->get('openid'))) { if (!empty($_GET['openid_mode']) && !empty($session->get('openid'))) {
$openid = new LightOpenID(DI::baseUrl()->getHostname()); $openid = new LightOpenID(DI::baseUrl()->getHost());
$l10n = DI::l10n(); $l10n = DI::l10n();
@ -82,7 +82,7 @@ class OpenID extends BaseModule
$session->set('openid_identity', $authId); $session->set('openid_identity', $authId);
// Detect the server URL // Detect the server URL
$open_id_obj = new LightOpenID(DI::baseUrl()->getHostname()); $open_id_obj = new LightOpenID(DI::baseUrl()->getHost());
$open_id_obj->identity = $authId; $open_id_obj->identity = $authId;
$session->set('openid_server', $open_id_obj->discover($open_id_obj->identity)); $session->set('openid_server', $open_id_obj->discover($open_id_obj->identity));

View file

@ -93,7 +93,6 @@ class PasswordTooLong extends \Friendica\BaseModule
'submit' => $this->l10n->t('Update Password'), 'submit' => $this->l10n->t('Update Password'),
], ],
'$baseurl' => $this->baseUrl->get(true),
'$form_security_token' => self::getFormSecurityToken('security/password_too_long'), '$form_security_token' => self::getFormSecurityToken('security/password_too_long'),
'$return_url' => $request['return_url'] ?? '', '$return_url' => $request['return_url'] ?? '',

View file

@ -555,10 +555,9 @@ class Account extends BaseSettings
$tpl = Renderer::getMarkupTemplate('settings/account.tpl'); $tpl = Renderer::getMarkupTemplate('settings/account.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$ptitle' => DI::l10n()->t('Account Settings'), '$ptitle' => DI::l10n()->t('Account Settings'),
'$desc' => DI::l10n()->t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . DI::baseUrl()->getHostname() . DI::baseUrl()->getUrlPath(), DI::baseUrl() . '/profile/' . $nickname), '$desc' => DI::l10n()->t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . DI::baseUrl()->getHost() . DI::baseUrl()->getPath(), DI::baseUrl() . '/profile/' . $nickname),
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$baseurl' => DI::baseUrl()->get(true),
'$uid' => DI::userSession()->getLocalUserId(), '$uid' => DI::userSession()->getLocalUserId(),
'$form_security_token' => self::getFormSecurityToken('settings'), '$form_security_token' => self::getFormSecurityToken('settings'),
'$open' => $this->parameters['open'] ?? 'password', '$open' => $this->parameters['open'] ?? 'password',

View file

@ -252,7 +252,6 @@ class Display extends BaseSettings
'$calendar_title' => $this->t('Calendar'), '$calendar_title' => $this->t('Calendar'),
'$form_security_token' => self::getFormSecurityToken('settings_display'), '$form_security_token' => self::getFormSecurityToken('settings_display'),
'$baseurl' => $this->baseUrl->get(true),
'$uid' => $uid, '$uid' => $uid,
'$theme' => ['theme', $this->t('Display Theme:'), $theme_selected, '', $themes, true], '$theme' => ['theme', $this->t('Display Theme:'), $theme_selected, '', $themes, true],

View file

@ -68,7 +68,6 @@ class OAuth extends BaseSettings
$tpl = Renderer::getMarkupTemplate('settings/oauth.tpl'); $tpl = Renderer::getMarkupTemplate('settings/oauth.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseSettings::getFormSecurityToken('settings_oauth'), '$form_security_token' => BaseSettings::getFormSecurityToken('settings_oauth'),
'$baseurl' => $this->baseUrl->get(true),
'$title' => $this->t('Connected Apps'), '$title' => $this->t('Connected Apps'),
'$name' => $this->t('Name'), '$name' => $this->t('Name'),
'$website' => $this->t('Home Page'), '$website' => $this->t('Home Page'),

View file

@ -208,7 +208,6 @@ class Index extends BaseSettings
]; ];
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/profile/index_head.tpl'), [ DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/profile/index_head.tpl'), [
'$baseurl' => DI::baseUrl()->get(true),
]); ]);
$personal_account = ($profile['account-type'] != User::ACCOUNT_TYPE_COMMUNITY); $personal_account = ($profile['account-type'] != User::ACCOUNT_TYPE_COMMUNITY);
@ -241,7 +240,7 @@ class Index extends BaseSettings
'$lbl_profile_photo' => DI::l10n()->t('Upload Profile Photo'), '$lbl_profile_photo' => DI::l10n()->t('Upload Profile Photo'),
'$baseurl' => DI::baseUrl()->get(true), '$baseurl' => DI::baseUrl(),
'$nickname' => $profile['nickname'], '$nickname' => $profile['nickname'],
'$name' => ['name', DI::l10n()->t('Display name:'), $profile['name']], '$name' => ['name', DI::l10n()->t('Display name:'), $profile['name']],
'$about' => ['about', DI::l10n()->t('Description:'), $profile['about']], '$about' => ['about', DI::l10n()->t('Description:'), $profile['about']],

View file

@ -46,14 +46,14 @@ class HostMeta extends BaseModule
$config->set('system', 'site_pubkey', $res['pubkey']); $config->set('system', 'site_pubkey', $res['pubkey']);
} }
$domain = DI::baseUrl()->get(); $domain = DI::baseUrl();
XML::fromArray([ XML::fromArray([
'XRD' => [ 'XRD' => [
'@attributes' => [ '@attributes' => [
'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0', 'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
], ],
'hm:Host' => DI::baseUrl()->getHostname(), 'hm:Host' => DI::baseUrl()->getHost(),
'1:link' => [ '1:link' => [
'@attributes' => [ '@attributes' => [
'rel' => 'lrdd', 'rel' => 'lrdd',

View file

@ -46,9 +46,9 @@ class NodeInfo extends BaseModule
$nodeinfo = [ $nodeinfo = [
'links' => [ 'links' => [
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
'href' => DI::baseUrl()->get() . '/nodeinfo/1.0'], 'href' => DI::baseUrl() . '/nodeinfo/1.0'],
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0', ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
'href' => DI::baseUrl()->get() . '/nodeinfo/2.0'], 'href' => DI::baseUrl() . '/nodeinfo/2.0'],
] ]
]; ];

View file

@ -64,17 +64,17 @@ class XSocialRelay extends BaseModule
'tags' => $tagList, 'tags' => $tagList,
'protocols' => [ 'protocols' => [
'activitypub' => [ 'activitypub' => [
'actor' => DI::baseUrl()->get() . '/friendica', 'actor' => DI::baseUrl() . '/friendica',
'receive' => DI::baseUrl()->get() . '/inbox' 'receive' => DI::baseUrl() . '/inbox'
], ],
'dfrn' => [ 'dfrn' => [
'receive' => DI::baseUrl()->get() . '/dfrn_notify' 'receive' => DI::baseUrl() . '/dfrn_notify'
] ]
] ]
]; ];
if (DI::config()->get("system", "diaspora_enabled")) { if (DI::config()->get("system", "diaspora_enabled")) {
$relay['protocols']['diaspora'] = ['receive' => DI::baseUrl()->get() . '/receive/public']; $relay['protocols']['diaspora'] = ['receive' => DI::baseUrl() . '/receive/public'];
} }
System::jsonExit($relay); System::jsonExit($relay);

View file

@ -105,7 +105,7 @@ class Xrd extends BaseModule
private function printSystemJSON(array $owner) private function printSystemJSON(array $owner)
{ {
$baseURL = $this->baseUrl->get(); $baseURL = $this->baseUrl;
$json = [ $json = [
'subject' => 'acct:' . $owner['addr'], 'subject' => 'acct:' . $owner['addr'],
'aliases' => [$owner['url']], 'aliases' => [$owner['url']],
@ -151,7 +151,7 @@ class Xrd extends BaseModule
private function printJSON(string $alias, array $owner, array $avatar) private function printJSON(string $alias, array $owner, array $avatar)
{ {
$baseURL = $this->baseUrl->get(); $baseURL = $this->baseUrl;
$json = [ $json = [
'subject' => 'acct:' . $owner['addr'], 'subject' => 'acct:' . $owner['addr'],
@ -228,7 +228,7 @@ class Xrd extends BaseModule
private function printXML(string $alias, array $owner, array $avatar) private function printXML(string $alias, array $owner, array $avatar)
{ {
$baseURL = $this->baseUrl->get(); $baseURL = $this->baseUrl;
$xmlString = XML::fromArray([ $xmlString = XML::fromArray([
'XRD' => [ 'XRD' => [

View file

@ -136,7 +136,7 @@ class FormattedNavNotification extends BaseFactory
self::$contacts[$notification->actorId]['url'], self::$contacts[$notification->actorId]['url'],
$message['notification'], $message['notification'],
$notification->created, $notification->created,
new Uri($this->baseUrl->get() . '/notification/' . $notification->id), new Uri($this->baseUrl . '/notification/' . $notification->id),
$notification->seen, $notification->seen,
); );
} }
@ -168,7 +168,7 @@ class FormattedNavNotification extends BaseFactory
self::$contacts[$intro->cid]['url'], self::$contacts[$intro->cid]['url'],
$msg, $msg,
$intro->datetime, $intro->datetime,
new Uri($this->baseUrl->get() . '/notifications/intros/' . $intro->id) new Uri($this->baseUrl . '/notifications/intros/' . $intro->id)
); );
} }
} }

View file

@ -90,7 +90,7 @@ class FormattedNotify extends BaseFactory
case Activity::LIKE: case Activity::LIKE:
return new ValueObject\FormattedNotify( return new ValueObject\FormattedNotify(
'like', 'like',
$this->baseUrl->get(true) . '/display/' . $formattedItem['parent-guid'], $this->baseUrl . '/display/' . $formattedItem['parent-guid'],
$formattedItem['author-avatar'], $formattedItem['author-avatar'],
$formattedItem['author-link'], $formattedItem['author-link'],
$this->l10n->t("%s liked %s's post", $formattedItem['author-name'], $formattedItem['parent-author-name']), $this->l10n->t("%s liked %s's post", $formattedItem['author-name'], $formattedItem['parent-author-name']),
@ -102,7 +102,7 @@ class FormattedNotify extends BaseFactory
case Activity::DISLIKE: case Activity::DISLIKE:
return new ValueObject\FormattedNotify( return new ValueObject\FormattedNotify(
'dislike', 'dislike',
$this->baseUrl->get(true) . '/display/' . $formattedItem['parent-guid'], $this->baseUrl . '/display/' . $formattedItem['parent-guid'],
$formattedItem['author-avatar'], $formattedItem['author-avatar'],
$formattedItem['author-link'], $formattedItem['author-link'],
$this->l10n->t("%s disliked %s's post", $formattedItem['author-name'], $formattedItem['parent-author-name']), $this->l10n->t("%s disliked %s's post", $formattedItem['author-name'], $formattedItem['parent-author-name']),
@ -114,7 +114,7 @@ class FormattedNotify extends BaseFactory
case Activity::ATTEND: case Activity::ATTEND:
return new ValueObject\FormattedNotify( return new ValueObject\FormattedNotify(
'attend', 'attend',
$this->baseUrl->get(true) . '/display/' . $formattedItem['parent-guid'], $this->baseUrl . '/display/' . $formattedItem['parent-guid'],
$formattedItem['author-avatar'], $formattedItem['author-avatar'],
$formattedItem['author-link'], $formattedItem['author-link'],
$this->l10n->t("%s is attending %s's event", $formattedItem['author-name'], $formattedItem['parent-author-name']), $this->l10n->t("%s is attending %s's event", $formattedItem['author-name'], $formattedItem['parent-author-name']),
@ -126,7 +126,7 @@ class FormattedNotify extends BaseFactory
case Activity::ATTENDNO: case Activity::ATTENDNO:
return new ValueObject\FormattedNotify( return new ValueObject\FormattedNotify(
'attendno', 'attendno',
$this->baseUrl->get(true) . '/display/' . $formattedItem['parent-guid'], $this->baseUrl . '/display/' . $formattedItem['parent-guid'],
$formattedItem['author-avatar'], $formattedItem['author-avatar'],
$formattedItem['author-link'], $formattedItem['author-link'],
$this->l10n->t("%s is not attending %s's event", $formattedItem['author-name'], $formattedItem['parent-author-name']), $this->l10n->t("%s is not attending %s's event", $formattedItem['author-name'], $formattedItem['parent-author-name']),
@ -138,7 +138,7 @@ class FormattedNotify extends BaseFactory
case Activity::ATTENDMAYBE: case Activity::ATTENDMAYBE:
return new ValueObject\FormattedNotify( return new ValueObject\FormattedNotify(
'attendmaybe', 'attendmaybe',
$this->baseUrl->get(true) . '/display/' . $formattedItem['parent-guid'], $this->baseUrl . '/display/' . $formattedItem['parent-guid'],
$formattedItem['author-avatar'], $formattedItem['author-avatar'],
$formattedItem['author-link'], $formattedItem['author-link'],
$this->l10n->t("%s may attending %s's event", $formattedItem['author-name'], $formattedItem['parent-author-name']), $this->l10n->t("%s may attending %s's event", $formattedItem['author-name'], $formattedItem['parent-author-name']),
@ -168,7 +168,7 @@ class FormattedNotify extends BaseFactory
return new ValueObject\FormattedNotify( return new ValueObject\FormattedNotify(
'friend', 'friend',
$this->baseUrl->get(true) . '/display/' . $formattedItem['parent-guid'], $this->baseUrl . '/display/' . $formattedItem['parent-guid'],
$formattedItem['author-avatar'], $formattedItem['author-avatar'],
$formattedItem['author-link'], $formattedItem['author-link'],
$this->l10n->t("%s is now friends with %s", $formattedItem['author-name'], $formattedItem['fname']), $this->l10n->t("%s is now friends with %s", $formattedItem['author-name'], $formattedItem['fname']),
@ -219,7 +219,7 @@ class FormattedNotify extends BaseFactory
foreach ($Notifies as $Notify) { foreach ($Notifies as $Notify) {
$formattedNotifications[] = new ValueObject\FormattedNotify( $formattedNotifications[] = new ValueObject\FormattedNotify(
'notification', 'notification',
$this->baseUrl->get(true) . '/notify/' . $Notify->id, $this->baseUrl . '/notify/' . $Notify->id,
Contact::getAvatarUrlForUrl($Notify->url, $Notify->uid, Proxy::SIZE_MICRO), Contact::getAvatarUrlForUrl($Notify->url, $Notify->uid, Proxy::SIZE_MICRO),
$Notify->url, $Notify->url,
strip_tags(BBCode::toPlaintext($Notify->msg)), strip_tags(BBCode::toPlaintext($Notify->msg)),
@ -369,7 +369,7 @@ class FormattedNotify extends BaseFactory
} }
$item['label'] = (($item['gravity'] == Item::GRAVITY_PARENT) ? 'post' : 'comment'); $item['label'] = (($item['gravity'] == Item::GRAVITY_PARENT) ? 'post' : 'comment');
$item['link'] = $this->baseUrl->get(true) . '/display/' . $item['parent-guid']; $item['link'] = $this->baseUrl . '/display/' . $item['parent-guid'];
$item['image'] = $item['author-avatar']; $item['image'] = $item['author-avatar'];
$item['url'] = $item['author-link']; $item['url'] = $item['author-link'];
$item['when'] = DateTimeFormat::local($item['created'], 'r'); $item['when'] = DateTimeFormat::local($item['created'], 'r');

View file

@ -125,8 +125,8 @@ class Introduction extends BaseFactory
continue; continue;
} }
$return_addr = bin2hex($this->nick . '@' . $return_addr = bin2hex($this->nick . '@' .
$this->baseUrl->getHostname() . $this->baseUrl->getHost() .
(($this->baseUrl->getUrlPath()) ? '/' . $this->baseUrl->getUrlPath() : '')); (($this->baseUrl->getPath()) ? '/' . $this->baseUrl->getPath() : ''));
$formattedIntroductions[] = new ValueObject\Introduction([ $formattedIntroductions[] = new ValueObject\Introduction([
'label' => 'friend_suggestion', 'label' => 'friend_suggestion',

Some files were not shown because too many files have changed in this diff Show more