<?php
// Generates files.json from the uploads directory structure
$base_dir = __DIR__ . '/../uploads/';
$output_file = __DIR__ . '/../uploads/files.json';
function scan_files($dir, $base = '') {
$result = [];
$items = scandir($dir);
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$full_path = $dir . DIRECTORY_SEPARATOR . $item;
$relative_path = ltrim($base . '/' . $item, '/');
if (is_dir($full_path)) {
$result = array_merge($result, scan_files($full_path, $relative_path));
} elseif (is_file($full_path)) {
$result[] = [
'name' => $item,
'path' => $relative_path,
'size' => filesize($full_path),
'modified' => date("Y-m-d H:i:s", filemtime($full_path))
];
}
}
return $result;
}
// Scan and write output
$files = scan_files($base_dir);
file_put_contents($output_file, json_encode($files, JSON_PRETTY_PRINT));
echo "[Jedi-Sec Remote] files.json generated. Total files: " . count($files) . "\n";
?>