3 namespace Friendica\Module\Admin;
6 use Friendica\Core\Config;
7 use Friendica\Core\L10n;
8 use Friendica\Core\Renderer;
9 use Friendica\Core\StorageManager;
10 use Friendica\Core\Theme;
11 use Friendica\Core\Worker;
12 use Friendica\Database\DBA;
13 use Friendica\Module\BaseAdminModule;
14 use Friendica\Module\Register;
15 use Friendica\Protocol\PortableContact;
16 use Friendica\Util\BasePath;
17 use Friendica\Util\BaseURL;
18 use Friendica\Util\Strings;
20 require_once __DIR__ . '/../../../boot.php';
22 class Site extends BaseAdminModule
24 public static function post()
28 self::checkFormSecurityTokenRedirectOnError('/admin/site', 'admin_site');
32 if (!empty($_POST['republish_directory'])) {
33 Worker::add(PRIORITY_LOW, 'Directory');
37 if (empty($_POST['page_site'])) {
42 // @TODO This file could benefit from moving this feature away in a Module\Admin\Relocate class for example
43 if (!empty($_POST['relocate']) && !empty($_POST['relocate_url']) && $_POST['relocate_url'] != "") {
44 $new_url = $_POST['relocate_url'];
45 $new_url = rtrim($new_url, "/");
47 $parsed = @parse_url($new_url);
48 if (!is_array($parsed) || empty($parsed['host']) || empty($parsed['scheme'])) {
49 notice(L10n::t("Can not parse base url. Must have at least <scheme>://<domain>"));
50 $a->internalRedirect('admin/site');
54 * replace all "baseurl" to "new_url" in config, profile, term, items and contacts
55 * send relocate for every local user
58 $old_url = $a->getBaseURL(true);
60 // Generate host names for relocation the addresses in the format user@address.tld
61 $new_host = str_replace("http://", "@", Strings::normaliseLink($new_url));
62 $old_host = str_replace("http://", "@", Strings::normaliseLink($old_url));
64 function update_table(App $a, $table_name, $fields, $old_url, $new_url)
66 $dbold = DBA::escape($old_url);
67 $dbnew = DBA::escape($new_url);
70 foreach ($fields as $f) {
71 $upd[] = "`$f` = REPLACE(`$f`, '$dbold', '$dbnew')";
74 $upds = implode(", ", $upd);
76 $r = DBA::e(sprintf("UPDATE %s SET %s;", $table_name, $upds));
77 if (!DBA::isResult($r)) {
78 notice("Failed updating '$table_name': " . DBA::errorMessage());
79 $a->internalRedirect('admin/site');
84 // update profile links in the format "http://server.tld"
85 update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url);
86 update_table($a, "term", ['url'], $old_url, $new_url);
87 update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
88 update_table($a, "gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
89 update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
91 // update profile addresses in the format "user@server.tld"
92 update_table($a, "contact", ['addr'], $old_host, $new_host);
93 update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host);
96 Config::set('system', 'url', $new_url);
97 $a->setBaseURL($new_url);
100 $usersStmt = DBA::select('user', ['uid'], ['account_removed' => false, 'account_expired' => false]);
101 while ($user = DBA::fetch($usersStmt)) {
102 Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', $user['uid']);
105 info("Relocation started. Could take a while to complete.");
107 $a->internalRedirect('admin/site');
111 $sitename = (!empty($_POST['sitename']) ? Strings::escapeTags(trim($_POST['sitename'])) : '');
112 $sender_email = (!empty($_POST['sender_email']) ? Strings::escapeTags(trim($_POST['sender_email'])) : '');
113 $banner = (!empty($_POST['banner']) ? trim($_POST['banner']) : false);
114 $shortcut_icon = (!empty($_POST['shortcut_icon']) ? Strings::escapeTags(trim($_POST['shortcut_icon'])) : '');
115 $touch_icon = (!empty($_POST['touch_icon']) ? Strings::escapeTags(trim($_POST['touch_icon'])) : '');
116 $additional_info = (!empty($_POST['additional_info']) ? trim($_POST['additional_info']) : '');
117 $language = (!empty($_POST['language']) ? Strings::escapeTags(trim($_POST['language'])) : '');
118 $theme = (!empty($_POST['theme']) ? Strings::escapeTags(trim($_POST['theme'])) : '');
119 $theme_mobile = (!empty($_POST['theme_mobile']) ? Strings::escapeTags(trim($_POST['theme_mobile'])) : '');
120 $maximagesize = (!empty($_POST['maximagesize']) ? intval(trim($_POST['maximagesize'])) : 0);
121 $maximagelength = (!empty($_POST['maximagelength']) ? intval(trim($_POST['maximagelength'])) : MAX_IMAGE_LENGTH);
122 $jpegimagequality = (!empty($_POST['jpegimagequality']) ? intval(trim($_POST['jpegimagequality'])) : JPEG_QUALITY);
124 $register_policy = (!empty($_POST['register_policy']) ? intval(trim($_POST['register_policy'])) : 0);
125 $daily_registrations = (!empty($_POST['max_daily_registrations']) ? intval(trim($_POST['max_daily_registrations'])) : 0);
126 $abandon_days = (!empty($_POST['abandon_days']) ? intval(trim($_POST['abandon_days'])) : 0);
128 $register_text = (!empty($_POST['register_text']) ? strip_tags(trim($_POST['register_text'])) : '');
130 $allowed_sites = (!empty($_POST['allowed_sites']) ? Strings::escapeTags(trim($_POST['allowed_sites'])) : '');
131 $allowed_email = (!empty($_POST['allowed_email']) ? Strings::escapeTags(trim($_POST['allowed_email'])) : '');
132 $forbidden_nicknames = (!empty($_POST['forbidden_nicknames']) ? strtolower(Strings::escapeTags(trim($_POST['forbidden_nicknames']))) : '');
133 $no_oembed_rich_content = !empty($_POST['no_oembed_rich_content']);
134 $allowed_oembed = (!empty($_POST['allowed_oembed']) ? Strings::escapeTags(trim($_POST['allowed_oembed'])) : '');
135 $block_public = !empty($_POST['block_public']);
136 $force_publish = !empty($_POST['publish_all']);
137 $global_directory = (!empty($_POST['directory']) ? Strings::escapeTags(trim($_POST['directory'])) : '');
138 $newuser_private = !empty($_POST['newuser_private']);
139 $enotify_no_content = !empty($_POST['enotify_no_content']);
140 $private_addons = !empty($_POST['private_addons']);
141 $disable_embedded = !empty($_POST['disable_embedded']);
142 $allow_users_remote_self = !empty($_POST['allow_users_remote_self']);
143 $explicit_content = !empty($_POST['explicit_content']);
145 $no_multi_reg = !empty($_POST['no_multi_reg']);
146 $no_openid = !empty($_POST['no_openid']);
147 $no_regfullname = !empty($_POST['no_regfullname']);
148 $community_page_style = (!empty($_POST['community_page_style']) ? intval(trim($_POST['community_page_style'])) : 0);
149 $max_author_posts_community_page = (!empty($_POST['max_author_posts_community_page']) ? intval(trim($_POST['max_author_posts_community_page'])) : 0);
151 $verifyssl = !empty($_POST['verifyssl']);
152 $proxyuser = (!empty($_POST['proxyuser']) ? Strings::escapeTags(trim($_POST['proxyuser'])) : '');
153 $proxy = (!empty($_POST['proxy']) ? Strings::escapeTags(trim($_POST['proxy'])) : '');
154 $timeout = (!empty($_POST['timeout']) ? intval(trim($_POST['timeout'])) : 60);
155 $maxloadavg = (!empty($_POST['maxloadavg']) ? intval(trim($_POST['maxloadavg'])) : 20);
156 $maxloadavg_frontend = (!empty($_POST['maxloadavg_frontend']) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
157 $min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0);
158 $optimize_max_tablesize = (!empty($_POST['optimize_max_tablesize']) ? intval(trim($_POST['optimize_max_tablesize'])) : 100);
159 $optimize_fragmentation = (!empty($_POST['optimize_fragmentation']) ? intval(trim($_POST['optimize_fragmentation'])) : 30);
160 $poco_completion = (!empty($_POST['poco_completion']) ? intval(trim($_POST['poco_completion'])) : false);
161 $poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
162 $poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : PortableContact::DISABLED);
163 $poco_discovery_since = (!empty($_POST['poco_discovery_since']) ? intval(trim($_POST['poco_discovery_since'])) : 30);
164 $poco_local_search = !empty($_POST['poco_local_search']);
165 $nodeinfo = !empty($_POST['nodeinfo']);
166 $dfrn_only = !empty($_POST['dfrn_only']);
167 $ostatus_disabled = !empty($_POST['ostatus_disabled']);
168 $ostatus_full_threads = !empty($_POST['ostatus_full_threads']);
169 $diaspora_enabled = !empty($_POST['diaspora_enabled']);
170 $ssl_policy = (!empty($_POST['ssl_policy']) ? intval($_POST['ssl_policy']) : 0);
171 $force_ssl = !empty($_POST['force_ssl']);
172 $hide_help = !empty($_POST['hide_help']);
173 $dbclean = !empty($_POST['dbclean']);
174 $dbclean_expire_days = (!empty($_POST['dbclean_expire_days']) ? intval($_POST['dbclean_expire_days']) : 0);
175 $dbclean_unclaimed = (!empty($_POST['dbclean_unclaimed']) ? intval($_POST['dbclean_unclaimed']) : 0);
176 $dbclean_expire_conv = (!empty($_POST['dbclean_expire_conv']) ? intval($_POST['dbclean_expire_conv']) : 0);
177 $suppress_tags = !empty($_POST['suppress_tags']);
178 $itemcache = (!empty($_POST['itemcache']) ? Strings::escapeTags(trim($_POST['itemcache'])) : '');
179 $itemcache_duration = (!empty($_POST['itemcache_duration']) ? intval($_POST['itemcache_duration']) : 0);
180 $max_comments = (!empty($_POST['max_comments']) ? intval($_POST['max_comments']) : 0);
181 $temppath = (!empty($_POST['temppath']) ? Strings::escapeTags(trim($_POST['temppath'])) : '');
182 $singleuser = (!empty($_POST['singleuser']) ? Strings::escapeTags(trim($_POST['singleuser'])) : '');
183 $proxy_disabled = !empty($_POST['proxy_disabled']);
184 $only_tag_search = !empty($_POST['only_tag_search']);
185 $rino = (!empty($_POST['rino']) ? intval($_POST['rino']) : 0);
186 $check_new_version_url = (!empty($_POST['check_new_version_url']) ? Strings::escapeTags(trim($_POST['check_new_version_url'])) : 'none');
188 $worker_queues = (!empty($_POST['worker_queues']) ? intval($_POST['worker_queues']) : 10);
189 $worker_dont_fork = !empty($_POST['worker_dont_fork']);
190 $worker_fastlane = !empty($_POST['worker_fastlane']);
191 $worker_frontend = !empty($_POST['worker_frontend']);
193 $relay_directly = !empty($_POST['relay_directly']);
194 $relay_server = (!empty($_POST['relay_server']) ? Strings::escapeTags(trim($_POST['relay_server'])) : '');
195 $relay_subscribe = !empty($_POST['relay_subscribe']);
196 $relay_scope = (!empty($_POST['relay_scope']) ? Strings::escapeTags(trim($_POST['relay_scope'])) : '');
197 $relay_server_tags = (!empty($_POST['relay_server_tags']) ? Strings::escapeTags(trim($_POST['relay_server_tags'])) : '');
198 $relay_user_tags = !empty($_POST['relay_user_tags']);
199 $active_panel = (!empty($_POST['active_panel']) ? "#" . Strings::escapeTags(trim($_POST['active_panel'])) : '');
202 * @var $storagebackend \Friendica\Model\Storage\IStorage
204 $storagebackend = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
206 // save storage backend form
207 if (!is_null($storagebackend) && $storagebackend != "") {
208 if (StorageManager::setBackend($storagebackend)) {
209 $storage_opts = $storagebackend::getOptions();
210 $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend);
211 $storage_opts_data = [];
212 foreach ($storage_opts as $name => $info) {
213 $fieldname = $storage_form_prefix . '_' . $name;
214 switch ($info[0]) { // type
217 $value = !empty($_POST[$fieldname]);
220 $value = defaults($_POST, $fieldname, '');
222 $storage_opts_data[$name] = $value;
227 $storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
228 if (count($storage_form_errors)) {
229 foreach ($storage_form_errors as $name => $err) {
230 notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
232 $a->internalRedirect('admin/site' . $active_panel);
235 info(L10n::t('Invalid storage backend setting value.'));
239 // Has the directory url changed? If yes, then resubmit the existing profiles there
240 if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
241 Config::set('system', 'directory', $global_directory);
242 Worker::add(PRIORITY_LOW, 'Directory');
245 if ($a->getURLPath() != "") {
246 $diaspora_enabled = false;
248 if ($ssl_policy != intval(Config::get('system', 'ssl_policy'))) {
249 if ($ssl_policy == BaseURL::SSL_POLICY_FULL) {
250 DBA::e("UPDATE `contact` SET
251 `url` = REPLACE(`url` , 'http:' , 'https:'),
252 `photo` = REPLACE(`photo` , 'http:' , 'https:'),
253 `thumb` = REPLACE(`thumb` , 'http:' , 'https:'),
254 `micro` = REPLACE(`micro` , 'http:' , 'https:'),
255 `request` = REPLACE(`request`, 'http:' , 'https:'),
256 `notify` = REPLACE(`notify` , 'http:' , 'https:'),
257 `poll` = REPLACE(`poll` , 'http:' , 'https:'),
258 `confirm` = REPLACE(`confirm`, 'http:' , 'https:'),
259 `poco` = REPLACE(`poco` , 'http:' , 'https:')
262 DBA::e("UPDATE `profile` SET
263 `photo` = REPLACE(`photo` , 'http:' , 'https:'),
264 `thumb` = REPLACE(`thumb` , 'http:' , 'https:')
267 } elseif ($ssl_policy == BaseURL::SSL_POLICY_SELFSIGN) {
268 DBA::e("UPDATE `contact` SET
269 `url` = REPLACE(`url` , 'https:' , 'http:'),
270 `photo` = REPLACE(`photo` , 'https:' , 'http:'),
271 `thumb` = REPLACE(`thumb` , 'https:' , 'http:'),
272 `micro` = REPLACE(`micro` , 'https:' , 'http:'),
273 `request` = REPLACE(`request`, 'https:' , 'http:'),
274 `notify` = REPLACE(`notify` , 'https:' , 'http:'),
275 `poll` = REPLACE(`poll` , 'https:' , 'http:'),
276 `confirm` = REPLACE(`confirm`, 'https:' , 'http:'),
277 `poco` = REPLACE(`poco` , 'https:' , 'http:')
280 DBA::e("UPDATE `profile` SET
281 `photo` = REPLACE(`photo` , 'https:' , 'http:'),
282 `thumb` = REPLACE(`thumb` , 'https:' , 'http:')
287 Config::set('system', 'ssl_policy' , $ssl_policy);
288 Config::set('system', 'maxloadavg' , $maxloadavg);
289 Config::set('system', 'maxloadavg_frontend' , $maxloadavg_frontend);
290 Config::set('system', 'min_memory' , $min_memory);
291 Config::set('system', 'optimize_max_tablesize', $optimize_max_tablesize);
292 Config::set('system', 'optimize_fragmentation', $optimize_fragmentation);
293 Config::set('system', 'poco_completion' , $poco_completion);
294 Config::set('system', 'poco_requery_days' , $poco_requery_days);
295 Config::set('system', 'poco_discovery' , $poco_discovery);
296 Config::set('system', 'poco_discovery_since' , $poco_discovery_since);
297 Config::set('system', 'poco_local_search' , $poco_local_search);
298 Config::set('system', 'nodeinfo' , $nodeinfo);
299 Config::set('config', 'sitename' , $sitename);
300 Config::set('config', 'sender_email' , $sender_email);
301 Config::set('system', 'suppress_tags' , $suppress_tags);
302 Config::set('system', 'shortcut_icon' , $shortcut_icon);
303 Config::set('system', 'touch_icon' , $touch_icon);
306 Config::delete('system', 'banner');
308 Config::set('system', 'banner', $banner);
311 if (empty($additional_info)) {
312 Config::delete('config', 'info');
314 Config::set('config', 'info', $additional_info);
316 Config::set('system', 'language', $language);
317 Config::set('system', 'theme', $theme);
318 Theme::install($theme);
320 if ($theme_mobile == '---') {
321 Config::delete('system', 'mobile-theme');
323 Config::set('system', 'mobile-theme', $theme_mobile);
325 if ($singleuser == '---') {
326 Config::delete('system', 'singleuser');
328 Config::set('system', 'singleuser', $singleuser);
330 Config::set('system', 'maximagesize' , $maximagesize);
331 Config::set('system', 'max_image_length' , $maximagelength);
332 Config::set('system', 'jpeg_quality' , $jpegimagequality);
334 Config::set('config', 'register_policy' , $register_policy);
335 Config::set('system', 'max_daily_registrations', $daily_registrations);
336 Config::set('system', 'account_abandon_days' , $abandon_days);
337 Config::set('config', 'register_text' , $register_text);
338 Config::set('system', 'allowed_sites' , $allowed_sites);
339 Config::set('system', 'allowed_email' , $allowed_email);
340 Config::set('system', 'forbidden_nicknames' , $forbidden_nicknames);
341 Config::set('system', 'no_oembed_rich_content' , $no_oembed_rich_content);
342 Config::set('system', 'allowed_oembed' , $allowed_oembed);
343 Config::set('system', 'block_public' , $block_public);
344 Config::set('system', 'publish_all' , $force_publish);
345 Config::set('system', 'newuser_private' , $newuser_private);
346 Config::set('system', 'enotify_no_content' , $enotify_no_content);
347 Config::set('system', 'disable_embedded' , $disable_embedded);
348 Config::set('system', 'allow_users_remote_self', $allow_users_remote_self);
349 Config::set('system', 'explicit_content' , $explicit_content);
350 Config::set('system', 'check_new_version_url' , $check_new_version_url);
352 Config::set('system', 'block_extended_register', $no_multi_reg);
353 Config::set('system', 'no_openid' , $no_openid);
354 Config::set('system', 'no_regfullname' , $no_regfullname);
355 Config::set('system', 'community_page_style' , $community_page_style);
356 Config::set('system', 'max_author_posts_community_page', $max_author_posts_community_page);
357 Config::set('system', 'verifyssl' , $verifyssl);
358 Config::set('system', 'proxyuser' , $proxyuser);
359 Config::set('system', 'proxy' , $proxy);
360 Config::set('system', 'curl_timeout' , $timeout);
361 Config::set('system', 'dfrn_only' , $dfrn_only);
362 Config::set('system', 'ostatus_disabled' , $ostatus_disabled);
363 Config::set('system', 'ostatus_full_threads' , $ostatus_full_threads);
364 Config::set('system', 'diaspora_enabled' , $diaspora_enabled);
366 Config::set('config', 'private_addons' , $private_addons);
368 Config::set('system', 'force_ssl' , $force_ssl);
369 Config::set('system', 'hide_help' , $hide_help);
371 Config::set('system', 'dbclean' , $dbclean);
372 Config::set('system', 'dbclean-expire-days' , $dbclean_expire_days);
373 Config::set('system', 'dbclean_expire_conversation', $dbclean_expire_conv);
375 if ($dbclean_unclaimed == 0) {
376 $dbclean_unclaimed = $dbclean_expire_days;
379 Config::set('system', 'dbclean-expire-unclaimed', $dbclean_unclaimed);
381 if ($itemcache != '') {
382 $itemcache = BasePath::getRealPath($itemcache);
385 Config::set('system', 'itemcache', $itemcache);
386 Config::set('system', 'itemcache_duration', $itemcache_duration);
387 Config::set('system', 'max_comments', $max_comments);
389 if ($temppath != '') {
390 $temppath = BasePath::getRealPath($temppath);
393 Config::set('system', 'temppath', $temppath);
395 Config::set('system', 'proxy_disabled' , $proxy_disabled);
396 Config::set('system', 'only_tag_search' , $only_tag_search);
398 Config::set('system', 'worker_queues' , $worker_queues);
399 Config::set('system', 'worker_dont_fork' , $worker_dont_fork);
400 Config::set('system', 'worker_fastlane' , $worker_fastlane);
401 Config::set('system', 'frontend_worker' , $worker_frontend);
403 Config::set('system', 'relay_directly' , $relay_directly);
404 Config::set('system', 'relay_server' , $relay_server);
405 Config::set('system', 'relay_subscribe' , $relay_subscribe);
406 Config::set('system', 'relay_scope' , $relay_scope);
407 Config::set('system', 'relay_server_tags', $relay_server_tags);
408 Config::set('system', 'relay_user_tags' , $relay_user_tags);
410 Config::set('system', 'rino_encrypt' , $rino);
412 info(L10n::t('Site settings updated.') . EOL);
414 $a->internalRedirect('admin/site' . $active_panel);
417 public static function content()
423 /* Installed langs */
424 $lang_choices = L10n::getAvailableLanguages();
426 if (strlen(Config::get('system', 'directory_submit_url')) &&
427 !strlen(Config::get('system', 'directory'))) {
428 Config::set('system', 'directory', dirname(Config::get('system', 'directory_submit_url')));
429 Config::delete('system', 'directory_submit_url');
432 /* Installed themes */
434 $theme_choices_mobile = [];
435 $theme_choices_mobile['---'] = L10n::t('No special theme for mobile devices');
436 $files = glob('view/theme/*');
437 if (is_array($files)) {
438 $allowed_theme_list = Config::get('system', 'allowed_themes');
440 foreach ($files as $file) {
441 if (intval(file_exists($file . '/unsupported'))) {
445 $f = basename($file);
447 // Only show allowed themes here
448 if (($allowed_theme_list != '') && !strstr($allowed_theme_list, $f)) {
452 $theme_name = ((file_exists($file . '/experimental')) ? L10n::t('%s - (Experimental)', $f) : $f);
454 if (file_exists($file . '/mobile')) {
455 $theme_choices_mobile[$f] = $theme_name;
457 $theme_choices[$f] = $theme_name;
462 /* Community page style */
463 $community_page_style_choices = [
464 CP_NO_INTERNAL_COMMUNITY => L10n::t('No community page for local users'),
465 CP_NO_COMMUNITY_PAGE => L10n::t('No community page'),
466 CP_USERS_ON_SERVER => L10n::t('Public postings from users of this site'),
467 CP_GLOBAL_COMMUNITY => L10n::t('Public postings from the federated network'),
468 CP_USERS_AND_GLOBAL => L10n::t('Public postings from local users and the federated network')
471 $poco_discovery_choices = [
472 PortableContact::DISABLED => L10n::t('Disabled'),
473 PortableContact::USERS => L10n::t('Users'),
474 PortableContact::USERS_GCONTACTS => L10n::t('Users, Global Contacts'),
475 PortableContact::USERS_GCONTACTS_FALLBACK => L10n::t('Users, Global Contacts/fallback'),
478 $poco_discovery_since_choices = [
479 '30' => L10n::t('One month'),
480 '91' => L10n::t('Three months'),
481 '182' => L10n::t('Half a year'),
482 '365' => L10n::t('One year'),
485 /* get user names to make the install a personal install of X */
486 // @TODO Move to Model\User::getNames()
488 $user_names['---'] = L10n::t('Multi user instance');
490 $usersStmt = DBA::select('user', ['username', 'nickname'], ['account_removed' => 0, 'account_expired' => 0]);
491 foreach (DBA::toArray($usersStmt) as $user) {
492 $user_names[$user['nickname']] = $user['username'];
496 $banner = Config::get('system', 'banner');
498 if ($banner == false) {
499 $banner = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
502 $additional_info = Config::get('config', 'info');
504 // Automatically create temporary paths
508 /* Register policy */
509 $register_choices = [
510 Register::CLOSED => L10n::t('Closed'),
511 Register::APPROVE => L10n::t('Requires approval'),
512 Register::OPEN => L10n::t('Open')
516 BaseURL::SSL_POLICY_NONE => L10n::t('No SSL policy, links will track page SSL state'),
517 BaseURL::SSL_POLICY_FULL => L10n::t('Force all links to use SSL'),
518 BaseURL::SSL_POLICY_SELFSIGN => L10n::t('Self-signed certificate, use SSL for local links only (discouraged)')
521 $check_git_version_choices = [
522 'none' => L10n::t('Don\'t check'),
523 'master' => L10n::t('check the stable version'),
524 'develop' => L10n::t('check the development version')
527 $diaspora_able = ($a->getURLPath() == '');
529 $optimize_max_tablesize = Config::get('system', 'optimize_max_tablesize', -1);
531 if ($optimize_max_tablesize <= 0) {
532 $optimize_max_tablesize = -1;
535 $storage_backends = StorageManager::listBackends();
536 /** @var $current_storage_backend \Friendica\Model\Storage\IStorage */
537 $current_storage_backend = StorageManager::getBackend();
539 $available_storage_backends = [];
541 // show legacy option only if it is the current backend:
542 // once changed can't be selected anymore
543 if ($current_storage_backend == '') {
544 $available_storage_backends[''] = L10n::t('Database (legacy)');
547 foreach ($storage_backends as $name => $class) {
548 $available_storage_backends[$class] = $name;
550 unset($storage_backends);
552 // build storage config form,
553 $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|' ,'', $current_storage_backend);
556 if (!is_null($current_storage_backend) && $current_storage_backend != '') {
557 foreach ($current_storage_backend::getOptions() as $name => $info) {
559 $info[0] = $storage_form_prefix . '_' . $name;
560 $info['type'] = $type;
561 $info['field'] = 'field_' . $type . '.tpl';
562 $storage_form[$name] = $info;
566 $t = Renderer::getMarkupTemplate('admin/site.tpl');
567 return Renderer::replaceMacros($t, [
568 '$title' => L10n::t('Administration'),
569 '$page' => L10n::t('Site'),
570 '$submit' => L10n::t('Save Settings'),
571 '$republish' => L10n::t('Republish users to directory'),
572 '$registration' => L10n::t('Registration'),
573 '$upload' => L10n::t('File upload'),
574 '$corporate' => L10n::t('Policies'),
575 '$advanced' => L10n::t('Advanced'),
576 '$portable_contacts' => L10n::t('Auto Discovered Contact Directory'),
577 '$performance' => L10n::t('Performance'),
578 '$worker_title' => L10n::t('Worker'),
579 '$relay_title' => L10n::t('Message Relay'),
580 '$relocate' => L10n::t('Relocate Instance'),
581 '$relocate_warning' => L10n::t('Warning! Advanced function. Could make this server unreachable.'),
582 '$baseurl' => $a->getBaseURL(true),
584 // name, label, value, help string, extra data...
585 '$sitename' => ['sitename', L10n::t('Site name'), Config::get('config', 'sitename'), ''],
586 '$sender_email' => ['sender_email', L10n::t('Sender Email'), Config::get('config', 'sender_email'), L10n::t('The email address your server shall use to send notification emails from.'), '', '', 'email'],
587 '$banner' => ['banner', L10n::t('Banner/Logo'), $banner, ''],
588 '$shortcut_icon' => ['shortcut_icon', L10n::t('Shortcut icon'), Config::get('system', 'shortcut_icon'), L10n::t('Link to an icon that will be used for browsers.')],
589 '$touch_icon' => ['touch_icon', L10n::t('Touch icon'), Config::get('system', 'touch_icon'), L10n::t('Link to an icon that will be used for tablets and mobiles.')],
590 '$additional_info' => ['additional_info', L10n::t('Additional Info'), $additional_info, L10n::t('For public servers: you can add additional information here that will be listed at %s/servers.', get_server())],
591 '$language' => ['language', L10n::t('System language'), Config::get('system', 'language'), '', $lang_choices],
592 '$theme' => ['theme', L10n::t('System theme'), Config::get('system', 'theme'), L10n::t('Default system theme - may be over-ridden by user profiles - <a href="/admin/themes" id="cnftheme">Change default theme settings</a>'), $theme_choices],
593 '$theme_mobile' => ['theme_mobile', L10n::t('Mobile system theme'), Config::get('system', 'mobile-theme', '---'), L10n::t('Theme for mobile devices'), $theme_choices_mobile],
594 '$ssl_policy' => ['ssl_policy', L10n::t('SSL link policy'), (string)intval(Config::get('system', 'ssl_policy')), L10n::t('Determines whether generated links should be forced to use SSL'), $ssl_choices],
595 '$force_ssl' => ['force_ssl', L10n::t('Force SSL'), Config::get('system', 'force_ssl'), L10n::t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')],
596 '$hide_help' => ['hide_help', L10n::t('Hide help entry from navigation menu'), Config::get('system', 'hide_help'), L10n::t('Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.')],
597 '$singleuser' => ['singleuser', L10n::t('Single user instance'), Config::get('system', 'singleuser', '---'), L10n::t('Make this instance multi-user or single-user for the named user'), $user_names],
599 '$storagebackend' => ['storagebackend', L10n::t('File storage backend'), $current_storage_backend, L10n::t('The backend used to store uploaded data. If you change the storage backend, you can manually move the existing files. If you do not do so, the files uploaded before the change will still be available at the old backend. Please see <a href="/help/Settings#1_2_3_1">the settings documentation</a> for more information about the choices and the moving procedure.'), $available_storage_backends],
600 '$storageform' => $storage_form,
601 '$maximagesize' => ['maximagesize', L10n::t('Maximum image size'), Config::get('system', 'maximagesize'), L10n::t('Maximum size in bytes of uploaded images. Default is 0, which means no limits.')],
602 '$maximagelength' => ['maximagelength', L10n::t('Maximum image length'), Config::get('system', 'max_image_length'), L10n::t('Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.')],
603 '$jpegimagequality' => ['jpegimagequality', L10n::t('JPEG image quality'), Config::get('system', 'jpeg_quality'), L10n::t('Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.')],
605 '$register_policy' => ['register_policy', L10n::t('Register policy'), Config::get('config', 'register_policy'), '', $register_choices],
606 '$daily_registrations' => ['max_daily_registrations', L10n::t('Maximum Daily Registrations'), Config::get('system', 'max_daily_registrations'), L10n::t('If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.')],
607 '$register_text' => ['register_text', L10n::t('Register text'), Config::get('config', 'register_text'), L10n::t('Will be displayed prominently on the registration page. You can use BBCode here.')],
608 '$forbidden_nicknames' => ['forbidden_nicknames', L10n::t('Forbidden Nicknames'), Config::get('system', 'forbidden_nicknames'), L10n::t('Comma separated list of nicknames that are forbidden from registration. Preset is a list of role names according RFC 2142.')],
609 '$abandon_days' => ['abandon_days', L10n::t('Accounts abandoned after x days'), Config::get('system', 'account_abandon_days'), L10n::t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
610 '$allowed_sites' => ['allowed_sites', L10n::t('Allowed friend domains'), Config::get('system', 'allowed_sites'), L10n::t('Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains')],
611 '$allowed_email' => ['allowed_email', L10n::t('Allowed email domains'), Config::get('system', 'allowed_email'), L10n::t('Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains')],
612 '$no_oembed_rich_content' => ['no_oembed_rich_content', L10n::t('No OEmbed rich content'), Config::get('system', 'no_oembed_rich_content'), L10n::t('Don\'t show the rich content (e.g. embedded PDF), except from the domains listed below.')],
613 '$allowed_oembed' => ['allowed_oembed', L10n::t('Allowed OEmbed domains'), Config::get('system', 'allowed_oembed'), L10n::t('Comma separated list of domains which oembed content is allowed to be displayed. Wildcards are accepted.')],
614 '$block_public' => ['block_public', L10n::t('Block public'), Config::get('system', 'block_public'), L10n::t('Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.')],
615 '$force_publish' => ['publish_all', L10n::t('Force publish'), Config::get('system', 'publish_all'), L10n::t('Check to force all profiles on this site to be listed in the site directory.') . '<strong>' . L10n::t('Enabling this may violate privacy laws like the GDPR') . '</strong>'],
616 '$global_directory' => ['directory', L10n::t('Global directory URL'), Config::get('system', 'directory', 'https://dir.friendica.social'), L10n::t('URL to the global directory. If this is not set, the global directory is completely unavailable to the application.')],
617 '$newuser_private' => ['newuser_private', L10n::t('Private posts by default for new users'), Config::get('system', 'newuser_private'), L10n::t('Set default post permissions for all new members to the default privacy group rather than public.')],
618 '$enotify_no_content' => ['enotify_no_content', L10n::t('Don\'t include post content in email notifications'), Config::get('system', 'enotify_no_content'), L10n::t('Don\'t include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.')],
619 '$private_addons' => ['private_addons', L10n::t('Disallow public access to addons listed in the apps menu.'), Config::get('config', 'private_addons'), L10n::t('Checking this box will restrict addons listed in the apps menu to members only.')],
620 '$disable_embedded' => ['disable_embedded', L10n::t('Don\'t embed private images in posts'), Config::get('system', 'disable_embedded'), 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.')],
621 '$explicit_content' => ['explicit_content', L10n::t('Explicit Content'), Config::get('system', 'explicit_content', false), 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.')],
622 '$allow_users_remote_self'=> ['allow_users_remote_self', L10n::t('Allow Users to set remote_self'), Config::get('system', 'allow_users_remote_self'), 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.')],
623 '$no_multi_reg' => ['no_multi_reg', L10n::t('Block multiple registrations'), Config::get('system', 'block_extended_register'), L10n::t('Disallow users to register additional accounts for use as pages.')],
624 '$no_openid' => ['no_openid', L10n::t('Disable OpenID'), Config::get('system', 'no_openid'), L10n::t('Disable OpenID support for registration and logins.')],
625 '$no_regfullname' => ['no_regfullname', L10n::t('No Fullname check'), Config::get('system', 'no_regfullname'), L10n::t('Allow users to register without a space between the first name and the last name in their full name.')],
626 '$community_page_style' => ['community_page_style', L10n::t('Community pages for visitors'), Config::get('system', 'community_page_style'), L10n::t('Which community pages should be available for visitors. Local users always see both pages.'), $community_page_style_choices],
627 '$max_author_posts_community_page' => ['max_author_posts_community_page', L10n::t('Posts per user on community page'), Config::get('system', 'max_author_posts_community_page'), L10n::t('The maximum number of posts per user on the community page. (Not valid for "Global Community")')],
628 '$ostatus_disabled' => ['ostatus_disabled', L10n::t('Disable OStatus support'), Config::get('system', 'ostatus_disabled'), L10n::t('Disable built-in OStatus (StatusNet, GNU Social etc.) compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.')],
629 '$ostatus_full_threads' => ['ostatus_full_threads', L10n::t('Only import OStatus/ActivityPub threads from our contacts'), Config::get('system', 'ostatus_full_threads'), L10n::t('Normally we import every content from our OStatus and ActivityPub contacts. With this option we only store threads that are started by a contact that is known on our system.')],
630 '$ostatus_not_able' => L10n::t('OStatus support can only be enabled if threading is enabled.'),
631 '$diaspora_able' => $diaspora_able,
632 '$diaspora_not_able' => L10n::t('Diaspora support can\'t be enabled because Friendica was installed into a sub directory.'),
633 '$diaspora_enabled' => ['diaspora_enabled', L10n::t('Enable Diaspora support'), Config::get('system', 'diaspora_enabled', $diaspora_able), L10n::t('Provide built-in Diaspora network compatibility.')],
634 '$dfrn_only' => ['dfrn_only', L10n::t('Only allow Friendica contacts'), Config::get('system', 'dfrn_only'), L10n::t('All contacts must use Friendica protocols. All other built-in communication protocols disabled.')],
635 '$verifyssl' => ['verifyssl', L10n::t('Verify SSL'), Config::get('system', 'verifyssl'), L10n::t('If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.')],
636 '$proxyuser' => ['proxyuser', L10n::t('Proxy user'), Config::get('system', 'proxyuser'), ''],
637 '$proxy' => ['proxy', L10n::t('Proxy URL'), Config::get('system', 'proxy'), ''],
638 '$timeout' => ['timeout', L10n::t('Network timeout'), Config::get('system', 'curl_timeout', 60), L10n::t('Value is in seconds. Set to 0 for unlimited (not recommended).')],
639 '$maxloadavg' => ['maxloadavg', L10n::t('Maximum Load Average'), Config::get('system', 'maxloadavg', 20), L10n::t('Maximum system load before delivery and poll processes are deferred - default %d.', 20)],
640 '$maxloadavg_frontend' => ['maxloadavg_frontend', L10n::t('Maximum Load Average (Frontend)'), Config::get('system', 'maxloadavg_frontend', 50), L10n::t('Maximum system load before the frontend quits service - default 50.')],
641 '$min_memory' => ['min_memory', L10n::t('Minimal Memory'), Config::get('system', 'min_memory', 0), L10n::t('Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).')],
642 '$optimize_max_tablesize' => ['optimize_max_tablesize', L10n::t('Maximum table size for optimization'), $optimize_max_tablesize, L10n::t('Maximum table size (in MB) for the automatic optimization. Enter -1 to disable it.')],
643 '$optimize_fragmentation' => ['optimize_fragmentation', L10n::t('Minimum level of fragmentation'), Config::get('system', 'optimize_fragmentation', 30), L10n::t('Minimum fragmenation level to start the automatic optimization - default value is 30%.')],
645 '$poco_completion' => ['poco_completion', L10n::t('Periodical check of global contacts'), Config::get('system', 'poco_completion'), L10n::t('If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.')],
646 '$poco_requery_days' => ['poco_requery_days', L10n::t('Days between requery'), Config::get('system', 'poco_requery_days'), L10n::t('Number of days after which a server is requeried for his contacts.')],
647 '$poco_discovery' => ['poco_discovery', L10n::t('Discover contacts from other servers'), (string)intval(Config::get('system', 'poco_discovery')), L10n::t('Periodically query other servers for contacts. You can choose between "Users": the users on the remote system, "Global Contacts": active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren\'t available. The fallback increases the server load, so the recommended setting is "Users, Global Contacts".'), $poco_discovery_choices],
648 '$poco_discovery_since' => ['poco_discovery_since', L10n::t('Timeframe for fetching global contacts'), (string)intval(Config::get('system', 'poco_discovery_since')), L10n::t('When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers.'), $poco_discovery_since_choices],
649 '$poco_local_search' => ['poco_local_search', L10n::t('Search the local directory'), Config::get('system', 'poco_local_search'), L10n::t('Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.')],
651 '$nodeinfo' => ['nodeinfo', L10n::t('Publish server information'), Config::get('system', 'nodeinfo'), L10n::t('If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href="http://the-federation.info/">the-federation.info</a> for details.')],
653 '$check_new_version_url' => ['check_new_version_url', L10n::t('Check upstream version'), Config::get('system', 'check_new_version_url'), L10n::t('Enables checking for new Friendica versions at github. If there is a new version, you will be informed in the admin panel overview.'), $check_git_version_choices],
654 '$suppress_tags' => ['suppress_tags', L10n::t('Suppress Tags'), Config::get('system', 'suppress_tags'), L10n::t('Suppress showing a list of hashtags at the end of the posting.')],
655 '$dbclean' => ['dbclean', L10n::t('Clean database'), Config::get('system', 'dbclean', false), L10n::t('Remove old remote items, orphaned database records and old content from some other helper tables.')],
656 '$dbclean_expire_days' => ['dbclean_expire_days', L10n::t('Lifespan of remote items'), Config::get('system', 'dbclean-expire-days', 0), L10n::t('When the database cleanup is enabled, this defines the days after which remote items will be deleted. Own items, and marked or filed items are always kept. 0 disables this behaviour.')],
657 '$dbclean_unclaimed' => ['dbclean_unclaimed', L10n::t('Lifespan of unclaimed items'), Config::get('system', 'dbclean-expire-unclaimed', 90), L10n::t('When the database cleanup is enabled, this defines the days after which unclaimed remote items (mostly content from the relay) will be deleted. Default value is 90 days. Defaults to the general lifespan value of remote items if set to 0.')],
658 '$dbclean_expire_conv' => ['dbclean_expire_conv', L10n::t('Lifespan of raw conversation data'), Config::get('system', 'dbclean_expire_conversation', 90), L10n::t('The conversation data is used for ActivityPub and OStatus, as well as for debug purposes. It should be safe to remove it after 14 days, default is 90 days.')],
659 '$itemcache' => ['itemcache', L10n::t('Path to item cache'), Config::get('system', 'itemcache'), L10n::t('The item caches buffers generated bbcode and external images.')],
660 '$itemcache_duration' => ['itemcache_duration', L10n::t('Cache duration in seconds'), Config::get('system', 'itemcache_duration'), L10n::t('How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.')],
661 '$max_comments' => ['max_comments', L10n::t('Maximum numbers of comments per post'), Config::get('system', 'max_comments'), L10n::t('How much comments should be shown for each post? Default value is 100.')],
662 '$temppath' => ['temppath', L10n::t('Temp path'), Config::get('system', 'temppath'), L10n::t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
663 '$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.')],
664 '$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.')],
666 '$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.')],
668 '$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')]],
670 '$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)],
671 '$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.')],
672 '$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.')],
673 '$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())],
675 '$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.')],
676 '$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')],
677 '$relay_directly' => ['relay_directly', L10n::t('Direct relay transfer'), Config::get('system', 'relay_directly'), L10n::t('Enables the direct transfer to other servers without using the relay servers')],
678 '$relay_scope' => ['relay_scope', L10n::t('Relay scope'), Config::get('system', 'relay_scope'), 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.'), ['' => L10n::t('Disabled'), 'all' => L10n::t('all'), 'tags' => L10n::t('tags')]],
679 '$relay_server_tags' => ['relay_server_tags', L10n::t('Server tags'), Config::get('system', 'relay_server_tags'), L10n::t('Comma separated list of tags for the "tags" subscription.')],
680 '$relay_user_tags' => ['relay_user_tags', L10n::t('Allow user tags'), Config::get('system', 'relay_user_tags', true), L10n::t('If enabled, the tags from the saved searches will used for the "tags" subscription in addition to the "relay_server_tags".')],
682 '$form_security_token' => parent::getFormSecurityToken('admin_site'),
683 '$relocate_button' => L10n::t('Start Relocation'),