<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/
use Pimcore\Tool;
use Symfony\Component\HttpFoundation\Request;
#### Elements debugging - start ####
####################################
if (php_sapi_name() != "cli") {
//If you are behind a load balancer you have to use $_SERVER["HTTP_X_FORWARDED_FOR"]
//Do not active check for HTTP_X_FORWARDED_FOR if you are not behind a load balancer because sensitive data could be exposed!
#$remoteIpAddress = $_SERVER["HTTP_X_FORWARDED_FOR"] ?? '';
$remoteIpAddress = $_SERVER["REMOTE_ADDR"] ?? '';
$privilegedIpAddresses = [
'89.26.34.65', //Elements Devs
'89.26.34.74', //Elements Pms
'192.80.196.1'
];
$profilingPrivilegedIpAddresses = [
'89.26.34.65', //Elements Devs
];
if (in_array($remoteIpAddress, $privilegedIpAddresses) || (isset($_ENV["APP_DEBUG_COOKIE"]) && $_ENV["APP_DEBUG_COOKIE"]) ) {
if ($_COOKIE["XDEBUG_SESSION"] ?? null) {
$_ENV["APP_DEBUG"] = $_SERVER["APP_DEBUG"] = true; //display errors and send E-Mails to dev email addresses
error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
}
if (in_array($remoteIpAddress, $privilegedIpAddresses) && ($_COOKIE["XDEBUG_PROFILE"] ?? null)) {
$_ENV["APP_ENV"] = $_SERVER["APP_ENV"] = "dev"; //switch to dev environment to display profiler - only enable it if you really need it, because it exposes sensitive data
}
}
}
##################################
#### Elements debugging - end ####
##################################
include __DIR__ . "/../vendor/autoload.php";
\Pimcore\Bootstrap::setProjectRoot();
\Pimcore\Bootstrap::bootstrap();
$request = Request::createFromGlobals();
// set current request as property on tool as there's no
// request stack available yet
Tool::setCurrentRequest($request);
/** @var \Pimcore\Kernel $kernel */
$kernel = \Pimcore\Bootstrap::kernel();
// reset current request - will be read from request stack from now on
Tool::setCurrentRequest(null);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);