1 | <?php |
||
2 | |||
3 | // phpcs:ignoreFile |
||
4 | |||
5 | declare(strict_types=1); |
||
6 | |||
7 | require_once 'functions.php'; |
||
8 | |||
9 | if (PHP_SAPI !== 'cli') { |
||
10 | $uri = $_SERVER['REQUEST_URI'] ?? ''; |
||
11 | $publicDir = getenv('CONIA_DOCUMENT_ROOT'); |
||
12 | $url = urldecode(parse_url($uri, PHP_URL_PATH)); |
||
13 | |||
14 | $start = microtime(true); |
||
15 | |||
16 | if ($publicDir) { |
||
17 | // serve existing files as-is |
||
18 | if (is_file($publicDir . $url)) { |
||
19 | /** @psalm-suppress PossiblyInvalidArgument */ |
||
20 | serverEcho(http_response_code() ?: 0, $uri, microtime(true) - $start); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
21 | |||
22 | return false; |
||
23 | } |
||
24 | |||
25 | if (is_file($publicDir . rtrim($url, '/') . '/index.html')) { |
||
26 | /** @psalm-suppress PossiblyInvalidArgument */ |
||
27 | serverEcho(http_response_code() ?: 0, $uri, microtime(true) - $start); |
||
28 | |||
29 | return false; |
||
30 | } |
||
31 | |||
32 | if ($url === '/phpinfo') { |
||
33 | echo phpinfo(); |
||
34 | /** @psalm-suppress PossiblyInvalidArgument */ |
||
35 | serverEcho(http_response_code() ?: 0, $uri, microtime(true) - $start); |
||
36 | |||
37 | return true; |
||
38 | } |
||
39 | |||
40 | $_SERVER['SCRIPT_NAME'] = 'index.php'; |
||
41 | |||
42 | /** @psalm-suppress UnresolvableInclude, MixedAssignment */ |
||
43 | $response = require_once $publicDir . '/index.php'; |
||
44 | |||
45 | if ($response) { |
||
46 | /** @psalm-suppress MixedMethodCall, MixedArgument */ |
||
47 | serverEcho($response->getStatusCode(), $uri, microtime(true) - $start); |
||
48 | } |
||
49 | |||
50 | return true; |
||
51 | } |
||
52 | |||
53 | return false; |
||
54 | } |
||
55 |