<?php
use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
//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]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
// if ($request->getPathInfo() != "" && $request->getPathInfo() != "/") {
// $expl = explode('/', $request->getPathInfo());
// array_shift($expl);
// if (in_array($expl[0], ['en', 'ru', 'lv', 'se', 'no', 'lt'])) {
// $_REQUEST['cultureKey'] = $expl[0];
// array_shift($expl);
// if (count($expl) > 0 && !empty($expl[0]) ) {
// $_REQUEST['q'] = join('/', $expl);
// $page = substr( $_REQUEST['q'], 0, 5 ) === "page/";
// $webinar = substr( $_REQUEST['q'], 0, 8 ) === "webinar/";
// if ($_REQUEST['q'] != 'form/contact_ajax' && !$page && !$webinar) {
// include(dirname(__FILE__) . '/index.php');
// return;
// }
// }
// }
// }
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);