fix: Behebe nicht angezeigte Icons mit PHP-Proxy
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
parent
fd016287a6
commit
c6e5a8b2b6
4 changed files with 52 additions and 6 deletions
46
public/image.php
Normal file
46
public/image.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
// Simpler Bild-Proxy, um mögliche Server-Konfigurationsprobleme für statische Dateien zu umgehen.
|
||||
|
||||
$file = $_GET['file'] ?? '';
|
||||
|
||||
// Sicherheit: Verhindere Directory Traversal und erlaube nur Dateien aus bestimmten Verzeichnissen.
|
||||
if (empty($file) || strpos($file, '..') !== false || substr($file, 0, 6) !== 'icons/') {
|
||||
http_response_code(400);
|
||||
echo "Bad Request";
|
||||
exit;
|
||||
}
|
||||
|
||||
$baseDir = __DIR__; // Dies ist das /public Verzeichnis
|
||||
$filePath = $baseDir . '/' . $file;
|
||||
|
||||
// Sicherheit: Stelle sicher, dass der endgültige Pfad innerhalb des erwarteten Verzeichnisses liegt.
|
||||
$realBasePath = realpath($baseDir . '/icons');
|
||||
$realFilePath = realpath($filePath);
|
||||
|
||||
if ($realBasePath === false || $realFilePath === false || strpos($realFilePath, $realBasePath) !== 0) {
|
||||
http_response_code(403);
|
||||
echo "Forbidden";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
http_response_code(404);
|
||||
echo "Not Found";
|
||||
exit;
|
||||
}
|
||||
|
||||
// MIME-Typ basierend auf der Dateiendung bestimmen
|
||||
$extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
|
||||
$mimeTypes = [
|
||||
'png' => 'image/png',
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'svg' => 'image/svg+xml',
|
||||
];
|
||||
|
||||
$mimeType = $mimeTypes[$extension] ?? 'application/octet-stream';
|
||||
|
||||
header('Content-Type: ' . $mimeType);
|
||||
readfile($filePath);
|
||||
|
|
@ -30,10 +30,10 @@ require __DIR__ . '/partials/header.php';
|
|||
<h3>Debug-Informationen</h3>
|
||||
<p>Versuch, das Joker-Icon zu laden:</p>
|
||||
<ul>
|
||||
<li>Pfad im <code><img></code>-Tag: <code>/icons/joker.png</code></li>
|
||||
<li>Pfad im <code><img></code>-Tag: <code>/image.php?file=icons/joker.png</code></li>
|
||||
<li>Erwarteter physischer Speicherort: <code>public/icons/joker.png</code></li>
|
||||
<li>Test-Link: <a href="/icons/joker.png" target="_blank">Öffne Icon in neuem Tab</a></li>
|
||||
<li>Test-Anzeige: <img src="/icons/joker.png" alt="Test" style="width: 20px; height: 20px; border: 1px solid red; vertical-align: middle;"></li>
|
||||
<li>Test-Link: <a href="/image.php?file=icons/joker.png" target="_blank">Öffne Icon in neuem Tab</a></li>
|
||||
<li>Test-Anzeige: <img src="/image.php?file=icons/joker.png" alt="Test" style="width: 20px; height: 20px; border: 1px solid red; vertical-align: middle;"></li>
|
||||
</ul>
|
||||
<hr>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
|
||||
<div class="legend">
|
||||
<div class="legend-item">🏆 Tagessieger</div>
|
||||
<div class="legend-item"><img src="/icons/joker.png" alt="Joker" class="joker-icon"> Joker gesetzt</div>
|
||||
<div class="legend-item"><img src="/image.php?file=icons/joker.png" alt="Joker" class="joker-icon"> Joker gesetzt</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: orange;"></div> Exaktes Ergebnis</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: red;"></div> Exakt mit Joker</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: gold;"></div> Richtige Differenz</div>
|
||||
|
|
@ -78,7 +78,7 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
<td class="tipp-cell <?php echo htmlspecialchars($td_class); ?>" title="Tipp: <?php echo htmlspecialchars($tipp['text']); ?> | Punkte: <?php echo $tipp['points']; ?>">
|
||||
<?php echo $tipp['points']; ?>
|
||||
<?php if ($tipp['is_joker']): ?>
|
||||
<img src="/icons/joker.png" alt="Joker" class="joker-icon" title="Joker">
|
||||
<img src="/image.php?file=icons/joker.png" alt="Joker" class="joker-icon" title="Joker">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ require __DIR__ . '/partials/header.php';
|
|||
<td class="tipp-cell <?php echo htmlspecialchars($td_class); ?>" title="Tipp: <?php echo htmlspecialchars($text); ?>">
|
||||
<?php echo htmlspecialchars($text); ?>
|
||||
<?php if ($is_joker && Game::isLocked($game['kickoff'])): ?>
|
||||
<img src="/icons/joker.png" alt="Joker" class="joker-icon" title="Joker">
|
||||
<img src="/image.php?file=icons/joker.png" alt="Joker" class="joker-icon" title="Joker">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue