";
echo "
🚨 Diagnóstico Error 500";
echo "";
echo "🚨 DIAGNÓSTICO ERROR 500 - WhatsApp Bot
";
echo "Fecha: " . date('Y-m-d H:i:s') . "
";
// 1. TEST BÁSICO PHP
echo "📍 1. TEST BÁSICO PHP
";
echo "
✅ PHP está funcionando (versión: " . phpversion() . ")
";
if (version_compare(phpversion(), '7.4', '>=')) {
echo "
✅ Versión PHP compatible
";
} else {
echo "
❌ Versión PHP muy antigua (requiere 7.4+)
";
}
echo "
";
// 2. TEST ARCHIVOS CRÍTICOS
echo "📂 2. ARCHIVOS CRÍTICOS
";
$critical_files = [
'config/config.php' => 'Configuración principal',
'classes/Database.php' => 'Clase Database',
'index.php' => 'Dashboard principal',
'login.php' => 'Sistema de login',
'.htaccess' => 'Configuración Apache'
];
foreach ($critical_files as $file => $desc) {
if (file_exists($file)) {
echo "
✅ $file ($desc)
";
// Test de carga PHP (sin shell_exec)
if (str_ends_with($file, '.php')) {
try {
// Intentar incluir el archivo para verificar errores
if ($file === 'config/config.php') {
// Test especial para config.php
ob_start();
$error_before = error_get_last();
include_once $file;
$output = ob_get_clean();
$error_after = error_get_last();
if ($error_after && $error_after !== $error_before) {
echo "
→ ❌ Error en archivo: " . htmlspecialchars($error_after['message']) . "
";
} elseif (!empty($output)) {
echo "
→ ⚠️ Archivo produce output: " . htmlspecialchars(substr($output, 0, 100)) . "
";
} else {
echo "
→ ✅ Archivo se carga correctamente
";
}
} else {
echo "
→ ✅ Archivo PHP existe
";
}
} catch (ParseError $e) {
echo "
→ ❌ ERROR SINTAXIS: " . htmlspecialchars($e->getMessage()) . "
";
} catch (Error $e) {
echo "
→ ❌ ERROR: " . htmlspecialchars($e->getMessage()) . "
";
} catch (Exception $e) {
echo "
→ ⚠️ ADVERTENCIA: " . htmlspecialchars($e->getMessage()) . "
";
}
}
} else {
echo "
❌ FALTA: $file ($desc)
";
}
}
echo "
";
// 3. TEST PERMISOS
echo "🔐 3. PERMISOS
";
$dirs_permissions = [
'logs/' => ['required' => '777', 'writable' => true],
'uploads/' => ['required' => '777', 'writable' => true],
'config/' => ['required' => '755', 'writable' => false],
'.' => ['required' => '755', 'writable' => false]
];
foreach ($dirs_permissions as $dir => $config) {
if (is_dir($dir)) {
$perms = substr(sprintf('%o', fileperms($dir)), -3);
echo "
✅ $dir existe (permisos: $perms)
";
if ($config['writable'] && !is_writable($dir)) {
echo "
→ ❌ No es escribible (necesita chmod 777)
";
}
} else {
echo "
❌ Directorio $dir no existe
";
}
}
echo "
";
// 4. TEST CONFIGURACIÓN
echo "⚙️ 4. CONFIGURACIÓN
";
if (file_exists('config/config.php')) {
try {
ob_start();
include_once 'config/config.php';
$config_output = ob_get_clean();
if (!empty($config_output)) {
echo "
❌ config.php produce output: " . htmlspecialchars($config_output) . "
";
} else {
echo "
✅ config.php se carga sin errores
";
}
// Verificar constantes básicas
$constants = ['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS'];
foreach ($constants as $const) {
if (defined($const)) {
$value = constant($const);
$display_value = ($const === 'DB_PASS') ? '***' : $value;
echo "
✅ $const = '$display_value'
";
} else {
echo "
❌ Constante $const no definida
";
}
}
} catch (Exception $e) {
echo "
❌ Error cargando config.php: " . htmlspecialchars($e->getMessage()) . "
";
} catch (Error $e) {
echo "
❌ Error fatal en config.php: " . htmlspecialchars($e->getMessage()) . "
";
}
} else {
echo "
❌ config/config.php no encontrado
";
}
echo "
";
// 5. TEST BASE DE DATOS
echo "🗄️ 5. BASE DE DATOS
";
if (defined('DB_HOST') && defined('DB_NAME')) {
try {
$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4";
$pdo = new PDO($dsn, DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]);
echo "
✅ Conexión a base de datos exitosa
";
// Verificar tablas principales
$tables = ['conversations', 'conversations', 'system_config'];
foreach ($tables as $table) {
$stmt = $pdo->query("SHOW TABLES LIKE '$table'");
if ($stmt->rowCount() > 0) {
echo "
✅ Tabla '$table' existe
";
} else {
echo "
⚠️ Tabla '$table' no existe
";
}
}
} catch (PDOException $e) {
echo "
❌ Error BD: " . htmlspecialchars($e->getMessage()) . "
";
}
} else {
echo "
❌ Configuración de BD incompleta
";
}
echo "
";
// 6. TEST .HTACCESS
echo "🛡️ 6. .HTACCESS
";
if (file_exists('.htaccess')) {
$htaccess_size = filesize('.htaccess');
echo "
✅ .htaccess existe ($htaccess_size bytes)
";
// Verificar sintaxis básica
$htaccess_content = file_get_contents('.htaccess');
$problematic_lines = [];
// Buscar sintaxis antigua que puede causar problemas
if (strpos($htaccess_content, 'Order Allow,Deny') !== false) {
$problematic_lines[] = "Sintaxis antigua 'Order Allow,Deny' (usar 'Require all denied')";
}
if (strpos($htaccess_content, 'Allow from') !== false) {
$problematic_lines[] = "Sintaxis antigua 'Allow from' (usar 'Require ip')";
}
if (empty($problematic_lines)) {
echo "
✅ Sintaxis .htaccess parece correcta
";
} else {
foreach ($problematic_lines as $issue) {
echo "
❌ $issue
";
}
}
} else {
echo "
❌ .htaccess no encontrado
";
}
echo "
";
// 7. TEST MÓDULOS APACHE
echo "🔧 7. EXTENSIONES PHP
";
$required_extensions = ['pdo', 'pdo_mysql', 'curl', 'json', 'mbstring', 'openssl'];
foreach ($required_extensions as $ext) {
if (extension_loaded($ext)) {
echo "
✅ Extensión '$ext' habilitada
";
} else {
echo "
❌ Extensión '$ext' NO habilitada
";
}
}
// Verificar funciones deshabilitadas
$dangerous_functions = ['shell_exec', 'exec', 'system', 'passthru'];
$disabled_functions = explode(',', ini_get('disable_functions'));
$disabled_functions = array_map('trim', $disabled_functions);
echo "
Funciones del sistema:
";
foreach ($dangerous_functions as $func) {
if (in_array($func, $disabled_functions)) {
echo "
⚠️ $func() deshabilitada (normal en hosting)
";
} else {
echo "
✅ $func() habilitada
";
}
}
echo "
";
// 8. INFORMACIÓN DEL SERVIDOR
echo "🖥️ 8. INFO SERVIDOR
";
echo "
Servidor: " . ($_SERVER['SERVER_SOFTWARE'] ?? 'Desconocido') . "
";
echo "
PHP: " . PHP_VERSION . "
";
echo "
SAPI: " . php_sapi_name() . "
";
echo "
Directorio: " . __DIR__ . "
";
echo "
Usuario: " . get_current_user() . "
";
// Límites PHP importantes
$limits = [
'memory_limit' => ini_get('memory_limit'),
'max_execution_time' => ini_get('max_execution_time'),
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size')
];
foreach ($limits as $setting => $value) {
echo "
$setting: $value
";
}
echo "
";
// 9. SUGERENCIAS DE SOLUCIÓN
echo "🔧 9. ACCIONES RECOMENDADAS
";
echo "
Si hay errores arriba, prueba estas soluciones:
";
echo "
1. Error sintaxis PHP: Corregir archivo mostrado
";
echo "
2. Permisos: chmod 777 logs/ uploads/
";
echo "
3. Base datos: Verificar credenciales en config.php
";
echo "
4. .htaccess: Renombrar temporalmente a .htaccess.bak
";
echo "
5. PHP version: Cambiar a PHP 8.1+ en panel
";
echo "
TESTS RÁPIDOS:
";
echo "
• Renombra .htaccess → .htaccess.bak y prueba
";
echo "
• Ve a login.php directamente
";
echo "
• Revisa error log del servidor
";
echo "
";
echo "📱 10. CONTACTO
";
echo "
Si necesitas ayuda, envía screenshot de este diagnóstico
";
echo "
";
echo "