note 76049 added to function.htmlentities
| From: | Ashus at osu1 dot php dot net | Date: | Wed, 27 Jun 2007 19:36:54 +0000 |
| Subject: | note 76049 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128035@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.
----
Server IP: 212.24.129.51
Probable Submitter: 85.135.10.2
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/76049
Del: integrated -- https://master.php.net/note/delete/76049/integrated
Del: useless -- https://master.php.net/note/delete/76049/useless
Del: bad code -- https://master.php.net/note/delete/76049/bad+code
Del: spam -- https://master.php.net/note/delete/76049/spam
Del: non-english -- https://master.php.net/note/delete/76049/non-english
Del: in docs -- https://master.php.net/note/delete/76049/in+docs
Del: other reasons-- https://master.php.net/note/delete/76049
Reject -- https://master.php.net/note/reject/76049
Search -- https://master.php.net/manage/user-notes.php