2022-10-12 12:35:23 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-06 02:26:21 +00:00
|
|
|
if (!Auth::check()) {
|
|
|
|
become403Page(UOJLocale::get('need login'));
|
|
|
|
}
|
2022-10-12 13:10:07 +00:00
|
|
|
|
2022-11-06 02:26:21 +00:00
|
|
|
$name = $_GET['image_name'];
|
|
|
|
if (!validateString($name)) {
|
|
|
|
become404Page();
|
|
|
|
}
|
2022-10-12 13:10:07 +00:00
|
|
|
|
2022-11-06 02:26:21 +00:00
|
|
|
$file_name = UOJContext::storagePath() . "/image_hosting/$name.png";
|
2022-10-12 13:10:07 +00:00
|
|
|
|
2022-11-06 02:26:21 +00:00
|
|
|
$finfo = finfo_open(FILEINFO_MIME);
|
|
|
|
$mimetype = finfo_file($finfo, $file_name);
|
|
|
|
if ($mimetype === false) {
|
|
|
|
become404Page();
|
|
|
|
}
|
|
|
|
finfo_close($finfo);
|
|
|
|
|
|
|
|
header("X-Sendfile: $file_name");
|
|
|
|
header("Content-type: $mimetype");
|
|
|
|
header("Cache-Control: max-age=604800", true);
|