bootstrap.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types = 1);
  3. use App\Core\ModuleManager;
  4. use Symfony\Component\Dotenv\Dotenv;
  5. $loader = require \dirname(__DIR__) . '/vendor/autoload.php';
  6. // Load cached env vars if the .env.local.php file exists
  7. // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
  8. if (\is_array($env = @include \dirname(__DIR__) . '/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
  9. foreach ($env as $k => $v) {
  10. $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && !str_starts_with($k, 'HTTP_') ? $_SERVER[$k] : $v);
  11. }
  12. } elseif (!class_exists(Dotenv::class)) {
  13. throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
  14. } else {
  15. // load all the .env files
  16. (new Dotenv())->loadEnv(\dirname(__DIR__) . '/.env');
  17. }
  18. $_SERVER += $_ENV;
  19. $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
  20. $_SERVER['APP_DEBUG'] ??= $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
  21. $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
  22. \define('INSTALLDIR', \dirname(__DIR__));
  23. \define('SRCDIR', INSTALLDIR . '/src');
  24. \define('PUBLICDIR', INSTALLDIR . '/public');
  25. \define('GNUSOCIAL_ENGINE_NAME', 'GNU social');
  26. // MERGE Change to https://gnu.io/social/
  27. \define('GNUSOCIAL_PROJECT_URL', 'https://gnusocial.rocks/');
  28. \define('GNUSOCIAL_ENGINE_URL', GNUSOCIAL_PROJECT_URL);
  29. // MERGE Change to https://git.gnu.io/gnu/gnu-social
  30. \define('GNUSOCIAL_REPOSITORY_URL', 'https://code.undefinedhackers.net/GNUsocial/gnu-social');
  31. // Current base version, major.minor.patch
  32. \define('GNUSOCIAL_BASE_VERSION', '3.0.0');
  33. // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
  34. \define('GNUSOCIAL_LIFECYCLE', 'dev');
  35. \define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
  36. \define('GNUSOCIAL_CODENAME', 'Big bang');
  37. \define('MODULE_CACHE_FILE', INSTALLDIR . '/var/cache/module_manager.php');
  38. /**
  39. * StatusNet had this string as valid path characters: '\pN\pL\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\'\@'
  40. * Some of those characters can be troublesome when auto-linking plain text. Such as "http://some.com/)"
  41. * URL encoding should be used whenever a weird character is used, the following strings are not definitive.
  42. */
  43. \define('URL_REGEX_VALID_PATH_CHARS', '\pN\pL\,\!\.\:\-\_\+\/\@\=\;\%\~\*\(\)');
  44. \define('URL_REGEX_VALID_QSTRING_CHARS', URL_REGEX_VALID_PATH_CHARS . '\&');
  45. \define('URL_REGEX_VALID_FRAGMENT_CHARS', URL_REGEX_VALID_QSTRING_CHARS . '\?\#');
  46. \define('URL_REGEX_EXCLUDED_END_CHARS', '\?\.\,\!\#\:\''); // don't include these if they are directly after a URL
  47. \define('URL_REGEX_DOMAIN_NAME', '(?:(?!-)[A-Za-z0-9\-]{1,63}(?<!-)\.)+[A-Za-z]{2,10}');
  48. // Work internally in UTC
  49. date_default_timezone_set('UTC');
  50. // Work internally with UTF-8
  51. mb_internal_encoding('UTF-8');
  52. ModuleManager::setLoader($loader);