From 5d294e8be8da11bff43cc78d2aa207d75bd76df9 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sun, 19 Jan 2020 21:20:10 +0100 Subject: [PATCH 01/10] Move Config::load() to DI::config()->load() --- bin/daemon.php | 2 +- src/Core/Config.php | 12 ------------ src/Core/Update.php | 2 +- view/theme/frio/style.php | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index f0154e74e8..7c5e01c41d 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -44,7 +44,7 @@ if (DI::mode()->isInstall()) { die("Friendica isn't properly installed yet.\n"); } -Config::load(); +DI::config()->load(); if (empty(Config::get('system', 'pidfile'))) { die(<<load($cat); - } - /** * Get a particular user's config variable given the category name ($family) and a key. * diff --git a/src/Core/Update.php b/src/Core/Update.php index b416f207af..e1bcc46d4f 100644 --- a/src/Core/Update.php +++ b/src/Core/Update.php @@ -90,7 +90,7 @@ class Update $stored = intval($build); $current = intval(DB_UPDATE_VERSION); if ($stored < $current || $force) { - Config::load('database'); + DI::config()->load('database'); Logger::info('Update starting.', ['from' => $stored, 'to' => $current]); diff --git a/view/theme/frio/style.php b/view/theme/frio/style.php index 363f7cd44d..cf27e39156 100644 --- a/view/theme/frio/style.php +++ b/view/theme/frio/style.php @@ -14,7 +14,7 @@ $schemecss = ''; $schemecssfile = false; $scheme_modified = 0; -Config::load('frio'); +DI::config()->load('frio'); // Default to hard-coded values for empty settings $scheme = Config::get('frio', 'scheme', Config::get('frio', 'schema')); From 6c36fd9e01510a14fea9de766b4afe6760912a2e Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sun, 19 Jan 2020 21:21:13 +0100 Subject: [PATCH 02/10] Move Config::get() to DI::config()->get() --- bin/daemon.php | 6 +- bin/worker.php | 2 +- boot.php | 12 +- doc/themes.md | 2 +- include/api.php | 32 ++--- include/conversation.php | 2 +- include/enotify.php | 8 +- include/items.php | 2 +- mod/cal.php | 4 +- mod/community.php | 12 +- mod/crepair.php | 2 +- mod/dfrn_confirm.php | 2 +- mod/dfrn_notify.php | 4 +- mod/dfrn_poll.php | 2 +- mod/dfrn_request.php | 4 +- mod/display.php | 4 +- mod/follow.php | 4 +- mod/item.php | 4 +- mod/lostpass.php | 4 +- mod/match.php | 2 +- mod/network.php | 6 +- mod/photos.php | 10 +- mod/ping.php | 2 +- mod/poco.php | 2 +- mod/profile_photo.php | 8 +- mod/profiles.php | 2 +- mod/profperm.php | 2 +- mod/pubsubhubbub.php | 2 +- mod/regmod.php | 6 +- mod/removeme.php | 2 +- mod/settings.php | 38 ++--- mod/uimport.php | 6 +- mod/videos.php | 4 +- mod/wall_attach.php | 2 +- mod/wall_upload.php | 4 +- mod/worker.php | 4 +- src/Api/Entity/Mastodon/Instance.php | 18 +-- src/Api/Entity/Mastodon/Stats.php | 6 +- src/Content/Feature.php | 32 ++--- src/Content/Nav.php | 22 +-- src/Content/OEmbed.php | 6 +- src/Content/Smilies.php | 2 +- src/Content/Text/BBCode.php | 8 +- src/Content/Text/HTML.php | 2 +- src/Content/Widget.php | 8 +- src/Core/ACL.php | 2 +- src/Core/Addon.php | 6 +- src/Core/Config.php | 15 -- src/Core/Search.php | 6 +- src/Core/Theme.php | 2 +- src/Core/Update.php | 12 +- src/Core/Worker.php | 54 +++---- src/Database/PostUpdate.php | 28 ++-- src/Model/APContact.php | 2 +- src/Model/Contact.php | 6 +- src/Model/GContact.php | 12 +- src/Model/GServer.php | 10 +- src/Model/Item.php | 14 +- src/Model/Photo.php | 2 +- src/Model/Profile.php | 6 +- src/Model/User.php | 22 +-- src/Module/Admin/Blocklist/Server.php | 4 +- src/Module/Admin/DBSync.php | 2 +- src/Module/Admin/Features.php | 2 +- src/Module/Admin/Federation.php | 2 +- src/Module/Admin/Logs/Settings.php | 8 +- src/Module/Admin/Logs/View.php | 4 +- src/Module/Admin/Site.php | 172 +++++++++++------------ src/Module/Admin/Summary.php | 20 +-- src/Module/Admin/Themes/Index.php | 2 +- src/Module/Admin/Tos.php | 6 +- src/Module/Admin/Users.php | 10 +- src/Module/Apps.php | 2 +- src/Module/Contact/Hovercard.php | 2 +- src/Module/Group.php | 2 +- src/Module/Inbox.php | 2 +- src/Module/Profile.php | 6 +- src/Module/Profile/Contacts.php | 2 +- src/Module/Register.php | 46 +++--- src/Module/Search/Index.php | 12 +- src/Module/Security/Login.php | 4 +- src/Module/Tos.php | 10 +- src/Network/FKOAuthDataStore.php | 2 +- src/Network/Probe.php | 4 +- src/Object/Image.php | 8 +- src/Object/Post.php | 4 +- src/Protocol/ActivityPub/Processor.php | 6 +- src/Protocol/ActivityPub/Transmitter.php | 12 +- src/Protocol/DFRN.php | 8 +- src/Protocol/Diaspora.php | 12 +- src/Protocol/OStatus.php | 8 +- src/Protocol/PortableContact.php | 6 +- src/Util/Crypto.php | 2 +- src/Util/Emailer.php | 2 +- src/Util/ExAuth.php | 4 +- src/Util/HTTPSignature.php | 2 +- src/Util/Network.php | 32 ++--- src/Util/Proxy.php | 2 +- src/Worker/CheckVersion.php | 2 +- src/Worker/Cron.php | 14 +- src/Worker/CronJobs.php | 10 +- src/Worker/DBClean.php | 36 ++--- src/Worker/DBUpdate.php | 2 +- src/Worker/Delivery.php | 4 +- src/Worker/Directory.php | 2 +- src/Worker/Expire.php | 2 +- src/Worker/Notifier.php | 6 +- src/Worker/OnePoll.php | 6 +- src/Worker/SearchDirectory.php | 2 +- src/Worker/UpdateGContacts.php | 2 +- src/Worker/UpdateServerDirectories.php | 4 +- update.php | 14 +- view/js/linkPreview.js | 2 +- view/theme/duepuntozero/config.php | 4 +- view/theme/duepuntozero/style.php | 2 +- view/theme/duepuntozero/theme.php | 2 +- view/theme/frio/config.php | 40 +++--- view/theme/frio/php/default.php | 8 +- view/theme/frio/php/standard.php | 4 +- view/theme/frio/style.php | 22 +-- view/theme/frio/theme.php | 4 +- view/theme/quattro/config.php | 8 +- view/theme/quattro/style.php | 8 +- view/theme/vier/config.php | 6 +- view/theme/vier/style.php | 2 +- view/theme/vier/theme.php | 8 +- 126 files changed, 581 insertions(+), 596 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index 7c5e01c41d..8de6e1a4cf 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -46,7 +46,7 @@ if (DI::mode()->isInstall()) { DI::config()->load(); -if (empty(Config::get('system', 'pidfile'))) { +if (empty(DI::config()->get('system', 'pidfile'))) { die(<<get('system', 'pidfile'); if (in_array("start", $_SERVER["argv"])) { $mode = "start"; @@ -158,7 +158,7 @@ Config::set('system', 'worker_daemon_mode', true); // Just to be sure that this script really runs endlessly set_time_limit(0); -$wait_interval = intval(Config::get('system', 'cron_interval', 5)) * 60; +$wait_interval = intval(DI::config()->get('system', 'cron_interval', 5)) * 60; $do_cron = true; $last_cron = 0; diff --git a/bin/worker.php b/bin/worker.php index 3510f9905d..bb71673955 100755 --- a/bin/worker.php +++ b/bin/worker.php @@ -46,7 +46,7 @@ if (!DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) { return; } -DI::baseUrl()->saveByURL(Config::get('system', 'url')); +DI::baseUrl()->saveByURL(DI::config()->get('system', 'url')); $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options); diff --git a/boot.php b/boot.php index 0835f7ffae..92be83ed0e 100644 --- a/boot.php +++ b/boot.php @@ -383,7 +383,7 @@ function is_site_admin() { $a = DI::app(); - $admin_email = Config::get('config', 'admin_email'); + $admin_email = DI::config()->get('config', 'admin_email'); $adminlist = explode(',', str_replace(' ', '', $admin_email)); @@ -446,7 +446,7 @@ function curPageURL() function get_temppath() { - $temppath = Config::get("system", "temppath"); + $temppath = DI::config()->get("system", "temppath"); if (($temppath != "") && System::isDirectoryUsable($temppath)) { // We have a temp path and it is usable @@ -520,7 +520,7 @@ function clear_cache($basepath = "", $path = "") return; } - $cachetime = (int) Config::get('system', 'itemcache_duration'); + $cachetime = (int) DI::config()->get('system', 'itemcache_duration'); if ($cachetime == 0) { $cachetime = 86400; } @@ -544,12 +544,12 @@ function clear_cache($basepath = "", $path = "") function get_itemcachepath() { // Checking, if the cache is deactivated - $cachetime = (int) Config::get('system', 'itemcache_duration'); + $cachetime = (int) DI::config()->get('system', 'itemcache_duration'); if ($cachetime < 0) { return ""; } - $itemcache = Config::get('system', 'itemcache'); + $itemcache = DI::config()->get('system', 'itemcache'); if (($itemcache != "") && System::isDirectoryUsable($itemcache)) { return BasePath::getRealPath($itemcache); } @@ -577,7 +577,7 @@ function get_itemcachepath() */ function get_spoolpath() { - $spoolpath = Config::get('system', 'spoolpath'); + $spoolpath = DI::config()->get('system', 'spoolpath'); if (($spoolpath != "") && System::isDirectoryUsable($spoolpath)) { // We have a spool path and it is usable return $spoolpath; diff --git a/doc/themes.md b/doc/themes.md index f50ea791da..94dc47da11 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -139,7 +139,7 @@ There you'll find somethink alike $colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset'); if (!$colorset) - $colorset = Config::get('duepuntozero', 'colorset'); + $colorset = DI::config()->get('duepuntozero', 'colorset'); if ($colorset) { if ($colorset == 'greenzero') DI::page()['htmlhead'] .= ''."\n"; diff --git a/include/api.php b/include/api.php index fdf7726e21..039275f20e 100644 --- a/include/api.php +++ b/include/api.php @@ -1096,7 +1096,7 @@ function api_statuses_update($type) if (!$parent) { // Check for throttling (maximum posts per day, week and month) - $throttle_day = Config::get('system', 'throttle_limit_day'); + $throttle_day = DI::config()->get('system', 'throttle_limit_day'); if ($throttle_day > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60); @@ -1110,7 +1110,7 @@ function api_statuses_update($type) } } - $throttle_week = Config::get('system', 'throttle_limit_week'); + $throttle_week = DI::config()->get('system', 'throttle_limit_week'); if ($throttle_week > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7); @@ -1124,7 +1124,7 @@ function api_statuses_update($type) } } - $throttle_month = Config::get('system', 'throttle_limit_month'); + $throttle_month = DI::config()->get('system', 'throttle_limit_month'); if ($throttle_month > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30); @@ -2739,7 +2739,7 @@ function api_get_entitities(&$text, $bbcode) if ($image) { // If image cache is activated, then use the following sizes: // thumb (150), small (340), medium (600) and large (1024) - if (!Config::get("system", "proxy_disabled")) { + if (!DI::config()->get("system", "proxy_disabled")) { $media_url = ProxyUtils::proxifyUrl($url); $sizes = []; @@ -3572,15 +3572,15 @@ api_register_func('api/friendships/incoming', 'api_friendships_incoming', true); */ function api_statusnet_config($type) { - $name = Config::get('config', 'sitename'); + $name = DI::config()->get('config', 'sitename'); $server = DI::baseUrl()->getHostname(); $logo = DI::baseUrl() . '/images/friendica-64.png'; - $email = Config::get('config', 'admin_email'); - $closed = intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 'true' : 'false'; - $private = Config::get('system', 'block_public') ? 'true' : 'false'; - $textlimit = (string) Config::get('config', 'api_import_size', Config::get('config', 'max_import_size', 200000)); - $ssl = Config::get('system', 'have_ssl') ? 'true' : 'false'; - $sslserver = Config::get('system', 'have_ssl') ? str_replace('http:', 'https:', DI::baseUrl()) : ''; + $email = DI::config()->get('config', 'admin_email'); + $closed = intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 'true' : 'false'; + $private = DI::config()->get('system', 'block_public') ? 'true' : 'false'; + $textlimit = (string) DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size', 200000)); + $ssl = DI::config()->get('system', 'have_ssl') ? 'true' : 'false'; + $sslserver = DI::config()->get('system', 'have_ssl') ? str_replace('http:', 'https:', DI::baseUrl()) : ''; $config = [ 'site' => ['name' => $name,'server' => $server, 'theme' => 'default', 'path' => '', @@ -4627,7 +4627,7 @@ function api_account_update_profile_image($type) // Update global directory in background $url = DI::baseUrl() . '/profile/' . DI::app()->user['nickname']; - if ($url && strlen(Config::get('system', 'directory'))) { + if ($url && strlen(DI::config()->get('system', 'directory'))) { Worker::add(PRIORITY_LOW, "Directory", $url); } @@ -4684,7 +4684,7 @@ function api_account_update_profile($type) Worker::add(PRIORITY_LOW, 'ProfileUpdate', $local_user); // Update global directory in background - if ($api_user['url'] && strlen(Config::get('system', 'directory'))) { + if ($api_user['url'] && strlen(DI::config()->get('system', 'directory'))) { Worker::add(PRIORITY_LOW, "Directory", $api_user['url']); } @@ -4792,7 +4792,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ throw new InternalServerErrorException("image size exceeds PHP config settings, file was rejected by server"); } // check against max upload size within Friendica instance - $maximagesize = Config::get('system', 'maximagesize'); + $maximagesize = DI::config()->get('system', 'maximagesize'); if ($maximagesize && ($filesize > $maximagesize)) { $formattedBytes = Strings::formatBytes($maximagesize); throw new InternalServerErrorException("image size exceeds Friendica config setting (uploaded size: $formattedBytes)"); @@ -4810,7 +4810,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ @unlink($src); // check max length of images on server - $max_length = Config::get('system', 'max_image_length'); + $max_length = DI::config()->get('system', 'max_image_length'); if (!$max_length) { $max_length = MAX_IMAGE_LENGTH; } @@ -6119,7 +6119,7 @@ function api_friendica_profile_show($type) // retrieve general information about profiles for user $multi_profiles = Feature::isEnabled(api_user(), 'multi_profiles'); - $directory = Config::get('system', 'directory'); + $directory = DI::config()->get('system', 'directory'); // get data of the specified profile id or all profiles of the user if not specified if ($profile_id != 0) { diff --git a/include/conversation.php b/include/conversation.php index e09f163efd..5e8018d723 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -850,7 +850,7 @@ function conversation_fetch_comments($thread_items, $pinned) { * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ function conversation_add_children(array $parents, $block_authors, $order, $uid) { - $max_comments = Config::get('system', 'max_comments', 100); + $max_comments = DI::config()->get('system', 'max_comments', 100); $params = ['order' => ['uid', 'commented' => true]]; diff --git a/include/enotify.php b/include/enotify.php index b4f5881403..8a21adbdf0 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -60,9 +60,9 @@ function notification($params) $product = FRIENDICA_PLATFORM; $siteurl = DI::baseUrl()->get(true); $thanks = $l10n->t('Thank You,'); - $sitename = Config::get('config', 'sitename'); - if (Config::get('config', 'admin_name')) { - $site_admin = $l10n->t('%1$s, %2$s Administrator', Config::get('config', 'admin_name'), $sitename); + $sitename = DI::config()->get('config', 'sitename'); + if (DI::config()->get('config', 'admin_name')) { + $site_admin = $l10n->t('%1$s, %2$s Administrator', DI::config()->get('config', 'admin_name'), $sitename); } else { $site_admin = $l10n->t('%s Administrator', $sitename); } @@ -587,7 +587,7 @@ function notification($params) // check whether sending post content in email notifications is allowed // always true for SYSTEM_EMAIL - $content_allowed = ((!Config::get('system', 'enotify_no_content')) || ($params['type'] == SYSTEM_EMAIL)); + $content_allowed = ((!DI::config()->get('system', 'enotify_no_content')) || ($params['type'] == SYSTEM_EMAIL)); // load the template for private message notifications $tpl = Renderer::getMarkupTemplate('email_notify_html.tpl'); diff --git a/include/items.php b/include/items.php index ef55acab14..5d10dd35d5 100644 --- a/include/items.php +++ b/include/items.php @@ -73,7 +73,7 @@ function add_page_info_data(array $data, $no_photos = false) $preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false)); // if the preview picture is larger than 500 pixels then show it in a larger mode // But only, if the picture isn't higher than large (To prevent huge posts) - if (!Config::get('system', 'always_show_preview') && ($data["images"][0]["width"] >= 500) + if (!DI::config()->get('system', 'always_show_preview') && ($data["images"][0]["width"] >= 500) && ($data["images"][0]["width"] >= $data["images"][0]["height"])) { $text .= " image='".$preview."'"; } else { diff --git a/mod/cal.php b/mod/cal.php index 1c14f9e770..d8140cf410 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -25,7 +25,7 @@ use Friendica\Util\Temporal; function cal_init(App $a) { - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } @@ -237,7 +237,7 @@ function cal_content(App $a) if (!empty($_GET['id'])) { $tpl = Renderer::getMarkupTemplate("event.tpl"); } else { -// if (Config::get('experimentals','new_calendar')==1){ +// if (DI::config()->get('experimentals','new_calendar')==1){ $tpl = Renderer::getMarkupTemplate("events_js.tpl"); // } else { // $tpl = Renderer::getMarkupTemplate("events.tpl"); diff --git a/mod/community.php b/mod/community.php index 975b601f9a..9d1fe0f7fb 100644 --- a/mod/community.php +++ b/mod/community.php @@ -21,12 +21,12 @@ function community_content(App $a, $update = 0) { $o = ''; - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { notice(DI::l10n()->t('Public access denied.') . EOL); return; } - $page_style = Config::get('system', 'community_page_style'); + $page_style = DI::config()->get('system', 'community_page_style'); if ($page_style == CP_NO_INTERNAL_COMMUNITY) { notice(DI::l10n()->t('Access denied.') . EOL); @@ -55,7 +55,7 @@ function community_content(App $a, $update = 0) if ($a->argc > 1) { $content = $a->argv[1]; } else { - if (!empty(Config::get('system', 'singleuser'))) { + if (!empty(DI::config()->get('system', 'singleuser'))) { // On single user systems only the global page does make sense $content = 'global'; } else { @@ -90,7 +90,7 @@ function community_content(App $a, $update = 0) if (!$update) { $tabs = []; - if ((local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(Config::get('system', 'singleuser'))) { + if ((local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(DI::config()->get('system', 'singleuser'))) { $tabs[] = [ 'label' => DI::l10n()->t('Local Community'), 'url' => 'community/local', @@ -156,7 +156,7 @@ function community_content(App $a, $update = 0) return $o; } - $maxpostperauthor = (int) Config::get('system', 'max_author_posts_community_page'); + $maxpostperauthor = (int) DI::config()->get('system', 'max_author_posts_community_page'); if (($maxpostperauthor != 0) && ($content == 'local')) { $count = 1; @@ -203,7 +203,7 @@ function community_content(App $a, $update = 0) return Renderer::replaceMacros($t, [ '$content' => $o, '$header' => '', - '$show_global_community_hint' => ($content == 'global') && Config::get('system', 'show_global_community_hint'), + '$show_global_community_hint' => ($content == 'global') && DI::config()->get('system', 'show_global_community_hint'), '$global_community_hint' => DI::l10n()->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.") ]); } diff --git a/mod/crepair.php b/mod/crepair.php index 70db308f17..57da284c81 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -117,7 +117,7 @@ function crepair_content(App $a) $returnaddr = "contact/$cid"; - $allow_remote_self = Config::get('system', 'allow_users_remote_self'); + $allow_remote_self = DI::config()->get('system', 'allow_users_remote_self'); // Disable remote self for everything except feeds. // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 1a262f7605..994c39cdd5 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -229,7 +229,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) return; } - if (strlen($leading_junk) && Config::get('system', 'debugging')) { + if (strlen($leading_junk) && DI::config()->get('system', 'debugging')) { // This might be more common. Mixed error text and some XML. // If we're configured for debugging, show the text. Proceed in either case. notice(DI::l10n()->t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 8c00ace723..a228f18a76 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -128,7 +128,7 @@ function dfrn_notify_post(App $a) { System::xmlExit(0, 'relationship dissolved'); } - $rino = Config::get('system', 'rino_encrypt'); + $rino = DI::config()->get('system', 'rino_encrypt'); $rino = intval($rino); if (strlen($key)) { @@ -343,7 +343,7 @@ function dfrn_notify_content(App $a) { $encrypted_id = bin2hex($encrypted_id); - $rino = Config::get('system', 'rino_encrypt'); + $rino = DI::config()->get('system', 'rino_encrypt'); $rino = intval($rino); Logger::log("Local rino version: ". $rino, Logger::DATA); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index bce7bf0cbf..74e2d89467 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -49,7 +49,7 @@ function dfrn_poll_init(App $a) $hidewall = false; if (($dfrn_id === '') && empty($_POST['dfrn_id'])) { - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { throw new \Friendica\Network\HTTPException\ForbiddenException(); } diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 76ddb09a5f..ca32820691 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -595,8 +595,8 @@ function dfrn_request_content(App $a) exit(); } else { // Normal web request. Display our user's introduction form. - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { - if (!Config::get('system', 'local_block')) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { + if (!DI::config()->get('system', 'local_block')) { notice(DI::l10n()->t('Public access denied.') . EOL); return; } diff --git a/mod/display.php b/mod/display.php index 35cac53d0b..56836beff1 100644 --- a/mod/display.php +++ b/mod/display.php @@ -30,7 +30,7 @@ function display_init(App $a) Objects::rawContent(); } - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { return; } @@ -164,7 +164,7 @@ function display_fetchauthor($a, $item) function display_content(App $a, $update = false, $update_uid = 0) { - if (Config::get('system','block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system','block_public') && !Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.')); } diff --git a/mod/follow.php b/mod/follow.php index 4f3acf5ef9..276a389e83 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -94,14 +94,14 @@ function follow_content(App $a) $protocol = Contact::getProtocol($ret['url'], $ret['network']); - if (($protocol == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) { + if (($protocol == Protocol::DIASPORA) && !DI::config()->get('system', 'diaspora_enabled')) { notice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added.")); $submit = ''; //$a->internalRedirect($_SESSION['return_path']); // NOTREACHED } - if (($protocol == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) { + if (($protocol == Protocol::OSTATUS) && DI::config()->get('system', 'ostatus_disabled')) { notice(DI::l10n()->t("OStatus support is disabled. Contact can't be added.")); $submit = ''; //$a->internalRedirect($_SESSION['return_path']); diff --git a/mod/item.php b/mod/item.php index 606c0ba580..3661dc81d1 100644 --- a/mod/item.php +++ b/mod/item.php @@ -315,7 +315,7 @@ function item_post(App $a) { // if using the API, we won't see pubmail_enable - figure out if it should be set if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) { - if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) { + if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) { $pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']); } } @@ -1060,7 +1060,7 @@ function handle_tag(&$body, &$inform, &$str_tags, $profile_uid, $tag, $network = function item_add_implicit_mentions(array $tags, array $thread_parent_contact, $thread_parent_id) { - if (Config::get('system', 'disable_implicit_mentions')) { + if (DI::config()->get('system', 'disable_implicit_mentions')) { // Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them) if (in_array($thread_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) { $contact = Term::TAG_CHARACTER[Term::MENTION] . '[url=' . $thread_parent_contact['url'] . ']' . $thread_parent_contact['nick'] . '[/url]'; diff --git a/mod/lostpass.php b/mod/lostpass.php index 3d397677bc..479b5c901b 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -38,7 +38,7 @@ function lostpass_post(App $a) info(DI::l10n()->t('Password reset request issued. Check your email.') . EOL); } - $sitename = Config::get('config', 'sitename'); + $sitename = DI::config()->get('config', 'sitename'); $resetlink = DI::baseUrl() . '/lostpass/' . $pwdreset_token; $preamble = Strings::deindent(DI::l10n()->t(' @@ -143,7 +143,7 @@ function lostpass_generate_password($user) info("Your password has been reset." . EOL); - $sitename = Config::get('config', 'sitename'); + $sitename = DI::config()->get('config', 'sitename'); $preamble = Strings::deindent(DI::l10n()->t(' Dear %1$s, Your password has been changed as requested. Please retain this diff --git a/mod/match.php b/mod/match.php index eab337d07f..0805af7c56 100644 --- a/mod/match.php +++ b/mod/match.php @@ -55,7 +55,7 @@ function match_content(App $a) $params['s'] = $tags; $params['n'] = 100; - if (strlen(Config::get('system', 'directory'))) { + if (strlen(DI::config()->get('system', 'directory'))) { $host = Search::getGlobalDirectory(); } else { $host = DI::baseUrl(); diff --git a/mod/network.php b/mod/network.php index b0154a80fd..9b8a0bc574 100644 --- a/mod/network.php +++ b/mod/network.php @@ -357,7 +357,7 @@ function networkFlatView(App $a, $update = 0) $o .= status_editor($a, $x); - if (!Config::get('theme', 'hide_eventlist')) { + if (!DI::config()->get('theme', 'hide_eventlist')) { $o .= Profile::getBirthdays(); $o .= Profile::getEventsReminderHTML(); } @@ -620,7 +620,7 @@ function networkThreadedView(App $a, $update, $parent) } } - if (!$gid && !$cid && !$update && !Config::get('theme', 'hide_eventlist')) { + if (!$gid && !$cid && !$update && !DI::config()->get('theme', 'hide_eventlist')) { $o .= Profile::getBirthdays(); $o .= Profile::getEventsReminderHTML(); } @@ -703,7 +703,7 @@ function networkThreadedView(App $a, $update, $parent) } else { // Load all unseen items $sql_extra4 = "`item`.`unseen`"; - if (Config::get("system", "like_no_comment")) { + if (DI::config()->get("system", "like_no_comment")) { $sql_extra4 .= " AND `item`.`gravity` IN (" . GRAVITY_PARENT . "," . GRAVITY_COMMENT . ")"; } if ($order === 'post') { diff --git a/mod/photos.php b/mod/photos.php index 2580719975..50e18db47d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -36,7 +36,7 @@ use Friendica\Util\XML; function photos_init(App $a) { - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { return; } @@ -696,7 +696,7 @@ function photos_post(App $a) Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', Logger::DEBUG); - $maximagesize = Config::get('system', 'maximagesize'); + $maximagesize = DI::config()->get('system', 'maximagesize'); if ($maximagesize && ($filesize > $maximagesize)) { notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL); @@ -732,7 +732,7 @@ function photos_post(App $a) $exif = $image->orient($src); @unlink($src); - $max_length = Config::get('system', 'max_image_length'); + $max_length = DI::config()->get('system', 'max_image_length'); if (!$max_length) { $max_length = MAX_IMAGE_LENGTH; } @@ -833,7 +833,7 @@ function photos_content(App $a) // photos/name/image/xxxxx/edit // photos/name/image/xxxxx/drop - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { notice(DI::l10n()->t('Public access denied.') . EOL); return; } @@ -1157,7 +1157,7 @@ function photos_content(App $a) * The query leads to a really intense used index. * By now we hide it if someone wants to. */ - if ($cmd === 'view' && !Config::get('system', 'no_count', false)) { + if ($cmd === 'view' && !DI::config()->get('system', 'no_count', false)) { $order_field = $_GET['order'] ?? ''; if ($order_field === 'posted') { diff --git a/mod/ping.php b/mod/ping.php index a00c5dfe35..614900ec19 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -186,7 +186,7 @@ function ping_init(App $a) ); $mail_count = count($mails); - if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::APPROVE && is_site_admin()) { + if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::APPROVE && is_site_admin()) { $regs = Friendica\Model\Register::getPending(); if (DBA::isResult($regs)) { diff --git a/mod/poco.php b/mod/poco.php index 595a4bd2ee..a100ceffbd 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -20,7 +20,7 @@ use Friendica\Util\XML; function poco_init(App $a) { $system_mode = false; - if (intval(Config::get('system', 'block_public')) || (Config::get('system', 'block_local_dir'))) { + if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) { throw new \Friendica\Network\HTTPException\ForbiddenException(); } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 47c058b6ea..e87e44e05b 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -123,7 +123,7 @@ function profile_photo_post(App $a) info(DI::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'))) { + if ($path && strlen(DI::config()->get('system', 'directory'))) { Worker::add(PRIORITY_LOW, "Directory", DI::baseUrl()->get() . '/' . $path); } @@ -145,7 +145,7 @@ function profile_photo_post(App $a) $filetype = Image::guessType($filename); } - $maximagesize = Config::get('system', 'maximagesize'); + $maximagesize = DI::config()->get('system', 'maximagesize'); if (($maximagesize) && ($filesize > $maximagesize)) { notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL); @@ -217,7 +217,7 @@ function profile_photo_content(App $a) // Update global directory in background $url = $_SESSION['my_url']; - if ($url && strlen(Config::get('system', 'directory'))) { + if ($url && strlen(DI::config()->get('system', 'directory'))) { Worker::add(PRIORITY_LOW, "Directory", $url); } @@ -271,7 +271,7 @@ function profile_photo_content(App $a) function profile_photo_crop_ui_head(Image $image) { - $max_length = Config::get('system', 'max_image_length'); + $max_length = DI::config()->get('system', 'max_image_length'); if (!$max_length) { $max_length = MAX_IMAGE_LENGTH; } diff --git a/mod/profiles.php b/mod/profiles.php index d979048a04..8b1cc5a30d 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -479,7 +479,7 @@ function profiles_post(App $a) { // Update global directory in background $url = $_SESSION['my_url']; - if ($url && strlen(Config::get('system', 'directory'))) { + if ($url && strlen(DI::config()->get('system', 'directory'))) { Worker::add(PRIORITY_LOW, "Directory", $url); } diff --git a/mod/profperm.php b/mod/profperm.php index 2e8803fde3..33c958cae7 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -42,7 +42,7 @@ function profperm_content(App $a) { $switchtotext = DI::pConfig()->get(local_user(),'system','groupedit_image_limit'); if (is_null($switchtotext)) { - $switchtotext = Config::get('system','groupedit_image_limit', 400); + $switchtotext = DI::config()->get('system','groupedit_image_limit', 400); } if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index d63a05d746..cdf6b8ee4c 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -16,7 +16,7 @@ function post_var($name) { function pubsubhubbub_init(App $a) { // PuSH subscription must be considered "public" so just block it // if public access isn't enabled. - if (Config::get('system', 'block_public')) { + if (DI::config()->get('system', 'block_public')) { throw new \Friendica\Network\HTTPException\ForbiddenException(); } diff --git a/mod/regmod.php b/mod/regmod.php index 2cfb576834..a7be314449 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -30,7 +30,7 @@ function user_allow($hash) $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid'], 'is-default' => true]); - if (DBA::isResult($profile) && $profile['net-publish'] && Config::get('system', 'directory')) { + if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) { $url = DI::baseUrl() . '/profile/' . $user['nickname']; Worker::add(PRIORITY_LOW, "Directory", $url); } @@ -40,7 +40,7 @@ function user_allow($hash) $res = User::sendRegisterOpenEmail( $l10n, $user, - Config::get('config', 'sitename'), + DI::config()->get('config', 'sitename'), DI::baseUrl()->get(), ($register['password'] ?? '') ?: 'Sent in a previous email' ); @@ -78,7 +78,7 @@ function regmod_content(App $a) { if (!local_user()) { info(DI::l10n()->t('Please login.') . EOL); - return Login::form(DI::args()->getQueryString(), intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1); + return Login::form(DI::args()->getQueryString(), intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1); } if (!is_site_admin() || !empty($_SESSION['submanage'])) { diff --git a/mod/removeme.php b/mod/removeme.php index 0e90bc197e..8f427f3d58 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -35,7 +35,7 @@ function removeme_post(App $a) // send notification to admins so that they can clean um the backups // send email to admins - $admin_mails = explode(",", str_replace(" ", "", Config::get('config', 'admin_email'))); + $admin_mails = explode(",", str_replace(" ", "", DI::config()->get('config', 'admin_email'))); foreach ($admin_mails as $mail) { $admin = DBA::selectFirst('user', ['uid', 'language', 'email', 'username'], ['email' => $mail]); if (!DBA::isResult($admin)) { diff --git a/mod/settings.php b/mod/settings.php index dbe58b0875..85fc6e1b80 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -250,9 +250,9 @@ function settings_post(App $a) $mail_pubmail = $_POST['mail_pubmail'] ?? ''; if ( - !Config::get('system', 'dfrn_only') + !DI::config()->get('system', 'dfrn_only') && function_exists('imap_open') - && !Config::get('system', 'imap_disabled') + && !DI::config()->get('system', 'imap_disabled') ) { $failed = false; $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", @@ -541,8 +541,8 @@ function settings_post(App $a) $err .= DI::l10n()->t('Invalid email.'); } // ensure new email is not the admin mail - if (Config::get('config', 'admin_email')) { - $adminlist = explode(",", str_replace(" ", "", strtolower(Config::get('config', 'admin_email')))); + if (DI::config()->get('config', 'admin_email')) { + $adminlist = explode(",", str_replace(" ", "", strtolower(DI::config()->get('config', 'admin_email')))); if (in_array(strtolower($email), $adminlist)) { $err .= DI::l10n()->t('Cannot change to that email.'); $email = $a->user['email']; @@ -625,7 +625,7 @@ function settings_post(App $a) if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) { // Update global directory in background $url = $_SESSION['my_url']; - if ($url && strlen(Config::get('system', 'directory'))) { + if ($url && strlen(DI::config()->get('system', 'directory'))) { Worker::add(PRIORITY_LOW, "Directory", $url); } } @@ -791,15 +791,15 @@ function settings_content(App $a) Hook::callAll('connector_settings', $settings_connectors); if (is_site_admin()) { - $diasp_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('Diaspora'), ((Config::get('system', 'diaspora_enabled')) ? DI::l10n()->t('enabled') : DI::l10n()->t('disabled'))); - $ostat_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t("GNU Social \x28OStatus\x29"), ((Config::get('system', 'ostatus_disabled')) ? DI::l10n()->t('disabled') : DI::l10n()->t('enabled'))); + $diasp_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('Diaspora'), ((DI::config()->get('system', 'diaspora_enabled')) ? DI::l10n()->t('enabled') : DI::l10n()->t('disabled'))); + $ostat_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t("GNU Social \x28OStatus\x29"), ((DI::config()->get('system', 'ostatus_disabled')) ? DI::l10n()->t('disabled') : DI::l10n()->t('enabled'))); } else { $diasp_enabled = ""; $ostat_enabled = ""; } - $mail_disabled = ((function_exists('imap_open') && (!Config::get('system', 'imap_disabled'))) ? 0 : 1); - if (Config::get('system', 'dfrn_only')) { + $mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1); + if (DI::config()->get('system', 'dfrn_only')) { $mail_disabled = 1; } if (!$mail_disabled) { @@ -827,7 +827,7 @@ function settings_content(App $a) $ssl_options = ['TLS' => 'TLS', 'SSL' => 'SSL']; - if (Config::get('system', 'insecure_imap')) { + if (DI::config()->get('system', 'insecure_imap')) { $ssl_options['notls'] = DI::l10n()->t('None'); } @@ -877,11 +877,11 @@ function settings_content(App $a) * DISPLAY SETTINGS */ if (($a->argc > 1) && ($a->argv[1] === 'display')) { - $default_theme = Config::get('system', 'theme'); + $default_theme = DI::config()->get('system', 'theme'); if (!$default_theme) { $default_theme = 'default'; } - $default_mobile_theme = Config::get('system', 'mobile-theme'); + $default_mobile_theme = DI::config()->get('system', 'mobile-theme'); if (!$default_mobile_theme) { $default_mobile_theme = 'none'; } @@ -894,7 +894,7 @@ function settings_content(App $a) $is_experimental = file_exists('view/theme/' . $theme . '/experimental'); $is_unsupported = file_exists('view/theme/' . $theme . '/unsupported'); $is_mobile = file_exists('view/theme/' . $theme . '/mobile'); - if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || is_null(Config::get('experimentals', 'exp_themes'))))) { + if (!$is_experimental || ($is_experimental && (DI::config()->get('experimentals', 'exp_themes')==1 || is_null(DI::config()->get('experimentals', 'exp_themes'))))) { $theme_name = ucfirst($theme); if ($is_unsupported) { $theme_name = DI::l10n()->t('%s - (Unsupported)', $theme_name); @@ -1068,7 +1068,7 @@ function settings_content(App $a) ]); - $noid = Config::get('system', 'no_openid'); + $noid = DI::config()->get('system', 'no_openid'); if ($noid) { $openid_field = false; @@ -1077,7 +1077,7 @@ function settings_content(App $a) } $opt_tpl = Renderer::getMarkupTemplate("field_yesno.tpl"); - if (Config::get('system', 'publish_all')) { + if (DI::config()->get('system', 'publish_all')) { $profile_in_dir = ''; } else { $profile_in_dir = Renderer::replaceMacros($opt_tpl, [ @@ -1085,9 +1085,9 @@ function settings_content(App $a) ]); } - if (strlen(Config::get('system', 'directory'))) { + if (strlen(DI::config()->get('system', 'directory'))) { $profile_in_net_dir = Renderer::replaceMacros($opt_tpl, [ - '$field' => ['profile_in_netdirectory', DI::l10n()->t('Publish your default profile in the global social directory?'), $profile['net-publish'], DI::l10n()->t('Your profile will be published in the global friendica directories (e.g. %s). Your profile will be visible in public.', Config::get('system', 'directory'), Config::get('system', 'directory')) . " " . DI::l10n()->t("This setting also determines whether Friendica will inform search engines that your profile should be indexed or not. Third-party search engines may or may not respect this setting."), [DI::l10n()->t('No'), DI::l10n()->t('Yes')]] + '$field' => ['profile_in_netdirectory', DI::l10n()->t('Publish your default profile in the global social directory?'), $profile['net-publish'], DI::l10n()->t('Your profile will be published in the global friendica directories (e.g. %s). Your profile will be visible in public.', DI::config()->get('system', 'directory'), DI::config()->get('system', 'directory')) . " " . DI::l10n()->t("This setting also determines whether Friendica will inform search engines that your profile should be indexed or not. Third-party search engines may or may not respect this setting."), [DI::l10n()->t('No'), DI::l10n()->t('Yes')]] ]); } else { $profile_in_net_dir = ''; @@ -1181,7 +1181,7 @@ function settings_content(App $a) '$password2'=> ['confirm', DI::l10n()->t('Confirm:'), '', DI::l10n()->t('Leave password fields blank unless changing')], '$password3'=> ['opassword', DI::l10n()->t('Current Password:'), '', DI::l10n()->t('Your current password to confirm the changes')], '$password4'=> ['mpassword', DI::l10n()->t('Password:'), '', DI::l10n()->t('Your current password to confirm the changes')], - '$oid_enable' => (!Config::get('system', 'no_openid')), + '$oid_enable' => (!DI::config()->get('system', 'no_openid')), '$openid' => $openid_field, '$delete_openid' => ['delete_openid', DI::l10n()->t('Delete OpenID URL'), false, ''], @@ -1256,7 +1256,7 @@ function settings_content(App $a) '$importcontact' => DI::l10n()->t('Import Contacts'), '$importcontact_text' => DI::l10n()->t('Upload a CSV file that contains the handle of your followed accounts in the first column you exported from the old account.'), '$importcontact_button' => DI::l10n()->t('Upload File'), - '$importcontact_maxsize' => Config::get('system', 'max_csv_file_size', 30720), + '$importcontact_maxsize' => DI::config()->get('system', 'max_csv_file_size', 30720), '$relocate' => DI::l10n()->t('Relocate'), '$relocate_text' => DI::l10n()->t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."), '$relocate_button' => DI::l10n()->t("Resend relocate message to contacts"), diff --git a/mod/uimport.php b/mod/uimport.php index 03bec61867..64eff338d2 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -13,7 +13,7 @@ use Friendica\DI; function uimport_post(App $a) { - if ((Config::get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) { + if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) { notice(DI::l10n()->t('Permission denied.') . EOL); return; } @@ -26,12 +26,12 @@ function uimport_post(App $a) function uimport_content(App $a) { - if ((Config::get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) { + if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) { notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.') . EOL); return; } - $max_dailies = intval(Config::get('system', 'max_daily_registrations')); + $max_dailies = intval(DI::config()->get('system', 'max_daily_registrations')); if ($max_dailies) { $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); if ($r && $r[0]['total'] >= $max_dailies) { diff --git a/mod/videos.php b/mod/videos.php index 342e988f3a..c14f4cfb7c 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -20,7 +20,7 @@ use Friendica\Util\Security; function videos_init(App $a) { - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { return; } @@ -108,7 +108,7 @@ function videos_content(App $a) // videos/name/video/xxxxx/edit - if (Config::get('system', 'block_public') && !Session::isAuthenticated()) { + if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { notice(DI::l10n()->t('Public access denied.') . EOL); return; } diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 749d09dc06..8fd274a017 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -78,7 +78,7 @@ function wall_attach_post(App $a) { $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); - $maxfilesize = Config::get('system','maxfilesize'); + $maxfilesize = DI::config()->get('system','maxfilesize'); /* Found html code written in text field of form, * when trying to upload a file with filesize diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 2f92b2f03c..eed3550693 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -179,7 +179,7 @@ function wall_upload_post(App $a, $desktopmode = true) Logger::log("File upload src: " . $src . " - filename: " . $filename . " - size: " . $filesize . " - type: " . $filetype, Logger::DEBUG); - $maximagesize = Config::get('system', 'maximagesize'); + $maximagesize = DI::config()->get('system', 'maximagesize'); if (($maximagesize) && ($filesize > $maximagesize)) { $msg = DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)); @@ -209,7 +209,7 @@ function wall_upload_post(App $a, $desktopmode = true) $Image->orient($src); @unlink($src); - $max_length = Config::get('system', 'max_image_length'); + $max_length = DI::config()->get('system', 'max_image_length'); if (!$max_length) { $max_length = MAX_IMAGE_LENGTH; } diff --git a/mod/worker.php b/mod/worker.php index 6b2b59c87f..d14f642bf9 100644 --- a/mod/worker.php +++ b/mod/worker.php @@ -13,7 +13,7 @@ use Friendica\Util\DateTimeFormat; function worker_init() { - if (!Config::get("system", "frontend_worker")) { + if (!DI::config()->get("system", "frontend_worker")) { return; } @@ -31,7 +31,7 @@ function worker_init() $workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'worker.php'"); - if ($workers[0]["processes"] > Config::get("system", "worker_queues", 4)) { + if ($workers[0]["processes"] > DI::config()->get("system", "worker_queues", 4)) { return; } diff --git a/src/Api/Entity/Mastodon/Instance.php b/src/Api/Entity/Mastodon/Instance.php index c3828e2b87..453abd1c7c 100644 --- a/src/Api/Entity/Mastodon/Instance.php +++ b/src/Api/Entity/Mastodon/Instance.php @@ -52,27 +52,27 @@ class Instance extends BaseEntity */ public static function get() { - $register_policy = intval(Config::get('config', 'register_policy')); + $register_policy = intval(DI::config()->get('config', 'register_policy')); $baseUrl = DI::baseUrl(); $instance = new Instance(); $instance->uri = $baseUrl->get(); - $instance->title = Config::get('config', 'sitename'); - $instance->description = Config::get('config', 'info'); - $instance->email = Config::get('config', 'admin_email'); + $instance->title = DI::config()->get('config', 'sitename'); + $instance->description = DI::config()->get('config', 'info'); + $instance->email = DI::config()->get('config', 'admin_email'); $instance->version = FRIENDICA_VERSION; $instance->urls = []; // Not supported $instance->stats = Stats::get(); - $instance->thumbnail = $baseUrl->get() . (Config::get('system', 'shortcut_icon') ?? 'images/friendica-32.png'); - $instance->languages = [Config::get('system', 'language')]; - $instance->max_toot_chars = (int)Config::get('config', 'api_import_size', Config::get('config', 'max_import_size')); + $instance->thumbnail = $baseUrl->get() . (DI::config()->get('system', 'shortcut_icon') ?? 'images/friendica-32.png'); + $instance->languages = [DI::config()->get('system', 'language')]; + $instance->max_toot_chars = (int)DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size')); $instance->registrations = ($register_policy != Register::CLOSED); $instance->approval_required = ($register_policy == Register::APPROVE); $instance->contact_account = []; - if (!empty(Config::get('config', 'admin_email'))) { - $adminList = explode(',', str_replace(' ', '', Config::get('config', 'admin_email'))); + if (!empty(DI::config()->get('config', 'admin_email'))) { + $adminList = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email'))); $administrator = User::getByEmail($adminList[0], ['nickname']); if (!empty($administrator)) { $adminContact = DBA::selectFirst('contact', ['id'], ['nick' => $administrator['nickname'], 'self' => true]); diff --git a/src/Api/Entity/Mastodon/Stats.php b/src/Api/Entity/Mastodon/Stats.php index 219587830a..c1661d5921 100644 --- a/src/Api/Entity/Mastodon/Stats.php +++ b/src/Api/Entity/Mastodon/Stats.php @@ -29,9 +29,9 @@ class Stats extends BaseEntity */ public static function get() { $stats = new Stats(); - if (!empty(Config::get('system', 'nodeinfo'))) { - $stats->user_count = intval(Config::get('nodeinfo', 'total_users')); - $stats->status_count = Config::get('nodeinfo', 'local_posts') + Config::get('nodeinfo', 'local_comments'); + if (!empty(DI::config()->get('system', 'nodeinfo'))) { + $stats->user_count = intval(DI::config()->get('nodeinfo', 'total_users')); + $stats->status_count = DI::config()->get('nodeinfo', 'local_posts') + DI::config()->get('nodeinfo', 'local_comments'); $stats->domain_count = DBA::count('gserver', ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]); } return $stats; diff --git a/src/Content/Feature.php b/src/Content/Feature.php index ef8a3d9a2d..4d89170d61 100644 --- a/src/Content/Feature.php +++ b/src/Content/Feature.php @@ -21,14 +21,14 @@ class Feature */ public static function isEnabled(int $uid, $feature) { - $x = Config::get('feature_lock', $feature, false); + $x = DI::config()->get('feature_lock', $feature, false); if ($x === false) { $x = DI::pConfig()->get($uid, 'feature', $feature, false); } if ($x === false) { - $x = Config::get('feature', $feature, false); + $x = DI::config()->get('feature', $feature, false); } if ($x === false) { @@ -80,45 +80,45 @@ class Feature 'general' => [ DI::l10n()->t('General Features'), //array('expire', DI::l10n()->t('Content Expiration'), DI::l10n()->t('Remove old posts/comments after a period of time')), - ['multi_profiles', DI::l10n()->t('Multiple Profiles'), DI::l10n()->t('Ability to create multiple profiles'), false, Config::get('feature_lock', 'multi_profiles', false)], - ['photo_location', DI::l10n()->t('Photo Location'), DI::l10n()->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, Config::get('feature_lock', 'photo_location', false)], - ['export_calendar', DI::l10n()->t('Export Public Calendar'), DI::l10n()->t('Ability for visitors to download the public calendar'), false, Config::get('feature_lock', 'export_calendar', false)], - ['trending_tags', DI::l10n()->t('Trending Tags'), DI::l10n()->t('Show a community page widget with a list of the most popular tags in recent public posts.'), false, Config::get('feature_lock', 'trending_tags', false)], + ['multi_profiles', DI::l10n()->t('Multiple Profiles'), DI::l10n()->t('Ability to create multiple profiles'), false, DI::config()->get('feature_lock', 'multi_profiles', false)], + ['photo_location', DI::l10n()->t('Photo Location'), DI::l10n()->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, DI::config()->get('feature_lock', 'photo_location', false)], + ['export_calendar', DI::l10n()->t('Export Public Calendar'), DI::l10n()->t('Ability for visitors to download the public calendar'), false, DI::config()->get('feature_lock', 'export_calendar', false)], + ['trending_tags', DI::l10n()->t('Trending Tags'), DI::l10n()->t('Show a community page widget with a list of the most popular tags in recent public posts.'), false, DI::config()->get('feature_lock', 'trending_tags', false)], ], // Post composition 'composition' => [ DI::l10n()->t('Post Composition Features'), - ['aclautomention', DI::l10n()->t('Auto-mention Forums'), DI::l10n()->t('Add/remove mention when a forum page is selected/deselected in ACL window.'), false, Config::get('feature_lock', 'aclautomention', false)], - ['explicit_mentions', DI::l10n()->t('Explicit Mentions'), DI::l10n()->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, Config::get('feature_lock', 'explicit_mentions', false)], + ['aclautomention', DI::l10n()->t('Auto-mention Forums'), DI::l10n()->t('Add/remove mention when a forum page is selected/deselected in ACL window.'), false, DI::config()->get('feature_lock', 'aclautomention', false)], + ['explicit_mentions', DI::l10n()->t('Explicit Mentions'), DI::l10n()->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, DI::config()->get('feature_lock', 'explicit_mentions', false)], ], // Network sidebar widgets 'widgets' => [ DI::l10n()->t('Network Sidebar'), - ['archives', DI::l10n()->t('Archives'), DI::l10n()->t('Ability to select posts by date ranges'), false, Config::get('feature_lock', 'archives', false)], - ['networks', DI::l10n()->t('Protocol Filter'), DI::l10n()->t('Enable widget to display Network posts only from selected protocols'), false, Config::get('feature_lock', 'networks', false)], + ['archives', DI::l10n()->t('Archives'), DI::l10n()->t('Ability to select posts by date ranges'), false, DI::config()->get('feature_lock', 'archives', false)], + ['networks', DI::l10n()->t('Protocol Filter'), DI::l10n()->t('Enable widget to display Network posts only from selected protocols'), false, DI::config()->get('feature_lock', 'networks', false)], ], // Network tabs 'net_tabs' => [ DI::l10n()->t('Network Tabs'), - ['new_tab', DI::l10n()->t('Network New Tab'), DI::l10n()->t("Enable tab to display only new Network posts \x28from the last 12 hours\x29"), false, Config::get('feature_lock', 'new_tab', false)], - ['link_tab', DI::l10n()->t('Network Shared Links Tab'), DI::l10n()->t('Enable tab to display only Network posts with links in them'), false, Config::get('feature_lock', 'link_tab', false)], + ['new_tab', DI::l10n()->t('Network New Tab'), DI::l10n()->t("Enable tab to display only new Network posts \x28from the last 12 hours\x29"), false, DI::config()->get('feature_lock', 'new_tab', false)], + ['link_tab', DI::l10n()->t('Network Shared Links Tab'), DI::l10n()->t('Enable tab to display only Network posts with links in them'), false, DI::config()->get('feature_lock', 'link_tab', false)], ], // Item tools 'tools' => [ DI::l10n()->t('Post/Comment Tools'), - ['categories', DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, Config::get('feature_lock', 'categories', false)], + ['categories', DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', 'categories', false)], ], // Advanced Profile Settings 'advanced_profile' => [ DI::l10n()->t('Advanced Profile Settings'), - ['forumlist_profile', DI::l10n()->t('List Forums'), DI::l10n()->t('Show visitors public community forums at the Advanced Profile Page'), false, Config::get('feature_lock', 'forumlist_profile', false)], - ['tagadelic', DI::l10n()->t('Tag Cloud'), DI::l10n()->t('Provide a personal tag cloud on your profile page'), false, Config::get('feature_lock', 'tagadelic', false)], - ['profile_membersince', DI::l10n()->t('Display Membership Date'), DI::l10n()->t('Display membership date in profile'), false, Config::get('feature_lock', 'profile_membersince', false)], + ['forumlist_profile', DI::l10n()->t('List Forums'), DI::l10n()->t('Show visitors public community forums at the Advanced Profile Page'), false, DI::config()->get('feature_lock', 'forumlist_profile', false)], + ['tagadelic', DI::l10n()->t('Tag Cloud'), DI::l10n()->t('Provide a personal tag cloud on your profile page'), false, DI::config()->get('feature_lock', 'tagadelic', false)], + ['profile_membersince', DI::l10n()->t('Display Membership Date'), DI::l10n()->t('Display membership date in profile'), false, DI::config()->get('feature_lock', 'profile_membersince', false)], ], ]; diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 041d07246b..64e4c79c4d 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -105,7 +105,7 @@ class Nav self::$app_menu = []; //Don't populate apps_menu if apps are private - $privateapps = Config::get('config', 'private_addons', false); + $privateapps = DI::config()->get('config', 'private_addons', false); if (local_user() || !$privateapps) { $arr = ['app_menu' => self::$app_menu]; @@ -180,13 +180,13 @@ class Nav $nav['home'] = [$homelink, DI::l10n()->t('Home'), '', DI::l10n()->t('Home Page')]; } - if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !Session::isAuthenticated()) { + if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !Session::isAuthenticated()) { $nav['register'] = ['register', DI::l10n()->t('Register'), '', DI::l10n()->t('Create an account')]; } $help_url = 'help'; - if (!Config::get('system', 'hide_help')) { + if (!DI::config()->get('system', 'hide_help')) { $nav['help'] = [$help_url, DI::l10n()->t('Help'), '', DI::l10n()->t('Help and documentation')]; } @@ -194,7 +194,7 @@ class Nav $nav['apps'] = ['apps', DI::l10n()->t('Apps'), '', DI::l10n()->t('Addon applications, utilities, games')]; } - if (local_user() || !Config::get('system', 'local_search')) { + if (local_user() || !DI::config()->get('system', 'local_search')) { $nav['search'] = ['search', DI::l10n()->t('Search'), '', DI::l10n()->t('Search site content')]; $nav['searchoption'] = [ @@ -203,22 +203,22 @@ class Nav DI::l10n()->t('Contacts') ]; - if (Config::get('system', 'poco_local_search')) { + if (DI::config()->get('system', 'poco_local_search')) { $nav['searchoption'][] = DI::l10n()->t('Forums'); } } $gdirpath = 'directory'; - if (strlen(Config::get('system', 'singleuser'))) { - $gdir = Config::get('system', 'directory'); + if (strlen(DI::config()->get('system', 'singleuser'))) { + $gdir = DI::config()->get('system', 'directory'); if (strlen($gdir)) { $gdirpath = Profile::zrl($gdir, true); } } - if ((local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) && - !(Config::get('system', 'community_page_style') == CP_NO_INTERNAL_COMMUNITY)) { + if ((local_user() || DI::config()->get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) && + !(DI::config()->get('system', 'community_page_style') == CP_NO_INTERNAL_COMMUNITY)) { $nav['community'] = ['community', DI::l10n()->t('Community'), '', DI::l10n()->t('Conversations on this and other servers')]; } @@ -230,7 +230,7 @@ class Nav $nav['about'] = ['friendica', DI::l10n()->t('Information'), '', DI::l10n()->t('Information about this friendica instance')]; - if (Config::get('system', 'tosdisplay')) { + if (DI::config()->get('system', 'tosdisplay')) { $nav['tos'] = ['tos', DI::l10n()->t('Terms of Service'), '', DI::l10n()->t('Terms of Service of this Friendica instance')]; } @@ -274,7 +274,7 @@ class Nav $nav['navigation'] = ['navigation/', DI::l10n()->t('Navigation'), '', DI::l10n()->t('Site map')]; // Provide a banner/logo/whatever - $banner = Config::get('system', 'banner'); + $banner = DI::config()->get('system', 'banner'); if (is_null($banner)) { $banner = 'logoFriendica'; } diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 8865e3c8c4..a92898b3c0 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -248,7 +248,7 @@ class OEmbed public static function BBCode2HTML($text) { - $stopoembed = Config::get("system", "no_oembed"); + $stopoembed = DI::config()->get("system", "no_oembed"); if ($stopoembed == true) { return preg_replace("/\[embed\](.+?)\[\/embed\]/is", "" . DI::l10n()->t('Embedding disabled') . " : $1", $text); } @@ -302,7 +302,7 @@ class OEmbed */ public static function isAllowedURL($url) { - if (!Config::get('system', 'no_oembed_rich_content')) { + if (!DI::config()->get('system', 'no_oembed_rich_content')) { return true; } @@ -311,7 +311,7 @@ class OEmbed return false; } - $str_allowed = Config::get('system', 'allowed_oembed', ''); + $str_allowed = DI::config()->get('system', 'allowed_oembed', ''); if (empty($str_allowed)) { return false; } diff --git a/src/Content/Smilies.php b/src/Content/Smilies.php index 1dd40e1631..5e87fd86cc 100644 --- a/src/Content/Smilies.php +++ b/src/Content/Smilies.php @@ -207,7 +207,7 @@ class Smilies */ public static function replaceFromArray($text, array $smilies, $no_images = false) { - if (intval(Config::get('system', 'no_smilies')) + if (intval(DI::config()->get('system', 'no_smilies')) || (local_user() && intval(DI::pConfig()->get(local_user(), 'system', 'no_smilies'))) ) { return $text; diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 11e6ee2115..1bcd7b09a7 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -496,7 +496,7 @@ class BBCode */ public static function limitBodySize($body) { - $maxlen = Config::get('config', 'max_import_size', 0); + $maxlen = DI::config()->get('config', 'max_import_size', 0); // If the length of the body, including the embedded images, is smaller // than the maximum, then don't waste time looking for the images @@ -598,7 +598,7 @@ class BBCode $data['title'] = null; } - if (((strpos($data['text'], "[img=") !== false) || (strpos($data['text'], "[img]") !== false) || Config::get('system', 'always_show_preview')) && !empty($data['image'])) { + if (((strpos($data['text'], "[img=") !== false) || (strpos($data['text'], "[img]") !== false) || DI::config()->get('system', 'always_show_preview')) && !empty($data['image'])) { $data['preview'] = $data['image']; $data['image'] = ''; } @@ -1345,7 +1345,7 @@ class BBCode $text = str_replace($search, $replace, $text); // removing multiplicated newlines - if (Config::get('system', 'remove_multiplicated_lines')) { + if (DI::config()->get('system', 'remove_multiplicated_lines')) { $search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n", "\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"]; $replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]", @@ -1835,7 +1835,7 @@ class BBCode // sanitize href attributes (only whitelisted protocols URLs) // default value for backward compatibility - $allowed_link_protocols = Config::get('system', 'allowed_link_protocols', []); + $allowed_link_protocols = DI::config()->get('system', 'allowed_link_protocols', []); // Always allowed protocol even if config isn't set or not including it $allowed_link_protocols[] = '//'; diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index 8116fa6378..38814e0ca1 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -912,7 +912,7 @@ class HTML 'contacts' => DI::l10n()->t('Contacts') ]; - if (Config::get('system', 'poco_local_search')) { + if (DI::config()->get('system', 'poco_local_search')) { $values['$searchoption']['forums'] = DI::l10n()->t('Forums'); } } diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 55277432b6..1aa26fdd40 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -46,9 +46,9 @@ class Widget */ public static function findPeople() { - $global_dir = Config::get('system', 'directory'); + $global_dir = DI::config()->get('system', 'directory'); - if (Config::get('system', 'invitation_only')) { + if (DI::config()->get('system', 'invitation_only')) { $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining')); if ($x || is_site_admin()) { DI::page()['aside'] .= '