<?php
header('Content-Type: text/plain; charset=utf-8');

$dir = __DIR__ . '/assets/img';
echo "Checking directory: $dir\n";

if (!is_dir($dir)) {
    echo "Directory does not exist!\n";
    exit;
}

echo "Directory exists.\n\nFiles list:\n";
$files = scandir($dir);
foreach ($files as $file) {
    if ($file === '.' || $file === '..') continue;
    $filePath = "$dir/$file";
    $size = filesize($filePath);
    $perms = substr(sprintf('%o', fileperms($filePath)), -4);
    $readable = is_readable($filePath) ? "Readable" : "NOT readable";
    echo "- $file (Size: $size bytes, Perms: $perms, $readable)\n";
}

echo "\nDocument root files:\n";
$rootFiles = scandir(__DIR__);
foreach ($rootFiles as $file) {
    if ($file === '.' || $file === '..') continue;
    echo "- $file\n";
}
