Refactor logoExists function to use document root for file path resolution

This commit is contained in:
Fabian Schieder 2026-02-28 01:29:03 +01:00
parent 59cfcdce61
commit 0318eba497

View File

@ -60,9 +60,10 @@ $projects = [
* Verhindert Broken Images. * Verhindert Broken Images.
*/ */
function logoExists(string $webPath): bool { function logoExists(string $webPath): bool {
// Absoluten Dateisystempfad relativ zur index.php auflösen $base = rtrim($_SERVER['DOCUMENT_ROOT'] ?? '/var/www/fabianschieder.com', '/');
$filePath = __DIR__ . '/' . ltrim($webPath, '/'); $full = $base . '/' . ltrim($webPath, '/');
return is_file($filePath); // Debug: echo "<!-- checking: $full -->\n";
return is_file($full);
} }
?> ?>
@ -114,7 +115,7 @@ function logoExists(string $webPath): bool {
> >
<div class="card-icon"> <div class="card-icon">
<?php if (!empty($project['logo']) && logoExists($project['logo'])): ?> <?php if (!empty($project['logo'])): ?>
<img <img
src="<?= htmlspecialchars($project['logo'], ENT_QUOTES) ?>" src="<?= htmlspecialchars($project['logo'], ENT_QUOTES) ?>"
alt="<?= htmlspecialchars($project['title'], ENT_QUOTES) ?> Logo" alt="<?= htmlspecialchars($project['title'], ENT_QUOTES) ?> Logo"