hnschat-web/etc/preview.php

26 lines
690 B
PHP
Raw Normal View History

2024-04-17 08:26:30 +10:00
<?php
include "includes.php";
$id = $_GET["id"];
$previewFile = $GLOBALS["path"]."/etc/previews/".$id;
$getImage = @sql("SELECT `image` FROM `previews` WHERE `id` = ? AND `image` IS NOT NULL", [$id])[0];
if ($getImage) {
if (file_exists($previewFile)) {
$image = file_get_contents($previewFile);
$type = mime_content_type($previewFile);
}
else {
$getImage["image"] = html_entity_decode(html_entity_decode($getImage["image"]));
$image = getContents($getImage["image"]);
if (validImageWithoutFetch($image)) {
file_put_contents($previewFile, $image);
$type = mime_content_type($previewFile);
}
}
header("Content-Type: ".$type);
die($image);
}
?>