<?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;
include __DIR__ . "/../vendor/autoload.php";
header("X-Frame-Options: SAMEORIGIN");
// only allow GET,POST if not admin
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
if (substr($_SERVER['REQUEST_URI'], 0, 6) == '/admin') {
header("Access-Control-Allow-Methods: *");
} else {
header("Access-Control-Allow-Methods: GET,POST");
}
header("Allow: *");
if (substr($_SERVER['REQUEST_URI'], 0, 6) !== '/admin') {
$method = $_SERVER['REQUEST_METHOD'];
if (!in_array($method, ['GET', 'POST'])) {
if ($method == 'OPTIONS') {
die();
} else {
header($_SERVER["SERVER_PROTOCOL"]." 405 Method Not Allowed", true, 405);
exit();
}
}
}
// if (substr($_SERVER['REQUEST_URI'], 0, 31) == '/admin/external_adminer/adminer'
// || substr($_SERVER['REQUEST_URI'], 0, 24) == '/admin/misc/fileexplorer'
// ) {
// header("403 Forbidden", true, 403);
// exit();
// }
\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);