<?php

namespace App\Utils;

class ShowImg {

    private $thumbPath = __DIR__ . '/../../cache/img/';

    function __construct($type, $hmac) {

        $img = $this->thumbPath . substr($hmac, 0, 4) . '/' . $hmac . '_' . $type . '.png';

        header("Content-type: image/png");
        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/error_thumb.png');
        }
        exit();
    }
}
