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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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('isLocaleWorking', OC_Util::isSetLocaleWorking());
  32. $template->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8());
  33. $template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
  34. $template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
  35. $template->assign('old_php', OC_Util::isPHPoutdated());
  36. $template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax'));
  37. $template->assign('cron_log', $config->getSystemValue('cron_log', true));
  38. $template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false));
  39. $template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes'));
  40. $template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no'));
  41. $template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7'));
  42. $template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no'));
  43. $excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
  44. $template->assign('shareExcludeGroups', $excludeGroups);
  45. $excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
  46. $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
  47. $template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
  48. // Check if connected using HTTPS
  49. $template->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https');
  50. $template->assign('enforceHTTPSEnabled', $config->getSystemValue('forcessl', false));
  51. $template->assign('forceSSLforSubdomainsEnabled', $config->getSystemValue('forceSSLforSubdomains', false));
  52. // If the current web root is non-empty but the web root from the config is,
  53. // and system cron is used, the URL generator fails to build valid URLs.
  54. $shouldSuggestOverwriteWebRoot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
  55. \OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
  56. !$config->getSystemValue('overwritewebroot', '');
  57. $suggestedOverwriteWebRoot = ($shouldSuggestOverwriteWebRoot) ? \OC::$WEBROOT : '';
  58. $template->assign('suggestedOverwriteWebroot', $suggestedOverwriteWebRoot);
  59. $template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes'));
  60. $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
  61. $template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
  62. $template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
  63. $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
  64. $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
  65. $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
  66. $template->assign('databaseOverload', $databaseOverload);
  67. // add hardcoded forms from the template
  68. $forms = OC_App::getForms('admin');
  69. $l = OC_L10N::get('settings');
  70. $formsAndMore = array();
  71. if (OC_Request::serverProtocol() !== 'https' || !$htAccessWorking || !OC_Util::isAnnotationsWorking() ||
  72. $suggestedOverwriteWebRoot || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() ||
  73. OC_Util::isPHPoutdated() || !OC_Util::fileInfoLoaded() || $databaseOverload
  74. ) {
  75. $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings'));
  76. }
  77. $formsMap = array_map(function ($form) {
  78. if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) {
  79. $sectionName = str_replace('<h2>', '', $regs[0]);
  80. $sectionName = str_replace('</h2>', '', $sectionName);
  81. $anchor = strtolower($sectionName);
  82. $anchor = str_replace(' ', '-', $anchor);
  83. return array(
  84. 'anchor' => 'goto-' . $anchor,
  85. 'section-name' => $sectionName,
  86. 'form' => $form
  87. );
  88. }
  89. return array(
  90. 'form' => $form
  91. );
  92. }, $forms);
  93. $formsAndMore = array_merge($formsAndMore, $formsMap);
  94. // add bottom hardcoded forms from the template
  95. $formsAndMore[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron'));
  96. $formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));
  97. $formsAndMore[] = array('anchor' => 'security', 'section-name' => $l->t('Security'));
  98. $formsAndMore[] = array('anchor' => 'mail_general_settings', 'section-name' => $l->t('Email Server'));
  99. $formsAndMore[] = array('anchor' => 'log-section', 'section-name' => $l->t('Log'));
  100. $template->assign('forms', $formsAndMore);
  101. $template->printPage();