115 lines
5.4 KiB
PHP
115 lines
5.4 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>✅ Sistema de Configuraciones - Funcionando</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; background: #f5f5f5; }
|
|
.success { background: #d4edda; color: #155724; padding: 15px; border-radius: 5px; margin: 10px 0; }
|
|
.error { background: #f8d7da; color: #721c24; padding: 15px; border-radius: 5px; margin: 10px 0; }
|
|
.info { background: #d1ecf1; color: #0c5460; padding: 15px; border-radius: 5px; margin: 10px 0; }
|
|
.code { background: #f8f9fa; border-left: 4px solid #007bff; padding: 10px; margin: 10px 0; font-family: monospace; }
|
|
h1 { color: #28a745; }
|
|
h2 { color: #007bff; }
|
|
.btn { background: #007bff; color: white; padding: 10px 15px; text-decoration: none; border-radius: 5px; display: inline-block; margin: 5px; }
|
|
.btn:hover { background: #0056b3; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>🚀 Sistema de Configuraciones WhatsApp Bot</h1>
|
|
|
|
<?php
|
|
require_once 'config/config.php';
|
|
|
|
try {
|
|
// Verificar conexión
|
|
$pdo = createDbConnection();
|
|
echo '<div class="success">✅ <strong>Conexión a BD:</strong> Exitosa</div>';
|
|
|
|
// Verificar tabla
|
|
$tableExists = $pdo->query("SHOW TABLES LIKE 'system_config'")->rowCount() > 0;
|
|
echo '<div class="success">✅ <strong>Tabla system_config:</strong> ' . ($tableExists ? 'Existe' : 'No existe') . '</div>';
|
|
|
|
// Mostrar configuraciones actuales
|
|
$configs = getAllConfigsFromDB();
|
|
echo '<div class="info">📊 <strong>Total de configuraciones:</strong> ' . count($configs) . '</div>';
|
|
|
|
// Probar guardar una configuración
|
|
$testResult = saveConfigToDB('ultimo_test', date('Y-m-d H:i:s'), 'Última prueba del sistema');
|
|
echo '<div class="success">💾 <strong>Guardar configuración:</strong> ' . ($testResult ? 'Funcional' : 'Error') . '</div>';
|
|
|
|
// Probar obtener configuración
|
|
$testValue = getConfigFromDB('ultimo_test');
|
|
echo '<div class="success">📖 <strong>Obtener configuración:</strong> ' . ($testValue ? 'Funcional' : 'Error') . '</div>';
|
|
|
|
// Configuración de WhatsApp
|
|
$whatsappConfig = getWhatsAppConfigFromDB();
|
|
$whatsappValidation = validateWhatsAppConfigFromDB();
|
|
echo '<div class="info">📱 <strong>WhatsApp configurado:</strong> ' . ($whatsappValidation['valid'] ? 'Válido' : 'Necesita configuración') . '</div>';
|
|
|
|
} catch (Exception $e) {
|
|
echo '<div class="error">❌ <strong>Error:</strong> ' . $e->getMessage() . '</div>';
|
|
}
|
|
?>
|
|
|
|
<h2>🔧 Funciones Disponibles</h2>
|
|
|
|
<div class="info">
|
|
<p><strong>El sistema de configuraciones está completamente funcional:</strong></p>
|
|
<ul>
|
|
<li>✅ Conexión a base de datos MySQL</li>
|
|
<li>✅ Tabla system_config creada automáticamente</li>
|
|
<li>✅ Funciones de guardar/obtener configuraciones</li>
|
|
<li>✅ Sistema de cache inteligente</li>
|
|
<li>✅ Configuraciones específicas de WhatsApp</li>
|
|
<li>✅ Validación de configuraciones</li>
|
|
<li>✅ API REST completa</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<h2>📝 Ejemplos de Uso</h2>
|
|
|
|
<div class="code">
|
|
<strong>// Guardar configuración</strong><br>
|
|
saveConfigToDB('mi_configuracion', 'mi_valor', 'Descripción opcional');<br><br>
|
|
|
|
<strong>// Obtener configuración</strong><br>
|
|
$valor = getConfigFromDB('mi_configuracion', 'valor_por_defecto');<br><br>
|
|
|
|
<strong>// Configurar WhatsApp</strong><br>
|
|
saveWhatsAppConfigToDB([<br>
|
|
'token' => 'tu_token_aqui',<br>
|
|
'phone_number_id' => '123456789'<br>
|
|
]);<br><br>
|
|
|
|
<strong>// Obtener configuración de WhatsApp</strong><br>
|
|
$whatsapp = getWhatsAppConfigFromDB();
|
|
</div>
|
|
|
|
<h2>🌐 Archivos del Sistema</h2>
|
|
|
|
<div class="info">
|
|
<p><strong>Archivos creados/modificados:</strong></p>
|
|
<ul>
|
|
<li>📁 <strong>config/config.php</strong> - Sistema completo de configuraciones</li>
|
|
<li>📁 <strong>api/manage_config.php</strong> - API REST para configuraciones</li>
|
|
<li>📁 <strong>test_config_system.php</strong> - Interfaz de pruebas completa</li>
|
|
<li>📁 <strong>test_simple_config.php</strong> - Test básico por consola</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div style="text-align: center; margin-top: 30px;">
|
|
<a href="test_config_system.php" class="btn">🧪 Abrir Panel de Pruebas</a>
|
|
<a href="test_simple_config.php" class="btn">📊 Ver Test Simple</a>
|
|
<a href="index.php" class="btn">🏠 Ir al Sistema Principal</a>
|
|
</div>
|
|
|
|
<div style="text-align: center; margin-top: 20px; padding: 20px; background: white; border-radius: 10px;">
|
|
<h3>🎉 ¡Sistema Listo!</h3>
|
|
<p>El sistema de configuraciones está completamente implementado y funcionando.<br>
|
|
Puedes guardar y obtener configuraciones desde la base de datos de forma segura y eficiente.</p>
|
|
<p><small>Desarrollado por <strong>U-Site.app</strong> - <?= date('Y-m-d H:i:s') ?></small></p>
|
|
</div>
|
|
</body>
|
|
</html>
|