update_advanced.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Updates the advanced settings for the primary site object.
  4. *
  5. * Options are saved among metadata on the site object, entries
  6. * in the datalist table, and entries in the config table.
  7. *
  8. * @package Elgg.Core
  9. * @subpackage Administration.Site
  10. */
  11. $site = elgg_get_site_entity();
  12. if (!$site) {
  13. throw new InstallationException("The system is missing an ElggSite entity!");
  14. }
  15. if (!($site instanceof ElggSite)) {
  16. throw new InstallationException("Passing a non-ElggSite to an ElggSite constructor!");
  17. }
  18. $site->url = rtrim(get_input('wwwroot', '', false), '/') . '/';
  19. datalist_set('path', sanitise_filepath(get_input('path', '', false)));
  20. $dataroot = sanitise_filepath(get_input('dataroot', '', false));
  21. // check for relative paths
  22. if (stripos(PHP_OS, 'win') === 0) {
  23. if (strpos($dataroot, ':') !== 1) {
  24. $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot));
  25. register_error($msg);
  26. forward(REFERER);
  27. }
  28. } else {
  29. if (strpos($dataroot, '/') !== 0) {
  30. $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot));
  31. register_error($msg);
  32. forward(REFERER);
  33. }
  34. }
  35. datalist_set('dataroot', $dataroot);
  36. if ('on' === get_input('simplecache_enabled')) {
  37. elgg_enable_simplecache();
  38. } else {
  39. elgg_disable_simplecache();
  40. }
  41. set_config('simplecache_minify_js', 'on' === get_input('simplecache_minify_js'), $site->getGUID());
  42. set_config('simplecache_minify_css', 'on' === get_input('simplecache_minify_css'), $site->getGUID());
  43. if ('on' === get_input('system_cache_enabled')) {
  44. elgg_enable_system_cache();
  45. } else {
  46. elgg_disable_system_cache();
  47. }
  48. set_config('default_access', get_input('default_access', ACCESS_PRIVATE), $site->getGUID());
  49. $user_default_access = ('on' === get_input('allow_user_default_access'));
  50. set_config('allow_user_default_access', $user_default_access, $site->getGUID());
  51. $debug = get_input('debug');
  52. if ($debug) {
  53. set_config('debug', $debug, $site->getGUID());
  54. } else {
  55. unset_config('debug', $site->getGUID());
  56. }
  57. // allow new user registration?
  58. $allow_registration = ('on' === get_input('allow_registration', false));
  59. set_config('allow_registration', $allow_registration, $site->getGUID());
  60. // setup walled garden
  61. $walled_garden = ('on' === get_input('walled_garden', false));
  62. set_config('walled_garden', $walled_garden, $site->getGUID());
  63. if ('on' === get_input('https_login')) {
  64. set_config('https_login', 1, $site->getGUID());
  65. } else {
  66. unset_config('https_login', $site->getGUID());
  67. }
  68. $regenerate_site_secret = get_input('regenerate_site_secret', false);
  69. if ($regenerate_site_secret) {
  70. // if you cancel this even you should present a message to the user
  71. if (elgg_trigger_before_event('regenerate_site_secret', 'system')) {
  72. init_site_secret();
  73. elgg_reset_system_cache();
  74. elgg_trigger_after_event('regenerate_site_secret', 'system');
  75. system_message(elgg_echo('admin:site:secret_regenerated'));
  76. elgg_delete_admin_notice('weak_site_key');
  77. }
  78. }
  79. if ($site->save()) {
  80. system_message(elgg_echo("admin:configuration:success"));
  81. } else {
  82. register_error(elgg_echo("admin:configuration:fail"));
  83. }
  84. forward(REFERER);