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 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. /**
  3. * @author Arthur Schiwon <blizzz@owncloud.com>
  4. * @author Bart Visscher <bartv@thisnet.nl>
  5. * @author Frank Karlitschek <frank@owncloud.org>
  6. * @author Georg Ehrke <georg@owncloud.com>
  7. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  8. * @author Joas Schilling <nickvergessen@owncloud.com>
  9. * @author Lukas Reschke <lukas@owncloud.com>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <icewind@owncloud.com>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @copyright Copyright (c) 2015, ownCloud, Inc.
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. OC_Util::checkAdminUser();
  32. OC_App::setActiveNavigationEntry("admin");
  33. $template = new OC_Template('settings', 'admin', 'user');
  34. $showLog = (\OC::$server->getConfig()->getSystemValue('log_type', 'owncloud') === 'owncloud');
  35. $numEntriesToLoad = 3;
  36. $entries = OC_Log_Owncloud::getEntries($numEntriesToLoad + 1);
  37. $entriesRemaining = count($entries) > $numEntriesToLoad;
  38. $entries = array_slice($entries, 0, $numEntriesToLoad);
  39. $logFilePath = OC_Log_Owncloud::getLogFilePath();
  40. $doesLogFileExist = file_exists($logFilePath);
  41. $logFileSize = filesize($logFilePath);
  42. $config = \OC::$server->getConfig();
  43. $appConfig = \OC::$server->getAppConfig();
  44. $request = \OC::$server->getRequest();
  45. // Should we display sendmail as an option?
  46. $template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
  47. $template->assign('loglevel', $config->getSystemValue("loglevel", 2));
  48. $template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
  49. $template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
  50. $template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
  51. $template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
  52. $template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
  53. $template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
  54. $template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
  55. $template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
  56. $template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
  57. $template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
  58. $template->assign('entries', $entries);
  59. $template->assign('entriesremain', $entriesRemaining);
  60. $template->assign('logFileSize', $logFileSize);
  61. $template->assign('doesLogFileExist', $doesLogFileExist);
  62. $template->assign('showLog', $showLog);
  63. $template->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled());
  64. $template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
  65. $template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
  66. $template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
  67. $template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax'));
  68. $template->assign('cron_log', $config->getSystemValue('cron_log', true));
  69. $template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false));
  70. $template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes'));
  71. $template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no'));
  72. $template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7'));
  73. $template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no'));
  74. $excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
  75. $template->assign('shareExcludeGroups', $excludeGroups);
  76. $excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
  77. $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
  78. $template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
  79. $template->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
  80. $backends = \OC::$server->getUserManager()->getBackends();
  81. $externalBackends = (count($backends) > 1) ? true : false;
  82. $template->assign('encryptionReady', \OC::$server->getEncryptionManager()->isReady());
  83. $template->assign('externalBackendsEnabled', $externalBackends);
  84. $encryptionModules = \OC::$server->getEncryptionManager()->getEncryptionModules();
  85. $defaultEncryptionModuleId = \OC::$server->getEncryptionManager()->getDefaultEncryptionModuleId();
  86. $encModulues = array();
  87. foreach ($encryptionModules as $module) {
  88. $encModulues[$module['id']]['displayName'] = $module['displayName'];
  89. $encModulues[$module['id']]['default'] = false;
  90. if ($module['id'] === $defaultEncryptionModuleId) {
  91. $encModulues[$module['id']]['default'] = true;
  92. }
  93. }
  94. $template->assign('encryptionModules', $encModulues);
  95. // If the current web root is non-empty but the web root from the config is,
  96. // and system cron is used, the URL generator fails to build valid URLs.
  97. $shouldSuggestOverwriteCliUrl = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
  98. \OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
  99. !$config->getSystemValue('overwrite.cli.url', '');
  100. $suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : '';
  101. $template->assign('suggestedOverwriteCliUrl', $suggestedOverwriteCliUrl);
  102. $template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes'));
  103. $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
  104. $template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
  105. $template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
  106. $template->assign('allowPublicMailNotification', $appConfig->getValue('core', 'shareapi_allow_public_notification', 'no'));
  107. $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
  108. $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
  109. $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
  110. $template->assign('databaseOverload', $databaseOverload);
  111. $template->assign('cronErrors', $appConfig->getValue('core', 'cronErrors'));
  112. // warn if php is not setup properly to get system variables with getenv
  113. $path = getenv('PATH');
  114. $template->assign('getenvServerNotWorking', empty($path));
  115. // warn if Windows is used
  116. $template->assign('WindowsWarning', OC_Util::runningOnWindows());
  117. // warn if outdated version of APCu is used
  118. $template->assign('ApcuOutdatedWarning',
  119. extension_loaded('apcu') && version_compare(phpversion('apc'), '4.0.6') === -1);
  120. // add hardcoded forms from the template
  121. $forms = OC_App::getForms('admin');
  122. $l = OC_L10N::get('settings');
  123. $formsAndMore = array();
  124. if ($request->getServerProtocol() !== 'https' || !OC_Util::isAnnotationsWorking() ||
  125. $suggestedOverwriteCliUrl || !OC_Util::isSetLocaleWorking() ||
  126. !OC_Util::fileInfoLoaded() || $databaseOverload
  127. ) {
  128. $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & setup warnings'));
  129. }
  130. $formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));
  131. $formsAndMore[] = ['anchor' => 'encryptionAPI', 'section-name' => $l->t('Server-side encryption')];
  132. // Prioritize fileSharingSettings and files_external and move updater to the version
  133. $fileSharingSettings = $filesExternal = $updaterAppPanel = $ocDefaultEncryptionModulePanel = '';
  134. foreach ($forms as $index => $form) {
  135. if (strpos($form, 'id="fileSharingSettings"')) {
  136. $fileSharingSettings = $form;
  137. unset($forms[$index]);
  138. continue;
  139. }
  140. if (strpos($form, 'id="files_external"')) {
  141. $filesExternal = $form;
  142. unset($forms[$index]);
  143. continue;
  144. }
  145. if (strpos($form, 'class="updater-admin"')) {
  146. $updaterAppPanel = $form;
  147. unset($forms[$index]);
  148. continue;
  149. }
  150. if (strpos($form, 'id="ocDefaultEncryptionModule"')) {
  151. $ocDefaultEncryptionModulePanel = $form;
  152. unset($forms[$index]);
  153. continue;
  154. }
  155. }
  156. if ($filesExternal) {
  157. $formsAndMore[] = array('anchor' => 'files_external', 'section-name' => $l->t('External Storage'));
  158. }
  159. $template->assign('fileSharingSettings', $fileSharingSettings);
  160. $template->assign('filesExternal', $filesExternal);
  161. $template->assign('updaterAppPanel', $updaterAppPanel);
  162. $template->assign('ocDefaultEncryptionModulePanel', $ocDefaultEncryptionModulePanel);
  163. $formsMap = array_map(function ($form) {
  164. if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) {
  165. $sectionName = str_replace('<h2>', '', $regs[0]);
  166. $sectionName = str_replace('</h2>', '', $sectionName);
  167. $anchor = strtolower($sectionName);
  168. $anchor = str_replace(' ', '-', $anchor);
  169. return array(
  170. 'anchor' => 'goto-' . $anchor,
  171. 'section-name' => $sectionName,
  172. 'form' => $form
  173. );
  174. }
  175. return array(
  176. 'form' => $form
  177. );
  178. }, $forms);
  179. $formsAndMore = array_merge($formsAndMore, $formsMap);
  180. // add bottom hardcoded forms from the template
  181. $formsAndMore[] = ['anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron')];
  182. $formsAndMore[] = ['anchor' => 'mail_general_settings', 'section-name' => $l->t('Email server')];
  183. $formsAndMore[] = ['anchor' => 'log-section', 'section-name' => $l->t('Log')];
  184. $formsAndMore[] = ['anchor' => 'admin-tips', 'section-name' => $l->t('Tips & tricks')];
  185. if ($updaterAppPanel) {
  186. $formsAndMore[] = ['anchor' => 'updater', 'section-name' => $l->t('Updates')];
  187. }
  188. $template->assign('forms', $formsAndMore);
  189. $template->printPage();