41 lines
1.8 KiB
PHP
41 lines
1.8 KiB
PHP
<?php
|
|
|
|
// === WEVAL SECRETS LOADER ===
|
|
$_WEVAL_SECRETS = [];
|
|
if (file_exists('/etc/weval/secrets.env')) {
|
|
foreach (file('/etc/weval/secrets.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
|
|
if (strpos($line, '#') === 0) continue;
|
|
if (strpos($line, '=') !== false) {
|
|
list($k, $v) = explode('=', $line, 2);
|
|
$_WEVAL_SECRETS[trim($k)] = trim($v);
|
|
}
|
|
}
|
|
}
|
|
function weval_secret($key, $default='') {
|
|
global $_WEVAL_SECRETS;
|
|
return $_WEVAL_SECRETS[$key] ?? getenv($key) ?: $default;
|
|
}
|
|
|
|
header("Content-Type: application/json");
|
|
$mode = isset($_GET["mode"]) ? $_GET["mode"] : "dry-run";
|
|
// SAFETY: mode=send is DISABLED until Ethica confirms. Only status and dry-run work.
|
|
|
|
if ($mode === "status") {
|
|
$cmd = urlencode("PGPASSWORD=admin123 psql -U admin -d adx_system -h localhost -t -c \"SELECT count(*) FROM ethica.medecins_validated WHERE email IS NOT NULL AND email != ''\"");
|
|
$r = @file_get_contents("http://10.1.0.3:5890/api/sentinel-brain.php?action=exec&cmd=" . $cmd);
|
|
$d = json_decode($r, true);
|
|
$count = trim($d["output"] ?? "0");
|
|
echo json_encode(["ok"=>true,"validated_with_email"=>$count,"kumomta"=>"active","mode"=>"status"]);
|
|
exit;
|
|
}
|
|
|
|
if ($mode === "dry-run") {
|
|
$cmd = urlencode("PGPASSWORD=admin123 psql -U admin -d adx_system -h localhost -t -c \"SELECT nom,prenom,email,specialite FROM ethica.medecins_validated WHERE nom ILIKE '%kaouther%' OR prenom ILIKE '%kaouther%' LIMIT 5\"");
|
|
$r = @file_get_contents("http://10.1.0.3:5890/api/sentinel-brain.php?action=exec&cmd=" . $cmd);
|
|
$d = json_decode($r, true);
|
|
echo json_encode(["ok"=>true,"dry_run"=>true,"kaouther_contacts"=>trim($d["output"] ?? ""),"note"=>"No email sent. Use mode=send&to=email"]);
|
|
exit;
|
|
}
|
|
|
|
echo json_encode(["modes"=>["status","dry-run","send"]]);
|