better-staridc-MNBT
1<?php
2@header('Content-Type: application/json; charset=UTF-8');
3include("../MPHX/common.php");
4require_once ROOT . 'MPHX/node.function.php';
5
6$act = $_GET['act'] ?? '';
7$body = file_get_contents('php://input');
8$payload = json_decode($body, true);
9if (!is_array($payload)) $payload = [];
10
11[$ok, $node, $authMsg] = mnbt_node_authenticate($DB, $conf, $body);
12if (!$ok) {
13 mnbt_node_exit(false, $authMsg);
14}
15
16if ($act === 'heartbeat') {
17 mnbt_node_upsert_heartbeat($DB, $node, $payload);
18 mnbt_node_exit(true, 'heartbeat ok', [
19 'server_time' => date('Y-m-d H:i:s'),
20 ]);
21}
22
23if ($act === 'pull_task') {
24 $task = mnbt_node_pull_task($DB, $node['node_id']);
25 mnbt_node_exit(true, 'pull task ok', [
26 'task' => $task,
27 ]);
28}
29
30if ($act === 'report_result') {
31 [$saved, $msg] = mnbt_node_report_result($DB, $node['node_id'], $payload);
32 mnbt_node_exit($saved, $msg);
33}
34
35if ($act === 'get_config') {
36 $config = [
37 'forbidden_scan' => [
38 'enabled' => ($conf['wjsckg'] ?? 'false') === 'true',
39 'content' => $conf['wjsccnr'] ?? '',
40 'scan_changed_only' => ($conf['wjsckgqbfx'] ?? 'true') === 'true',
41 'scan_dir' => $conf['wjscml'] ?? '/www/wwwroot',
42 'skip_dirs' => $conf['wjstqml'] ?? '.git,node_modules,vendor,runtime,cache,logs',
43 'skip_exts' => $conf['wjstqhz'] ?? '.jpg,.png,.gif,.webp,.mp4,.zip,.rar,.7z,.pdf,.woff,.ttf',
44 'max_file_size' => (int)($conf['wjscdzmax'] ?? 5242880),
45 'max_matches' => (int)($conf['wjscdhmax'] ?? 1000),
46 'full_scan_enabled' => ($conf['wjscqzcskg'] ?? 'true') === 'true',
47 'full_scan_cron' => $conf['wjscqzcs'] ?? '0 3 * * *',
48 ],
49 ];
50 mnbt_node_exit(true, 'config ok', $config);
51}
52
53mnbt_node_exit(false, 'unknown action');