PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/application/bootstrap.php

https://bitbucket.org/chrispiechowicz/zepto
PHP | 167 lines | 65 code | 26 blank | 76 comment | 7 complexity | 8adde97fbad7baecab73081454d236d5 MD5 | raw file
Possible License(s): LGPL-2.1, MIT, BSD-3-Clause
  1. <?php defined('SYSPATH') or die('No direct script access.');
  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. * Enable the Kohana auto-loader.
  17. *
  18. * @link http://kohanaframework.org/guide/using.autoloading
  19. * @link http://www.php.net/manual/function.spl-autoload-register
  20. */
  21. spl_autoload_register(array('Kohana', 'auto_load'));
  22. /* load default config */
  23. require_once(APPPATH."config.php");
  24. /**
  25. * Set the default time zone.
  26. *
  27. * @link http://kohanaframework.org/guide/using.configuration
  28. * @link http://www.php.net/manual/timezones
  29. */
  30. if (Config::sys("locale/timezone") != "###TIMEZONE###")
  31. date_default_timezone_set(Config::sys("locale/timezone"));
  32. /**
  33. * Set the default locale.
  34. *
  35. * @link http://kohanaframework.org/guide/using.configuration
  36. * @link http://www.php.net/manual/function.setlocale
  37. *
  38. */
  39. setlocale(LC_ALL, Config::sys("locale/language").'.utf-8');
  40. /**
  41. * Optionally, you can enable a compatibility auto-loader for use with
  42. * older modules that have not been updated for PSR-0.
  43. *
  44. * It is recommended to not enable this unless absolutely necessary.
  45. */
  46. //spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
  47. /**
  48. * Enable the Kohana auto-loader for unserialization.
  49. *
  50. * @link http://www.php.net/manual/function.spl-autoload-call
  51. * @link http://www.php.net/manual/var.configuration#unserialize-callback-func
  52. */
  53. ini_set('unserialize_callback_func', 'spl_autoload_call');
  54. // -- Configuration and initialization -----------------------------------------
  55. /**
  56. * Set the default language
  57. */
  58. I18n::lang(Config::sys("locale/default"));
  59. /**
  60. * Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
  61. *
  62. * Note: If you supply an invalid environment name, a PHP warning will be thrown
  63. * saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
  64. */
  65. if (isset($_SERVER['KOHANA_ENV']))
  66. {
  67. Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
  68. }
  69. /**
  70. * Initialize Kohana, setting the default options.
  71. *
  72. * The following options are available:
  73. *
  74. * - string base_url path, and optionally domain, of your application NULL
  75. * - string index_file name of your index file, usually "index.php" index.php
  76. * - string charset internal character set used for input and output utf-8
  77. * - string cache_dir set the internal cache directory APPPATH/cache
  78. * - integer cache_life lifetime, in seconds, of items cached 60
  79. * - boolean errors enable or disable error handling TRUE
  80. * - boolean profile enable or disable internal profiling TRUE
  81. * - boolean caching enable or disable internal caching FALSE
  82. * - boolean expose set the X-Powered-By header FALSE
  83. */
  84. Kohana::init(array(
  85. 'base_url' => parse_url("http://".$_SERVER["SERVER_NAME"], PHP_URL_PATH), // automatically detect folder
  86. 'index_file' => '',
  87. 'caching' => (Kohana::$environment === Kohana::PRODUCTION), // cache only when PRODUCTION
  88. 'profile' => (Kohana::$environment !== Kohana::PRODUCTION), // profile only when DEVELOPMENT
  89. 'errors' => (Kohana::$environment !== Kohana::PRODUCTION) // show errors only when DEVELOPMENT
  90. ));
  91. /**
  92. * Attach the file write to logging. Multiple writers are supported.
  93. */
  94. Kohana::$log->attach(new Log_File(DOCROOT.'logs'));
  95. define("LOG", DOCROOT.'logs/');
  96. /**
  97. * Attach a file reader to config. Multiple readers are supported.
  98. */
  99. Kohana::$config->attach(new Config_File);
  100. /**
  101. * Enable modules. Modules are referenced by a relative or absolute path.
  102. */
  103. Kohana::modules(array(
  104. 'cache' => MODPATH.'cache', // Caching with multiple backends
  105. 'database' => MODPATH.'database', // Database access
  106. 'image' => MODPATH.'image', // Image manipulation
  107. 'pagination' => MODPATH.'pagination', // pagination
  108. 'kotal' => MODPATH.'kotal', // phptal templates
  109. 'captcha' => MODPATH.'captcha', // captcha
  110. ));
  111. /* set default cache method */
  112. //Cache::$default = "apc";
  113. Cache::$default = "file";
  114. /* set cookie salt */
  115. Cookie::$salt = "61ae9c66f03cedc00f37af53ed958abe";
  116. /* set current language */
  117. I18n::lang(Language::current(Config::sys("locale/default")));
  118. /* routes */
  119. if (file_exists(APPPATH."INSTALL"))
  120. {
  121. Route::set('install', '(install)(/<action>)', array('action' => '.+'))
  122. ->defaults(array(
  123. 'controller' => 'Install'
  124. ));
  125. }
  126. else
  127. {
  128. if (Kohana::$environment == Kohana::DEVELOPMENT)
  129. {
  130. require_once(APPPATH."routes_tools.php");
  131. }
  132. require_once(APPPATH."routes_lib.php");
  133. require_once(APPPATH."routes_admin.php");
  134. require_once(APPPATH."routes_site.php");
  135. }
  136. Route::set('default', '<url>', array('url' => '.+'))
  137. ->defaults(array(
  138. 'directory' => 'site',
  139. 'controller' => 'Page',
  140. 'action' => 'page'
  141. ));