Soshot/app/Utils/ShowImg.php

25 lines
635 B
PHP
Raw Normal View History

2023-06-21 11:42:36 +02:00
<?php
namespace App\Utils;
class ShowImg {
private $thumbPath = __DIR__ . '/../../cache/img/';
2023-06-28 12:29:20 +02:00
function __construct($type, $hmac, $fileFormat) {
2023-06-21 11:42:36 +02:00
2023-06-28 12:29:20 +02:00
$img = $this->thumbPath . substr($hmac, 0, 4) . '/' . $hmac . '_' . $type . '.'.$fileFormat;
2023-06-21 11:42:36 +02:00
2023-06-28 12:29:20 +02:00
header("Content-type: image/$fileFormat");
2023-06-21 11:42:36 +02:00
header('Expires: ', gmdate('D, d M Y H:i:s', time()) . ' GMT');
if (file_exists($img)) {
echo file_get_contents($img);
} else {
// todo not gen
echo file_get_contents(__DIR__ . '/../../src/images/hd_generation_in_progress.jpg');
2023-06-21 11:42:36 +02:00
}
exit();
}
}