You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
6.3 KiB

  1. <?php
  2. /**
  3. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  4. * This file is licensed under the Affero General Public License version 3 or later.
  5. * See the COPYING-README file.
  6. */
  7. OC_Util::checkAdminUser();
  8. OC_App::setActiveNavigationEntry("admin");
  9. $template = new OC_Template('settings', 'admin', 'user');
  10. $htAccessWorking = OC_Util::isHtaccessWorking();
  11. $entries = OC_Log_Owncloud::getEntries(3);
  12. $entriesRemaining = count(OC_Log_Owncloud::getEntries(4)) > 3;
  13. $config = \OC::$server->getConfig();
  14. $appConfig = \OC::$server->getAppConfig();
  15. // Should we display sendmail as an option?
  16. $template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
  17. $template->assign('loglevel', $config->getSystemValue("loglevel", 2));
  18. $template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
  19. $template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
  20. $template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
  21. $template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
  22. $template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
  23. $template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
  24. $template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
  25. $template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
  26. $template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
  27. $template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
  28. $template->assign('entries', $entries);
  29. $template->assign('entriesremain', $entriesRemaining);
  30. $template->assign('htaccessworking', $htAccessWorking);
  31. $template->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled());
  32. $template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
  33. $template->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8());
  34. $template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
  35. $template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
  36. $template->assign('old_php', OC_Util::isPHPoutdated());
  37. $template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax'));
  38. $template->assign('cron_log', $config->getSystemValue('cron_log', true));
  39. $template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false));
  40. $template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes'));
  41. $template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no'));
  42. $template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7'));
  43. $template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no'));
  44. $excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
  45. $template->assign('shareExcludeGroups', $excludeGroups);
  46. $excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
  47. $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
  48. $template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
  49. // Check if connected using HTTPS
  50. $template->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https');
  51. $template->assign('enforceHTTPSEnabled', $config->getSystemValue('forcessl', false));
  52. $template->assign('forceSSLforSubdomainsEnabled', $config->getSystemValue('forceSSLforSubdomains', false));
  53. // If the current web root is non-empty but the web root from the config is,
  54. // and system cron is used, the URL generator fails to build valid URLs.
  55. $shouldSuggestOverwriteWebRoot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
  56. \OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
  57. !$config->getSystemValue('overwritewebroot', '');
  58. $suggestedOverwriteWebRoot = ($shouldSuggestOverwriteWebRoot) ? \OC::$WEBROOT : '';
  59. $template->assign('suggestedOverwriteWebroot', $suggestedOverwriteWebRoot);
  60. $template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes'));
  61. $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
  62. $template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
  63. $template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
  64. $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
  65. $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
  66. $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
  67. $template->assign('databaseOverload', $databaseOverload);
  68. // add hardcoded forms from the template
  69. $forms = OC_App::getForms('admin');
  70. $l = OC_L10N::get('settings');
  71. $formsAndMore = array();
  72. if (OC_Request::serverProtocol() !== 'https' || !$htAccessWorking || !OC_Util::isAnnotationsWorking() ||
  73. $suggestedOverwriteWebRoot || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() ||
  74. OC_Util::isPHPoutdated() || !OC_Util::fileInfoLoaded() || $databaseOverload
  75. ) {
  76. $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings'));
  77. }
  78. $formsMap = array_map(function ($form) {
  79. if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) {
  80. $sectionName = str_replace('<h2>', '', $regs[0]);
  81. $sectionName = str_replace('</h2>', '', $sectionName);
  82. $anchor = strtolower($sectionName);
  83. $anchor = str_replace(' ', '-', $anchor);
  84. return array(
  85. 'anchor' => 'goto-' . $anchor,
  86. 'section-name' => $sectionName,
  87. 'form' => $form
  88. );
  89. }
  90. return array(
  91. 'form' => $form
  92. );
  93. }, $forms);
  94. $formsAndMore = array_merge($formsAndMore, $formsMap);
  95. // add bottom hardcoded forms from the template
  96. $formsAndMore[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron'));
  97. $formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));
  98. $formsAndMore[] = array('anchor' => 'security', 'section-name' => $l->t('Security'));
  99. $formsAndMore[] = array('anchor' => 'mail_general_settings', 'section-name' => $l->t('Email Server'));
  100. $formsAndMore[] = array('anchor' => 'log-section', 'section-name' => $l->t('Log'));
  101. $template->assign('forms', $formsAndMore);
  102. $template->printPage();