feat: auto-refresh AJAX, bouton transfert entre comptes, webhook par compte
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
web/api/mails.php
Normal file
34
web/api/mails.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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);
|
||||
Reference in New Issue
Block a user