webapp/public/image.php

37 lines
800 B
PHP
Raw Normal View History

2021-08-07 13:37:01 +03:00
<?php
2022-05-06 23:55:49 +03:00
require_once('../config.php');
2021-08-07 13:37:01 +03:00
require_once('../library/icon.php');
if (isset($_GET['hash'])) {
2022-05-13 18:57:07 +03:00
$hash = md5($_GET['hash']);
$width = isset($_GET['width']) ? (int) $_GET['width'] : 60;
$height = isset($_GET['height']) ? (int) $_GET['height'] : 60;
$radius = isset($_GET['radius']) ? (int) $_GET['radius'] : 0;
2022-05-13 18:31:50 +03:00
header("Content-Type: image/png");
2022-05-06 22:45:46 +03:00
2022-05-06 23:55:49 +03:00
if (CACHE_ENABLED) {
2022-05-06 22:45:46 +03:00
2022-05-13 18:57:07 +03:00
$filename = dirname(__FILE__) . '/../cache/' . $hash . '.png';
2022-05-06 23:55:49 +03:00
if (!file_exists($filename)) {
$icon = new Icon();
2022-05-13 18:57:07 +03:00
file_put_contents($filename, $icon->generateImageResource($hash, $width, $height, false, $radius));
2022-05-06 23:55:49 +03:00
}
echo file_get_contents($filename);
} else {
2022-05-06 22:45:46 +03:00
$icon = new Icon();
2022-05-13 18:57:07 +03:00
echo $icon->generateImageResource($hash, $width, $height, false, $radius);
2022-05-06 22:45:46 +03:00
}
2021-08-07 13:37:01 +03:00
}