Generate this:
<a href="mailto:fred@example.com">fred@example.com</a>
Using this:
<script type="text/Javascript">var ui='lto';var ofbq='fred&#x';var rd='http://';var xc='40;example.com';var flaj='fred&#x';var md='do_ajax()';var xzko='40;example.com';document.write('<a href="mai'+ui+':'+ofbq+xc+'">'+flaj+xzko+'</a>');</script><NOSCRIPT>Please enable Javascript :(</NOSCRIPT>
<?php /* >=4 */
/** Copyright 2008 Max Howell <www.methylblue.com>
* Licensed as defined by the GNU General Public License version 3 */
function uniqueRandomTokens( $n, $min = 2, $max = 4 )
{
$tokens = array(); // warning--
for ($i = 1; $i <= $n; $i++) {
$length = rand( $min, $max );
$token = '';
for ($j = 0; $j < $length; ++$j)
$token .= chr( rand( 97, 122 ) );
while (in_array( $token, $tokens ))
$token .= chr( rand( 97, 122 ) );
while (in_array( $token, array( 'if', 'for', 'var', 'do', 'while' ) ))
$token .= chr( rand( 97, 122 ) );
$tokens[ "v$i" ] = $token;
}
return $tokens;
}
/** @returns JavaScript to render <a href='mailto:$address'>$text</a>
*/
function print_emunger( $address, $text = '' )
{
// split around the @ symbol, then split the hex entity of that too
$n = strpos( $address, '@' );
$x1 = toHtmlEntities( substr( $address, 0, $n ) );
$x2 = toHtmlEntities( substr( $address, $n + 1 ) );
$x1 = "$x1&#x";
$x2 = "40;$x2";
if ($text == '') {
$x3 = $x1;
$x4 = $x2;
}
elseif (($n = strpos( $text, '@' )) === false) {
// no @ symbol so do a 50/50 split
$n = strlen( $text / 2 );
$x3 = toHtmlEntities( substr( $text, 0, $n ) );
$x4 = toHtmlEntities( substr( $text, $n ) );
}
else {
$x4 = toHtmlEntities( substr( $text, $n + 1 ) );
$x3 = toHtmlEntities( substr( $text, 0, $n ) );
$x3 = "$x3&#x";
$x4 = "40;$x4";
}
extract( uniqueRandomTokens( 7 ) );
echo '<script type="text/Javascript">'.
"var $v1='lto';".
"var $v2='$x1';".
"var $v6='http://';".
"var $v3='$x2';".
"var $v4='$x3';".
"var $v7='do_ajax()';".
"var $v5='$x4';".
"document.write('<a href=\"mai'+$v1+':'+$v2+$v3+'\">'+$v4+$v5+'</a>');".
'</script>';
}
?>
This page was last updated on 2nd February, 2008. © , all content can be freely modified and republished under the terms of the Creative Commons. |