One Hat Cyber Team
Your IP :
104.23.243.59
Server IP :
172.67.218.182
Server :
Linux 128-201-239-36.cprapid.com 3.10.0-1160.41.1.el7.x86_64 #1 SMP Tue Aug 31 14:52:47 UTC 2021 x86_64
Server Software :
Apache
PHP Version :
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
juscatamarca
/
www
/
subdomains
/
escuela
/
View File Name :
conteo-inscripciones.php
<?php // Configuración $api_url = 'https://sheetdb.io/api/v1/vayk0kta4cqur'; // Función para obtener datos del API function obtenerInscripciones() { global $api_url; try { // Intentar con curl primero (más confiable) if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($response === false || $http_code !== 200) { return ['error' => 'Error al conectar con el API (curl): HTTP ' . $http_code]; } } else { // Fallback a file_get_contents $context = stream_context_create(['http' => ['timeout' => 10]]); $response = @file_get_contents($api_url, false, $context); if ($response === false) { return ['error' => 'Error al conectar con el API (file_get_contents)']; } } $data = json_decode($response, true); if (json_last_error() !== JSON_ERROR_NONE) { return ['error' => 'Error al procesar datos JSON']; } return $data; } catch (Exception $e) { return ['error' => 'Excepción: ' . $e->getMessage()]; } } // Obtener datos $inscripciones = obtenerInscripciones(); // Procesar datos $poder_judicial = 0; $no_poder_judicial = 0; $detalle_por_circunscripcion = []; $detalle_por_residencia = []; $presenciales = 0; if (!isset($inscripciones['error'])) { foreach ($inscripciones as $row) { $pertenece_pj = strtolower($row['¿Pertenece al Poder Judicial de Catamarca?'] ?? 'no'); $circunscripcion = $row['Circunscripción'] ?? 'Sin especificar'; $lugar_residencia = $row['Lugar de residencia'] ?? 'Sin especificar'; if ($pertenece_pj === 'sí' || $pertenece_pj === 'si') { $poder_judicial++; // Contar por circunscripción if (!isset($detalle_por_circunscripcion[$circunscripcion])) { $detalle_por_circunscripcion[$circunscripcion] = 0; } $detalle_por_circunscripcion[$circunscripcion]++; // Contar presenciales (1ª circunscripción) if (strpos($circunscripcion, '1') !== false || strpos($circunscripcion, 'Primera') !== false) { $presenciales++; } } else { $no_poder_judicial++; // Contar por lugar de residencia para no PJ if ($lugar_residencia !== 'Sin especificar' && $lugar_residencia !== '') { if (!isset($detalle_por_residencia[$lugar_residencia])) { $detalle_por_residencia[$lugar_residencia] = 0; } $detalle_por_residencia[$lugar_residencia]++; // Contar presenciales (residencia en San Fernando del Valle de Catamarca) $residencia_lower = strtolower($lugar_residencia); if (strpos($residencia_lower, 'san fernando') !== false) { $presenciales++; } } } } arsort($detalle_por_circunscripcion); arsort($detalle_por_residencia); } $total = $poder_judicial + $no_poder_judicial; ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Inscriptos a presentación de libro</title> <link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="assets/css/styles.css" rel="stylesheet"> <style> body { background-color: #f8f9fa; padding: 20px 0; } .card { border: none; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 20px; } .card-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; } .stat-card { text-align: center; padding: 30px; } .stat-number { font-size: 48px; font-weight: bold; color: #667eea; margin: 10px 0; } .stat-label { font-size: 14px; color: #6c757d; text-transform: uppercase; letter-spacing: 1px; } .progress-section { margin-top: 20px; } .badge-circunscripcion { display: inline-block; margin: 5px; padding: 8px 12px; background-color: #e9ecef; border-radius: 20px; font-size: 12px; } .error-message { background-color: #f8d7da; color: #721c24; padding: 15px; border-radius: 4px; margin-bottom: 20px; } .refresh-time { font-size: 12px; color: #6c757d; text-align: center; margin-top: 10px; } </style> </head> <body> <div class="container mt-5"> <div class="row"> <div class="col-lg-10 mx-auto"> <div style="text-align: center; margin-bottom: 30px;"> <img src="assets/images/logo-ecj.png" alt="logo ecj" width="150px"/> </div> <h1 class="mb-4">Inscriptos a presentación de libro</h1> <?php if (isset($inscripciones['error'])): ?> <div class="error-message"> <strong>Error:</strong> <?php echo htmlspecialchars($inscripciones['error']); ?> </div> <?php else: ?> <!-- Cards principales --> <div class="row mb-4"> <div class="col-md-6"> <div class="card stat-card"> <div class="stat-label">Total de Inscritos</div> <div class="stat-number"><?php echo $total; ?></div> <small class="text-muted">Personas registradas</small> </div> </div> <div class="col-md-6"> <div class="card stat-card"> <div class="stat-label">Presenciales</div> <div class="stat-number" style="color: #28a745;"><?php echo $presenciales; ?></div> <small class="text-muted"><?php echo $total > 0 ? round(($presenciales/$total)*100, 1) : 0; ?>% del total</small> </div> </div> </div> <!-- Barra de progreso: Poder Judicial vs No Poder Judicial --> <?php if ($total > 0): ?> <div class="card"> <div class="card-body progress-section"> <h5 class="card-title">Distribución por Afiliación</h5> <div class="progress" style="height: 25px;"> <div class="progress-bar bg-success" role="progressbar" style="width: <?php echo ($poder_judicial/$total)*100; ?>%" aria-valuenow="<?php echo $poder_judicial; ?>" aria-valuemin="0" aria-valuemax="<?php echo $total; ?>"> Poder Judicial: <?php echo $poder_judicial; ?> </div> <div class="progress-bar bg-info" role="progressbar" style="width: <?php echo ($no_poder_judicial/$total)*100; ?>%" aria-valuenow="<?php echo $no_poder_judicial; ?>" aria-valuemin="0" aria-valuemax="<?php echo $total; ?>"> No Poder Judicial: <?php echo $no_poder_judicial; ?> </div> </div> </div> </div> <!-- Barra de progreso: Presenciales vs Otros --> <div class="card"> <div class="card-body progress-section"> <h5 class="card-title">Distribución por Modalidad</h5> <div class="progress" style="height: 25px;"> <div class="progress-bar bg-warning" role="progressbar" style="width: <?php echo ($presenciales/$total)*100; ?>%" aria-valuenow="<?php echo $presenciales; ?>" aria-valuemin="0" aria-valuemax="<?php echo $total; ?>"> Presenciales: <?php echo $presenciales; ?> </div> <div class="progress-bar bg-secondary" role="progressbar" style="width: <?php echo (($total - $presenciales)/$total)*100; ?>%" aria-valuenow="<?php echo $total - $presenciales; ?>" aria-valuemin="0" aria-valuemax="<?php echo $total; ?>"> Otros: <?php echo $total - $presenciales; ?> </div> </div> </div> </div> <?php endif; ?> <!-- SECCIÓN 1: PODER JUDICIAL --> <div style="margin-top: 30px; padding: 20px; background-color: #f0f4f8; border-left: 4px solid #667eea; border-radius: 4px;"> <h4 style="color: #667eea; margin-bottom: 20px;">Pertenece al Poder Judicial</h4> <!-- Detalle por circunscripción --> <?php if (!empty($detalle_por_circunscripcion)): ?> <div class="card"> <div class="card-header"> <h5 class="mb-0">Desglose por Circunscripción</h5> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>Circunscripción</th> <th class="text-right">Cantidad</th> <th class="text-right">Porcentaje</th> </tr> </thead> <tbody> <?php foreach ($detalle_por_circunscripcion as $circunscripcion => $cantidad): ?> <tr> <td><?php echo htmlspecialchars($circunscripcion); ?></td> <td class="text-right"><strong><?php echo $cantidad; ?></strong></td> <td class="text-right"><?php echo $poder_judicial > 0 ? round(($cantidad/$poder_judicial)*100, 1) : 0; ?>%</td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> <?php else: ?> <div class="alert alert-info">No hay datos del Poder Judicial.</div> <?php endif; ?> </div> <!-- SECCIÓN 2: NO PODER JUDICIAL --> <div style="margin-top: 30px; padding: 20px; background-color: #f8f4f0; border-left: 4px solid #d4a574; border-radius: 4px;"> <h4 style="color: #d4a574; margin-bottom: 20px;">No Pertenece al Poder Judicial</h4> <!-- Detalle por lugar de residencia --> <?php if (!empty($detalle_por_residencia)): ?> <div class="card"> <div class="card-header" style="background: linear-gradient(135deg, #d4a574 0%, #b8885c 100%);"> <h5 class="mb-0">Desglose por Lugar de Residencia</h5> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>Lugar de Residencia</th> <th class="text-right">Cantidad</th> <th class="text-right">Porcentaje</th> </tr> </thead> <tbody> <?php foreach ($detalle_por_residencia as $residencia => $cantidad): ?> <tr> <td><?php echo htmlspecialchars($residencia); ?></td> <td class="text-right"><strong><?php echo $cantidad; ?></strong></td> <td class="text-right"><?php echo $no_poder_judicial > 0 ? round(($cantidad/$no_poder_judicial)*100, 1) : 0; ?>%</td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> <?php else: ?> <div class="alert alert-info">No hay inscritos fuera del Poder Judicial.</div> <?php endif; ?> </div> <div class="refresh-time"> 🔄 Última actualización: <?php echo date('d/m/Y H:i:s'); ?> | <a href="javascript:location.reload()">Actualizar ahora</a> </div> <?php endif; ?> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script> <script> // Auto-refresh cada 5 minutos setTimeout(function() { location.reload(); }, 5 * 60 * 1000); </script> </body> </html>