$MAX_FILE_LINES) { $lines = array_slice($lines, 0, $MAX_FILE_LINES); } if (file_put_contents($TRACK_FILE, implode(PHP_EOL, $lines) . PHP_EOL)) { echo "Track logged: {$formattedTrack}"; } else { http_response_code(500); echo "Error writing to file"; } exit; } } // Original command execution logic from your bash script if (isset($_GET['command'])) { $command = $_GET['command']; // Execute the command (assuming this is running in an environment with ADB/shell access) exec($command, $output, $return_var); if ($return_var === 0) { echo "Command executed successfully"; } else { http_response_code(500); echo "Error executing command"; } exit; } // Optional: Handle delete request if needed if (isset($_GET['delete']) && $_GET['delete'] === 'ok') { // Your original delete logic would go here echo "Delete request received"; exit; } // If no parameters provided, show usage echo "Usage: - Log track: ?track=\"Song Title\" - \"Album Name\" - Send command: ?command=am+broadcast+... - Delete: ?delete=ok"; ?>