Davidson CI testing & AI refinement
This commit is contained in:
@@ -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
@@ -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>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user