index.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of GNU social - https://www.gnu.org/software/social
  4. *
  5. * GNU social is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GNU social is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * GNU social's true web entry point, bootstraps Symfony's configuration and instantiates our Kernel
  20. *
  21. * @package GNUsocial
  22. * @category Framework
  23. *
  24. * @author Hugo Sales <hugo@fc.up.pt>
  25. * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
  26. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  27. */
  28. use App\Kernel;
  29. use Symfony\Component\ErrorHandler\Debug;
  30. use Symfony\Component\HttpFoundation\Request;
  31. require dirname(__DIR__) . '/config/bootstrap.php';
  32. if ($_SERVER['APP_DEBUG']) {
  33. umask(0000);
  34. Debug::enable();
  35. }
  36. if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
  37. Request::setTrustedProxies(\explode(',', $trustedProxies),
  38. Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
  39. }
  40. if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
  41. Request::setTrustedHosts([$trustedHosts]);
  42. }
  43. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  44. $request = Request::createFromGlobals();
  45. $response = $kernel->handle($request);
  46. $response->send();
  47. $kernel->terminate($request, $response);