<?php
error_reporting(E_ALL ^ E_WARNING);
use Symfony\Component\HttpFoundation\Request;
use Dotenv\Dotenv;
use Symfony\Component\Debug\Debug;
require __DIR__.'/../vendor/autoload.php';
if (PHP_VERSION_ID < 70000) {
include_once __DIR__.'/../var/bootstrap.php.cache';
}
// Get the document root
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
$pathToEnv = dirname($documentRoot).DIRECTORY_SEPARATOR.'_secrets'.DIRECTORY_SEPARATOR;
// Load the env variables to ensure parameters are set
if (!file_exists($pathToEnv.'.env')) {
die('Something very wrong happened');
exit;
// @todo - make website down or maintainance
}
$dotenv = Dotenv::createImmutable($pathToEnv, '.env');
$dotenv->load();
$kernel = null;
if ($_ENV['IS_MAINTAINANCE_MODE'] == 1) {
if (strpos($_ENV['BACKEND_ALLOWED_IPS'], $_SERVER['REMOTE_ADDR']) === false) {
echo require_once 'maintainance.html';
exit;
}
}
$currentHost = $_SERVER['HTTP_HOST'];
if (in_array($currentHost, ['dev-social.online', 'dev1-social.online'])) {
$allowedIps = explode(',',$_SERVER['BACKEND_ALLOWED_IPS']);
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if(!in_array($ip,$allowedIps)) {
exit('<h1 style="text-align: center;margin-top: 20%;margin-bottom: 0;">^.^</h1><h1 style="text-align: center;margin-top: 0;"> O </h1>');
}
}
if ($_ENV['APP_DEBUG'] == 1) {
Debug::enable(E_ALL ^ E_WARNING);
$kernel = new AppKernel('dev', true);
} else {
$kernel = new AppKernel('prod', false);
}
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
}
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);