SproutCMS

This is the code documentation for the SproutCMS project

source of /index.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14.  
  15. if (version_compare(PHP_VERSION, '5.5') < 0) {
  16. exit('PHP 5.5 or newer required');
  17. }
  18.  
  19. // This file contains a class with a methods for determining the details of
  20. // the very initial environment, prior to the rest of the system coming up
  21. require __DIR__ . '/config/_bootstrap_config.php';
  22.  
  23. // Define the website environment status. This determines how much debugging
  24. // information is provided when errors occur, among other things.
  25. if (file_exists(__DIR__ . '/config/dev_hosts.php')) {
  26. require __DIR__ . '/config/dev_hosts.php';
  27. if (@is_array($dev_hosts)) {
  28. $dev_hosts = array_filter($dev_hosts);
  29. if (in_array(php_uname('n'), $dev_hosts)) {
  30. define('IN_PRODUCTION', false);
  31. }
  32. }
  33. unset($dev_hosts);
  34. }
  35. if (!defined('IN_PRODUCTION')) {
  36. define('IN_PRODUCTION', true);
  37. }
  38.  
  39. // All errors need to be fixed before code goes into production
  40. if (IN_PRODUCTION) {
  41. error_reporting(E_ALL ^ E_NOTICE);
  42. } else {
  43. }
  44.  
  45. // The timezone is explicitly set to avoid warnings from bad server configuration
  46. if (!empty(BootstrapConfig::TIMEZONE)) {
  47. date_default_timezone_set(BootstrapConfig::TIMEZONE);
  48. }
  49.  
  50. /**
  51.  * Occasionally a server is offline - it does not have internet access, but it
  52.  * is still available through the local network. In this case, the following
  53.  * flag should be changed to FALSE. This will disable external services such
  54.  * as remote login.
  55.  */
  56. define('SERVER_ONLINE', true);
  57.  
  58. /**
  59.  * Turning off display_errors will effectively disable Kohana error display
  60.  * and logging. You can turn off Kohana errors in sprout/config/config.php
  61.  */
  62. ini_set('display_errors', true);
  63.  
  64. define('DOCROOT', realpath(__DIR__) . DIRECTORY_SEPARATOR);
  65. define('KOHANA', basename(__FILE__));
  66. define('APPPATH', DOCROOT . 'sprout' . DIRECTORY_SEPARATOR);
  67.  
  68. // If behind a reverse proxy, make the server think it is the proxy server
  69. if (!empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
  70. $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_X_FORWARDED_SERVER'];
  71. }
  72.  
  73. // CLI-server for development.
  74. if (!IN_PRODUCTION and PHP_SAPI === 'cli-server') {
  75. $ok = require APPPATH . 'cli_bootstrap.php';
  76. if ($ok !== null) return $ok;
  77. }
  78.  
  79. if (file_exists(DOCROOT . 'install.php')) {
  80. // Load the installation tests
  81. require DOCROOT . 'install.php';
  82. } else {
  83. // Initialize Kohana
  84. require APPPATH . 'core/Bootstrap.php';
  85. }
  86.