35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/db.php';
|
|
require_once __DIR__ . '/../includes/auth.php';
|
|
|
|
auth_check();
|
|
header('Content-Type: application/json');
|
|
|
|
$rows = db()->query(
|
|
'SELECT sf.id, sf.title, sf.sender, sf.date_processing, a.username,
|
|
GROUP_CONCAT(f.id, ":", f.file_name, ":", f.path ORDER BY f.id SEPARATOR "|") as files
|
|
FROM source_file sf
|
|
LEFT JOIN accounts a ON sf.account_id = a.id
|
|
LEFT JOIN files f ON sf.id = f.source_file_id
|
|
GROUP BY sf.id
|
|
ORDER BY sf.date_processing DESC'
|
|
)->fetchAll();
|
|
|
|
// Vérifie l'existence physique des fichiers
|
|
foreach ($rows as &$r) {
|
|
$r['files_list'] = [];
|
|
if ($r['files']) {
|
|
foreach (explode('|', $r['files']) as $f) {
|
|
[$fid, $fname, $fpath] = array_pad(explode(':', $f, 3), 3, '');
|
|
$r['files_list'][] = [
|
|
'id' => (int)$fid,
|
|
'name' => $fname,
|
|
'exists' => file_exists($fpath),
|
|
];
|
|
}
|
|
}
|
|
unset($r['files']);
|
|
}
|
|
|
|
echo json_encode($rows);
|