rate limiting

This commit is contained in:
biglyderv 2025-01-25 18:18:21 -05:00
parent 8e334458f3
commit 0ebb3aa45f

View file

@ -44,12 +44,24 @@
}
$poid = bin2hex(random_bytes(16));
$stmt = $db->prepare("SELECT * FROM comment WHERE username = ? ORDER BY date DESC");
$stmt->execute([
$username
]);
$userposts = $stmt->fetchAll(PDO::FETCH_DEFAULT);
if ($userposts[0]['date'] - (microtime(true) - $ref) > -3) {
echo "You have been rate limited.";
return;
}
$stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)");
$stmt->execute([$username,$postType,$postId,microtime(true) - $ref,$postie,$poid]);
$postieP = "https://nbg.dervland.net/comment.php?id=" . $poid;
$user10 = ':system';
if ($postType == 'user') {
$postie = "A user commented on your wall: " . $postieP;