<?php
use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
ob_start();
require dirname(__DIR__).'/config/bootstrap.php';
require_once dirname(__DIR__).'/bb-legacy/app/defines.php';
$isMobile = false;
if (MOBILE_SWITCH_VIEWS) {
$detection = new Mobile_Detect();
$isMobile = ($detection->isMobile() || $detection->isTablet());
}
if (!\defined('USER_TIMEZONE')) {
$GLOBALS['USER_TIMEZONE'] = date_default_timezone_get();
}
define('IS_MOBILE', $isMobile);
/*
* The kernel will always be available globally, allowing you to
* access it from your existing application and through it the
* service container. This allows for introducing new features in
* the existing application.
*/
global $kernel;
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(
explode(',', $trustedProxies),
Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST
);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
ini_set("session.cookie_lifetime", 172800);
ini_set("session.gc_maxlifetime", 172800);
ini_set("session.cookie_domain", PARENT_DOMAIN);
session_name(SESSION_NAME);
session_start();
$session = new Session(new PhpBridgeSessionStorage());
// symfony will now interface with the existing PHP session
$session->start();
$kernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
// Restrict uris depending on environment.
$uri = substr($request->getPathInfo(), 1);
$_GET['url'] = $uri;
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);