-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathapp.php
52 lines (41 loc) · 1.51 KB
/
app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
use Composer\Autoload\ClassLoader;
use Symfony\Component\HttpFoundation\Request;
$isDevEnv = isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'dev';
$isTestEnv = isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'test';
if ($_SERVER['HTTP_HOST'] === 'afup.dev' || $isDevEnv || $isTestEnv) {
if (!$isDevEnv && !$isTestEnv
&&
(
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1', '192.168.42.1']) && php_sapi_name() !== 'cli-server'
)
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check ' . basename(__FILE__) . ' for more information.');
}
/** @var ClassLoader $loader */
$loader = require __DIR__ . '/../vendor/autoload.php';
$kernel = $isDevEnv ? new AppKernel('dev', true) : new AppKernel('test', true);
} else {
/** @var ClassLoader $loader */
$loader = require __DIR__ . '/../vendor/autoload.php';
$kernel = new AppKernel('prod', false);
}
$request = Request::createFromGlobals();
$proxies = [
'127.0.0.1',
];
$ccReverseProxyIps = getenv('CC_REVERSE_PROXY_IPS');
if (false !== $ccReverseProxyIps) {
$proxies = array_merge($proxies, explode(',', $ccReverseProxyIps));
}
Request::setTrustedProxies(
$proxies,
Request::HEADER_X_FORWARDED_ALL
);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);