antispambot函数 » 荒野无灯weblog

Keep It Simple, Stupid.

荒野无灯weblog

antispambot函数

formatting.php line 1322

/**
 * Converts email addresses characters to HTML entities to block spam bots.
 *
 * @since 0.71
 *
 * @param string $emailaddy Email address.
 * @param int $mailto Optional. Range from 0 to 1. Used for encoding.
 * @return string Converted email address.
 */
function antispambot($emailaddy, $mailto=0) {
    $emailNOSPAMaddy = '';
    srand ((float) microtime() * 1000000);
    for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
        $j = floor(rand(0, 1+$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, $i, 1))), 2);
        }
    }
    $emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);
    return $emailNOSPAMaddy;
}

Tagged in :

All Comments (0)
Gravatar image
No Comments