| Current Path : /home/h/a/p/happyrenas/myreco.online/administration/panel/ajax/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/h/a/p/happyrenas/myreco.online/administration/panel/ajax/email_queue_get.php |
<?php
// administration/ajax/email_queue_get.php
header('Content-Type: application/json; charset=utf-8');
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../');
include("../../../configuration.php");
include("../../../includes/fonctions.php");
setlocale(LC_TIME, 'fr_FR.UTF-8');
include("auth.php");
$id = (int)($_GET['id'] ?? 0);
if ($id <= 0){
echo json_encode(['ok'=>false,'error'=>'ID invalide']);
exit;
}
$esc = function($v) use ($db){
return "'" . $db->escape($v) . "'";
};
$row = $db->get_row("
SELECT *
FROM email_queue
WHERE id = $id
LIMIT 1
");
if (!$row){
echo json_encode(['ok'=>false,'error'=>'Introuvable']);
exit;
}
function statusBadge($s){
$s = (string)$s;
$cls = 'badge badge-secondary';
if ($s === 'queued') $cls = 'badge badge-queued';
if ($s === 'sending') $cls = 'badge badge-sending';
if ($s === 'sent') $cls = 'badge badge-sent';
if ($s === 'failed') $cls = 'badge badge-failed';
return '<span class="'.$cls.'">'.htmlspecialchars($s, ENT_QUOTES, 'UTF-8').'</span>';
}
function date_fr($dt){
$dt = trim((string)$dt);
if ($dt === '' || $dt === '0000-00-00 00:00:00') return '';
$ts = strtotime($dt);
if (!$ts) return '';
return date('d/m/Y H:i', $ts); // ex: 21/12/2025 14:07
}
$contextPretty = '';
if (!empty($row->context_json)){
$decoded = json_decode($row->context_json, true);
if (is_array($decoded)){
$contextPretty = json_encode($decoded, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
} else {
$contextPretty = (string)$row->context_json;
}
}
$out = [
'id' => (int)$row->id,
'request_uid' => (string)($row->request_uid ?? ''),
'token' => (string)($row->token ?? ''),
'modele_id' => (int)($row->modele_id ?? 0),
'expediteur' => (string)($row->expediteur ?? ''),
'destinataire_principal' => (string)($row->destinataire_principal ?? ''),
'destinataire_copie' => (string)($row->destinataire_copie ?? ''),
'objet' => (string)($row->objet ?? ''),
'message' => (string)($row->message ?? ''),
'status' => (string)($row->status ?? ''),
'status_html' => statusBadge($row->status ?? ''),
'error_message' => (string)($row->error_message ?? ''),
'retries' => (int)($row->retries ?? 0),
'created_at' => (string)(date_fr($row->created_at) ?? ''),
'sent_at' => (string)(date_fr($row->sent_at) ?? ''),
'last_attempt' => (string)(date_fr($row->last_attempt) ?? ''),
'next_attempt' => (string)(date_fr($row->next_attempt) ?? ''),
'context_json_pretty' => $contextPretty,
];
echo json_encode(['ok'=>true,'row'=>$out], JSON_UNESCAPED_UNICODE);
exit;