I have the following code which runs as Custom Code when the form is submitted. The idea is that it loops through all of the fields (assuming it's not an email field) and runs a regexp against the fields for a URL or Email address.
I'm still seeing some forms with URLs in the fields come through.
The last one I had was:
http://www.rmtbear.com/info-3.html
Validating the regexp at http://regexpal.com/ I get a match using:
Can you see why this doesn't stop the form running?
The custom code is run as Controller and is the first OnSubmit event:
Do I need to exit() after the redirect to make sure?
I'm still seeing some forms with URLs in the fields come through.
The last one I had was:
http://www.rmtbear.com/info-3.html
Validating the regexp at http://regexpal.com/ I get a match using:
(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?
Can you see why this doesn't stop the form running?
The custom code is run as Controller and is the first OnSubmit event:
<?php
$isthisspam = false;
//Honeypot
if ( $form->data['parmaham'] != '' ) {
$isthisspam=true;
}
foreach($form->data as $name => $value) {
if ($name == 'email') {
//Skip validation
} else {
//Email
if (preg_match("/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/",$value)) {
$isthisspam=true;
}
//URL
if (preg_match("/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/",$value)) {
$isthisspam=true;
}
}
}
//Is this spam?
if ($isthisspam) {
$mainframe->redirect('http://www.ic3.gov/default.aspx');
}
?>
Do I need to exit() after the redirect to make sure?
Hi petersen,
I think that the ^ and $ in your regexp mean that you will only get a match if the URL is the entire value - but you want to check even if it's only part of the value.
Bob
I think that the ^ and $ in your regexp mean that you will only get a match if the URL is the entire value - but you want to check even if it's only part of the value.
Bob
This topic is locked and no more replies can be posted.