admin.php 6.6 KB

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