bootstrap.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. // -- Environment setup --------------------------------------------------------
  3. // Load the core KO7 class
  4. require SYSPATH.'classes/KO7/Core'.EXT;
  5. if (is_file(APPPATH.'classes/KO7'.EXT))
  6. {
  7. // Application extends the core
  8. require APPPATH.'classes/KO7'.EXT;
  9. }
  10. else
  11. {
  12. // Load empty core extension
  13. require SYSPATH.'classes/KO7'.EXT;
  14. }
  15. /**
  16. * Set the default time zone.
  17. *
  18. * @link http://koseven.dev/guide/using.configuration
  19. * @link http://www.php.net/manual/timezones
  20. */
  21. date_default_timezone_set('America/Chicago');
  22. /**
  23. * Set the default locale.
  24. *
  25. * @link http://koseven.dev/guide/using.configuration
  26. * @link http://www.php.net/manual/function.setlocale
  27. */
  28. setlocale(LC_ALL, 'en_US.utf-8');
  29. /**
  30. * Enable the KO7 auto-loader.
  31. *
  32. * @link http://koseven.dev/guide/using.autoloading
  33. * @link http://www.php.net/manual/function.spl-autoload-register
  34. */
  35. spl_autoload_register(['KO7', 'auto_load']);
  36. /**
  37. * Optionally, you can enable a compatibility auto-loader for use with
  38. * older modules that have not been updated for PSR-0.
  39. *
  40. * It is recommended to not enable this unless absolutely necessary.
  41. */
  42. // spl_autoload_register(array('KO7', 'auto_load_lowercase'));
  43. /**
  44. * Enable the KO7 auto-loader for unserialization.
  45. *
  46. * @link http://www.php.net/manual/function.spl-autoload-call
  47. * @link http://www.php.net/manual/var.configuration#unserialize-callback-func
  48. */
  49. ini_set('unserialize_callback_func', 'spl_autoload_call');
  50. /**
  51. * Enable Custom Kohana Classes for Backwards Compatibility
  52. */
  53. if (KO7::$compatibility AND is_file(APPPATH.'classes/Kohana'.EXT))
  54. {
  55. // Application extends the core
  56. require APPPATH.'classes/Kohana'.EXT;
  57. }
  58. /**
  59. * Enable composer autoload libraries
  60. */
  61. if (is_file(DOCROOT.'vendor/autoload.php'))
  62. {
  63. require DOCROOT.'vendor/autoload.php';
  64. }
  65. /**
  66. * Set the mb_substitute_character to "none"
  67. *
  68. * @link http://www.php.net/manual/function.mb-substitute-character.php
  69. */
  70. mb_substitute_character('none');
  71. // -- Configuration and initialization -----------------------------------------
  72. /**
  73. * Set the default language
  74. */
  75. I18n::lang('en-us');
  76. if (isset($_SERVER['SERVER_PROTOCOL']))
  77. {
  78. // Replace the default protocol.
  79. HTTP::$protocol = $_SERVER['SERVER_PROTOCOL'];
  80. }
  81. /**
  82. * Set KO7::$environment if a 'KOSEVEN_ENV' environment variable has been supplied.
  83. *
  84. * Note: If you supply an invalid environment name, a PHP warning will be thrown
  85. * saying "Couldn't find constant KO7::<INVALID_ENV_NAME>"
  86. */
  87. if (isset($_SERVER['KOSEVEN_ENV']))
  88. {
  89. KO7::$environment = constant('KO7::'.strtoupper($_SERVER['KOSEVEN_ENV']));
  90. }
  91. /**
  92. * Initialize KO7, setting the default options.
  93. *
  94. * The following options are available:
  95. *
  96. * - string base_url path, and optionally domain, of your application NULL
  97. * - string index_file name of your index file, usually "index.php", if set to FALSE uses clean URLS index.php
  98. * - string charset internal character set used for input and output utf-8
  99. * - string cache_dir set the internal cache directory APPPATH/cache
  100. * - integer cache_life lifetime, in seconds, of items cached 60
  101. * - boolean errors enable or disable error handling TRUE
  102. * - boolean profile enable or disable internal profiling TRUE
  103. * - boolean caching enable or disable internal caching FALSE
  104. * - boolean expose set the X-Powered-By header FALSE
  105. */
  106. KO7::init([
  107. 'base_url' => '/',
  108. ]);
  109. /**
  110. * Attach the file write to logging. Multiple writers are supported.
  111. */
  112. KO7::$log->attach(new Log_File(APPPATH.'logs'));
  113. /**
  114. * Attach a file reader to config. Multiple readers are supported.
  115. */
  116. KO7::$config->attach(new Config_File);
  117. /**
  118. * Enable modules. Modules are referenced by a relative or absolute path.
  119. */
  120. $modules = array(
  121. // 'auth' => MODPATH.'auth', // Basic authentication
  122. // 'cache' => MODPATH.'cache', // Caching with multiple backends
  123. // 'codebench' => MODPATH.'codebench', // Benchmarking tool
  124. // 'database' => MODPATH.'database', // Database access
  125. // 'encrypt' => MODPATH.'encrypt', // Encryption support
  126. // 'image' => MODPATH.'image', // Image manipulation
  127. // 'minion' => MODPATH.'minion', // CLI Tasks
  128. // 'orm' => MODPATH.'orm', // Object Relationship Mapping
  129. // 'pagination' => MODPATH.'pagination', // Pagination
  130. // 'unittest' => MODPATH.'unittest', // Unit testing
  131. // 'userguide' => MODPATH.'userguide', // User guide and API documentation
  132. );
  133. /**
  134. * Load legacy Module for Kohana Support
  135. */
  136. if (KO7::$compatibility)
  137. {
  138. $modules = ['kohana' => MODPATH.'kohana'] + $modules;
  139. }
  140. /**
  141. * Initialize Modules
  142. */
  143. KO7::modules($modules);
  144. /**
  145. * Cookie Salt
  146. * @see http://koseven.dev/3.3/guide/ko7/cookies
  147. *
  148. * If you have not defined a cookie salt in your Cookie class then
  149. * uncomment the line below and define a preferrably long salt.
  150. */
  151. // Cookie::$salt = NULL;
  152. /**
  153. * Cookie HttpOnly directive
  154. * If set to true, disallows cookies to be accessed from JavaScript
  155. * @see https://en.wikipedia.org/wiki/Session_hijacking
  156. */
  157. // Cookie::$httponly = TRUE;
  158. /**
  159. * If website runs on secure protocol HTTPS, allows cookies only to be transmitted
  160. * via HTTPS.
  161. * Warning: HSTS must also be enabled in .htaccess, otherwise first request
  162. * to http://www.example.com will still reveal this cookie
  163. */
  164. // Cookie::$secure = isset($_SERVER['HTTPS']) AND $_SERVER['HTTPS'] == 'on' ? TRUE : FALSE;
  165. /**
  166. * Set the routes. Each route must have a minimum of a name, a URI and a set of
  167. * defaults for the URI.
  168. */
  169. Route::set('default', '(<controller>(/<action>(/<id>)))')
  170. ->defaults([
  171. 'controller' => 'welcome',
  172. 'action' => 'index',
  173. ]);