Primer commit del sistema separado falta mejorar mucho

This commit is contained in:
nickpons666
2025-12-30 01:18:46 -06:00
commit 1679c73e52
2384 changed files with 472342 additions and 0 deletions

304
discord/views/commands/list.php Executable file
View File

@@ -0,0 +1,304 @@
<?php
session_start();
// Habilitar logging para depuración
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/../../../shared/utils/helpers.php';
require_once __DIR__ . '/../../../shared/auth/jwt.php';
require_once __DIR__ . '/../../../shared/database/connection.php';
$userData = JWTAuth::requireAuth();
// Verificar permiso para ver la página de comandos
if (!hasPermission('view_commands', 'discord')) {
die('No tienes permiso para ver los comandos de Discord.');
}
$db = getDB();
// Obtener comandos con información de la plantilla asociada
$stmt = $db->query("
SELECT c.id, p.nombre, c.comando, c.fecha_creacion, c.descripcion
FROM comandos_discord c
LEFT JOIN plantillas_discord p ON c.plantilla_id = p.id
ORDER BY c.comando ASC
");
$comandos = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="<?php echo $userData->idioma ?? 'es'; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Comandos Discord - Sistema de Bots</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--discord-color: #5865F2;
--discord-dark: #4752C4;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, var(--discord-color) 0%, var(--discord-dark) 100%);
min-height: 100vh;
padding: 20px;
}
.header {
background: white;
border-radius: 15px;
padding: 20px 30px;
margin-bottom: 30px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}
.header h1 {
color: var(--discord-color);
font-size: 24px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.card {
background: white;
border-radius: 15px;
padding: 25px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.table-responsive {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #eee;
}
th {
font-weight: 600;
color: #555;
background: #f8f9fa;
}
.command-tag {
background: #2b2d31;
color: #dbdee1;
padding: 4px 8px;
border-radius: 4px;
font-family: monospace;
font-weight: 600;
}
.btn {
padding: 10px 20px;
border-radius: 8px;
text-decoration: none;
transition: all 0.2s;
border: none;
cursor: pointer;
font-size: 14px;
font-weight: 600;
}
.btn-primary {
background: var(--discord-color);
color: white;
}
.btn-primary:hover {
background: var(--discord-dark);
transform: translateY(-2px);
}
.btn-secondary {
background: #6c757d;
color: white;
}
.btn-danger {
background: #dc3545;
color: white;
padding: 5px 10px;
font-size: 12px;
}
.btn-edit {
background: #ffc107;
color: #212529;
padding: 5px 10px;
font-size: 12px;
margin-right: 5px;
}
/* Modal */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
}
.modal-content {
background: white;
margin: 10% auto;
padding: 30px;
border-radius: 15px;
width: 90%;
max-width: 600px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
}
.form-control {
width: 100%;
padding: 10px;
border: 2px solid #eee;
border-radius: 8px;
}
.close {
float: right;
font-size: 24px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="header">
<h1><i class="fas fa-terminal"></i> Comandos Discord</h1>
<div style="display: flex; gap: 10px;">
<a href="/discord/dashboard_discord.php" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Volver
</a>
<?php if (hasPermission('manage_templates', 'discord')): ?>
<a href="/discord/views/templates/create.php" class="btn btn-primary">
<i class="fas fa-plus"></i> Nuevo Comando (Plantilla)
</a>
<?php endif; ?>
</div>
</div>
<div class="container">
<div class="card">
<?php if (empty($comandos)): ?>
<div style="text-align: center; padding: 40px; color: #666;">
<i class="fas fa-terminal" style="font-size: 48px; margin-bottom: 20px; color: #ddd;"></i>
<h3>No hay comandos configurados</h3>
<p>Los comandos se definen al crear o editar una plantilla.</p>
<?php if (hasPermission('manage_templates', 'discord')): ?>
<a href="/discord/views/templates/create.php" class="btn btn-primary" style="margin-top: 10px;">
Ir a Plantillas
</a>
<?php endif; ?>
</div>
<?php else: ?>
<div class="table-responsive">
<table>
<thead>
<tr>
<th>Comando</th>
<th>Plantilla Asociada</th>
<th>Fecha Creación</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php foreach ($comandos as $cmd): ?>
<tr>
<td>
<span class="command-tag"><?php echo htmlspecialchars($cmd['comando']); ?></span>
</td>
<td>
<i class="fas fa-file-alt"></i> <?php echo htmlspecialchars($cmd['nombre']); ?>
</td>
<td>
<?php echo date('d/m/Y', strtotime($cmd['fecha_creacion'])); ?>
</td>
<td>
<?php if (hasPermission('manage_templates', 'discord')): ?>
<a href="/discord/views/templates/edit.php?id=<?php echo $cmd['id']; ?>" class="btn btn-edit">
<i class="fas fa-edit"></i> Editar
</a>
<button onclick="deleteCommand(<?php echo $cmd['id']; ?>, '<?php echo htmlspecialchars($cmd['comando'], ENT_QUOTES); ?>')" class="btn btn-danger">
<i class="fas fa-trash"></i> Eliminar
</button>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<!-- Scripts eliminados ya que no se necesita modal local -->
<script>
async function deleteCommand(templateId, commandName) {
if (!confirm(`¿Estás seguro de eliminar el comando "${commandName}"? Esto eliminará también la plantilla asociada.`)) {
return;
}
try {
const response = await fetch('/discord/api/templates/delete.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ id: templateId })
});
const result = await response.json();
if (result.success) {
alert('Comando y plantilla eliminados correctamente.');
location.reload(); // Recargar la página para actualizar la lista
} else {
alert('Error al eliminar: ' + (result.error || 'Error desconocido.'));
}
} catch (error) {
console.error('Error al enviar la solicitud de eliminación:', error);
alert('Error de conexión al intentar eliminar el comando.');
}
}
</script>
</body>
</html>

View File

@@ -0,0 +1,5 @@
[04-Dec-2025 16:44:49 America/Mexico_City] PHP Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'comando' in 'field list' in /var/www/html/bot/discord/views/commands/list.php:23
Stack trace:
#0 /var/www/html/bot/discord/views/commands/list.php(23): PDO->query()
#1 {main}
thrown in /var/www/html/bot/discord/views/commands/list.php on line 23