rate limiting
This commit is contained in:
parent
8e334458f3
commit
0ebb3aa45f
1 changed files with 13 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue