%
'***********************************************************
'Copyright 2003 Ferruh Mavituna
'ASP Email Obfuscator v1.1
'http://ferruh.mavituna.com
'Encode email addresses to make it harder for spammers to harvest them.
'Inspired from http://www.zapyon.de/spam-me-not/
'***********************************************************
'This program is free software; you can redistribute it and/or modify
'it under the terms of the GNU General Public License as published by
'the Free Software Foundation; either version 2 of the License, or
'(at your option) any later version.
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
'
'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'***********************************************************
'Details : http://www.gnu.org/licenses/gpl.txt
'***********************************************************
'***********************************************************
'// USAGE
'***********************************************************
'// [1] Add fm_str2Arr, fm_decode, fm_obfuscate function into your page or include.
'// [2] Print fm_obfuscate
'// ARGUMENTS
'// @email : String
'// @method : Number (default=3)
'// 1 : Decimal
'// 2 : Hexadecimal
'// 3 : Random
'// @Optional Text : E-mail Text
'// SAMPLE (see more in demonstrations -at the end of the code-)
'// Response.Write fm_obfuscate("email@address.com",2,"Drop me a mail")
'// OptText Encode Fixed
'***********************************************************
'******************************************************************
'// Convert a String to Array by Ferruh Mavituna
'******************************************************************
Function fm_str2Arr(byVal Str, byRef Arr)
Dim i, StrLen
StrLen = Len(Str)-1
Redim Arr(StrLen)
For i = 0 to StrLen
Arr(i)=Left(Str,1)
If Len(Str)>0 Then Str=Right(Str,Len(Str)-1)
Next
End Function
'******************************************************************
'// Decode Characters by Ferruh Mavituna
'******************************************************************
Function fm_decode(byVal Char, byVal method)
'// Randomize
'***********************************
If method=3 Then
Randomize Timer
method = CInt(Rnd*1)+1
End If
'// Select Method
'***********************************
Select Case method
Case 1 '// Decimal Notation
'***********************************
fm_decode = Asc(Char)
Case 2 '// Hexadecimal Notation
'***********************************
fm_decode = "x" & Hex(Asc(Char))
End Select
End Function
Function fm_obfuscate(byVal email,byVal method, byval OptText)
Dim tmpStr, mailArr(), i, finalStr, mailtoArr(), tmpMailtoStr, OptStrArr()
'// Fix method
If NOT isNumeric(method) Then method = 3
If method>3 Then method = 3
'// Encode "mailto:"
fm_str2Arr "mailto:",mailtoArr
For i = 0 To Ubound(mailtoArr)
tmpMailtoStr = tmpMailtoStr & "" & fm_decode(mailtoArr(i),method) & ";"
Next
'// Convert String to Array
'***********************************
fm_str2Arr email,mailArr
'// Generate Text
'***********************************
For i = 0 To Ubound(mailArr)
finalStr = finalStr & "" & fm_decode(mailArr(i),method) & ";"
Next
'// Fix OptionText
'***********************************
If OptText="" Then
OptText = finalStr
Else
fm_str2Arr OptText,OptStrArr
'// Generate Text
'***********************************
OptText=""
For i = 0 To Ubound(mailArr)
OptText = OptText & "" & fm_decode(mailArr(i),method) & ";"
Next
End If
finalStr = tmpMailtoStr & finalStr
'// Return
'***********************************
fm_obfuscate = "" & OptText & "
"
End Function
'***********************************
'***********************************
'// Demonstrations
'***********************************
'***********************************
Response.Write "by Ferruh Mavituna | Download Source Code
" '// Decimal '*********************************** Response.Write "