admin.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_Util::addStyle( "settings", "settings" );
  9. OC_Util::addScript( "settings", "admin" );
  10. OC_Util::addScript( "settings", "log" );
  11. OC_Util::addScript( 'core', 'multiselect' );
  12. OC_App::setActiveNavigationEntry( "admin" );
  13. $tmpl = new OC_Template( 'settings', 'admin', 'user');
  14. $forms=OC_App::getForms('admin');
  15. $htaccessworking=OC_Util::isHtaccessWorking();
  16. $entries=OC_Log_Owncloud::getEntries(3);
  17. $entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3;
  18. // Should we display sendmail as an option?
  19. $tmpl->assign('sendmail_is_available', (bool) findBinaryPath('sendmailsendmail'));
  20. $tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 ));
  21. $tmpl->assign('mail_domain', OC_Config::getValue( "mail_domain", '' ));
  22. $tmpl->assign('mail_from_address', OC_Config::getValue( "mail_from_address", '' ));
  23. $tmpl->assign('mail_smtpmode', OC_Config::getValue( "mail_smtpmode", '' ));
  24. $tmpl->assign('mail_smtpsecure', OC_Config::getValue( "mail_smtpsecure", '' ));
  25. $tmpl->assign('mail_smtphost', OC_Config::getValue( "mail_smtphost", '' ));
  26. $tmpl->assign('mail_smtpport', OC_Config::getValue( "mail_smtpport", '' ));
  27. $tmpl->assign('mail_smtpauthtype', OC_Config::getValue( "mail_smtpauthtype", '' ));
  28. $tmpl->assign('mail_smtpauth', OC_Config::getValue( "mail_smtpauth", false ));
  29. $tmpl->assign('mail_smtpname', OC_Config::getValue( "mail_smtpname", '' ));
  30. $tmpl->assign('mail_smtppassword', OC_Config::getValue( "mail_smtppassword", '' ));
  31. $tmpl->assign('entries', $entries);
  32. $tmpl->assign('entriesremain', $entriesremain);
  33. $tmpl->assign('htaccessworking', $htaccessworking);
  34. $tmpl->assign('internetconnectionworking', OC_Util::isInternetConnectionEnabled() ? OC_Util::isInternetConnectionWorking() : false);
  35. $tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
  36. $tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
  37. $tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
  38. $tmpl->assign('old_php', OC_Util::isPHPoutdated());
  39. $tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
  40. $tmpl->assign('cron_log', OC_Config::getValue('cron_log', true));
  41. $tmpl->assign('lastcron', OC_Appconfig::getValue('core', 'lastcron', false));
  42. $tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
  43. $tmpl->assign('shareDefaultExpireDateSet', OC_Appconfig::getValue('core', 'shareapi_default_expire_date', 'no'));
  44. $tmpl->assign('shareExpireAfterNDays', OC_Appconfig::getValue('core', 'shareapi_expire_after_n_days', '7'));
  45. $tmpl->assign('shareEnforceExpireDate', OC_Appconfig::getValue('core', 'shareapi_enforce_expire_date', 'no'));
  46. $excludeGroups = OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
  47. $tmpl->assign('shareExcludeGroups', $excludeGroups);
  48. $allGroups = OC_Group::getGroups();
  49. $excludedGroupsList = OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', '');
  50. $excludedGroups = $excludedGroupsList !== '' ? explode(',', $excludedGroupsList) : array();
  51. $groups = array();
  52. foreach ($allGroups as $group) {
  53. if (in_array($group, $excludedGroups)) {
  54. $groups[$group] = array('gid' => $group,
  55. 'excluded' => true);
  56. } else {
  57. $groups[$group] = array('gid' => $group,
  58. 'excluded' => false);
  59. }
  60. }
  61. ksort($groups);
  62. $tmpl->assign('groups', $groups);
  63. // Check if connected using HTTPS
  64. if (OC_Request::serverProtocol() === 'https') {
  65. $connectedHTTPS = true;
  66. } else {
  67. $connectedHTTPS = false;
  68. }
  69. $tmpl->assign('isConnectedViaHTTPS', $connectedHTTPS);
  70. $tmpl->assign('enforceHTTPSEnabled', OC_Config::getValue( "forcessl", false));
  71. $tmpl->assign('allowLinks', OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes'));
  72. $tmpl->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
  73. $tmpl->assign('allowPublicUpload', OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'));
  74. $tmpl->assign('allowResharing', OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes'));
  75. $tmpl->assign('allowMailNotification', OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'yes'));
  76. $tmpl->assign('sharePolicy', OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'));
  77. $tmpl->assign('forms', array());
  78. foreach($forms as $form) {
  79. $tmpl->append('forms', $form);
  80. }
  81. $tmpl->printPage();
  82. /**
  83. * Try to find a programm
  84. *
  85. * @param string $program
  86. * @return null|string
  87. */
  88. function findBinaryPath($program) {
  89. exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
  90. if ($returnCode === 0 && count($output) > 0) {
  91. return escapeshellcmd($output[0]);
  92. }
  93. return null;
  94. }