From c1e6a69e0519e67752ad96d64bcaebca0230e5ca Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sun, 15 Feb 2026 16:20:34 +1100 Subject: [PATCH] BE+FE: legacy sync endpoint removal - see release notes Signed-off-by: jokob-sk --- front/php/components/graph_online_history.php | 3 - front/plugins/sync/hub.php | 103 ------------------ front/plugins/sync/sync.py | 1 - 3 files changed, 107 deletions(-) delete mode 100755 front/plugins/sync/hub.php diff --git a/front/php/components/graph_online_history.php b/front/php/components/graph_online_history.php index 19ad37ef..46275870 100755 --- a/front/php/components/graph_online_history.php +++ b/front/php/components/graph_online_history.php @@ -27,11 +27,8 @@ function initOnlineHistoryGraph() { var archivedCounts = []; res.data.forEach(function(entry) { - console.log(entry.Scan_Date); - // var dateObj = new Date(entry.Scan_Date); var formattedTime = localizeTimestamp(entry.Scan_Date).slice(11, 17); - // dateObj.toLocaleTimeString([], {hour: '2-digit', minute: '2-digit', hour12: false}); timeStamps.push(formattedTime); onlineCounts.push(entry.Online_Devices); diff --git a/front/plugins/sync/hub.php b/front/plugins/sync/hub.php deleted file mode 100755 index 3894b2ae..00000000 --- a/front/plugins/sync/hub.php +++ /dev/null @@ -1,103 +0,0 @@ - getSettingValue('SYNC_node_name'), - 'status' => $status, - 'message' => $message, - 'data_base64' => $data, - 'timestamp' => date('Y-m-d H:i:s') - ]); -} - -// ---------------------------------------------- -// MAIN -// ---------------------------------------------- - - -// requesting data (this is a NODE) -if ($method === 'GET') { - checkAuthorization($method); - - $apiRoot = getenv('NETALERTX_API') ?: '/tmp/api'; - $file_path = rtrim($apiRoot, '/') . '/table_devices.json'; - - $data = file_get_contents($file_path); - - // Prepare the data to return as a JSON response - $response_data = base64_encode($data); - - // Return JSON response - jsonResponse(200, $response_data, 'OK'); - - displayInAppNoti("[Plugin: SYNC] Data sent", "info"); - -} -// receiving data (this is a HUB) -else if ($method === 'POST') { - checkAuthorization($method); - - // Retrieve and decode the data from the POST request - $data = $_POST['data'] ?? ''; - $file_path = $_POST['file_path'] ?? ''; - $node_name = $_POST['node_name'] ?? ''; - $plugin = $_POST['plugin'] ?? ''; - - $logRoot = getenv('NETALERTX_PLUGINS_LOG') ?: (rtrim(getenv('NETALERTX_LOG') ?: '/tmp/log', '/') . '/plugins'); - $storage_path = rtrim($logRoot, '/'); - - // // check location - // if (!is_dir($storage_path)) { - // echo "Could not open folder: {$storage_path}"; - // write_notification("[Plugin: SYNC] Could not open folder: {$storage_path}", "alert"); - // http_response_code(500); - // exit; - // } - - // Generate a unique file path to avoid overwriting existing files - $encoded_files = glob("{$storage_path}/last_result.{$plugin}.encoded.{$node_name}.*.log"); - $decoded_files = glob("{$storage_path}/last_result.{$plugin}.decoded.{$node_name}.*.log"); - - $files = array_merge($encoded_files, $decoded_files); - $file_count = count($files) + 1; - - $file_path_new = "{$storage_path}/last_result.{$plugin}.encoded.{$node_name}.{$file_count}.log"; - - // Save the decoded data to the file - file_put_contents($file_path_new, $data); - http_response_code(200); - echo 'Data received and stored successfully'; - displayInAppNoti("[Plugin: SYNC] Data received ({$file_path_new})", "info"); - -} else { - http_response_code(405); - echo 'Method Not Allowed'; - displayInAppNoti("[Plugin: SYNC] Method Not Allowed", "error"); -} -?> diff --git a/front/plugins/sync/sync.py b/front/plugins/sync/sync.py index 7848fa68..919008a9 100755 --- a/front/plugins/sync/sync.py +++ b/front/plugins/sync/sync.py @@ -269,7 +269,6 @@ def main(): # Data retrieval methods api_endpoints = [ "/sync", # New Python-based endpoint - "/plugins/sync/hub.php" # Legacy PHP endpoint ]