|
|
|
contributed by http://sarahk.pcpropertymanager.com/obfuscate.php
see working example!
at the moment mail harvesters/bots don't read this code,
therefore your email addresses are protected if you put them
on your page like this.
browsers still read them
| [code]
<?php
function getEmail($name)
{
$name .= '@mysite.com';
$email = getOrdString('mailto:'.$name);
$label = getOrdString($name);
return "<a href='{$email}'>{$label}</a>";
}
function getOrdString($string)
{
for($i=0;$i<strlen($string);$i++) $output .= '&#'.ord($string[$i]).';';
return $output;
}//function getOrdString($string)
?> | | |
|
| email new items in db Categories : PHP, Email, Databases, MySQL, Beginner Guides | | | PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | | | Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip Categories : Email, Network, PHP, PHP Classes | | | A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more. Categories : Email, PHP, LDAP | | | Encoding data using PGP via PHP's proc_* functions Categories : Cryptography, Security, Email, PHP, PGP | | | email validator check checker email e-mail email address Categories : PHP, Email, Regexps | | | Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users). Categories : Algorithms, Email, PHP | | | PHPRecommend v1.0 - "Recommend this page to a friend" script written in
PHP. Easy to install Categories : PHP, URLs, Complete Programs, Email, Site Planning | | | validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email, Regexps, PHP | | | Validator - A PHP class that can can be used for validating Email IDs and Dates Categories : PHP, PHP Classes, Data Validation, Email, Date Time | | | making links from text Categories : PHP, Regexps, Email | | | HTTP Basic Authentication via POP3. Categories : Authentication, HTTP, Email, PHP | | | A PHP based webmail at : http://www.horde.org/imp Categories : Email, IMAP, PHP, Complete Programs | | | Protect your mailto: email addresses from bots - pure PHP Categories : PHP, Email, Security | | | Protect your email links from being spidered by spam email robots! Categories : PHP, Security, Mail, Email | |
| | | | matthew waygood wrote : 1150
This is absolutely rubbish.
PHP is run server side and produces results that can be seen by browsers and bots.
In order to protect you email from bots you must use javascript which is run client side.
what you need to protect your email address is:-
<script language="JavaScript">
<!-- Begin
user = "matthew";
site = "somewhere.co.uk";
document.write(`<a href=\"mailto:` + user + `@` + site + `\">`);
document.write(`>>Contact me<<</a>`);
// End -->
</script>
You could write a php function to take the parameters and output the above. which I will do for you as my own example
| | | | Sarah King wrote : 1151
I disagree.
This code hides the vital mailto and @ symbols and at the moment the harvesters appear to be too lazy to code their bots to read & interpret absolutely everything in an <a> link.
The more any of this is publicised, obviously, the more likely the spammers are to find a way around the technique. But that goes for javascript too.
Thanks for your comments, though, Matthew.
| | | | Adam Ewing wrote : 1154
As stated by Matthew PHP runs server side so I prefer not to send the email address to the browser at all. Instead provide a html form for the user to fill in and then use the php mail() function (or the available formmail script) to send the mail behind the scenes. I have the form and receive script as code blocks I just add to a project and away you go.
As the email is coded into the php script even if it is called from a browser it will not display. You can even go the next step and have this include another php script that is NOT in the public area of the webserver that has a php variable with the email address. You could even store the address in a database and then you can talk about encrypting it as well.
I know that this goes a lot further than a simple mailto link but I feel the form is in some ways a more elegent way of doing it.
| | | | Sarah King wrote : 1172
Having stated that this is rubbish, Matthew seems to have changed his mind and is recommending that you don`t use Javascript but a similar server side process: http://www.weberdev.com/get_example.php3?count=3951
| | | | matthew waygood wrote : 1226
Yup I did a u turn on this. The suggestion to encode the mailto: is a good one.
To make it more difficult for bot to find "mailto:" or the coded equivalent, the example I suggested uses randomly chosen hex/dec codes for each character so finding the coded equivalent is more difficult. I have amended this to also allow the normal character to be used (which is potentially bad - but added a lesser probability of it choosing this)
ie
converting abc to  allows bot to search for <a href="....."
converting abc to a makes it more difficult to do a pattern match as there are greater combinations).
(this is an example and not the actual codes)
| | | | matthew waygood wrote :1227
Ah! those squares where supposed to be &#01; and &#x07;
| |
|
|
|