|
|
|
After reading an example of how to secure your email on your website from robots, which was incorrect, as it was pure PHP, I decided to give you my function for doing it.
The code below takes 1 or 2 parameters, the email and the text for the link. If you omit the text, the email address is used.
|
<?php
function secure_email($email, $name=null)
{
$email_parts=split("@",$email);
$email_parts[1]=str_replace(".", ".", $email_parts[1]);
if(is_null($name))
{
$name='\' + user + \'@\' + site + \'';
}
else
{
// change ' to \' to prevent messing up javascript, dont addslashes as only ' needs to be converted
$name=str_replace("'", "\'", $name);
}
$code="";
$code.='<script language="JavaScript">' . "\n";
$code.='<!-- Begin user' . "\n";
$code.='user = "' . $email_parts[0] . '";' . "\n";
$code.='site = "' . $email_parts[1] . '";' . "\n";
$code.='document.write(\'<a href=\\"mailto:\' + user + \'@\' + site + \'\\">\');' . "\n";
$code.='document.write(\'' . $name . '</a>\');' . "\n";
$code.='// End -->' . "\n";
$code.='</script>' . "\n";
return $code;
}
echo secure_email("bob@hotmail.com");
echo secure_email("bob@hotmail.com", "email me");
echo secure_email("bob@hotmail.com", "don't email me");
?> | | |
|
| Calendars to choose a range of dates , reservation events ... Categories : PHP, Calendar, Java Script, Date Time | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | phpEasyMail: An easy way to send data from HTML-forms via EMail. Categories : Email, HTML and PHP, Complete Programs, PHP | | | How to check if JavaScript is enabled on a remote browser with PHP Categories : PHP, Java Script | | | validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email, Regexps, PHP | | | Broadcast HTML Email Categories : PHP, Email, MySQL, Databases | | | POP3 Class Categories : PHP Classes, PHP, Email | | | Validator 98 - a PHP-script to generate form-validation-code in JavaScript. Categories : Complete Programs, Java Script, PHP, HTML and PHP | | | Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript. Categories : PHP, Java Script, DOM XML, XML, Arrays | | | Classic guest book made with PHP and Flash Categories : PHP, Flash, Java Script | | | email validator check checker email e-mail email address Categories : PHP, Email, Regexps | | | Upload any fixed type of files, control file type through javascript and encrypt filename using php so file not get overwrite Categories : PHP, Java Script, Functions, PHP References, Form Processing | | | simple script to send emails via a html-form to different users Categories : Email, MySQL, PHP, Databases | | | Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item. Categories : PHP Classes, PHP, Java Script, DHTML | | | Protect your email links from being spidered by spam email robots! Categories : PHP, Security, Mail, Email | |
| | | | matthew waygood wrote : 1167
Hello,
I recommend you use another persons code as it has been tested and found to work with a few email extractors I have and doesnt use javascript, so it can be used with browsers that have javascript turned off.
Protect your mailto: email addresses from bots - pure PHP
Submitted by: Klingenspor Gerd
http://www.weberdev.com/get_example.php3/3957
| | | | Sarah King wrote :1173
Here`s another option (although not favoured by this author).
http://www.weberdev.com/get_example.php3?count=3939
| |
|
|