From 35ee0eeb4ba7ee74cb031e25e609a72bb999bc85 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 10:01:04 +0200 Subject: [PATCH 1/7] removed @ sign from emails --- content/french/sections/footer.md | 2 +- content/german/sections/footer.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/french/sections/footer.md b/content/french/sections/footer.md index 68d110a..a975c16 100644 --- a/content/french/sections/footer.md +++ b/content/french/sections/footer.md @@ -21,7 +21,7 @@ CH-8253 Diessenhofen 079 393 86 83 -support@verua.ch +support"at"verua.ch     diff --git a/content/german/sections/footer.md b/content/german/sections/footer.md index 7d39497..799afc0 100644 --- a/content/german/sections/footer.md +++ b/content/german/sections/footer.md @@ -19,7 +19,7 @@ CH-8253 Diessenhofen 079 393 86 83 -support@verua.ch +support"at"verua.ch     @@ -42,4 +42,4 @@ support@verua.ch {{% /columns %}} -{{% /aligncenter %}} \ No newline at end of file +{{% /aligncenter %}} From af62a449e6b4ad4573be3e1a798cce7b41a478d2 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 11:07:05 +0200 Subject: [PATCH 2/7] added filter for curren spam mails --- assets/js/kontaktformular.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/assets/js/kontaktformular.js b/assets/js/kontaktformular.js index a3f63bf..606b3bc 100644 --- a/assets/js/kontaktformular.js +++ b/assets/js/kontaktformular.js @@ -1,5 +1,5 @@ // Configuration and Messages -const debugEnabled = false +const debugEnabled = true const mouseDebugEnabled = false const zsrCheckEnabled = false const interactionThreshold = 15 // Time in seconds @@ -43,6 +43,11 @@ const captcha = document.querySelectorAll('.captcha') const captchaInput = document.querySelectorAll('.captcha-input') const captchaVerifyButton = document.querySelectorAll('.captcha-verify') const botBadge = document.createElement('div') + +// Form fields +const subjectField = document.getElementById('subject') +const messageField = document.getElementById('description') + if (debugEnabled) { botBadge.className = 'bot-badge' document.body.appendChild(botBadge) @@ -102,6 +107,9 @@ function handleMouseMove(event) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = + subjectField.value === "I promised." || +// or if messageField Has string "Hi, this is" in it + messageField.value.startsWith("Hi, this is") || !userInteracted || interactionCount === 0 || honeypotInput1.value !== '' || @@ -131,7 +139,11 @@ function checkForBotBehavior() { ' honeypotInput2:' + honeypotInput2.value + ' verifyEmailInput:' + - verifyEmailInput.value + verifyEmailInput.value + + ' subjectField:' + + subjectField.value + + ' messageField:' + + messageField.value ) } function handleSubmit(e) { @@ -144,7 +156,6 @@ function handleSubmit(e) { fakeOut() return false } - const formData = new FormData(form) const formDataEncoded = new URLSearchParams(formData).toString() const formURL = form.action + '.json' @@ -164,7 +175,7 @@ function handleSubmit(e) { }) .then((data) => { submitButton.disabled = true - submitButton.innerHTML = ` + submitButton.innerHTML = ` ` setTimeout(() => { @@ -189,7 +200,7 @@ function handleSubmit(e) { } function fakeOut() { submitButton.disabled = true - submitButton.innerHTML = ` + submitButton.innerHTML = ` ` setTimeout(() => { From 8445bb23ab771dd631b94c8e83c97ea99289c7ef Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 11:09:36 +0200 Subject: [PATCH 3/7] added current branch to build --- .gitea/workflows/build-and-deploy-pipeline.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/build-and-deploy-pipeline.yaml b/.gitea/workflows/build-and-deploy-pipeline.yaml index 7395958..d753ffe 100644 --- a/.gitea/workflows/build-and-deploy-pipeline.yaml +++ b/.gitea/workflows/build-and-deploy-pipeline.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - kontaktformular-filter-spam jobs: buildAndDeploy: From 7de49d32d34311441789344b823d57f59275d4b7 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 11:22:26 +0200 Subject: [PATCH 4/7] added filtering for bot known bot subject and textarea --- assets/js/bestellformular.js | 10 +++++++++- assets/js/kontaktformular.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/js/bestellformular.js b/assets/js/bestellformular.js index 314539b..b7c81c8 100644 --- a/assets/js/bestellformular.js +++ b/assets/js/bestellformular.js @@ -41,6 +41,11 @@ const textInputs = document.querySelectorAll('input[type="text"]') const captcha = document.querySelectorAll('.captcha') const captchaInput = document.querySelectorAll('.captcha-input') const captchaVerifyButton = document.querySelectorAll('.captcha-verify') + +// Form fields +const subjectField = document.getElementById('subject') +const messageField = document.getElementById('description') + const botBadge = document.createElement('div') if (debugEnabled) { botBadge.className = 'bot-badge' @@ -112,6 +117,9 @@ function validateZSRNumber(form) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = + subjectField.value === "I promised." || +// or if messageField Has string "Hi, this is" in it + messageField.value.startsWith("Hi, this is") || !userInteracted || interactionCount === 0 || timeSpent < interactionThreshold || @@ -176,7 +184,7 @@ function handleSubmit(e) { }) .then((data) => { submitButton.disabled = true - submitButton.innerHTML = ` + submitButton.innerHTML = ` ` setTimeout(() => { diff --git a/assets/js/kontaktformular.js b/assets/js/kontaktformular.js index 606b3bc..449ebe0 100644 --- a/assets/js/kontaktformular.js +++ b/assets/js/kontaktformular.js @@ -1,5 +1,5 @@ // Configuration and Messages -const debugEnabled = true +const debugEnabled = false const mouseDebugEnabled = false const zsrCheckEnabled = false const interactionThreshold = 15 // Time in seconds From 304c20e618d87d226fb3b8bc06ad0fd91e6ce737 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 12:13:24 +0200 Subject: [PATCH 5/7] setup method to handle logs of submissions --- assets/js/kontaktformular.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/assets/js/kontaktformular.js b/assets/js/kontaktformular.js index 449ebe0..a47ef94 100644 --- a/assets/js/kontaktformular.js +++ b/assets/js/kontaktformular.js @@ -107,9 +107,9 @@ function handleMouseMove(event) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = - subjectField.value === "I promised." || -// or if messageField Has string "Hi, this is" in it - messageField.value.startsWith("Hi, this is") || + subjectField.value === 'I promised.' || + // or if messageField Has string "Hi, this is" in it + messageField.value.startsWith('Hi, this is') || !userInteracted || interactionCount === 0 || honeypotInput1.value !== '' || @@ -146,6 +146,26 @@ function checkForBotBehavior() { messageField.value ) } + +// function logSubmission() { +// console.log('in logSubmission()') +// const data = { logData: 'Hi, this is some log data from JavaScript.' } +// fetch('/php/log.php', { +// method: 'POST', +// headers: { +// 'Content-Type': 'application/json', +// }, +// body: JSON.stringify(data), +// }) +// .then((response) => response.json()) +// .then((data) => { +// console.log('Success:', data) +// }) +// .catch((error) => { +// console.error('Error:', error) +// }) +// } +// function handleSubmit(e) { e.preventDefault() @@ -160,6 +180,10 @@ function handleSubmit(e) { const formDataEncoded = new URLSearchParams(formData).toString() const formURL = form.action + '.json' + // logSubmission() + // fakeOut() + // return false + fetch(formURL, { method: 'POST', headers: { From 5c401526bb25f86784ddc3c5ae8e2ece436fb0bf Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 12:17:54 +0200 Subject: [PATCH 6/7] fixed bestellformular --- assets/js/bestellformular.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/assets/js/bestellformular.js b/assets/js/bestellformular.js index b7c81c8..0467bdd 100644 --- a/assets/js/bestellformular.js +++ b/assets/js/bestellformular.js @@ -43,8 +43,6 @@ const captchaInput = document.querySelectorAll('.captcha-input') const captchaVerifyButton = document.querySelectorAll('.captcha-verify') // Form fields -const subjectField = document.getElementById('subject') -const messageField = document.getElementById('description') const botBadge = document.createElement('div') if (debugEnabled) { @@ -117,9 +115,6 @@ function validateZSRNumber(form) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = - subjectField.value === "I promised." || -// or if messageField Has string "Hi, this is" in it - messageField.value.startsWith("Hi, this is") || !userInteracted || interactionCount === 0 || timeSpent < interactionThreshold || From 72bdab6785a4439ab513d0358ebd668d35909598 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 12:38:59 +0200 Subject: [PATCH 7/7] added Verua email to order form --- static/php/ajaxmail.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/static/php/ajaxmail.php b/static/php/ajaxmail.php index 62cbefc..7acf297 100644 --- a/static/php/ajaxmail.php +++ b/static/php/ajaxmail.php @@ -27,7 +27,7 @@ try { // Es handelt sich wahrscheinlich um einen Bot $subject = 'Botverdacht - ' . $subject; } - + if (empty($name) || !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($message)) { // Invalid input throw new Exception('Ungültige Eingabedaten.'); @@ -44,11 +44,9 @@ try { $mail->Port = 465; // TCP port for the connection // Recipients - $mail->setFrom($email, $name); // Sender address + $mail->setFrom('support@verua.ch', 'Verua Support'); // Sender address $mail->addAddress('ah@mediendesign-hnida.de', 'Andreas Hnida'); // Add recipient - // $mail->addAddress('bettina.rasberger@rabe-web.ch', 'Bettina Rasberger'); // Add another recipient - // $mail->addAddress('norbert.wagner@verua.ch'); // Add another recipient - $mail->addReplyTo($email, $name); // Set reply address + $mail->addAddress('support@verua.ch', 'Verua Support'); // Add another recipient $mail->addBCC('ah@mediendesign-hnida.de'); // Add bounce email address as BCC // Content