bootstrap.php 5.3 KB

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