diff options
| author | Agando <roduccomm@gmail.com> | 2026-11-09 15:36:23 +0100 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-11-09 15:36:23 +0100 |
| commit | a065a4c30be748b0c8fc6dd0b5ee1dc4d3de4b1c (patch) | |
| tree | 8a84adabfccee9994937cd71888170ab205b9361 /.bkp-fix-20261023_143429/config.php | |
| parent | a46ebee30cfbbac86abb45068411bc28e1c65503 (diff) | |
The daily collector and the feedback pipeline had left 57 modified files uncommitted (skills,
modules-index, CHANGELOG, feedback decisions, debug counters). The public mirror publishes git
HEAD, so without this the published repo stayed behind the tree - and it blocked the publisher
outright once uncommitted subtrees started failing loudly.
Diffstat (limited to '.bkp-fix-20261023_143429/config.php')
| -rw-r--r-- | .bkp-fix-20261023_143429/config.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/.bkp-fix-20261023_143429/config.php b/.bkp-fix-20261023_143429/config.php new file mode 100644 index 0000000..9abc262 --- /dev/null +++ b/.bkp-fix-20261023_143429/config.php @@ -0,0 +1,59 @@ +<?php +// api/debug/config.php — Shared config for debug backend +header('Content-Type: application/json; charset=utf-8'); +header('Access-Control-Allow-Origin: https://webx11.duckdns.org'); +header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); +header('Access-Control-Allow-Headers: Content-Type'); +header('Access-Control-Max-Age: 86400'); + +// Handle preflight +if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { + http_response_code(204); + exit; +} + +date_default_timezone_set('UTC'); + +define('DEBUG_DATA_DIR', __DIR__ . '/../../data/debug'); +define('MAX_ERRORS_PER_BATCH', 100); +define('MAX_BATCH_SIZE_KB', 1024); // raised 64->1024 (2026-10-05): error batches with stacks legitimately exceed 64KB, causing endless 413s +define('CLUSTER_SIMILARITY_THRESHOLD', 0.35); +define('ERRORS_FILE', DEBUG_DATA_DIR . '/errors.json'); +define('SESSIONS_FILE', DEBUG_DATA_DIR . '/sessions.json'); +define('CLUSTERS_FILE', DEBUG_DATA_DIR . '/clusters.json'); + +if (!is_dir(DEBUG_DATA_DIR)) { + mkdir(DEBUG_DATA_DIR, 0755, true); +} + +function load_json($path) { + if (!file_exists($path)) return []; + $data = json_decode(file_get_contents($path), true); + return is_array($data) ? $data : []; +} + +function save_json($path, $data) { + $encoded = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + $fp = fopen($path, 'c'); + if ($fp && flock($fp, LOCK_EX)) { + ftruncate($fp, 0); + fwrite($fp, $encoded); + fflush($fp); + flock($fp, LOCK_UN); + fclose($fp); + } else { + // Fallback: write without lock + file_put_contents($path, $encoded); + } + @chmod($path, 0664); +} + +function json_response($data, $code = 200) { + http_response_code($code); + echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + exit; +} + +function error_response($msg, $code = 400) { + json_response(['success' => false, 'error' => $msg], $code); +} |