Login   Register  
PHP Classes

File: MailCrypter.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pablo Gazmuri  >  MailCrypter  >  MailCrypter.php  >  Download  
File: MailCrypter.php
Role: Class source
Content type: text/plain
Description: Allows for easy scrambling of email addresses in mailto links. This hides them from email harvesting programs, but will be descrambled in any javascript enabled browser.
Class: MailCrypter
Easily scramble mailto links to avoid harvesting.
Author: By
Last change: Changed File Role.
Date: 12 years ago
Size: 1,348 bytes


Class file image Download

//    MailCrypter class
//    Written by: Pablo Gazmuri on July 23, 2002
//    This class writes scrambled mailto: links,
//    keeping email addresses invisible to email
//    harvesting programs.
//    NOTE: Only tested in IE and Netscape 6

class MailCrypter{

//this function adds a link and returns the scrambled link text
function addMailTo($address$addlAttributes ""){
$new "";
$this->links[] = $address;
$new .= chr(ord(substr($address$i1)) - 1);
"<a id=\"link".(count($this->links)-1)."\" href=\"mailto:$new\" $addlAttributes >$new</a>";
//this function echos the javascript code to descramble the links
function writeScript(){
"\n\n<script language=\"JavaScript\">
        <!--hide from older browsers\n"
        function ConvLink(link){
            var temp='';
            var i;
            for(i =0;i<link.href.length;i++){
                if (i>6){
                    temp = temp + String.fromCharCode(link.href.charCodeAt(i)+1);
                    temp = temp + link.href.charAt(i);
            link.href = temp
            link.innerHTML = temp.substring(7);
$i=0$i<count($this->links);$i++){ echo "