guestbook: reject non-htmx POSTs (stops direct-POST spam bots)
Deploy / deploy (push) Successful in 41s
Deploy / deploy (push) Successful in 41s
This commit is contained in:
+4
-1
@@ -33,7 +33,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$trap = trim($_POST['url'] ?? '');
|
||||
$ok = false;
|
||||
|
||||
if ($trap !== '') {
|
||||
// bots POST name/msg straight to this endpoint, skipping the htmx form and
|
||||
// its honeypot. Real signs come via hx-post (HX-Request header); treat any
|
||||
// non-htmx POST like a honeypot hit — fake success, insert nothing.
|
||||
if ($trap !== '' || !$isHtmx) {
|
||||
$ok = true;
|
||||
} elseif ($name === '' || $msg === '') {
|
||||
$notice = 'name and message are required.';
|
||||
|
||||
Reference in New Issue
Block a user