Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Member Board

From: Paavo::Nevalainen::saunalahti::fi at: 27-Feb-2008 17:43

At 08:57 AM 2/27/2008, Graham Chiu wrote:
>Some way to obfuscate the email addresses from bots would be good.
My favorite obfuscator is this one: ; ---------------------------------- yes this is code from now on ---------------------------- init-email2pngs: func [ char [string!] ][ return view/new/options layout [ origin 4x2 text rejoin [char ""] ; old View versions, use [char " "] ] [resize no-border] ] if not exists? %pngs/ [ make-dir %pngs/ for i 0 255 1 [ save/png to-file rejoin ["pngs/" i ".png"] to-image init-email2pngs to-string to-char i ] ] email2pngs: function [ email [email!] ][ out char ][ out: make string! "" foreach char to-string email [ append out rejoin [ {<img src="} html-address {pngs/} to-integer char {.png"></a>} ] ] return out ] test: does [ html-address: http://your.favorite.com/ email-address: charlie.brown-ubiquituous.com print rejoin ["<tr><td>contact info: </td><td>" email2pngs email-address "</td></tr>"] ] ; --------------------------------- the code is not all, the world begins here ------------- This might be originally one of the classic REBOL examples, I use it so that I add the above code to my CGI folder , and after the first "compile" I copy the %pngs/ directory to the html folder. The code uses the limited part of the classic 255 chars ASCII, I think nowadays some more chars are supported (e.g. &auml;) but still no UNICODE I think, so it is quite valid piece of code. I use this function especially where the normal obfuscation is enough, e.g. when there are names of persons and such things. Of course the formatting can vary and spacing made more intelligent. -- Attached file included as plaintext by Ecartis -- REBOL [] change-dir %/c/documents and settings/tapani/työpöytä/uusi kansio/ init-email2pngs: func [ char [string!] ][ return view/new/options layout [ origin 4x2 text rejoin [char ""] ; old View versions, use [char " "] ] [resize no-border] ] if not exists? %pngs/ [ make-dir %pngs/ for i 0 255 1 [ save/png to-file rejoin ["pngs/" i ".png"] to-image init-email2pngs to-string to-char i ] ] email2pngs: function [ email [email!] ][ out char ][ out: make string! "" foreach char to-string email [ append out rejoin [ {<img src="} html-address {pngs/} to-integer char {.png"></a>} ] ] return out ] email2chars: function [ email [email!] ][ out char ][ out: make string! "" foreach char to-string email [append out rejoin ["&#" to-integer char ";"]] return out ] test: does [ html-address: http://your.favorite.com/ print rejoin ["<tr><td>contact info: </td><td>" email2pngs charlie.brown-ubiquituous.com "</td></tr>"] ]