webapp/public/image.php

37 lines
800 B
PHP
Raw Normal View History

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