diff --git a/create-critter.php b/create-critter.php index 8953fff..862d326 100644 --- a/create-critter.php +++ b/create-critter.php @@ -349,8 +349,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $userCredits > 0 && !$dailyLimitRea // disallowed or missing image URL, oversized or non-image download, or a failed // write to disk) leaves $imageFilename null, so this single check refunds the // reserved credit for all of them instead of only the initial request-failure case. + // The placeholder row is removed too, so a failed attempt doesn't also cost the + // user one of their daily critters or start a cooldown — refunding the credit but + // leaving the row behind would silently charge the daily/cooldown quota for + // something that, as far as the user is concerned, never happened. $refundStmt = $pdo->prepare('UPDATE users SET credits = credits + 1 WHERE id = :id'); $refundStmt->execute(['id' => $_SESSION['user_id']]); + + $deleteStmt = $pdo->prepare('DELETE FROM critters WHERE id = :id'); + $deleteStmt->execute(['id' => $critterId]); } else { $updateStmt = $pdo->prepare('UPDATE critters SET image = :image WHERE id = :id'); $updateStmt->execute(['image' => $imageFilename, 'id' => $critterId]); diff --git a/lib/head.php b/lib/head.php index 3ae8b67..dd4b4b5 100644 --- a/lib/head.php +++ b/lib/head.php @@ -40,7 +40,7 @@ $isLoggedIn = isset($_SESSION['user_id']) && isset($_SESSION['username']); function openCheckout(items){ Paddle.Checkout.open({ items: items, - customData: {user_id: ""} + customData: {user_id: ""} }); } diff --git a/lib/ticket.php b/lib/ticket.php index 5a522e6..3ab7dfd 100644 --- a/lib/ticket.php +++ b/lib/ticket.php @@ -1,6 +1,12 @@