note 76049 modified in function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:54:20 +0000 |
| Subject: | note 76049 modified in function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154909@lists.php.net to get a copy of this message | ||
This should basically protect the mail addresses on webpages:
<?php
function InsertMail($mail)
{
if ($mail=='') return '';
$mail = str_replace(array('@',':','.'),
array('@',':','.'), $mail);
$mail = '<a
href=mailto:'.$mail.'>'.$mail.'</a>';
$len = strlen($mail);
$i=0;
while($i<$len)
{
$c = mt_rand(1,4);
$par[] = (substr($mail, $i, $c));
$i += $c;
}
$join = implode('"+ "', $par);
return '<script language=javascript>
<!--
document.write("'.$join.'")
//-->
</script>';
}
echo InsertMail ('user@example.com');
?>
Prints a javascript, that joins a bunch of randomly long substrings (1-4) of hyperlink prefix mailto
and email address, considering that the chars . : and @ are replaced by html entities. It should
work just fine.
--was--
This should basically protect the mail addresses on webpages:
<?php
function InsertMail($mail)
{
if ($mail=='') return '';
$mail = str_replace(array('@',':','.'),
array('@',':','.'), $mail);
$mail = '<a
href=mailto:'.$mail.'>'.$mail.'</a>';
$len = strlen($mail);
$i=0;
while($i<$len)
{
$c = mt_rand(1,4);
$par[] = (substr($mail, $i, $c));
$i += $c;
}
$join = implode('"+ "', $par);
return '<script language=javascript>
<!--
document.write("'.$join.'")
//-->
</script>';
}
echo InsertMail ('user@example.com');
?>
Prints a javascript, that joins a bunch of randomly long substrings (1-4) of hyperlink prefix mailto
and email address, considering that the chars . : and @ are replaced by html entities. It should
work just fine.
http://php.net/manual/en/function.htmlentities.php