Anti Spam Bot Email by ASCII

Nov 21, 2008 Author: City Hall

This class can be used to encode e-mail addresses to avoid robots that crawl pages to harvest e-mail addresses. It takes an e-mail address and can generate two versions: one for displaying in Web pages and another to use in mailto: links. In both versions the @ character is replaced by alternative characters. In the mailto: link version the other characters are encoded using equivalent numeric HTML entities.

<?php
/**
+-------------------------------------------------------------------------
+---------------------->> In The Name Of Live <<-------------------------
+-------------------------------------------------------------------------
| Class AntiIFLSpamBotEmail version 0.0.1 (for php 4)
| Security Email Print 100% Protected For Spam Bot
| Anti Span Bot Email by ASCII
| Author  Behrouz Pooladrag  (IFLashLord) %lt; Me [at] IFLashLord [dot] Com>
| Email bugs/suggestions to  Me [at] iflashlord.com
| Copyright (c) 2008 By Behrouz Pooladrag ,IFLashLord Co.
+-------------------------------------------------------------------------
| This script has been created and released under
| the GNU GPL and is free to use and redistribute
| only if this copyright statement is not removed
+-------------------------------------------------------------------------
+--------------| Contact 2 Behrouz Pooladrag |----------------------------
| Email : Me [ at ] IFLashLord [dot] Com
| WebSite : http://www.IFLashLord.Com
| Yahoo : BehrouzPC [at] yahoo.Com
| G-Mail : FLashLordX [at] gmail.Com
| Mobile : +98 913 12 777 14
+-------------------------------------------------------------------------
| (Zakate Elame Nasher Aan Ast )
+-------------------------------------------------------------------------
**/
/*
+--------------| arguments |----------------------------------------------
|*new AntiIFLSpamBotEmail (string [Email Address for AntiSpam]);
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|*AntiIFLSpamBotEmail->antispambot([integer Number]);
| Number 0  ---> For Show Email text Print
| Number 1  ---> For Set Email to Link (mailto:..)
| Number 2  ---> Return Randomly Part Of Eamil in Hexadecimal
+-------------------------------------------------------------------------
*/



/* Full Exampel of This Class

$antiSpambotBehrouzpc=new AntiIFLSpamBotEmail("behrouzpc@yahoo.com"); //start class
$EmailForShow=$antiSpambotBehrouzpc->antispambot(0);  // for show mode return
$EmailForLink=$antiSpambotBehrouzpc->antispambot(1);  // for link mode return
print "<a href='mailto:".$EmailForLink."'>".$EmailForShow.""; //and Print

*/

/* Result is this Type

<a href='mailto:behr%6f%75zpc@ya%68oo%2ec%6f%6d'>
behrouzpc@yahoo.com

*/

/////////////////////////////////////////////////////


//Start Class
class AntiIFLSpamBotEmail {

var $VERSION = '0.0.1';
var $emailaddy;

    //construct
    function AntiIFLSpamBotEmail ($emailaddy) {
       $this->emailaddy=$emailaddy;
    }//end function construct

    //function to add leading zeros when necessary
    function zeroise($number,$threshold) {
        return sprintf('%0'.$threshold.'s', $number);
    }//end function

    //function to change words To ASCII Random
    function antispambot($mailto=0) {
        $emailNOSPAMaddy = '';
        srand ((float) microtime() * 1000000);
        for ($i = 0; $i < strlen($this->emailaddy); $i = $i + 1) {
            $j = floor(rand(0, 1+$mailto));
            if ($j==0) {
                $emailNOSPAMaddy .= '&#'.ord(substr($this->emailaddy,$i,1)).';';
            } elseif ($j==1) {
                $emailNOSPAMaddy .= substr($this->emailaddy,$i,1);
            } elseif ($j==2) {
                $emailNOSPAMaddy .= '%'.
               $this->zeroise(dechex(ord(substr($this->emailaddy, $i, 1))), 2);
            }
        }
        $emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);
        return $emailNOSPAMaddy;
    }//end function

}//end Class

?> 

tags: anti spam bot email

views 8453
  1. Add New Comment