This commit is contained in:
Lizandro Guarnizo
2026-01-22 11:29:24 -05:00
parent 84e2d1d236
commit fcba5919a8
5 changed files with 31 additions and 7 deletions
+8 -1
View File
@@ -40,12 +40,19 @@ try {
// Total de mensajes
$totalconversations = $db->fetch("SELECT COUNT(*) as count FROM conversations")['count'];
// Mensajes pendientes / no leídos: preferir columna is_read si existe, si no usar status = 'received'
$unreadResult = $db->fetch(
"SELECT COUNT(*) as count FROM conversations WHERE direction = 'incoming' AND ( (is_read IS NULL OR is_read = 0) OR status = 'received' )"
);
$unreadMessages = intval($unreadResult['count'] ?? 0);
$stats = [
'total_users' => (int)$totalUsers,
'conversations_today' => (int)$conversationsToday,
'active_users' => (int)$activeUsers,
'total_conversations' => (int)$totalconversations
'total_conversations' => (int)$totalconversations,
'unread_messages' => $unreadMessages
];
echo json_encode($stats);
+15 -1
View File
@@ -6,9 +6,17 @@
require_once '../config/config.php';
// Asegurar que errores no se impriman al cliente y se registren en logs
error_reporting(E_ALL);
@ini_set('display_errors', 0);
@ini_set('log_errors', 1);
// Verificar autenticación
requireAuthentication();
// Forzar buffer para poder limpiar salidas accidentales
if (ob_get_level() === 0) ob_start();
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
@@ -23,7 +31,13 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
try {
// Verificar que se subió un archivo
if (!isset($_FILES['file']) || $_FILES['file']['error'] !== UPLOAD_ERR_OK) {
throw new Exception('No se recibió ningún archivo o hubo un error en la carga');
// Log for debugging
error_log('upload_media.php - FILES content: ' . print_r($_FILES, true));
// Make sure any buffered content is cleared before sending JSON
if (ob_get_length()) ob_clean();
http_response_code(400);
echo json_encode(['success' => false, 'error' => 'No se recibió ningún archivo o hubo un error en la carga']);
exit;
}
$file = $_FILES['file'];