<?php
// liste.php — renvoie en JSON la liste des images du dossier /medias
header('Content-Type: application/json; charset=utf-8');
$MEDIAS_DIR = dirname(__DIR__) . '/medias';
$out = [];
foreach (glob($MEDIAS_DIR . '/*.{webp,jpg,jpeg,png,gif}', GLOB_BRACE) as $f) {
    $out[] = [
        'url'  => 'medias/' . basename($f),
        'full' => 'https://tuinaloygue.fr/medias/' . basename($f),
        'name' => basename($f),
        'time' => filemtime($f),
        'size' => filesize($f),
    ];
}
usort($out, fn($a,$b) => $b['time'] <=> $a['time']); // plus récent d'abord
echo json_encode($out);
