synch
All checks were successful
Deploy / deploy (push) Successful in 1m43s

This commit is contained in:
2026-07-27 00:24:12 +02:00
parent 56d29f09e5
commit e274e07f45
142 changed files with 235 additions and 295 deletions

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
use App\Avatar;
$seed = Avatar::normalizeSeed((string)($_GET['seed'] ?? 'papa-kind-treff'));
$cacheDir = dirname(__DIR__, 3) . '/assets/avatars/dicebear-cache';
if (!is_dir($cacheDir)) {
@mkdir($cacheDir, 0775, true);
}
$cacheFile = $cacheDir . '/' . $seed . '.svg';
$svg = is_file($cacheFile) ? file_get_contents($cacheFile) : false;
if ($svg === false) {
$url = 'https://api.dicebear.com/10.x/lorelei/svg?seed=' . rawurlencode($seed) . '&size=256';
$context = stream_context_create([
'http' => [
'method' => 'GET',
'timeout' => 6,
'header' => "User-Agent: Papa-Kind-Treff/1.0\r\nAccept: image/svg+xml\r\n",
],
]);
$remote = @file_get_contents($url, false, $context);
if (is_string($remote) && str_contains($remote, '<svg')) {
$svg = $remote;
@file_put_contents($cacheFile, $svg);
}
}
if (!is_string($svg) || $svg === '') {
$svg = Avatar::fallbackSvg($seed, 'Avatar');
}
header('Content-Type: image/svg+xml; charset=utf-8');
header('Cache-Control: public, max-age=604800, immutable');
echo $svg;