Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form-spam protection ( continuation )

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hi guys,

This is the continuation of the following thread : thread434-1220430

A few days ago, I started to get flooded by a spam robot targeting my
forms, so, I decided it was time for me to acccept to waste one hour
of my time for those <insert anything here> spammers.

I chose to use the security code solution that I mentioned in the
previous thread. I don't get the spam anymore now.

So, here is the code I've came up with :

Code:
function hd_secur_securitycode_add($session_name, $string_length, $explanation, $content) {

    if (strstr($content, $_SESSION[$session_name])) {
    
    $output = $content;

    } else {
    
        for($i=0; $i < 10; $i++ ) {
        
        $string .= str_shuffle(md5(time()));
        
        }
    
    $limit = strlen($string) - $string_length;
    
    $string = substr($string, rand(0, $limit), $string_length);
    
    $_SESSION[$session_name] = $string;
    
    $output = $explanation . $string;    
    
    }

return $output;

}

function hd_secur_securitycode_check($session_name, $content) {

return strstr($content, $_SESSION[$session_name]);

}

Code:
...

if (hd_secur_securitycode_check("securiform", $_POST["form_mail_message"])) {

mail(.....);

}

...

Code:
...

$temp_string = "
\n\n\n\n\n\n\n
In order to guarantee the genuineness of your message, please leave the following security code intact.
----
";  

echo"
<textarea name=\"form_mail_message\">
" . hd_secur_securitycode_add("securiform", 55, $temp_string, $_POST["form_mail_message"]) . "
</textarea>
";

...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top