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