Soshot/app/Utils/ShowImg.php

24 lines
635 B
PHP

<?php
namespace App\Utils;
class ShowImg {
private $thumbPath = __DIR__ . '/../../cache/img/';
function __construct($type, $hmac, $fileFormat) {
$img = $this->thumbPath . substr($hmac, 0, 4) . '/' . $hmac . '_' . $type . '.'.$fileFormat;
header("Content-type: image/$fileFormat");
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');
}
exit();
}
}