Web Interfaces of PROSUME

bootstrap.php 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 0.10.8
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. /*
  16. * Configure paths required to find CakePHP + general filepath constants
  17. */
  18. require __DIR__ . '/paths.php';
  19. /*
  20. * Bootstrap CakePHP.
  21. *
  22. * Does the various bits of setup that CakePHP needs to do.
  23. * This includes:
  24. *
  25. * - Registering the CakePHP autoloader.
  26. * - Setting the default application paths.
  27. */
  28. require CORE_PATH . 'config' . DS . 'bootstrap.php';
  29. use Cake\Cache\Cache;
  30. use Cake\Console\ConsoleErrorHandler;
  31. use Cake\Core\Configure;
  32. use Cake\Core\Configure\Engine\PhpConfig;
  33. use Cake\Core\Plugin;
  34. use Cake\Database\Type;
  35. use Cake\Datasource\ConnectionManager;
  36. use Cake\Error\ErrorHandler;
  37. use Cake\Http\ServerRequest;
  38. use Cake\Log\Log;
  39. use Cake\Mailer\Email;
  40. use Cake\Mailer\TransportFactory;
  41. use Cake\Utility\Inflector;
  42. use Cake\Utility\Security;
  43. /**
  44. * Uncomment block of code below if you want to use `.env` file during development.
  45. * You should copy `config/.env.default to `config/.env` and set/modify the
  46. * variables as required.
  47. *
  48. * It is HIGHLY discouraged to use a .env file in production, due to security risks
  49. * and decreased performance on each request. The purpose of the .env file is to emulate
  50. * the presence of the environment variables like they would be present in production.
  51. */
  52. // if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
  53. // $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
  54. // $dotenv->parse()
  55. // ->putenv()
  56. // ->toEnv()
  57. // ->toServer();
  58. // }
  59. /*
  60. * Read configuration file and inject configuration into various
  61. * CakePHP classes.
  62. *
  63. * By default there is only one configuration file. It is often a good
  64. * idea to create multiple configuration files, and separate the configuration
  65. * that changes from configuration that does not. This makes deployment simpler.
  66. */
  67. try {
  68. Configure::config('default', new PhpConfig());
  69. Configure::load('app', 'default', false);
  70. } catch (\Exception $e) {
  71. exit($e->getMessage() . "\n");
  72. }
  73. /*
  74. * Load an environment local configuration file.
  75. * You can use a file like app_local.php to provide local overrides to your
  76. * shared configuration.
  77. */
  78. //Configure::load('app_local', 'default');
  79. /*
  80. * When debug = true the metadata cache should only last
  81. * for a short time.
  82. */
  83. if (Configure::read('debug')) {
  84. Configure::write('Cache._cake_model_.duration', '+2 minutes');
  85. Configure::write('Cache._cake_core_.duration', '+2 minutes');
  86. // disable router cache during development
  87. Configure::write('Cache._cake_routes_.duration', '+2 seconds');
  88. }
  89. /*
  90. * Set the default server timezone. Using UTC makes time calculations / conversions easier.
  91. * Check http://php.net/manual/en/timezones.php for list of valid timezone strings.
  92. */
  93. date_default_timezone_set(Configure::read('App.defaultTimezone'));
  94. /*
  95. * Configure the mbstring extension to use the correct encoding.
  96. */
  97. mb_internal_encoding(Configure::read('App.encoding'));
  98. /*
  99. * Set the default locale. This controls how dates, number and currency is
  100. * formatted and sets the default language to use for translations.
  101. */
  102. ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
  103. /*
  104. * Register application error and exception handlers.
  105. */
  106. $isCli = PHP_SAPI === 'cli';
  107. if ($isCli) {
  108. (new ConsoleErrorHandler(Configure::read('Error')))->register();
  109. } else {
  110. (new ErrorHandler(Configure::read('Error')))->register();
  111. }
  112. /*
  113. * Include the CLI bootstrap overrides.
  114. */
  115. if ($isCli) {
  116. require __DIR__ . '/bootstrap_cli.php';
  117. }
  118. /*
  119. * Set the full base URL.
  120. * This URL is used as the base of all absolute links.
  121. *
  122. * If you define fullBaseUrl in your config file you can remove this.
  123. */
  124. if (!Configure::read('App.fullBaseUrl')) {
  125. $s = null;
  126. if (env('HTTPS')) {
  127. $s = 's';
  128. }
  129. $httpHost = env('HTTP_HOST');
  130. if (isset($httpHost)) {
  131. Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
  132. }
  133. unset($httpHost, $s);
  134. }
  135. Cache::setConfig(Configure::consume('Cache'));
  136. ConnectionManager::setConfig(Configure::consume('Datasources'));
  137. TransportFactory::setConfig(Configure::consume('EmailTransport'));
  138. Email::setConfig(Configure::consume('Email'));
  139. Log::setConfig(Configure::consume('Log'));
  140. Security::setSalt(Configure::consume('Security.salt'));
  141. /*
  142. * The default crypto extension in 3.0 is OpenSSL.
  143. * If you are migrating from 2.x uncomment this code to
  144. * use a more compatible Mcrypt based implementation
  145. */
  146. //Security::engine(new \Cake\Utility\Crypto\Mcrypt());
  147. /*
  148. * Setup detectors for mobile and tablet.
  149. */
  150. ServerRequest::addDetector('mobile', function ($request) {
  151. $detector = new \Detection\MobileDetect();
  152. return $detector->isMobile();
  153. });
  154. ServerRequest::addDetector('tablet', function ($request) {
  155. $detector = new \Detection\MobileDetect();
  156. return $detector->isTablet();
  157. });
  158. /*
  159. * Enable immutable time objects in the ORM.
  160. *
  161. * You can enable default locale format parsing by adding calls
  162. * to `useLocaleParser()`. This enables the automatic conversion of
  163. * locale specific date formats. For details see
  164. * @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
  165. */
  166. Type::build('time')
  167. ->useImmutable();
  168. Type::build('date')
  169. ->useImmutable();
  170. Type::build('datetime')
  171. ->useImmutable();
  172. Type::build('timestamp')
  173. ->useImmutable();
  174. /*
  175. * Custom Inflector rules, can be set to correctly pluralize or singularize
  176. * table, model, controller names or whatever other string is passed to the
  177. * inflection functions.
  178. */
  179. //Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
  180. //Inflector::rules('irregular', ['red' => 'redlings']);
  181. //Inflector::rules('uninflected', ['dontinflectme']);
  182. //Inflector::rules('transliteration', ['/å/' => 'aa']);