Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




antispambot [ WordPress Function ]

antispambot ( $emailaddy, $mailto = 0 )
Parameters:
  • (string) $emailaddy Email address.
  • (int) $mailto Optional. Range from 0 to 1. Used for encoding.
Returns:
  • (string) Converted email address.
Defined at:



Converts email addresses characters to HTML entities to block spam bots.

Source


<?php
function antispambot($emailaddy$mailto=0) {
    
$emailNOSPAMaddy '';
    
srand ((float) microtime() * 1000000);
    for (
$i 0$i strlen($emailaddy); $i $i 1) {
        
$j floor(rand(01+$mailto));
        if (
$j==0) {
            
$emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
        } elseif (
$j==1) {
            
$emailNOSPAMaddy .= substr($emailaddy,$i,1);
        } elseif (
$j==2) {
            
$emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy$i1))), 2);
        }
    }
    
$emailNOSPAMaddy str_replace('@','&#64;',$emailNOSPAMaddy);
    return 
$emailNOSPAMaddy;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics