From e944d7bed6b971494bff82396960d280e6a82cca Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Mon, 16 Dec 2019 01:05:15 +0100 Subject: [PATCH] Remove deprecated App::getBaseURL() - process methods to DI::baseUrl()->get() --- mod/dfrn_request.php | 2 +- mod/profile_photo.php | 2 +- mod/regmod.php | 4 +--- mod/removeme.php | 2 +- mod/settings.php | 2 +- src/App.php | 20 +++----------------- src/Content/Text/BBCode.php | 2 +- src/Core/Renderer.php | 3 +-- src/Model/Item.php | 2 +- src/Model/Photo.php | 6 ++---- src/Model/Profile.php | 6 +++--- src/Module/Admin/Addons/Details.php | 2 +- src/Module/Admin/Addons/Index.php | 4 +--- src/Module/Admin/Blocklist/Contact.php | 2 +- src/Module/Admin/Blocklist/Server.php | 4 +--- src/Module/Admin/DBSync.php | 4 ++-- src/Module/Admin/Logs/Settings.php | 4 +--- src/Module/Admin/Site.php | 10 ++++------ src/Module/Admin/Summary.php | 10 +++++----- src/Module/Admin/Themes/Details.php | 2 +- src/Module/Admin/Themes/Index.php | 6 ++---- src/Module/Admin/Users.php | 6 ++---- src/Module/AllFriends.php | 2 +- src/Module/BaseSearchModule.php | 4 +--- src/Module/Bookmarklet.php | 2 +- src/Module/Contact.php | 4 ++-- src/Module/Debug/Localtime.php | 2 +- src/Module/Diaspora/Fetch.php | 2 +- src/Module/Friendica.php | 11 +++++------ src/Module/Help.php | 2 +- src/Module/Home.php | 2 +- src/Module/Install.php | 12 +++++------- src/Module/Invite.php | 6 +++--- src/Module/Magic.php | 2 +- src/Module/OpenSearch.php | 2 +- src/Module/ReallySimpleDiscovery.php | 3 +-- src/Module/Security/Login.php | 4 ++-- src/Module/WellKnown/HostMeta.php | 5 ++--- src/Module/WellKnown/NodeInfo.php | 13 ++++--------- src/Module/WellKnown/XSocialRelay.php | 5 ++--- src/Module/Xrd.php | 4 ++-- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Protocol/DFRN.php | 2 +- 43 files changed, 76 insertions(+), 120 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 0c0e5421ad..f7dc5f55cd 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -437,7 +437,7 @@ function dfrn_request_post(App $a) } // "Homecoming" - send the requestor back to their site to record the introduction. - $dfrn_url = bin2hex($a->getBaseURL() . '/profile/' . $nickname); + $dfrn_url = bin2hex(DI::baseUrl()->get() . '/profile/' . $nickname); $aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0); System::externalRedirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url" diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 412d19029e..6d625cedeb 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -126,7 +126,7 @@ function profile_photo_post(App $a) info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL); // Update global directory in background if ($path && strlen(Config::get('system', 'directory'))) { - Worker::add(PRIORITY_LOW, "Directory", $a->getBaseURL() . '/' . $path); + Worker::add(PRIORITY_LOW, "Directory", DI::baseUrl()->get() . '/' . $path); } Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user()); diff --git a/mod/regmod.php b/mod/regmod.php index 0fc5a88994..e08edfbcc9 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -16,8 +16,6 @@ use Friendica\Module\Security\Login; function user_allow($hash) { - $a = \get_app(); - $register = Register::getByHash($hash); if (!DBA::isResult($register)) { return false; @@ -45,7 +43,7 @@ function user_allow($hash) $l10n, $user, Config::get('config', 'sitename'), - $a->getBaseUrl(), + DI::baseUrl()->get(), ($register['password'] ?? '') ?: 'Sent in a previous email' ); diff --git a/mod/removeme.php b/mod/removeme.php index 30e332d328..ecf65c04c1 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -80,7 +80,7 @@ function removeme_content(App $a) $tpl = Renderer::getMarkupTemplate('removeme.tpl'); $o = Renderer::replaceMacros($tpl, [ - '$basedir' => $a->getBaseURL(), + '$basedir' => DI::baseUrl()->get(), '$hash' => $hash, '$title' => L10n::t('Remove My Account'), '$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'), diff --git a/mod/settings.php b/mod/settings.php index eb664e378a..7dad1f04c1 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -721,7 +721,7 @@ function settings_content(App $a) $tpl = Renderer::getMarkupTemplate('settings/oauth.tpl'); $o .= Renderer::replaceMacros($tpl, [ '$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$title' => L10n::t('Connected Apps'), '$add' => L10n::t('Add application'), '$edit' => L10n::t('Edit'), diff --git a/src/App.php b/src/App.php index c00a574c2d..35ef04df6e 100644 --- a/src/App.php +++ b/src/App.php @@ -271,20 +271,6 @@ class App return $this->baseURL->getScheme(); } - /** - * Retrieves the Friendica instance base URL - * - * @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN - * - * @return string Friendica server base URL - * - * @deprecated 2019.09 - use BaseUrl->get($ssl) instead - */ - public function getBaseURL($ssl = false) - { - return $this->baseURL->get($ssl); - } - /** * Returns the current UserAgent as a String * @@ -298,7 +284,7 @@ class App FRIENDICA_CODENAME . "' " . FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION . '; ' . - $this->getBaseURL(); + $this->baseURL->get(); } /** @@ -478,8 +464,8 @@ class App // and www.example.com vs example.com. // We will only change the url to an ip address if there is no existing setting - if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) { - $this->config->set('system', 'url', $this->getBaseURL()); + if (empty($url) || (!Util\Strings::compareLink($url, $this->baseURL->get())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) { + $this->config->set('system', 'url', $this->baseURL->get()); } } diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index f7ca6efd97..ada0a0f35a 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1152,7 +1152,7 @@ class BBCode $a = DI::app(); // When the picture link is the own photo path then we can avoid fetching the link - $own_photo_url = preg_quote(Strings::normaliseLink($a->getBaseURL()) . '/photos/'); + $own_photo_url = preg_quote(Strings::normaliseLink(DI::baseUrl()->get()) . '/photos/'); if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) { if (!empty($match[3])) { $text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]'; diff --git a/src/Core/Renderer.php b/src/Core/Renderer.php index 8366d0db80..32247310cf 100644 --- a/src/Core/Renderer.php +++ b/src/Core/Renderer.php @@ -61,10 +61,9 @@ class Renderer public static function replaceMacros($s, array $vars = []) { $stamp1 = microtime(true); - $a = DI::app(); // pass $baseurl to all templates if it isn't set - $vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars); + $vars = array_merge(['$baseurl' => DI::baseUrl()->get()], $vars); $t = self::getTemplateEngine(); diff --git a/src/Model/Item.php b/src/Model/Item.php index 507ee654ec..16a6a0a24c 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2511,7 +2511,7 @@ class Item $guid = System::createUUID(); } - return DI::app()->getBaseURL() . '/objects/' . $guid; + return DI::baseUrl()->get() . '/objects/' . $guid; } /** diff --git a/src/Model/Photo.php b/src/Model/Photo.php index af17cc395e..dd49892240 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -679,8 +679,7 @@ class Photo */ public static function getGUID($name) { - $a = \get_app(); - $base = $a->getBaseURL(); + $base = DI::baseUrl()->get(); $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name)); @@ -725,8 +724,7 @@ class Photo */ public static function isLocalPage($name) { - $a = \get_app(); - $base = $a->getBaseURL(); + $base = DI::baseUrl()->get(); $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name)); $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid); diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 3f7877c558..0ebb400f6e 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -337,7 +337,7 @@ class Profile if (isset($profile['url'])) { $profile_url = $profile['url']; } else { - $profile_url = $a->getBaseURL() . '/profile/' . $profile['nickname']; + $profile_url = DI::baseUrl()->get() . '/profile/' . $profile['nickname']; } $follow_link = null; @@ -1080,13 +1080,13 @@ class Profile $query = rtrim(str_replace($addr_request, '', $a->query_string), '?&'); // The other instance needs to know where to redirect. - $dest = urlencode($a->getBaseURL() . '/' . $query); + $dest = urlencode(DI::baseUrl()->get() . '/' . $query); // We need to extract the basebath from the profile url // to redirect the visitors '/magic' module. $basepath = Contact::getBasepath($contact['url']); - if ($basepath != $a->getBaseURL() && !strstr($dest, '/magic')) { + if ($basepath != DI::baseUrl()->get() && !strstr($dest, '/magic')) { $magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request; // We have to check if the remote server does understand /magic without invoking something diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index afca0b150c..bc1925717e 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -101,7 +101,7 @@ class Details extends BaseAdminModule '$page' => L10n::t('Addons'), '$toggle' => L10n::t('Toggle'), '$settings' => L10n::t('Settings'), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$addon' => $addon, '$status' => $status, diff --git a/src/Module/Admin/Addons/Index.php b/src/Module/Admin/Addons/Index.php index bc28aaa8fe..511cb44755 100644 --- a/src/Module/Admin/Addons/Index.php +++ b/src/Module/Admin/Addons/Index.php @@ -14,8 +14,6 @@ class Index extends BaseAdminModule { parent::content($parameters); - $a = DI::app(); - // reload active themes if (!empty($_GET['action'])) { parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't'); @@ -52,7 +50,7 @@ class Index extends BaseAdminModule '$page' => L10n::t('Addons'), '$submit' => L10n::t('Save Settings'), '$reload' => L10n::t('Reload active addons'), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$function' => 'addons', '$addons' => $addons, '$pcount' => count($addons), diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index 71e96834b6..b2e9c50827 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -76,7 +76,7 @@ class Contact extends BaseAdminModule '$form_security_token' => parent::getFormSecurityToken('admin_contactblock'), // values // - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$contacts' => $contacts, '$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total), diff --git a/src/Module/Admin/Blocklist/Server.php b/src/Module/Admin/Blocklist/Server.php index 87cb8709db..43c6543e46 100644 --- a/src/Module/Admin/Blocklist/Server.php +++ b/src/Module/Admin/Blocklist/Server.php @@ -55,8 +55,6 @@ class Server extends BaseAdminModule { parent::content($parameters); - $a = DI::app(); - $blocklist = Config::get('system', 'blocklist'); $blocklistform = []; if (is_array($blocklist)) { @@ -91,7 +89,7 @@ class Server extends BaseAdminModule '$threason' => L10n::t('Reason for the block'), '$delentry' => L10n::t('Delete entry from blocklist'), '$entries' => $blocklistform, - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$confirm_delete' => L10n::t('Delete entry from blocklist?'), '$form_security_token' => parent::getFormSecurityToken("admin_blocklist") ]); diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index 6f6ebe3d00..a0e70737e5 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -88,13 +88,13 @@ class DBSync extends BaseAdminModule if (!count($failed)) { $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [ - '$base' => $a->getBaseURL(true), + '$base' => DI::baseUrl()->get(true), '$banner' => L10n::t('No failed updates.'), '$check' => L10n::t('Check database structure'), ]); } else { $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [ - '$base' => $a->getBaseURL(true), + '$base' => DI::baseUrl()->get(true), '$banner' => L10n::t('Failed Updates'), '$desc' => L10n::t('This does not include updates prior to 1139, which did not return a status.'), '$mark' => L10n::t("Mark success \x28if update was manually applied\x29"), diff --git a/src/Module/Admin/Logs/Settings.php b/src/Module/Admin/Logs/Settings.php index ccddf69a1d..21380af4a5 100644 --- a/src/Module/Admin/Logs/Settings.php +++ b/src/Module/Admin/Logs/Settings.php @@ -42,8 +42,6 @@ class Settings extends BaseAdminModule { parent::content($parameters); - $a = DI::app(); - $log_choices = [ LogLevel::ERROR => 'Error', LogLevel::WARNING => 'Warning', @@ -65,7 +63,7 @@ class Settings extends BaseAdminModule '$page' => L10n::t('Logs'), '$submit' => L10n::t('Save Settings'), '$clear' => L10n::t('Clear'), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$logname' => Config::get('system', 'logfile'), // see /help/smarty3-templates#1_1 on any Friendica node '$debugging' => ['debugging', L10n::t("Enable Debugging"), Config::get('system', 'debugging'), ""], diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 267680583d..ed16a65b77 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -56,7 +56,7 @@ class Site extends BaseAdminModule * send relocate for every local user * */ - $old_url = $a->getBaseURL(true); + $old_url = DI::baseUrl()->get(true); // Generate host names for relocation the addresses in the format user@address.tld $new_host = str_replace("http://", "@", Strings::normaliseLink($new_url)); @@ -417,8 +417,6 @@ class Site extends BaseAdminModule { parent::content($parameters); - $a = DI::app(); - /* Installed langs */ $lang_choices = L10n::getAvailableLanguages(); @@ -578,7 +576,7 @@ class Site extends BaseAdminModule '$relay_title' => L10n::t('Message Relay'), '$relocate' => L10n::t('Relocate Instance'), '$relocate_warning' => L10n::t('Warning! Advanced function. Could make this server unreachable.'), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), // name, label, value, help string, extra data... '$sitename' => ['sitename', L10n::t('Site name'), Config::get('config', 'sitename'), ''], @@ -661,14 +659,14 @@ class Site extends BaseAdminModule '$proxy_disabled' => ['proxy_disabled', L10n::t('Disable picture proxy'), Config::get('system', 'proxy_disabled'), L10n::t('The picture proxy increases performance and privacy. It shouldn\'t be used on systems with very low bandwidth.')], '$only_tag_search' => ['only_tag_search', L10n::t('Only search in tags'), Config::get('system', 'only_tag_search'), L10n::t('On large systems the text search can slow down the system extremely.')], - '$relocate_url' => ['relocate_url', L10n::t('New base url'), $a->getBaseURL(), L10n::t('Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.')], + '$relocate_url' => ['relocate_url', L10n::t('New base url'), DI::baseUrl()->get(), L10n::t('Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.')], '$rino' => ['rino', L10n::t('RINO Encryption'), intval(Config::get('system', 'rino_encrypt')), L10n::t('Encryption layer between nodes.'), [0 => L10n::t('Disabled'), 1 => L10n::t('Enabled')]], '$worker_queues' => ['worker_queues', L10n::t('Maximum number of parallel workers'), Config::get('system', 'worker_queues'), L10n::t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)], '$worker_dont_fork' => ['worker_dont_fork', L10n::t('Don\'t use "proc_open" with the worker'), Config::get('system', 'worker_dont_fork'), L10n::t('Enable this if your system doesn\'t allow the use of "proc_open". This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.')], '$worker_fastlane' => ['worker_fastlane', L10n::t('Enable fastlane'), Config::get('system', 'worker_fastlane'), L10n::t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')], - '$worker_frontend' => ['worker_frontend', L10n::t('Enable frontend worker'), Config::get('system', 'frontend_worker'), L10n::t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', $a->getBaseURL())], + '$worker_frontend' => ['worker_frontend', L10n::t('Enable frontend worker'), Config::get('system', 'frontend_worker'), L10n::t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', DI::baseUrl()->get())], '$relay_subscribe' => ['relay_subscribe', L10n::t('Subscribe to relay'), Config::get('system', 'relay_subscribe'), L10n::t('Enables the receiving of public posts from the relay. They will be included in the search, subscribed tags and on the global community page.')], '$relay_server' => ['relay_server', L10n::t('Relay server'), Config::get('system', 'relay_server', 'https://relay.diasp.org'), L10n::t('Address of the relay server where public posts should be send to. For example https://relay.diasp.org')], diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index 9853ce951b..6f304082af 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -63,18 +63,18 @@ class Summary extends BaseAdminModule // Legacy config file warning if (file_exists('.htconfig.php')) { - $warningtext[] = 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 .htconfig.php. See the Config help page for help with the transition.', $a->getBaseURL() . '/help/Config'); + $warningtext[] = 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 .htconfig.php. See the Config help page for help with the transition.', DI::baseUrl()->get() . '/help/Config'); } if (file_exists('config/local.ini.php')) { - $warningtext[] = 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 config/local.ini.php. See the Config help page for help with the transition.', $a->getBaseURL() . '/help/Config'); + $warningtext[] = 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 config/local.ini.php. See the Config help page for help with the transition.', DI::baseUrl()->get() . '/help/Config'); } // Check server vitality if (!self::checkSelfHostMeta()) { - $well_known = $a->getBaseURL() . '/.well-known/host-meta'; + $well_known = DI::baseUrl()->get() . '/.well-known/host-meta'; $warningtext[] = L10n::t('%s is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See the installation page for help.', - $well_known, $well_known, $a->getBaseURL() . '/help/Install'); + $well_known, $well_known, DI::baseUrl()->get() . '/help/Install'); } // Check logfile permission @@ -208,7 +208,7 @@ class Summary extends BaseAdminModule private static function checkSelfHostMeta() { // Fetch the host-meta to check if this really is a vital server - return Network::curl(DI::app()->getBaseURL() . '/.well-known/host-meta')->isSuccess(); + return Network::curl(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess(); } } diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index f6a3c61b73..2b573eec3b 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -106,7 +106,7 @@ class Details extends BaseAdminModule '$page' => L10n::t('Themes'), '$toggle' => L10n::t('Toggle'), '$settings' => L10n::t('Settings'), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$addon' => $theme, '$status' => $status, '$action' => $action, diff --git a/src/Module/Admin/Themes/Index.php b/src/Module/Admin/Themes/Index.php index 63b3d6f39e..dc848f93f8 100644 --- a/src/Module/Admin/Themes/Index.php +++ b/src/Module/Admin/Themes/Index.php @@ -16,13 +16,11 @@ class Index extends BaseAdminModule { parent::content($parameters); - $a = DI::app(); - $allowed_themes = Theme::getAllowedList(); // reload active themes if (!empty($_GET['action'])) { - parent::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/themes', 'admin_themes', 't'); + parent::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get() . '/admin/themes', 'admin_themes', 't'); switch ($_GET['action']) { case 'reload': @@ -97,7 +95,7 @@ class Index extends BaseAdminModule '$page' => L10n::t('Themes'), '$submit' => L10n::t('Save Settings'), '$reload' => L10n::t('Reload active themes'), - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$function' => 'themes', '$addons' => $addons, '$pcount' => count($themes), diff --git a/src/Module/Admin/Users.php b/src/Module/Admin/Users.php index 7d8574e56b..286bc04452 100644 --- a/src/Module/Admin/Users.php +++ b/src/Module/Admin/Users.php @@ -20,8 +20,6 @@ class Users extends BaseAdminModule { parent::post($parameters); - $a = DI::app(); - $pending = $_POST['pending'] ?? []; $users = $_POST['user'] ?? []; $nu_name = $_POST['new_user_name'] ?? ''; @@ -78,7 +76,7 @@ class Users extends BaseAdminModule Thank you and welcome to %4$s.')); $preamble = sprintf($preamble, $user['username'], Config::get('config', 'sitename')); - $body = sprintf($body, $a->getBaseURL(), $user['nickname'], $result['password'], Config::get('config', 'sitename')); + $body = sprintf($body, DI::baseUrl()->get(), $user['nickname'], $result['password'], Config::get('config', 'sitename')); notification([ 'type' => SYSTEM_EMAIL, @@ -306,7 +304,7 @@ class Users extends BaseAdminModule '$form_security_token' => parent::getFormSecurityToken('admin_users'), // values // - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), '$pending' => $pending, 'deleted' => $deleted, diff --git a/src/Module/AllFriends.php b/src/Module/AllFriends.php index 2699990736..14095f4507 100644 --- a/src/Module/AllFriends.php +++ b/src/Module/AllFriends.php @@ -70,7 +70,7 @@ class AllFriends extends BaseModule $friend['id'] = $friend['cid']; $photoMenu = Model\Contact::photoMenu($friend); } else { - $connlnk = $app->getBaseURL() . '/follow/?url=' . $friend['url']; + $connlnk = DI::baseUrl()->get() . '/follow/?url=' . $friend['url']; $photoMenu = [ 'profile' => [L10n::t('View Profile'), Model\Contact::magicLinkbyId($friend['id'], $friend['url'])], 'follow' => [L10n::t('Connect/Follow'), $connlnk] diff --git a/src/Module/BaseSearchModule.php b/src/Module/BaseSearchModule.php index efedca92af..cf0159cc27 100644 --- a/src/Module/BaseSearchModule.php +++ b/src/Module/BaseSearchModule.php @@ -97,8 +97,6 @@ class BaseSearchModule extends BaseModule return ''; } - $a = DI::app(); - $id = 0; $entries = []; foreach ($results->getResults() as $result) { @@ -131,7 +129,7 @@ class BaseSearchModule extends BaseModule $photo_menu = []; } } else { - $connLink = $a->getBaseURL() . '/follow/?url=' . $result->getUrl(); + $connLink = DI::baseUrl()->get() . '/follow/?url=' . $result->getUrl(); $connTxt = L10n::t('Connect'); $photo_menu['profile'] = [L10n::t("View Profile"), Model\Contact::magicLink($result->getUrl())]; diff --git a/src/Module/Bookmarklet.php b/src/Module/Bookmarklet.php index 93f790a37d..c7f4cdae4a 100644 --- a/src/Module/Bookmarklet.php +++ b/src/Module/Bookmarklet.php @@ -30,7 +30,7 @@ class Bookmarklet extends BaseModule } $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? ''); - $page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet"); + $page = Strings::normaliseLink(DI::baseUrl()->get() . "/bookmarklet"); if (!strstr($referer, $page)) { if (empty($_REQUEST["url"])) { diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 45e4900ac2..f7c6680ed4 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -351,7 +351,7 @@ class Contact extends BaseModule $tpl = Renderer::getMarkupTemplate('contacts-head.tpl'); $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), ]); $sort_type = 0; @@ -473,7 +473,7 @@ class Contact extends BaseModule $contact = $a->data['contact']; $a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [ - '$baseurl' => $a->getBaseURL(true), + '$baseurl' => DI::baseUrl()->get(true), ]); $contact['blocked'] = Model\Contact::isBlockedByUser($contact['id'], local_user()); diff --git a/src/Module/Debug/Localtime.php b/src/Module/Debug/Localtime.php index b762abdbc5..d9e2489790 100644 --- a/src/Module/Debug/Localtime.php +++ b/src/Module/Debug/Localtime.php @@ -40,7 +40,7 @@ class Localtime extends BaseModule $output .= '

' . L10n::t('Converted localtime: %s', $app->data['mod-localtime']) . '

'; } - $output .= '
'; + $output .= ''; $output .= '

' . L10n::t('Please select your timezone:') . '

'; $output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ); $output .= '
'; diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index 9ed8fb109e..c19857fde3 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -47,7 +47,7 @@ class Fetch extends BaseModule } $host = $parts["scheme"] . "://" . $parts["host"]; - if (Strings::normaliseLink($host) != Strings::normaliseLink($app->getBaseURL())) { + if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl()->get())) { $location = $host . "/fetch/" . $app->argv[1] . "/" . urlencode($guid); System::externalRedirect($location, 301); } diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index 4f33fea43a..11773a06d2 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -18,7 +18,6 @@ class Friendica extends BaseModule { public static function content(array $parameters = []) { - $app = DI::app(); $config = DI::config(); $visibleAddonList = Addon::getVisibleList(); @@ -48,7 +47,7 @@ class Friendica extends BaseModule } $tos = ($config->get('system', 'tosdisplay')) ? - L10n::t('Read about the Terms of Service of this node.', $app->getBaseURL()) : + L10n::t('Read about the Terms of Service of this node.', DI::baseUrl()->get()) : ''; $blockList = $config->get('system', 'blocklist'); @@ -75,7 +74,7 @@ class Friendica extends BaseModule return Renderer::replaceMacros($tpl, [ 'about' => 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.', '' . FRIENDICA_VERSION . '', - $app->getBaseURL(), + DI::baseUrl()->get(), '' . DB_UPDATE_VERSION . '', '' . $config->get('system', 'post_update_version') . ''), 'friendica' => L10n::t('Please visit Friendi.ca to learn more about the Friendica project.'), @@ -125,7 +124,7 @@ class Friendica extends BaseModule if (!empty($administrator)) { $admin = [ 'name' => $administrator['username'], - 'profile' => $app->getBaseURL() . '/profile/' . $administrator['nickname'], + 'profile' => DI::baseUrl()->get() . '/profile/' . $administrator['nickname'], ]; } } @@ -147,7 +146,7 @@ class Friendica extends BaseModule $data = [ 'version' => FRIENDICA_VERSION, - 'url' => $app->getBaseURL(), + 'url' => DI::baseUrl()->get(), 'addons' => $visible_addons, 'locked_features' => $locked_features, 'explicit_content' => intval($config->get('system', 'explicit_content', 0)), @@ -157,7 +156,7 @@ class Friendica extends BaseModule 'site_name' => $config->get('config', 'sitename'), 'platform' => FRIENDICA_PLATFORM, 'info' => $config->get('config', 'info'), - 'no_scrape_url' => $app->getBaseURL() . '/noscrape', + 'no_scrape_url' => DI::baseUrl()->get() . '/noscrape', ]; header('Content-type: application/json; charset=utf-8'); diff --git a/src/Module/Help.php b/src/Module/Help.php index 70c99a0a6f..d9362712fd 100644 --- a/src/Module/Help.php +++ b/src/Module/Help.php @@ -87,7 +87,7 @@ class Help extends BaseModule $idNum[$level] ++; - $href = $a->getBaseURL() . "/help/{$filename}#{$anchor}"; + $href = DI::baseUrl()->get() . "/help/{$filename}#{$anchor}"; $toc .= "
  • " . strip_tags($line) . "
  • "; $id = implode("_", array_slice($idNum, 1, $level)); $line = "" . $line; diff --git a/src/Module/Home.php b/src/Module/Home.php index fc8817b31b..fbdc252a66 100644 --- a/src/Module/Home.php +++ b/src/Module/Home.php @@ -42,7 +42,7 @@ class Home extends BaseModule $customHome = $homeFilePath; if (file_exists($cssFilePath)) { - $app->page['htmlhead'] .= ''; + $app->page['htmlhead'] .= ''; } } diff --git a/src/Module/Install.php b/src/Module/Install.php index 10a6176e40..537338da15 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -71,7 +71,7 @@ class Install extends BaseModule // 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 - Renderer::$theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css'; + Renderer::$theme['stylesheet'] = DI::baseUrl()->get() . '/view/install/style.css'; self::$currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK; } @@ -162,7 +162,7 @@ class Install extends BaseModule case self::SYSTEM_CHECK: $php_path = $configCache->get('config', 'php_path'); - $status = self::$installer->checkEnvironment($a->getBaseURL(), $php_path); + $status = self::$installer->checkEnvironment(DI::baseUrl()->get(), $php_path); $tpl = Renderer::getMarkupTemplate('install_checks.tpl'); $output .= Renderer::replaceMacros($tpl, [ @@ -303,7 +303,7 @@ class Install extends BaseModule '$title' => $install_title, '$checks' => self::$installer->getChecks(), '$pass' => L10n::t('Installation finished'), - '$text' => $db_return_text . self::whatNext($a), + '$text' => $db_return_text . self::whatNext(), ]); break; @@ -315,14 +315,12 @@ class Install extends BaseModule /** * Creates the text for the next steps * - * @param App $a The global App - * * @return string The text for the next steps * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - private static function whatNext($a) + private static function whatNext() { - $baseurl = $a->getBaseUrl(); + $baseurl = DI::baseUrl()->get(); return L10n::t('

    What next

    ') . "

    " . L10n::t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.') diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 52d9bbcea3..67d26f6fa7 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -129,14 +129,14 @@ class Invite extends BaseModule if ($config->get('config', 'register_policy') === Register::CLOSED) { $linkTxt = 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 { - $linkTxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', $app->getBaseURL()) + $linkTxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', DI::baseUrl()->get()) . "\r\n" . "\r\n" . 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 if ($config->get('config', 'register_policy') === Register::CLOSED) { return L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); } else { - $linkTxt = L10n::t('To accept this invitation, please visit and register at %s.', $app->getBaseURL() + $linkTxt = L10n::t('To accept this invitation, please visit and register at %s.', DI::baseUrl()->get() . "\r\n" . "\r\n" . 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.')); } } @@ -152,7 +152,7 @@ class Invite extends BaseModule 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 . "\r\n" . "\r\n" . (($inviteOnly) ? L10n::t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . L10n::t('Once you have registered, please connect with me via my profile page at:') - . "\r\n" . "\r\n" . $app->getBaseURL() . '/profile/' . $app->user['nickname'] + . "\r\n" . "\r\n" . DI::baseUrl()->get() . '/profile/' . $app->user['nickname'] . "\r\n" . "\r\n" . 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' => L10n::t('Submit') diff --git a/src/Module/Magic.php b/src/Module/Magic.php index b878b0e701..0ac05ccdf8 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -49,7 +49,7 @@ class Magic extends BaseModule $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); // Redirect if the contact is already authenticated on this site. - if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::app()->getBaseURL())) !== false) { + if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) { if ($test) { $ret['success'] = true; $ret['message'] .= 'Local site - you are already authenticated.' . EOL; diff --git a/src/Module/OpenSearch.php b/src/Module/OpenSearch.php index dbf04040b8..e1da674184 100644 --- a/src/Module/OpenSearch.php +++ b/src/Module/OpenSearch.php @@ -22,7 +22,7 @@ class OpenSearch extends BaseModule header('Content-type: application/opensearchdescription+xml'); $hostname = DI::baseUrl()->getHostname()(); - $baseUrl = DI::app()->getBaseURL(); + $baseUrl = DI::baseUrl()->get(); /** @var DOMDocument $xml */ $xml = null; diff --git a/src/Module/ReallySimpleDiscovery.php b/src/Module/ReallySimpleDiscovery.php index 43fdcf102c..382fe12d4f 100644 --- a/src/Module/ReallySimpleDiscovery.php +++ b/src/Module/ReallySimpleDiscovery.php @@ -16,7 +16,6 @@ class ReallySimpleDiscovery extends BaseModule { header('Content-Type: text/xml'); - $app = DI::app(); $xml = null; echo XML::fromArray([ 'rsd' => [ @@ -32,7 +31,7 @@ class ReallySimpleDiscovery extends BaseModule '@attributes' => [ 'name' => 'Twitter', 'preferred' => 'true', - 'apiLink' => $app->getBaseURL(), + 'apiLink' => DI::baseUrl()->get(), 'blogID' => '', ], 'settings' => [ diff --git a/src/Module/Security/Login.php b/src/Module/Security/Login.php index c525778985..cddd014d00 100644 --- a/src/Module/Security/Login.php +++ b/src/Module/Security/Login.php @@ -104,7 +104,7 @@ class Login extends BaseModule $a->page['htmlhead'] .= Renderer::replaceMacros( Renderer::getMarkupTemplate('login_head.tpl'), [ - '$baseurl' => $a->getBaseURL(true) + '$baseurl' => DI::baseUrl()->get(true) ] ); @@ -127,7 +127,7 @@ class Login extends BaseModule $o .= Renderer::replaceMacros( $tpl, [ - '$dest_url' => DI::app()->getBaseURL(true) . '/login', + '$dest_url' => DI::baseUrl()->get(true) . '/login', '$logout' => L10n::t('Logout'), '$login' => L10n::t('Login'), diff --git a/src/Module/WellKnown/HostMeta.php b/src/Module/WellKnown/HostMeta.php index 2e63f300de..2bae006a70 100644 --- a/src/Module/WellKnown/HostMeta.php +++ b/src/Module/WellKnown/HostMeta.php @@ -16,7 +16,6 @@ class HostMeta extends BaseModule { public static function rawContent(array $parameters = []) { - $app = DI::app(); $config = DI::config(); header('Content-type: text/xml'); @@ -31,8 +30,8 @@ class HostMeta extends BaseModule $tpl = Renderer::getMarkupTemplate('xrd_host.tpl'); echo Renderer::replaceMacros($tpl, [ '$zhost' => DI::baseUrl()->getHostname()(), - '$zroot' => $app->getBaseURL(), - '$domain' => $app->getBaseURL(), + '$zroot' => DI::baseUrl()->get(), + '$domain' => DI::baseUrl()->get(), '$bigkey' => Salmon::salmonKey($config->get('system', 'site_pubkey')) ]); diff --git a/src/Module/WellKnown/NodeInfo.php b/src/Module/WellKnown/NodeInfo.php index 4f44e81d9c..d0d2ea7a02 100644 --- a/src/Module/WellKnown/NodeInfo.php +++ b/src/Module/WellKnown/NodeInfo.php @@ -2,7 +2,6 @@ namespace Friendica\Module\WellKnown; -use Friendica\App; use Friendica\BaseModule; use Friendica\DI; @@ -14,26 +13,22 @@ class NodeInfo extends BaseModule { public static function rawContent(array $parameters = []) { - $app = DI::app(); - - self::printWellKnown($app); + self::printWellKnown(); } /** * Prints the well-known nodeinfo redirect * - * @param App $app - * * @throws \Friendica\Network\HTTPException\NotFoundException */ - private static function printWellKnown(App $app) + private static function printWellKnown() { $nodeinfo = [ 'links' => [ ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', - 'href' => $app->getBaseURL() . '/nodeinfo/1.0'], + 'href' => DI::baseUrl()->get() . '/nodeinfo/1.0'], ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0', - 'href' => $app->getBaseURL() . '/nodeinfo/2.0'], + 'href' => DI::baseUrl()->get() . '/nodeinfo/2.0'], ] ]; diff --git a/src/Module/WellKnown/XSocialRelay.php b/src/Module/WellKnown/XSocialRelay.php index 38a9e12435..f9a806f03c 100644 --- a/src/Module/WellKnown/XSocialRelay.php +++ b/src/Module/WellKnown/XSocialRelay.php @@ -14,7 +14,6 @@ class XSocialRelay extends BaseModule { public static function rawContent(array $parameters = []) { - $app = DI::app(); $config = DI::config(); $subscribe = $config->get('system', 'relay_subscribe', false); @@ -50,10 +49,10 @@ class XSocialRelay extends BaseModule 'tags' => $tagList, 'protocols' => [ 'diaspora' => [ - 'receive' => $app->getBaseURL() . '/receive/public' + 'receive' => DI::baseUrl()->get() . '/receive/public' ], 'dfrn' => [ - 'receive' => $app->getBaseURL() . '/dfrn_notify' + 'receive' => DI::baseUrl()->get() . '/dfrn_notify' ] ] ]; diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 63b293daf4..0048350be8 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -75,9 +75,9 @@ class Xrd extends BaseModule } if ($mode == 'xml') { - self::printXML($alias, $app->getBaseURL(), $user, $owner, $avatar); + self::printXML($alias, DI::baseUrl()->get(), $user, $owner, $avatar); } else { - self::printJSON($alias, $app->getBaseURL(), $owner, $avatar); + self::printJSON($alias, DI::baseUrl()->get(), $owner, $avatar); } } diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 398ee3ae8f..d345340f85 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -204,7 +204,7 @@ class Transmitter { return ['type' => 'Service', 'name' => FRIENDICA_PLATFORM . " '" . FRIENDICA_CODENAME . "' " . FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, - 'url' => DI::app()->getBaseURL()]; + 'url' => DI::baseUrl()->get()]; } /** diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index c20f069567..e058854c94 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2372,7 +2372,7 @@ class DFRN /// @todo Do we really need this check for HTML elements? (It was copied from the old function) if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) { - $base_url = \get_app()->getBaseURL(); + $base_url = DI::baseUrl()->get(); $item['body'] = HTML::relToAbs($item['body'], $base_url); $item['body'] = HTML::toBBCodeVideo($item['body']); -- 2.39.5