Fix CSP violations and revert to stable CSS version

- Add region1.google-analytics.com to CSP headers in index.php and blog articles
- Fix manifest.json icon purpose warning by changing to "any"
- Add mobile-web-app-capable meta tag for mobile compatibility
- Revert CSS files to stable version from commit 5558f53 to resolve hero section animation issues
- Remove spam protection code that was causing layout problems

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-06-18 05:17:33 +00:00
parent 283ea68ff8
commit cffe81f960
23 changed files with 424 additions and 184 deletions

View File

@@ -171,82 +171,13 @@ document.addEventListener('DOMContentLoaded', function() {
console.log('Enhanced animations initialized');
// Enhanced Form Validation with Anti-Spam Measures
// Form Validation and Enhancement
const contactForm = document.querySelector('.contact-form form');
if (contactForm) {
// Track form interactions for bot detection
let formInteractions = {
mouseMovements: 0,
keystrokes: 0,
focusEvents: 0,
startTime: Date.now(),
fields: {}
};
// Add hidden timestamp field
const timestampField = document.createElement('input');
timestampField.type = 'hidden';
timestampField.name = 'form_timestamp';
timestampField.value = Date.now();
contactForm.appendChild(timestampField);
// Add hidden interaction token
const interactionToken = document.createElement('input');
interactionToken.type = 'hidden';
interactionToken.name = 'interaction_token';
contactForm.appendChild(interactionToken);
// Track mouse movements (humans move mouse)
let mouseMoveHandler = function() {
if (formInteractions.mouseMovements < 100) {
formInteractions.mouseMovements++;
}
};
document.addEventListener('mousemove', mouseMoveHandler);
// Track interactions on form fields
contactForm.querySelectorAll('input, textarea, select').forEach(field => {
field.addEventListener('keydown', function() {
formInteractions.keystrokes++;
if (!formInteractions.fields[field.name]) {
formInteractions.fields[field.name] = {
keystrokes: 0,
changes: 0,
focusTime: 0
};
}
formInteractions.fields[field.name].keystrokes++;
});
field.addEventListener('focus', function() {
formInteractions.focusEvents++;
if (formInteractions.fields[field.name]) {
formInteractions.fields[field.name].focusTime = Date.now();
}
});
field.addEventListener('change', function() {
if (formInteractions.fields[field.name]) {
formInteractions.fields[field.name].changes++;
}
});
});
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Calculate interaction score
const timeSpent = Date.now() - formInteractions.startTime;
const interactionScore = calculateInteractionScore(formInteractions, timeSpent);
// Set interaction token
interactionToken.value = btoa(JSON.stringify({
score: interactionScore,
time: timeSpent,
interactions: formInteractions.mouseMovements + formInteractions.keystrokes + formInteractions.focusEvents
}));
// Basic form validation
const formData = new FormData(this);
const name = formData.get('name');
@@ -272,12 +203,6 @@ document.addEventListener('DOMContentLoaded', function() {
isValid = false;
}
// Check interaction score (low score = likely bot)
if (interactionScore < 30) {
errors.push('Please complete the form normally');
isValid = false;
}
if (isValid) {
// Show loading state
const submitButton = this.querySelector('button[type="submit"]');
@@ -285,29 +210,18 @@ document.addEventListener('DOMContentLoaded', function() {
submitButton.textContent = 'Sending...';
submitButton.disabled = true;
// Submit form with XMLHttpRequest header
// Submit form (you'll need to implement the backend handler)
fetch('contact-handler.php', {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
showNotification(data.message || 'Message sent successfully! We\'ll get back to you soon.', 'success');
showNotification('Message sent successfully! We\'ll get back to you soon.', 'success');
this.reset();
// Reset interaction tracking
formInteractions = {
mouseMovements: 0,
keystrokes: 0,
focusEvents: 0,
startTime: Date.now(),
fields: {}
};
} else {
showNotification(data.message || 'There was an error sending your message. Please try again.', 'error');
showNotification('There was an error sending your message. Please try again.', 'error');
}
})
.catch(error => {
@@ -324,29 +238,6 @@ document.addEventListener('DOMContentLoaded', function() {
});
}
// Calculate interaction score to detect bots
function calculateInteractionScore(interactions, timeSpent) {
let score = 0;
// Time-based scoring (bots submit too fast)
if (timeSpent > 5000) score += 20; // More than 5 seconds
if (timeSpent > 10000) score += 20; // More than 10 seconds
if (timeSpent > 30000) score += 10; // More than 30 seconds
// Mouse movement scoring (humans move mouse)
if (interactions.mouseMovements > 10) score += 20;
if (interactions.mouseMovements > 50) score += 10;
// Keystroke scoring (humans type)
if (interactions.keystrokes > 20) score += 20;
if (interactions.keystrokes > 50) score += 10;
// Focus event scoring (humans tab/click between fields)
if (interactions.focusEvents > 3) score += 10;
return Math.min(score, 100); // Cap at 100
}
// Email validation function
function isValidEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;