From e52192469ad6a8a8d6e3f907ec3182c1d21bcab9 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 27 Feb 2025 22:12:28 -0500 Subject: [PATCH] Moved data variable before use --- create_ticket_api.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/create_ticket_api.php b/create_ticket_api.php index f8a824b..ef44380 100644 --- a/create_ticket_api.php +++ b/create_ticket_api.php @@ -53,6 +53,10 @@ $createTableSQL = "CREATE TABLE IF NOT EXISTS tickets ( $conn->query($createTableSQL); +// Parse input regardless of content-type header +$rawInput = file_get_contents('php://input'); +$data = json_decode($rawInput, true); + // Generate hash from stable components function generateTicketHash($data) { $stableComponents = [ @@ -91,10 +95,6 @@ if ($result->num_rows > 0) { // Force JSON content type for all incoming requests header('Content-Type: application/json'); -// Parse input regardless of content-type header -$rawInput = file_get_contents('php://input'); -$data = json_decode($rawInput, true); - if (!$data) { // Try parsing as URL-encoded data parse_str($rawInput, $data);