Davidson CI testing & AI refinement
pauljd/davidson-ci: Davidson CI / quality (push) Successful in 20s
pauljd/davidson-ci: Davidson CI / ai-review (push) Successful in 1m5s

This commit is contained in:
2026-09-11 09:42:27 +01:00
parent c9d1a42751
commit d41725cd68
3 changed files with 14 additions and 1 deletions
+7
View File
@@ -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]);
+1 -1
View File
@@ -40,7 +40,7 @@ $isLoggedIn = isset($_SESSION['user_id']) && isset($_SESSION['username']);
function openCheckout(items){
Paddle.Checkout.open({
items: items,
customData: {user_id: "<?php echo htmlspecialchars(createTicket((int) $_SESSION['user_id'], 'purchase'), ENT_QUOTES, 'UTF-8'); ?>"}
customData: {user_id: "<?php echo htmlspecialchars(createTicket((int) $_SESSION['user_id'], 'purchase', PURCHASE_TICKET_LIFETIME_SECONDS), ENT_QUOTES, 'UTF-8'); ?>"}
});
}
</script>
+6
View File
@@ -1,6 +1,12 @@
<?php
define('TICKET_LIFETIME_SECONDS', 20 * 60);
define('EMAIL_VERIFICATION_LIFETIME_SECONDS', 60 * 60 * 24 * 3);
// A Paddle checkout can sit open well past the default 20-minute ticket lifetime before
// the buyer completes payment, so the ticket that maps the resulting webhook back to a
// user needs a much longer window than a login-flow ticket. The ticket only carries an
// identity claim — actually crediting an account still requires a validly signed Paddle
// webhook for a real transaction — so a long lifetime here doesn't weaken anything.
define('PURCHASE_TICKET_LIFETIME_SECONDS', 60 * 60 * 24);
function getTicketSecret(): string
{