aboutsummaryrefslogtreecommitdiff
path: root/_site/rewrites/assets.php
blob: bd2baac0d5342e66f43d41acf50648cd0903f317 (plain)
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
<?php

if (!isset($_GET['i'])) {
    die();
}

if (strpos($_GET['i'], ".") !== false && strpos($_GET['i'], "\\") !== false) {
    die();
}

if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/../_posts/assets/" . $_GET['i']) || !is_file($_SERVER['DOCUMENT_ROOT'] . "/../_posts/assets/" . $_GET['i'])) {
    die();
}

$file = $_SERVER['DOCUMENT_ROOT'] . "/../_posts/assets/" . $_GET['i'];

header('Content-Type: ' . mime_content_type($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
readfile($file);
exit;