Advertisements

antispambot

Definition:
function antispambot($emailaddy, $mailto=0) {}

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

Parameters

  • string $emailaddy: Email address.
  • int $mailto: Optional. Range from 0 to 1. Used for encoding.

Return values

returns:Converted email address.

Source code

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;

}

531

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: