mirror of
https://github.com/Nathanwoodburn/hnschat-web.git
synced 2026-01-30 05:13:02 +11:00
v2
This commit is contained in:
26
etc/preview.php
Normal file
26
etc/preview.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user