bootstrap.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. * The directory in which your application specific resources are located.
  4. * The application directory must contain the bootstrap.php file.
  5. */
  6. $application = 'application';
  7. /**
  8. * The directory in which your modules are located.
  9. */
  10. $modules = 'modules';
  11. /**
  12. * The directory in which the KO7 resources are located. The system
  13. * directory must contain the classes/ko7.php file.
  14. */
  15. $system = 'system';
  16. /**
  17. * The directory in which the KO7 public files are located. The public
  18. * directory contains for example the index.php and .htaccess files.
  19. */
  20. $public = 'public';
  21. /**
  22. * The default extension of resource files. If you change this, all resources
  23. * must be renamed to use the new extension.
  24. *
  25. * @link http://koseven.dev/guide/about.install#ext
  26. */
  27. define('EXT', '.php');
  28. /**
  29. * Set the path to the document root
  30. *
  31. * This assumes that this file is stored 2 levels below the DOCROOT, if you move
  32. * this bootstrap file somewhere else then you'll need to modify this value to
  33. * compensate.
  34. */
  35. define('DOCROOT', dirname(__DIR__, 2).DIRECTORY_SEPARATOR);
  36. /**
  37. * Set the PHP error reporting level. If you set this in php.ini, you remove this.
  38. * @link http://www.php.net/manual/errorfunc.configuration#ini.error-reporting
  39. *
  40. * When developing your application, it is highly recommended to enable notices
  41. * and warnings. Enable them by using: E_ALL
  42. *
  43. * In a production environment, it is safe to ignore notices. Disable them by
  44. * using: E_ALL & ~E_NOTICE
  45. *
  46. * When using a legacy application, it is recommended to disable deprecated
  47. * notices. Disable with: E_ALL & ~E_DEPRECATED
  48. */
  49. error_reporting(E_ALL & ~E_DEPRECATED);
  50. /**
  51. * End of standard configuration! Changing any of the code below should only be
  52. * attempted by those with a working knowledge of KO7 internals.
  53. *
  54. * @link http://koseven.dev/guide/using.configuration
  55. */
  56. // Make the application relative to the docroot
  57. if ( ! is_dir($application) && is_dir(DOCROOT.$application))
  58. {
  59. $application = DOCROOT.$application;
  60. }
  61. // Make the modules relative to the docroot
  62. if ( ! is_dir($modules) && is_dir(DOCROOT.$modules))
  63. {
  64. $modules = DOCROOT.$modules;
  65. }
  66. // Make the system relative to the docroot
  67. if ( ! is_dir($system) && is_dir(DOCROOT.$system))
  68. {
  69. $system = DOCROOT.$system;
  70. }
  71. // Make the public relative to the docroot
  72. if ( ! is_dir($public) && is_dir(DOCROOT.$public))
  73. {
  74. $public = DOCROOT.$public;
  75. }
  76. // Define the absolute paths for configured directories
  77. define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
  78. define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
  79. define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
  80. define('PUBPATH', realpath($public).DIRECTORY_SEPARATOR);
  81. // Clean up the configuration vars
  82. unset($application, $modules, $system, $public);
  83. /**
  84. * Define the start time of the application, used for profiling.
  85. */
  86. if ( ! defined('KO7_START_TIME'))
  87. {
  88. define('KO7_START_TIME', microtime(TRUE));
  89. }
  90. /**
  91. * Define the memory usage at the start of the application, used for profiling.
  92. */
  93. if ( ! defined('KO7_START_MEMORY'))
  94. {
  95. define('KO7_START_MEMORY', memory_get_usage());
  96. }
  97. // Bootstrap the application
  98. require APPPATH.'bootstrap'.EXT;
  99. // Disable output buffering
  100. if (($ob_len = ob_get_length()) !== FALSE)
  101. {
  102. // flush_end on an empty buffer causes headers to be sent. Only flush if needed.
  103. if ($ob_len > 0)
  104. {
  105. ob_end_flush();
  106. }
  107. else
  108. {
  109. ob_end_clean();
  110. }
  111. }
  112. // Enable all modules we can find
  113. $modules_iterator = new DirectoryIterator(MODPATH);
  114. $modules = [];
  115. foreach ($modules_iterator as $module)
  116. {
  117. if ($module->isDir() AND ! $module->isDot())
  118. {
  119. $modules[$module->getFilename()] = MODPATH.$module->getFilename();
  120. }
  121. }
  122. KO7::modules($modules);
  123. unset($modules_iterator, $modules, $module);