[On-Rev] Email masking

Mark Wieder mwieder at ahsoftware.net
Sun Oct 18 11:15:10 EDT 2009


Dom-

Sunday, October 18, 2009, 3:50:15 AM, you wrote:

> So I wondered if it is possible to achieve the same goal with a *.irev
> procedure??

I put a stack on the old revOnline that does this and someday I need
to migrate things to the new revOnline. But here's the relevant code:
pass the Obfuscate function the actual email address and the text you
want to display and it will return the javascript code that gets
embedded in the HTML stream.

--------------------------------------
-- Obfuscate
--
-- Do the real work of converting the email address.
-- Return the javascript code.
--------------------------------------
function Obfuscate pEmailAddress, pVisibleText
  local tEncrypted
  local tNum
  local tDomain, tUser, tDelimiter
  local tJavaScript
  
  -- divide the email address into three chunks
  put trunc(the number of chars in pEmailAddress / 3) into tNum
  put char 1 to tNum of pEmailAddress into tUser
  put char tNum+1 to 2*tNum of pEmailAddress into tDelimiter
  put char 2*tNum +1 to -1 of pEmailAddress into tDomain
  
  put GenerateHeader() into tJavaScript
  -- generate the variables from the email address
  put "var sb_u=" & EncodeString(tUser) after tJavaScript
  put "var sb_d=" & EncodeString(tDomain) after tJavaScript
  put "var sb_a=" & EncodeString(tDelimiter) after tJavaScript
  -- and from the desired visible text
  put "var sb_v=" & quote & pVisibleText & quote & cr after tJavaScript
  put GenerateTrailer() after tJavaScript
  return tJavaScript
end Obfuscate

--------------------------------------
-- EncodeString
--
-- urlEncode the string, char by char
--------------------------------------
function EncodeString pString
  local tEncrypted
  
  repeat for each char c in pString
    put EncodeChar(c) after tEncrypted
  end repeat
  return quote & tEncrypted & quote & cr
end EncodeString

--------------------------------------
-- EncodeChar
--
-- urlEncode the char
--------------------------------------
function EncodeChar pCharToEncode
  return "&#" & CharToNum(pCharToEncode) & ";"
end EncodeChar

--------------------------------------
-- GenerateHeader
--
-- generate the unchanging stuff at the start of the javascript
--------------------------------------
function GenerateHeader
  local tReturn
  
  put "<script language=" & quote & "JavaScript" & quote & ">" & cr into tReturn
  put "<!--" & cr after tReturn
  put "// hide script" & cr after tReturn
  return tReturn
end GenerateHeader

--------------------------------------
-- GenerateTrailer
--
-- the unchanging stuff at the end of the javascript
--------------------------------------
function GenerateTrailer
  local tReturn
  
  put "var sb_r = sb_u + sb_a + sb_d" & cr into tReturn
  put "var sb_x" after tReturn
  put "= " & quote & "mai" & quote && "+" && quote & "lto:" & quote && "+ sb_r" & cr after tReturn
  put "document.write(sb_v.link(sb_x));" & cr after tReturn
  put "// -->" & cr after tReturn
  put "</script>" after tReturn
  return tReturn
end GenerateTrailer

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list