<?php
# NOCACHE
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Pragma: no-cache"); // HTTP/1.0 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
if (isset($_GET['audit'])) { ## ESTA INICIALIZADA
if ($_GET['audit'] === 'ON') {
# SEGURIDAD: VALIDACION DE ERRORES
ini_set('display_startup_errors', 1); echo (ini_get('display_errors') == 1 ?
'AUDIT MODE => ON ' . '<hr>' : ''); } else {
}
}
## DO NOT LET ECHO CONSOLE.LOGS OR THE AJAX CALING IT WILL TROW ERRORS ONLY WITH init_GET FOR DEVELOPING PORPOUSE
echo (ini_get('display_errors') == 1 ?
' INITIALITED => ' . __FILE__ . '<hr>' : '');
try {
// Zona Horaria
// date_default_timezone_set("America/Mazatlan");
echo (ini_get('display_errors') == 1 ?
' $fecha Actual=> ' . date('Y-m-d H:i:sa') . '<br>' : ''); # FECHA les 1 day
$fecha1da = date('Y-m-d', $nfecha1d);
$url = "";
if (isset($_SERVER['HTTPS'])) { $url = 'https://localhost/' . '/tools/PHP/feedsmn/cap.php';
} else {
$url = 'http://localhost/' . '/tools/PHP/feedsmn/cap.php';
}
$xmld = get_web_page($url);
# ECHO (ini_get('display_errors') == 1 ? ' $xmld => ' . print_r($xmld, 1) . '<hr>' : '');
## ECHO (ini_get('display_errors') == 1 ? ' $xmld[content] => ' . print_r($xmld['content'], 1) . '<br>' : '');
## IF EMPTY CURL EXIT
if (empty($xmld['content'])) { echo (ini_get('display_errors') == 1 ?
'<script>console.log("Curl URL => FAIL, content empty...");</script>' . '<hr>' : ''); }
$xml = new SimpleXMLElement($xmld['content']);
# ECHO (ini_get('display_errors') == 1 ? ' $xml => ' . print_r($xml, 1) . '<br>' : '');
$contador = 0;
echo (ini_get('display_errors') == 1 ?
'<script>console.log("fechaActual => ' . $fecha1da . '");</script>' : '');
// Iniciar el HTML
echo '<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Resultados CAP</title>
<style>
.resultado {
border: 1px solid #ccc;
padding: 15px;
margin: 10px 0;
border-radius: 5px;
background-color: #f9f9f9;
}
.resultado h2 {
margin-top: 0;
}
.resultado p {
margin: 5px 0;
}
</style>
</head>
<body>
<h1>Resultados CAP</h1>';
foreach ($xml->entry as $entry_x) {
echo (ini_get('display_errors') == 1 ?
'<script>console.log("%cFeed id => ' . $entry_x->id . '","background-color: Snow");</script>' : ''); echo (ini_get('display_errors') == 1 ?
'<script>console.log("Feed title => ' . ((!empty($entry_x->title)) ?
htmlspecialchars($entry_x->title) : 'Empty title') . '");</script>' : '');
$fechaXml = $entry_x->updated;
echo (ini_get('display_errors') == 1 ?
'<script>console.log("Feed updated => ' . $fechaXml . '");</script>' : ''); $fechaExp = explode("T", $fechaXml); $fecha_entry = $fechaExp[0];
# ECHO (ini_get('display_errors') == 1 ? '<script>console.log("$fecha_entry => ' . $fecha_entry . '");</script>' : '');
$idhrf1 = 'href';
$link1 = (string)$entry_x->link->attributes()->$idhrf1;
echo (ini_get('display_errors') == 1 ?
'<script>console.log("Feed $link1 => ' . $link1 . '");</script>' : '');
if ($fecha_entry >= $fecha1da) {
echo (ini_get('display_errors') == 1 ?
'<script>console.log("Cap => Date in less than 1 day Range ... ' . '");</script>' : ''); $idhrf = 'href';
$title = (string)$entry_x->title;
$sumary = (string)$entry_x->summary;
$update = (string)$entry_x->updated;
$link = (string)$entry_x->link->attributes()->$idhrf;
$linkCp = $linkExp[1];
$url2 = '../../..' . substr($linkCp, 6); $efectivo = (string)$xml2->info[0]->effective;
$expira = (string)$xml2->info[0]->expires;
$fecha = date('Y-m-j\TH:i:s'); $fecha1d = date('Y-m-d\TH:i:s', $fechas); echo (ini_get('display_errors') == 1 ?
'<script>console.log("<Actual Date> => ' . $fecha1d . '");</script>' : ''); echo (ini_get('display_errors') == 1 ?
'<script>console.log("<Effective> => ' . $efectivo . '");</script>' : ''); echo (ini_get('display_errors') == 1 ?
'<script>console.log("<expires> => ' . $expira . '");</script>' : '');
if ($expira >= $fecha1d) {
if ($fecha1d >= $efectivo) {
echo (ini_get('display_errors') == 1 ?
'<script>console.log("CAP => Valido para mostrar ... ' . '");</script>' : '');
$event = (string)$xml2->info[0]->event;
$urgencia = (string)$xml2->info[0]->urgency;
$severidad = (string)$xml2->info[0]->severity;
$inicia = (string)$xml2->info[0]->effective;
$encabezado = (string)$xml2->info[0]->headline;
$descrp_texto = (string)$xml2->info[0]->description;
$posDesc = strpos($descrp_texto, "datos"); $gtDescr = substr($descrp_texto, 0, $posDesc - 5); $instruc = (string)$xml2->info[0]->instruction;
$semaforo = "";
$region = "";
foreach ($xml2->info[0]->parameter as $parametro) {
$semaforo = (string)$parametro->value;
}
if ($parametro->valueName == 'layer:Google:Region:0.1') {
$region = (string)$parametro->value;
}
}
$area_par = (string)$xml2->info[0]->area->polygon;
$area_Alerta = (string)$xml2->info[0]->area->areaDesc[0];
$poligon1 = (string)$xml2->info[0]->area->polygon[0];
$poligon2 = (string)$xml2->info[0]->area->polygon[1];
$idlink = (string)$xml2->identifier;
$titulo_e = trim($encabezado); if ($area_par == "") {
$poligon01 = "";
} else {
$i = 0;
foreach ($xml2->info[0]->area->polygon as $polgn) {
}
$poligon01 = implode(":", $poligon0); }
// Imprimir cada resultado en un bloque separado
echo '<div class="resultado">
</div>';
}
}
}
}
// Cerrar el HTML
echo '</body>
</html>';
} catch (PDOException $e) {
}
##################################################################
# Get url only way with SSL
###############################################################
function get_web_page($url)
{
echo (ini_get('display_errors') == 1 ?
'get_web_page => START...' . '<br>' : '');
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FRESH_CONNECT => true,
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "SMN", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 30, // timeout on connect
CURLOPT_TIMEOUT => 30, // timeout on response
CURLOPT_MAXREDIRS => 1, // stop after 10 redirects
CURLOPT_SSL_VERIFYHOST => false, //stop SSL host verification
CURLOPT_SSL_VERIFYPEER => false // Disabled SSL Cert checks
);
$response['header'] = $header;
$response['errno'] = $err;
$response['errmsg'] = $errmsg;
$response['content'] = $content;
return $response;
}
?>