<?php
// Script untuk check status gambar
$imageDir = 'uploads/images/';
$images = glob($imageDir . '*.*');

echo "<h2>Image Directory Check</h2>";
echo "<p>Directory: " . realpath($imageDir) . "</p>";
echo "<p>Writable: " . (is_writable($imageDir) ? 'Yes' : 'No') . "</p>";
echo "<p>Exists: " . (file_exists($imageDir) ? 'Yes' : 'No') . "</p>";

echo "<h3>Images Found:</h3>";
foreach ($images as $image) {
    $filename = basename($image);
    $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' . $imageDir . $filename;
    $size = filesize($image);
    $accessible = @getimagesize($image) ? 'Yes' : 'No';
    
    echo "<div style='border:1px solid #ccc; padding:10px; margin:5px;'>";
    echo "<strong>File:</strong> $filename<br>";
    echo "<strong>Size:</strong> " . number_format($size) . " bytes<br>";
    echo "<strong>Accessible:</strong> $accessible<br>";
    echo "<strong>URL:</strong> <a href='$url' target='_blank'>$url</a><br>";
    echo "<img src='$url' style='max-width:200px; height:auto; border:1px solid red;' onerror='this.style.border=\"3px solid red\"'><br>";
    echo "</div>";
}
?>