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.

admin.php 6.2KB

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