-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
stub.php
92 lines (76 loc) · 2.74 KB
/
stub.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
error_reporting(-1);
if (function_exists('ini_set')) {
@ini_set('display_errors', 1);
@ini_set('display_startup_errors', 1);
@ini_set('opcache.enable_cli', '0');
if (isset($_GET['opcache_reset']) && $_GET['opcache_reset'] === md5(Phar::running(false))) {
$GLOBALS['opcacheEnabled'] = @ini_get('opcache.enable');
} else {
$GLOBALS['opcacheEnabled'] = @ini_set('opcache.enable', '0');
}
}
if (PHP_VERSION_ID < 50509) {
die('You are using PHP '.PHP_VERSION." but you need least PHP 5.5.9 to run the Contao Manager.\n");
}
if (!extension_loaded('Phar')) {
echo 'PHP\'s phar extension is missing. Contao Manager requires it to run. Enable the extension or recompile php without --disable-phar then try again.' . PHP_EOL;
exit(1);
}
if (PHP_VERSION_ID < 70205) {
Phar::mapPhar('contao-manager.phar');
@include 'phar://contao-manager.phar/downgrade.php';
die('<script>setTimeout(function() { window.location.reload(true) }, 1000)</script>');
}
if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
date_default_timezone_set(@date_default_timezone_get());
}
if ('cli' === PHP_SAPI || !isset($_SERVER['REQUEST_URI'])) {
if (isset($_SERVER['argv'][1]) && 'test' === $_SERVER['argv'][1]) {
die(json_encode(['version' => PHP_VERSION, 'version_id' => PHP_VERSION_ID, 'sapi' => PHP_SAPI]));
}
Phar::mapPhar('contao-manager.phar');
require 'phar://contao-manager.phar/api/console';
} else {
function rewrites()
{
// The function argument is unreliable across servers, Nginx for example is always empty
list(,$url) = explode(basename(__FILE__), $_SERVER['REQUEST_URI'], 2);
if (strpos($url, '..')) {
return false;
}
if ('' === $url) {
header('Location: /'.basename(__FILE__).'/');
exit;
}
if (0 === strpos($url, '/api/')) {
return '/dist/api.php'.$url;
}
if (!empty($url) && is_file('phar://'.__FILE__.'/dist'.$url)) {
return '/dist'.$url;
}
return '/dist/index.html';
}
Phar::webPhar(
null,
'index.html',
null,
array(
'log' => 'text/plain',
'txt' => 'text/plain',
'php' => Phar::PHP, // parse as PHP
'css' => 'text/css',
'gif' => 'image/gif',
'html' => 'text/html',
'ico' => 'image/x-ico',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'js' => 'application/x-javascript',
'png' => 'image/png',
'svg' => 'image/svg+xml',
'json' => 'application/json'
),
'rewrites'
);
}
__HALT_COMPILER();