<?php
ini_set("log_errors", 1);
ini_set("error_log", __DIR__."/../var/log/php-error.log");
putenv('LC_ALL=pl_PL');
setlocale(LC_ALL, 'pl_PL');
use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
ini_set('memory_limit', '2G');
error_reporting(E_ALL);
ini_set('display_errors', 1);
umask(0000);
Debug::enable();
}
if($_SERVER['SERVER_NAME'] === 'api.autopunkt.pl') {
if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off") {
$location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $location);
exit;
}
}
else {
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
$_SERVER['REQUEST_SCHEME'] = 'https';
if(isset($_SERVER['SCRIPT_URI'])) {
$_SERVER['SCRIPT_URI'] = str_replace('http','https', $_SERVER['SCRIPT_URI']);
}
}
if (in_array(@$_SERVER['REMOTE_ADDR'], ['85.14.122.42', '93.105.223.55', '127.0.0.1', '::1'], true)) {
$_SERVER['APP_ENV'] = 'dev';
$_SERVER['APP_DEBUG'] = 1;
}
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();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);