#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@"  EmailEncoder2 J--> all handlers -- The following is a joint effort from Sarah Reichelt and Tim Ponn. -- This is a set of handlers that will hide "mailto:" email links contained -- in a web page from the web crawling address harvesters that spammers use. -- Just click the "Encode" button, choose the file you want encoded, -- and a new file with encoded "mailto:" links will be created for you. -- Your original file will remain untouched. -- This function encodes a "mailto:" link by changing some of the chars -- to ASCII numbers. This renders it too confusing for web crawlers on -- an email harvesting mission to deal with, yet leaves it fully readable -- by browsers. -- function encodeThis pData put empty into tCode set the randomSeed to (char-7 to -1 of the milliseconds) --Not really necessary, but things are a bit more "random" if we set a new seed everytime we call this function. repeat for each char c in pData --We look at every char in the string that was passed. if random(10)=1 then --10% of the time, put c after tCode --we'll just leave the char alone and append it to the output local var...this makes it more difficult for the web crawler to parse the file quickly. else --90% of the time, put fattenThis(charToNum(c)) into tNum --we confuse the crawler by changing the char into it's ascii equivalent, and passing it to a function that may or may not add leading zeroes to it, confusing it further. put "&#"&tNum&";" after tCode --Then appending it to the output local var. end if end repeat return tCode end encodeThis --This function adds a random quantity of leading zeros to a number. -- function fattenThis pNum put random(5) into tLen if tLen > (the length of pNum) then return char -tLen to -1 of ("00000" & pNum) else return pNum end if end fattenThis -- loops through the data from a file encoding all mailto's found -- function encodeFile pFileData put empty into tEncodedFile --Initialize a local var. where we can later collect the modified contents. repeat get offset("mailto:",pFileData) -- get the character number where a "mailto:" link starts in the input local var. put char 1 to (it+6) of pFileData after tEncodedFile -- copy the chars up to & including the "mailto:" link into the output local var (we don't want to mess with that code), delete char 1 to (it+6) of pFileData --and delete them from the input local var. get offset(quote&">",pFileData) --Now get the character number of the END of the mailto:" link, put char 1 to (it-1) of pFileData into tLink delete char 1 to (it-1) of pFileData --and delete them from the input local var. put encodeThis(tLink) after tEncodedFile --encode this string of chars, and append it to the end of the output local var, if offset("mailto:",pFileData)=0 then exit repeat --If offset is zero, we're done encoding, end repeat --so exit the repeat, put pFileData after tEncodedFile --and append whatever we have leftover in the input local var to the output local var. -- my web page creator puts multiple blank lines in the source repeat while tEncodedFile contains cr & cr replace cr & cr with cr in tEncodedFile end repeat return tEncodedFile end encodeFile -- this is called after return or enter in the two data entry fields -- if both are filled in, it will encode immediately -- on checkForEnoughData if fld "Email" is not empty and fld "Email" contains "@" and fld "Link" is not empty then send "mouseUp" to btn "Encode" end checkForEnoughData -- function to force a given filename to have the required extension -- function forceExtension pFilePath, pExtension set itemDel to "/" put last item of pFilePath into tFileName delete last item of pFilePath set itemDel to "." if the last item of tFileName <> pExtension then put pExtension into item (the number of items of tFileName+1) of tFileName end if return pFilePath & "/" & tFileName end forceExtension bEmail Encoder_ ULucida Grande UAbadi MT Condensed LightUAbadi MT Condensed LightUApple ChanceryUApple LiGothic Medium,ChineseUAppleGothic,KoreanUAristocrat LETU Bank GothicU BaskervilleUBickley Script LETUBitstream Vera SansU Big CaslonU GaramondU Engravers MTUFootlight MT LightUGadget UGadgetU Arial BlackcREVGeometryCachestackID1022 cREVGeneral debugObjects breakPointscConsNoSetPropsForArchive4CompilesForSave2CompilesForArchive4SetPropsForSave4 cConsLastHandlerScroll225 HandlerName  @cREVGeometryCacheIDs 1135399096460102211098092608751004110980928207910081109810064558101311353948588021018110980927418210061135394064602101511353948656561019113539420743710171109809289388101011353940646321016cREVGeometrycacheorder total11  EmailLabel   cConsLastHandlerScroll47 HandlerName cREVGeneral revUniqueID 1109809260875 Email Address: Emailip--> all handlers -- if return, enter or tab is pressed, a hander in the stack script will check if sufficient data has been entered -- and encode the link if so. -- -- as the encoding has a random aspect, the link will change each time -- on returnInField checkForEnoughData end returnInField on enterInField checkForEnoughData end enterInField on tabKey checkForEnoughData pass tabKey end tabKey & cConsLastHandlerScroll0 HandlerName cREVGeneral revUniqueID 1109809274182  EncodeEw<--> all handlers on mouseUp -- clear the newly created link first put empty into fld "Result" -- check that a valid email address has been supplied put fld "Email" into tEmail if tEmail is empty or tEmail contains "@" is false then answer error "Please type a valid email address" & cr & "into the email address field!" as sheet exit to top end if -- check that some link text has been entered put fld "Link" into tLink if tLink is empty then answer error "Please type some plain text into the link text field!" & cr & \ "This is the text that will appear on the web page." as sheet exit to top end if -- the encoding is done by a handler in the stack scripts put encodeThis(tEmail) into tCode -- then the encoded text is formatted into a mailto link & displayed put "" & tLink & "" into fld "Result" -- and copied to the clipboard set the clipboardData["text"] to fld "Result" end mouseUp K^z cConsLastHandlerScroll0 HandlerNamemouseUp message cREVGeneral scriptChecksum%uK-e=A handlerListmouseUp breakPointsscriptSelection char 1 to 0 revUniqueID 1109809282079 bookmarks tempScript prevHandlermouseUpscript Info  cREVTable currentviewMEnter an email address and click 'Encode'. The randomly encoded link will appear in the box above and be placed in the clipboard. This can be used in a web page where it is clickable by people, but cannot be read by web-crawlers. Use the buttons below to encode all the mailto links in a single html file or a folder of html files. cREVGeneral revUniqueID 1109810064558 +Enter an email address and click 'Encode'. 7The randomly encoded link will appear in the box above and be placed in the clipboard. dThis can be used in a web page where it is clickable by people, but cannot be read by web-crawlers. fUse the buttons below to encode all the mailto links in a single html file or a folder of html files.  TextLabel , cConsLastHandlerScroll47 HandlerName cREVGeneral revUniqueID 1135394064602 Link text: Linkip--> all handlers -- if return, enter or tab is pressed, a hander in the stack script will check if sufficient data has been entered -- and encode the link if so. -- -- as the encoding has a random aspect, the link will change each time -- on returnInField checkForEnoughData end returnInField on enterInField checkForEnoughData end enterInField on tabKey checkForEnoughData pass tabKey end tabKey ,& cConsLastHandlerScroll0 HandlerNameenterInField message cREVGeneral revUniqueID 1135394064632  email meTestEw--> all handlers on mouseUp -- check that the required data has been entered and encoded put fld "Result" into tLink if tLink is empty then send mouseUp to btn "Encode" put fld "Result" into tLink end if if tLink is empty then answer error "No encoded link available!" as sheet exit to top end if -- assemble a basic html page including the encoded link put "" & cr & "" & cr into tHTML put "Email encoding test" & cr after tHTML put "" & cr & "" & cr after tHTML put "

Click the link below to test if an email will be sent to the correct address.

" & cr after tHTML put tLink & cr after tHTML put "" & cr & "" & cr after tHTML -- save to the users desktop put specialFolderPath("Desktop") & "/EncodingTest.html" into tFile put the fileType into tOldType set the fileType to empty put tHTML into URL ("file:" & tFile) set the fileType to tOldType -- open in the default browser - only tested on MacOS X with Safari & Firefox revGoURL "file://" & tFile end mouseUp /^z cConsLastHandlerScroll0 HandlerNamemouseUp message cREVGeneral scriptChecksum%uK-e=A handlerListmouseUp breakPointsscriptSelectionchar 215 to 214 bookmarks revUniqueID 1135394207437 prevHandlermouseUp tempScriptscript

on mouseUp

put empty into fld "Result"

put fld "Email" into tEmail

put empty into tCode

repeat for each char c in tEmail

put charToNum(c) into tNum

put "&#" & char -3 to -1 of ("000" & tNum) & ";" after tCode

end repeat

put "<a href=" & quote & "mailto:" & tCode & quote & ">Send email</a>" into fld "Result"

set the clipboardData["text"] to fld "Result"

beep

end mouseUp

 Encode fileEw --> all handlers on mouseUp -- check that the required data has been entered and encoded put fld "Result" into tCode if tCode is empty then send mouseUp to btn "Encode" put fld "Result" into tCode end if if tCode is empty then answer error "No encoded link available!" as sheet exit to top end if -- ask for a file to encode "mailto:" links in. answer file "Please choose a file to encode:" with type "Web pages|htm,html|HTML" or type "All files" if the result is "Cancel" or it is empty then exit to top -- no file selected if char -5 to -1 of it <>".html" and char -4 to -1 of it <>".htm" then -- if the file extension is not standard html stuff, answer error "Sorry, this file doesn't have the correct file extension of" && quote \ & ".html" & quote && "or" && quote &".htm" & quote &"."as sheet exit to top -- get out. end if put it into tFileName --We'll need the full filename later so let's tuck it away in a local var. put URL ("file:" & tFileName) into fileContentsIn --Read the file, stick the file's contents into a local var. -- check it really is an html file if fileContentsIn contains "" is false then answer error "Sorry, this file doesn't seem to be a valid html file." as sheet exit to top --and bail out if not end if -- check if there are any "mailto:" links in the file... if offset("mailto:",fileContentsIn)=0 then answer error "Sorry, this file doesn't contain any email links " & cr & \ "or they may already be encoded." as sheet exit to top --and bail out if not end if -- the encoding function is in the stack script put encodeFile(fileContentsIn) into fileContentsOut --Initialize a local var. where we can later collect the modified contents. -- ask where to save the new file: offer to over-write but warn if this is accepted ask file "Save encoded file as:" with tFileName if the result is "Cancel" or it is empty then exit to top --Allow the user to bailout if she wishes. put forceExtension(it, "html") into tNewFile if tNewFile = tFileName then answer warning "Are you sure you want to overwrite the previous version of the file?" with "Cancel" or "Overwrite" as sheet if it = "Cancel" then ask file "Save encoded file as:" with tFileName if the result is "Cancel" or it is empty then exit to top --Allow the user to bailout if she wishes. put forceExtension(it, "html") into tNewFile end if end if -- save the new file -- setting the filetype to empty forces OS X to use the extension to work out what sort of file it is -- the other platforms don't care put the fileType into tOldType set the fileType to empty put fileContentsOut into URL("file:" & tNewFile) set the fileType to tOldType -- preview in browser - only tested on MacOS X with Safari & Firefox answer info "Would you like to view the results in your default browser?" with "No" or "Yes" as sheet if it="Yes" then revGoURL "file://" & tNewFile end if end mouseUp x cConsLastHandlerScroll35 HandlerName mouseUp on cREVGeneral scriptChecksum%uK-e=A handlerListmouseUp breakPointsscriptSelectionchar 215 to 214 bookmarks revUniqueID 1135394858802 prevHandlermouseUp tempScriptscript

on mouseUp

put empty into fld "Result"

put fld "Email" into tEmail

put empty into tCode

repeat for each char c in tEmail

put charToNum(c) into tNum

put "&#" & char -3 to -1 of ("000" & tNum) & ";" after tCode

end repeat

put "<a href=" & quote & "mailto:" & tCode & quote & ">Send email</a>" into fld "Result"

set the clipboardData["text"] to fld "Result"

beep

end mouseUp

Encode folderEw --> all handlers on mouseUp -- check that the required data has been entered and encoded put fld "Result" into tCode if tCode is empty then send mouseUp to btn "Encode" put fld "Result" into tCode end if if tCode is empty then answer error "No encoded link available!" as sheet exit to top end if -- warn that this overwrites all html files answer warning "This will encode ALL mailto links in EVERY .html or .htm file in the selected folder." & cr & cr & \ "The existing files will be overwritten by the encoded versions, so make sure you have a backup of the folder before proceeding." \ with "Cancel" or "Proceed - I have a backup" as sheet if it = "Cancel" then exit to top -- ask for a folder and get out if none is selected answer folder "Select the folder to encode:" put it into tFolder if tFolder is empty then exit to top put the defaultFolder into tOldDefault set the defaultFolder to tFolder put the files into tFileList -- look for .htm & .html files put tFileList into tHTMs put tFileList into tHTMLs filter tHTMs with "*?.htm" filter tHTMLs with "*?.html" put tHTMs & cr & tHTMLs into tFileList sort lines of tFileList filter tFileList without empty -- exit if no valid htm or html files can be found if tFileList is empty then answer error "That folder does not contains any html files!" as sheet set the defaultFolder to tOldDefault exit to top end if -- setting the filetype to empty forces OS X to use the extension to work out what sort of file it is -- the other platforms don't care put 0 into tCount put the fileType into tOldType set the fileType to empty -- loop through the files processing each -- the encodeFile handler is in the stack script repeat for each line L in tFileList -- read the file and check that it really is an html file put URL("file:" & L) into tRawData if tRawData contains "" is false then next repeat -- encode it and add to the report counter add 1 to tCount put encodeFile(tRawData) into tEncodedData put tEncodedData into URL("file:" & L) end repeat -- set everything back the way it was and inform the user how many files have been encoded set the fileType to tOldType set the defaultFolder to tOldDefault answer info tCount & " html files encoded." as sheet end mouseUp ?x cConsLastHandlerScroll1 HandlerName mouseUp on cREVGeneral scriptChecksum%uK-e=A handlerListmouseUp breakPointsscriptSelectionchar 215 to 214 revUniqueID 1135394865656 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

put empty into fld "Result"

put fld "Email" into tEmail

put empty into tCode

repeat for each char c in tEmail

put charToNum(c) into tNum

put "&#" & char -3 to -1 of ("000" & tNum) & ";" after tCode

end repeat

put "<a href=" & quote & "mailto:" & tCode & quote & ">Send email</a>" into fld "Result"

set the clipboardData["text"] to fld "Result"

beep

end mouseUp

ResultCi`, cConsLastHandlerScroll0 HandlerName cREVGeneral revUniqueID 1109809289388 bookmarks handlerList tempScript prevHandlerscriptSelection char 1 to 0script  a AboutbC--> all handlers on mouseUp answer info "Email encoding scripts written by Tim Ponn" & cr & \ "& Sarah Reichelt, 2005" as sheet end mouseUp  4U cConsLastHandlerScroll0 HandlerNamemouseUp message cREVGeneral revUniqueID 1135399096460