index.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. define('EXT', '.php');
  26. /**
  27. * Set the PHP error reporting level. If you set this in php.ini, you remove this.
  28. * @link http://www.php.net/manual/errorfunc.configuration#ini.error-reporting
  29. *
  30. * When developing your application, it is highly recommended to enable notices
  31. * and warnings. Enable them by using: E_ALL
  32. *
  33. * In a production environment, it is safe to ignore notices. Disable them by
  34. * using: E_ALL & ~E_NOTICE
  35. *
  36. * When using a legacy application, it is recommended to disable deprecated
  37. * notices. Disable with: E_ALL & ~E_DEPRECATED
  38. */
  39. error_reporting(E_ALL);
  40. /**
  41. * End of standard configuration! Changing any of the code below should only be
  42. * attempted by those with a working knowledge of KO7 internals.
  43. */
  44. // Set the full path to the docroot
  45. define('DOCROOT', dirname(__DIR__).DIRECTORY_SEPARATOR);
  46. // Make the application relative to the docroot, for symlink'd index.php
  47. if ( ! is_dir($application) && is_dir(DOCROOT.$application))
  48. $application = DOCROOT.$application;
  49. // Make the modules relative to the docroot, for symlink'd index.php
  50. if ( ! is_dir($modules) && is_dir(DOCROOT.$modules))
  51. $modules = DOCROOT.$modules;
  52. // Make the system relative to the docroot, for symlink'd index.php
  53. if ( ! is_dir($system) && is_dir(DOCROOT.$system))
  54. $system = DOCROOT.$system;
  55. // Make the public relative to the docroot, for symlink'd index.php
  56. if ( ! is_dir($public) && is_dir(DOCROOT.$public))
  57. $public = DOCROOT.$public;
  58. // Define the absolute paths for configured directories
  59. define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
  60. define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
  61. define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
  62. define('PUBPATH', realpath($public).DIRECTORY_SEPARATOR);
  63. // Clean up the configuration vars
  64. unset($application, $modules, $system, $public);
  65. if (file_exists('install'.EXT))
  66. {
  67. // Load the installation check
  68. return include 'install'.EXT;
  69. }
  70. /**
  71. * Define the start time of the application, used for profiling.
  72. */
  73. if ( ! defined('KO7_START_TIME'))
  74. {
  75. define('KO7_START_TIME', microtime(TRUE));
  76. }
  77. /**
  78. * Define the memory usage at the start of the application, used for profiling.
  79. */
  80. if ( ! defined('KO7_START_MEMORY'))
  81. {
  82. define('KO7_START_MEMORY', memory_get_usage());
  83. }
  84. // Bootstrap the application
  85. require APPPATH.'bootstrap'.EXT;
  86. if (PHP_SAPI === 'cli') // Try and load minion
  87. {
  88. class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.');
  89. set_exception_handler(['Minion_Exception', 'handler']);
  90. Minion_Task::factory(Minion_CLI::options())->execute();
  91. }
  92. else
  93. {
  94. /**
  95. * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
  96. * If no source is specified, the URI will be automatically detected.
  97. */
  98. echo Request::factory(TRUE, [], FALSE)
  99. ->execute()
  100. ->send_headers(TRUE)
  101. ->body();
  102. }