]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/Site.php
Use rawContent for Special Options to avoid a protected options() method
[friendica.git] / src / Module / Admin / Site.php
index 0ce2724447c259b1c5950eb6959b3029934f7de5..2bac3d79edf76532c9b97ce6def3fc55f833bcd1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,6 +24,7 @@ namespace Friendica\Module\Admin;
 use Friendica\App;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
+use Friendica\Core\System;
 use Friendica\Core\Theme;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -42,7 +43,7 @@ require_once __DIR__ . '/../../../boot.php';
 
 class Site extends BaseAdmin
 {
-       public static function post(array $parameters = [])
+       protected function post(array $request = [])
        {
                self::checkAdminAccess();
 
@@ -127,19 +128,19 @@ class Site extends BaseAdmin
                }
                // end relocate
 
-               $sitename         = (!empty($_POST['sitename'])         ? Strings::escapeTags(trim($_POST['sitename']))      : '');
-               $sender_email     = (!empty($_POST['sender_email'])     ? Strings::escapeTags(trim($_POST['sender_email']))  : '');
+               $sitename         = (!empty($_POST['sitename'])         ? trim($_POST['sitename'])      : '');
+               $sender_email     = (!empty($_POST['sender_email'])     ? trim($_POST['sender_email'])  : '');
                $banner           = (!empty($_POST['banner'])           ? trim($_POST['banner'])                             : false);
                $email_banner     = (!empty($_POST['email_banner'])     ? trim($_POST['email_banner'])                       : false);
-               $shortcut_icon    = (!empty($_POST['shortcut_icon'])    ? Strings::escapeTags(trim($_POST['shortcut_icon'])) : '');
-               $touch_icon       = (!empty($_POST['touch_icon'])       ? Strings::escapeTags(trim($_POST['touch_icon']))    : '');
+               $shortcut_icon    = (!empty($_POST['shortcut_icon'])    ? trim($_POST['shortcut_icon']) : '');
+               $touch_icon       = (!empty($_POST['touch_icon'])       ? trim($_POST['touch_icon'])    : '');
                $additional_info  = (!empty($_POST['additional_info'])  ? trim($_POST['additional_info'])                    : '');
-               $language         = (!empty($_POST['language'])         ? Strings::escapeTags(trim($_POST['language']))      : '');
-               $theme            = (!empty($_POST['theme'])            ? Strings::escapeTags(trim($_POST['theme']))         : '');
-               $theme_mobile     = (!empty($_POST['theme_mobile'])     ? Strings::escapeTags(trim($_POST['theme_mobile']))  : '');
+               $language         = (!empty($_POST['language'])         ? trim($_POST['language'])      : '');
+               $theme            = (!empty($_POST['theme'])            ? trim($_POST['theme'])         : '');
+               $theme_mobile     = (!empty($_POST['theme_mobile'])     ? trim($_POST['theme_mobile'])  : '');
                $maximagesize     = (!empty($_POST['maximagesize'])     ? intval(trim($_POST['maximagesize']))               : 0);
-               $maximagelength   = (!empty($_POST['maximagelength'])   ? intval(trim($_POST['maximagelength']))             : MAX_IMAGE_LENGTH);
-               $jpegimagequality = (!empty($_POST['jpegimagequality']) ? intval(trim($_POST['jpegimagequality']))           : JPEG_QUALITY);
+               $maximagelength   = (!empty($_POST['maximagelength'])   ? intval(trim($_POST['maximagelength']))             : -1);
+               $jpegimagequality = (!empty($_POST['jpegimagequality']) ? intval(trim($_POST['jpegimagequality']))           : 100);
 
                $register_policy        = (!empty($_POST['register_policy'])         ? intval(trim($_POST['register_policy']))             : 0);
                $daily_registrations    = (!empty($_POST['max_daily_registrations']) ? intval(trim($_POST['max_daily_registrations']))     : 0);
@@ -147,21 +148,23 @@ class Site extends BaseAdmin
 
                $register_text          = (!empty($_POST['register_text'])           ? strip_tags(trim($_POST['register_text']))           : '');
 
-               $allowed_sites          = (!empty($_POST['allowed_sites'])           ? Strings::escapeTags(trim($_POST['allowed_sites']))  : '');
-               $allowed_email          = (!empty($_POST['allowed_email'])           ? Strings::escapeTags(trim($_POST['allowed_email']))  : '');
-               $forbidden_nicknames    = (!empty($_POST['forbidden_nicknames'])     ? strtolower(Strings::escapeTags(trim($_POST['forbidden_nicknames']))) : '');
-               $system_actor_name      = (!empty($_POST['system_actor_name'])       ? Strings::escapeTags(trim($_POST['system_actor_name'])) : '');
+               $allowed_sites          = (!empty($_POST['allowed_sites'])           ? trim($_POST['allowed_sites'])  : '');
+               $allowed_email          = (!empty($_POST['allowed_email'])           ? trim($_POST['allowed_email'])  : '');
+               $forbidden_nicknames    = (!empty($_POST['forbidden_nicknames'])     ? strtolower(trim($_POST['forbidden_nicknames'])) : '');
+               $system_actor_name      = (!empty($_POST['system_actor_name'])       ? trim($_POST['system_actor_name']) : '');
                $no_oembed_rich_content = !empty($_POST['no_oembed_rich_content']);
-               $allowed_oembed         = (!empty($_POST['allowed_oembed'])          ? Strings::escapeTags(trim($_POST['allowed_oembed'])) : '');
+               $allowed_oembed         = (!empty($_POST['allowed_oembed'])          ? trim($_POST['allowed_oembed']) : '');
                $block_public           = !empty($_POST['block_public']);
                $force_publish          = !empty($_POST['publish_all']);
-               $global_directory       = (!empty($_POST['directory'])               ? Strings::escapeTags(trim($_POST['directory']))      : '');
+               $global_directory       = (!empty($_POST['directory'])               ? trim($_POST['directory'])      : '');
                $newuser_private        = !empty($_POST['newuser_private']);
                $enotify_no_content     = !empty($_POST['enotify_no_content']);
                $private_addons         = !empty($_POST['private_addons']);
                $disable_embedded       = !empty($_POST['disable_embedded']);
                $allow_users_remote_self = !empty($_POST['allow_users_remote_self']);
                $explicit_content       = !empty($_POST['explicit_content']);
+               $proxify_content        = !empty($_POST['proxify_content']);
+               $cache_contact_avatar   = !empty($_POST['cache_contact_avatar']);
 
                $enable_multi_reg       = !empty($_POST['enable_multi_reg']);
                $enable_openid          = !empty($_POST['enable_openid']);
@@ -170,11 +173,10 @@ class Site extends BaseAdmin
                $max_author_posts_community_page = (!empty($_POST['max_author_posts_community_page']) ? intval(trim($_POST['max_author_posts_community_page'])) : 0);
 
                $verifyssl              = !empty($_POST['verifyssl']);
-               $proxyuser              = (!empty($_POST['proxyuser'])              ? Strings::escapeTags(trim($_POST['proxyuser'])) : '');
-               $proxy                  = (!empty($_POST['proxy'])                  ? Strings::escapeTags(trim($_POST['proxy']))     : '');
+               $proxyuser              = (!empty($_POST['proxyuser'])              ? trim($_POST['proxyuser']) : '');
+               $proxy                  = (!empty($_POST['proxy'])                  ? trim($_POST['proxy'])     : '');
                $timeout                = (!empty($_POST['timeout'])                ? intval(trim($_POST['timeout']))                : 60);
                $maxloadavg             = (!empty($_POST['maxloadavg'])             ? intval(trim($_POST['maxloadavg']))             : 20);
-               $maxloadavg_frontend    = (!empty($_POST['maxloadavg_frontend'])    ? intval(trim($_POST['maxloadavg_frontend']))    : 50);
                $min_memory             = (!empty($_POST['min_memory'])             ? intval(trim($_POST['min_memory']))             : 0);
                $optimize_tables        = (!empty($_POST['optimize_tables'])        ? intval(trim($_POST['optimize_tables']))        : false);
                $contact_discovery      = (!empty($_POST['contact_discovery'])      ? intval(trim($_POST['contact_discovery']))      : Contact\Relation::DISCOVERY_NONE);
@@ -196,20 +198,20 @@ class Site extends BaseAdmin
                $suppress_tags          = !empty($_POST['suppress_tags']);
                $max_comments           = (!empty($_POST['max_comments'])           ? intval($_POST['max_comments'])                  : 0);
                $max_display_comments   = (!empty($_POST['max_display_comments'])   ? intval($_POST['max_display_comments'])          : 0);
-               $temppath               = (!empty($_POST['temppath'])               ? Strings::escapeTags(trim($_POST['temppath']))   : '');
-               $singleuser             = (!empty($_POST['singleuser'])             ? Strings::escapeTags(trim($_POST['singleuser'])) : '');
+               $temppath               = (!empty($_POST['temppath'])               ? trim($_POST['temppath'])   : '');
+               $singleuser             = (!empty($_POST['singleuser'])             ? trim($_POST['singleuser']) : '');
                $only_tag_search        = !empty($_POST['only_tag_search']);
-               $check_new_version_url  = (!empty($_POST['check_new_version_url'])  ? Strings::escapeTags(trim($_POST['check_new_version_url'])) : 'none');
+               $check_new_version_url  = (!empty($_POST['check_new_version_url'])  ? trim($_POST['check_new_version_url']) : 'none');
 
                $worker_queues    = (!empty($_POST['worker_queues'])                ? intval($_POST['worker_queues'])                 : 10);
                $worker_fastlane  = !empty($_POST['worker_fastlane']);
 
                $relay_directly    = !empty($_POST['relay_directly']);
-               $relay_scope       = (!empty($_POST['relay_scope'])       ? Strings::escapeTags(trim($_POST['relay_scope']))        : '');
-               $relay_server_tags = (!empty($_POST['relay_server_tags']) ? Strings::escapeTags(trim($_POST['relay_server_tags']))  : '');
-               $relay_deny_tags   = (!empty($_POST['relay_deny_tags'])   ? Strings::escapeTags(trim($_POST['relay_deny_tags']))    : '');
+               $relay_scope       = (!empty($_POST['relay_scope'])       ? trim($_POST['relay_scope'])        : '');
+               $relay_server_tags = (!empty($_POST['relay_server_tags']) ? trim($_POST['relay_server_tags'])  : '');
+               $relay_deny_tags   = (!empty($_POST['relay_deny_tags'])   ? trim($_POST['relay_deny_tags'])    : '');
                $relay_user_tags   = !empty($_POST['relay_user_tags']);
-               $active_panel      = (!empty($_POST['active_panel'])      ? "#" . Strings::escapeTags(trim($_POST['active_panel'])) : '');
+               $active_panel      = (!empty($_POST['active_panel'])      ? "#" . trim($_POST['active_panel']) : '');
 
                // Has the directory url changed? If yes, then resubmit the existing profiles there
                if ($global_directory != DI::config()->get('system', 'directory') && ($global_directory != '')) {
@@ -261,7 +263,6 @@ class Site extends BaseAdmin
                }
                DI::config()->set('system', 'ssl_policy'            , $ssl_policy);
                DI::config()->set('system', 'maxloadavg'            , $maxloadavg);
-               DI::config()->set('system', 'maxloadavg_frontend'   , $maxloadavg_frontend);
                DI::config()->set('system', 'min_memory'            , $min_memory);
                DI::config()->set('system', 'optimize_tables'       , $optimize_tables);
                DI::config()->set('system', 'contact_discovery'     , $contact_discovery);
@@ -328,6 +329,8 @@ class Site extends BaseAdmin
                DI::config()->set('system', 'disable_embedded'       , $disable_embedded);
                DI::config()->set('system', 'allow_users_remote_self', $allow_users_remote_self);
                DI::config()->set('system', 'explicit_content'       , $explicit_content);
+               DI::config()->set('system', 'proxify_content'        , $proxify_content);
+               DI::config()->set('system', 'cache_contact_avatar'   , $cache_contact_avatar);
                DI::config()->set('system', 'check_new_version_url'  , $check_new_version_url);
 
                DI::config()->set('system', 'block_extended_register', !$enable_multi_reg);
@@ -381,9 +384,9 @@ class Site extends BaseAdmin
                DI::baseUrl()->redirect('admin/site' . $active_panel);
        }
 
-       public static function content(array $parameters = [])
+       protected function content(array $request = []): string
        {
-               parent::content($parameters);
+               parent::content();
 
                /* Installed langs */
                $lang_choices = DI::l10n()->getAvailableLanguages();
@@ -459,7 +462,7 @@ class Site extends BaseAdmin
                $additional_info = DI::config()->get('config', 'info');
 
                // Automatically create temporary paths
-               get_temppath();
+               System::getTempPath();
 
                /* Register policy */
                $register_choices = [
@@ -551,6 +554,8 @@ class Site extends BaseAdmin
                        '$private_addons'         => ['private_addons', DI::l10n()->t('Disallow public access to addons listed in the apps menu.'), DI::config()->get('config', 'private_addons'), DI::l10n()->t('Checking this box will restrict addons listed in the apps menu to members only.')],
                        '$disable_embedded'       => ['disable_embedded', DI::l10n()->t('Don\'t embed private images in posts'), DI::config()->get('system', 'disable_embedded'), DI::l10n()->t('Don\'t replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.')],
                        '$explicit_content'       => ['explicit_content', DI::l10n()->t('Explicit Content'), DI::config()->get('system', 'explicit_content'), DI::l10n()->t('Set this to announce that your node is used mostly for explicit content that might not be suited for minors. This information will be published in the node information and might be used, e.g. by the global directory, to filter your node from listings of nodes to join. Additionally a note about this will be shown at the user registration page.')],
+                       '$proxify_content'        => ['proxify_content', DI::l10n()->t('Proxify external content'), DI::config()->get('system', 'proxify_content'), DI::l10n()->t('Route external content via the proxy functionality. This is used for example for some OEmbed accesses and in some other rare cases.')],
+                       '$cache_contact_avatar'   => ['cache_contact_avatar', DI::l10n()->t('Cache contact avatars'), DI::config()->get('system', 'cache_contact_avatar'), DI::l10n()->t('Locally store the avatar pictures of the contacts. This uses a lot of storage space but it increases the performance.')],
                        '$allow_users_remote_self'=> ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
                        '$enable_multi_reg'       => ['enable_multi_reg', DI::l10n()->t('Enable multiple registrations'), !DI::config()->get('system', 'block_extended_register'), DI::l10n()->t('Enable users to register additional accounts for use as pages.')],
                        '$enable_openid'          => ['enable_openid', DI::l10n()->t('Enable OpenID'), !DI::config()->get('system', 'no_openid'), DI::l10n()->t('Enable OpenID support for registration and logins.')],
@@ -569,7 +574,6 @@ class Site extends BaseAdmin
                        '$proxy'                  => ['proxy', DI::l10n()->t('Proxy URL'), DI::config()->get('system', 'proxy'), ''],
                        '$timeout'                => ['timeout', DI::l10n()->t('Network timeout'), DI::config()->get('system', 'curl_timeout'), DI::l10n()->t('Value is in seconds. Set to 0 for unlimited (not recommended).')],
                        '$maxloadavg'             => ['maxloadavg', DI::l10n()->t('Maximum Load Average'), DI::config()->get('system', 'maxloadavg'), DI::l10n()->t('Maximum system load before delivery and poll processes are deferred - default %d.', 20)],
-                       '$maxloadavg_frontend'    => ['maxloadavg_frontend', DI::l10n()->t('Maximum Load Average (Frontend)'), DI::config()->get('system', 'maxloadavg_frontend'), DI::l10n()->t('Maximum system load before the frontend quits service - default 50.')],
                        '$min_memory'             => ['min_memory', DI::l10n()->t('Minimal Memory'), DI::config()->get('system', 'min_memory'), DI::l10n()->t('Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).')],
                        '$optimize_tables'        => ['optimize_tables', DI::l10n()->t('Periodically optimize tables'), DI::config()->get('system', 'optimize_tables'), DI::l10n()->t('Periodically optimize tables like the cache and the workerqueue')],
 
@@ -603,7 +607,7 @@ class Site extends BaseAdmin
                        '$worker_fastlane'        => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
 
                        '$relay_directly'         => ['relay_directly', DI::l10n()->t('Direct relay transfer'), DI::config()->get('system', 'relay_directly'), DI::l10n()->t('Enables the direct transfer to other servers without using the relay servers')],
-                       '$relay_scope'            => ['relay_scope', DI::l10n()->t('Relay scope'), DI::config()->get('system', 'relay_scope'), DI::l10n()->t('Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'), [SR_SCOPE_NONE => DI::l10n()->t('Disabled'), SR_SCOPE_ALL => DI::l10n()->t('all'), SR_SCOPE_TAGS => DI::l10n()->t('tags')]],
+                       '$relay_scope'            => ['relay_scope', DI::l10n()->t('Relay scope'), DI::config()->get('system', 'relay_scope'), DI::l10n()->t('Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'), [Relay::SCOPE_NONE => DI::l10n()->t('Disabled'), Relay::SCOPE_ALL => DI::l10n()->t('all'), Relay::SCOPE_TAGS => DI::l10n()->t('tags')]],
                        '$relay_server_tags'      => ['relay_server_tags', DI::l10n()->t('Server tags'), DI::config()->get('system', 'relay_server_tags'), DI::l10n()->t('Comma separated list of tags for the "tags" subscription.')],
                        '$relay_deny_tags'        => ['relay_deny_tags', DI::l10n()->t('Deny Server tags'), DI::config()->get('system', 'relay_deny_tags'), DI::l10n()->t('Comma separated list of tags that are rejected.')],
                        '$relay_user_tags'        => ['relay_user_tags', DI::l10n()->t('Allow user tags'), DI::config()->get('system', 'relay_user_tags'), DI::l10n()->t('If enabled, the tags from the saved searches will used for the "tags" subscription in addition to the "relay_server_tags".')],