File: //proc/thread-self/root/home/awaldron/public_html/archive/tbl/include/functions/f_mail_encode.php
<?php
/*
* URL Encoder script.
* Version 1.0 - February 2002
* (c) 2002, Paul Gregg <pgregg@pgregg.com>
* http://www.pgregg.com
*
* Function: Take an href link and the visible text and make an obfuscated
* link to prevent search engines (or spam harvesters) from picking it up.
*
* Open Source Code: If you use this code on your site for public
* access (i.e. on the Internet) then you must attribute the author and
* source web site: http://www.pgregg.com/projects/
* You must also make this original source code available for download
* unmodified or provide a link to the source. Additionally you must provide
* the source to any modified or translated versions or derivatives.
*
* PHP function-ised version.
*/
Function transpose($str) {
# function takes the string and swaps the order of each group of 2 chars
$len = strlen($str);
$ret = "";
for ($i=0; $i<$len; $i=$i+2) {
if ($i+1 == $len)
$ret .= substr($str, $i, 1);
else
$ret .= sprintf("%s%s", substr($str, $i+1, 1), substr($str, $i, 1));
}
return $ret;
}
Function escapeencode ($str) {
$ret = "";
$arr = unpack("C*", $str);
foreach ($arr as $char)
$ret .= sprintf("%%%X", $char);
return $ret;
}
Function encodelink($href, $text) {
$code = sprintf("var s='%s';var r='';for(var i=0;i<s.length;i++,i++){r=r+s.substring(i+1,i+2)+s.substring(i,i+1)}document.write('<a href=\"'+r+'\">%s</a>');", transpose($href), $text);
$UserCode = sprintf("%s%s%s",
"<script type=\"text/javascript\">\n<!--\neval(unescape('",
escapeencode($code),
"'));\n-->\n</script>");
return $UserCode;
}
?>