diff --git a/server/php/timetrack.php b/server/php/timetrack.php index f29d28c..fdabe93 100644 --- a/server/php/timetrack.php +++ b/server/php/timetrack.php @@ -35,7 +35,12 @@ switch($jsx['cmd']) { $stmt->close(); // Prepare data as JSON and insert into `data` table - $data = json_encode($jsx['data']); + if(is_array($jsx['data'])) { + $data = json_encode($jsx['data']); + } // else: The data is binary or NBT. + else { + $data = base64_decode($jsx['data']); + } $stmt = $DB->prepare("INSERT INTO `data` (`ID`, `SessionData`) VALUES (?, ?)"); $null = NULL; // Required for bind_param with blob @@ -74,11 +79,14 @@ switch($jsx['cmd']) { $stmt->close(); // Decode the JSON blob (optional — if you want raw JSON output) - header("Content-Type: application/json"); - echo $sessionData; + if(substr($sessionData, 0, 1) == "{") { + header("Content-Type: application/json"); + die($sessionData); + }else { + header("Content-Type: application/nbt"); + die(base64_encode($sessionData)); + } break; } - - } ?> \ No newline at end of file