Primer commit del sistema separado falta mejorar mucho
This commit is contained in:
40
shared/api/php_errors.log
Executable file
40
shared/api/php_errors.log
Executable file
@@ -0,0 +1,40 @@
|
||||
[30-Nov-2025 06:47:27 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:47:40 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:47:45 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:47:48 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:47:52 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:47:58 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:48:18 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:48:26 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 06:51:10 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
[30-Nov-2025 21:00:05 UTC] PHP Fatal error: Uncaught Error: Call to undefined function hasPermission() in /var/www/html/bot/shared/api/stats.php:29
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /var/www/html/bot/shared/api/stats.php on line 29
|
||||
78
shared/api/stats.php
Executable file
78
shared/api/stats.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* API de estadísticas para el panel principal
|
||||
*/
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Cargar variables de entorno
|
||||
if (file_exists(__DIR__ . '/../../.env')) {
|
||||
$lines = file(__DIR__ . '/../../.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos(trim($line), '#') === 0) continue;
|
||||
if (strpos($line, '=') === false) continue;
|
||||
list($key, $value) = explode('=', $line, 2);
|
||||
$_ENV[trim($key)] = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../database/connection.php';
|
||||
require_once __DIR__. '/../auth/jwt.php';
|
||||
|
||||
// Verificar autenticación
|
||||
$userData = JWTAuth::authenticate();
|
||||
if (!$userData) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['success' => false, 'error' => 'No autenticado']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$db = getDB();
|
||||
|
||||
// Estadísticas de Discord
|
||||
$discordStats = [
|
||||
'users' => 0,
|
||||
'messages' => 0,
|
||||
'templates' => 0
|
||||
];
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) as total FROM destinatarios_discord WHERE activo = 1 AND tipo = 'usuario'");
|
||||
$discordStats['users'] = $stmt->fetch()['total'];
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) as total FROM mensajes_discord WHERE estado = 'enviado'");
|
||||
$discordStats['messages'] = $stmt->fetch()['total'];
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) as total FROM plantillas_discord");
|
||||
$discordStats['templates'] = $stmt->fetch()['total'];
|
||||
|
||||
// Estadísticas de Telegram
|
||||
$telegramStats = [
|
||||
'users' => 0,
|
||||
'messages' => 0,
|
||||
'templates' => 0
|
||||
];
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) as total FROM destinatarios_telegram WHERE activo = 1 AND tipo = 'usuario'");
|
||||
$telegramStats['users'] = $stmt->fetch()['total'];
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) as total FROM mensajes_telegram WHERE estado = 'enviado'");
|
||||
$telegramStats['messages'] = $stmt->fetch()['total'];
|
||||
|
||||
$stmt = $db->query("SELECT COUNT(*) as total FROM plantillas_telegram");
|
||||
$telegramStats['templates'] = $stmt->fetch()['total'];
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'discord' => $discordStats,
|
||||
'telegram' => $telegramStats
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'error' => 'Error al obtener estadísticas'
|
||||
]);
|
||||
error_log('Error en stats.php: ' . $e->getMessage());
|
||||
}
|
||||
Reference in New Issue
Block a user