cambios importantes

This commit is contained in:
Lizandro Guarnizo
2026-06-13 09:19:36 -05:00
parent a6595862ec
commit 774cd829d9
2 changed files with 42 additions and 1 deletions
+29
View File
@@ -13,6 +13,12 @@ require_once __DIR__ . '/../services/Settings.php';
if ($r['value'] !== null && $r['value'] !== '') {
$_ENV[$r['key']] = $r['value'];
putenv("{$r['key']}={$r['value']}");
// Also set uppercase version for env() lookups
$upper = strtoupper($r['key']);
if ($upper !== $r['key']) {
$_ENV[$upper] = $r['value'];
putenv("{$upper}={$r['value']}");
}
}
}
} catch (\Throwable $e) {
@@ -407,11 +413,34 @@ $routes = [
foreach ($pairs as $k => $v) {
$_ENV[$k] = $v;
putenv("{$k}={$v}");
$upper = strtoupper($k);
if ($upper !== $k) {
$_ENV[$upper] = $v;
putenv("{$upper}={$v}");
}
}
header('Location: /admin/settings?msg=saved');
exit;
})()],
// ─── Debug: captura cruda de webhooks (loguea todo sin validar) ───────
['GET', '/admin/v1/wp-webhook-debug', fn() => (function () {
$log = '[' . date('Y-m-d H:i:s') . "] GET " . ($_SERVER['QUERY_STRING'] ?? '') . "\n";
file_put_contents('/tmp/wp-debug.log', $log, FILE_APPEND);
jsonResponse(200, ['logged' => true, 'query' => $_GET]);
})()],
['POST', '/admin/v1/wp-webhook-debug', fn() => (function () {
$raw = file_get_contents('php://input');
$headers = getallheaders();
$log = '[' . date('Y-m-d H:i:s') . "] POST\n";
$log .= "Headers: " . json_encode($headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
$log .= "Body: {$raw}\n";
$log .= str_repeat('-', 60) . "\n";
file_put_contents('/tmp/wp-debug.log', $log, FILE_APPEND);
$decoded = json_decode($raw, true);
jsonResponse(200, ['logged' => true, 'headers' => $headers, 'body' => $decoded ?? $raw]);
})()],
// ─── Admin: estado de salud de los ERP ──────────────────────────────────
['GET', '/admin/erp-health', fn() => (function () {
SessionAuth::require();