Answer the question
In order to leave comments, you need to log in
How to protect mail on the site from spammers (autoparsing)?
Hello.
I may have a strange one, but the question is - how can I protect the mail on the site so that for a regular visitor it will be a standard mailto, and the robot scanning the site could not detect it?
The same question for the phone (there is no mailto, but I want to leave the ability to copy the number).
The site is quite well adapted for mobile phones, it is desirable that the solution works there too.
Answer the question
In order to leave comments, you need to log in
Make the mailto field initially empty, and on the left the "Show mail" or "Send mail" link, on which hang a JS handler that will create (calculate or decrypt) the final "mailto" field using some simple algorithm. Probably, then you can also call onClick over the second (collected) field from it.
From time immemorial:
#!/usr/bin/perl
# Usage (SSI):
# <!--#include virtual="[email protected]&[email protected]&text=Some text (may contain e-mails)" -->
#
print "Content-type: text/html\n\n";
&ParseInput;
$JSEMailArray = '\\\''. join ('\\\',\\\'',(split('',$email))) .'\\\'';
$JSTextArray = '\''. join ('\',\'',(split('',$text))) .'\'';
$JSOut = q|<script language=javascript>document.write('<a href="mailto:%%fakedemail%%" onmouseover="email = new Array(%%JSEMailArray%%);this.href=\'mailto:\';for(i=0;i<email.length;i++){this.href+=email[i]}">')</script><script language=javascript>text=new Array(%%JSTextArray%%);for(i=0;i<text.length;i++){document.write(text[i])}</script><script language=javascript>document.write('</a>')</script>|;
$JSOut =~ s|%%(.*?)%%|$$1|ge;
print $JSOut;
exit;
sub ParseInput { #GET only
@allowednames=('email','text','fakedemail');
if ($ENV{'REQUEST_METHOD'} =~ m/^get$/i){@pairs=split(/&/,$ENV{'QUERY_STRING'})}
else {print ''; exit}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack('C', hex($1))/eg;
$name =~ tr/\0//d;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack('C', hex($1))/eg;
$value =~ tr/\0//d;
$value =~ s/<!--(.|\n)*-->//g;
$found = '';
foreach $allowedname(@allowednames){if($allowedname eq $name){$found='OK';last}}
unless ($found){print '';exit}
$$name = $value;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question