-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathindex.php
36 lines (29 loc) · 1.23 KB
/
index.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
<?php
// Redirect to HTTPS if HTTPS_REDIRECT is defined in environment variables
if (getenv('ADMINER_HTTPS_REDIRECT') === 'true' && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off')) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
define('ASSETS_VERSION', '1');
if (empty($_GET['file'])) {
ob_start(function ($s) {
return preg_replace_callback('#(<(link|script)\s[^>]*(href|src)=")(adminer\.css|static/.+)(\?v=\d+)?"#U', function ($m) {
return $m[1] . '?file=' . urlencode($m[4]) . '&version=' . ASSETS_VERSION . '"';
}, $s);
}, 4096);
} elseif (preg_match('#^(default|adminer|static(/\w[\w.-]*)+)\.(\w+)\z#', $_GET['file'], $m)) {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('HTTP/1.1 304 Not Modified');
exit;
}
header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('1 month')) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
$types = ['css' => 'text/css', 'js' => 'text/javascript', 'gif' => 'image/gif', 'png' => 'image/png'];
if (isset($types[$m[3]])) {
header('Content-Type: ' . $types[$m[3]]);
}
@readfile(__DIR__ . '/' . $_GET['file']);
exit;
}
include __DIR__ . '/adminer.php';