Files
html/api/ethica-consent-check.php
2026-04-16 03:09:54 +02:00

30 lines
1.2 KiB
PHP

<?php
require_once __DIR__ . '/_secrets.php';
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
$pg = @pg_connect("host=10.1.0.3 dbname=adx_system user=admin password=" . weval_secret('WEVAL_PG_ADMIN_PASS'));
if (!$pg) { echo json_encode(["error"=>"DB connection failed"]); exit; }
$result = ["ok"=>true];
// Total HCPs
$r = @pg_query($pg, "SELECT count(*) FROM ethica.medecins_real");
$result["total"] = $r ? (int)pg_fetch_result($r, 0, 0) : "query_fail";
// Email
$r = @pg_query($pg, "SELECT count(*) FROM ethica.medecins_real WHERE email IS NOT NULL AND email!=''");
$result["with_email"] = $r ? (int)pg_fetch_result($r, 0, 0) : "query_fail";
// Consent log
$r = @pg_query($pg, "SELECT count(*) FROM ethica.consent_log");
$result["consent_log"] = $r ? (int)pg_fetch_result($r, 0, 0) : "table_missing";
// Validated consent
$r = @pg_query($pg, "SELECT count(*) FROM ethica.medecins_validated WHERE consent_status=true");
$result["consent_real"] = $r ? (int)pg_fetch_result($r, 0, 0) : "table_missing";
$result["consent_warning"] = ($result["consent_real"] === 0 || $result["consent_real"] === "table_missing") ? "ZERO opt-in reel collecte" : null;
echo json_encode($result);
@pg_close($pg);