<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<script language=JavaScript type=text/javascript>
<!--
function Dec2Hex(Decimal)
{
var hexChars = "0123456789ABCDEF";
var a = Decimal % 16;
var b = (Decimal - a)/16;
hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
return hex;
}
function GenererCode()
{
// génère contenu 1
StrFinal = ''
StrLien = ''
StrMail = document.FormeCode.AdresseEMail.value
StrMail = StrMail.toLowerCase()
for (j=0; j<StrMail.length; j++)
{
StrLien += '%' + Dec2Hex(StrMail.charCodeAt(j))
}
StrFinal = '<a href = "mailto:' + StrLien + '">' + document.FormeCode.LienEMail.value + '<' + '/a>'
document.FormeCode.source1.value=StrFinal
// génère contenu 1
StrFinal = ''
StrLien = ''
StrMail = document.FormeCode.AdresseEMail.value
StrMail = StrMail.toLowerCase()
StrCode = ""
StrCodage = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890"
IntLong = StrMail.length
StrFinal = '<script type="text/javascript" language="javascript">\n' +
'<!-'+'-\n' +
'{\n'
for (j=0; j<StrMail.length; j++)
{
if (StrCodage.indexOf(StrMail.charAt(j)) == -1 )
{
chr = StrMail.charAt(j)
StrCode += StrMail.charAt(j)
}
else
{
chr = (StrCodage.indexOf(StrMail.charAt(j)) + IntLong) % StrCodage.length
StrCode += StrCodage.charAt(chr)
}
}
StrFinal += ' StrCode = \"' + StrCode + '\"\n' +
' StrCodage = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890"\n'+
' IntLong=StrCode.length\n'+
' StrLien=""\n'+
' for (i=0; i<StrCode.length; i++)\n' +
' {\n' +
' if (StrCodage.indexOf(StrCode.charAt(i))==-1)\n' +
' {\n' +
' StrLettre=StrCode.charAt(i)\n' +
' StrLien+=(StrLettre)\n' +
' }\n' +
' else\n'+
' {\n'+
' StrLettre = (StrCodage.indexOf(StrCode.charAt(i))-IntLong+StrCodage.length) % StrCodage.length\n'+
' StrLien+=(StrCodage.charAt(StrLettre))\n'+
' }\n'+
' }\n'+
' document.write("<a href=\'mailto:"+StrLien+"\'>'+document.FormeCode.LienEMail.value+'</a>")\n' +
'}\n'+
'//-'+'->\n' +
'<' + '/script>\n'
document.FormeCode.source2.value=StrFinal
}
// -->
</script>
</head>
<body>
<div id="conteneur">
<h3>mail anti spam<br />
<p><form name="FormeCode">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td> L'adresse mail à coder : </td>
<td> <input name="AdresseEMail"> </td>
</tr>
<tr>
<td> Texte du lien: </td>
<td> <input value="Contactez-moi" name="LienEMail"> </td>
</tr>
<tr>
<td> </td>
<td><input name="button" type="button" onClick="GenererCode()" value="Générer le code" ></td>
</tr>
<tr align="left" valign="top">
<td><strong>Solution 1</strong><br>
Code javascript à insérer <br>
dans votre page :</td>
<td>
<textarea name="source1" rows="5" cols="40"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr align="left" valign="top">
<td><strong>Solution 2</strong><br>
Code javascript à insérer <br>
dans votre page :</td>
<td>
<textarea name="source2" rows="10" cols="40"></textarea>
</td>
</tr>
</table>
</form> </p></h3>
</div>
</body>
</html>
/* Encodage d'email pour contrer le spam */
// Transforme les caractères de l'email en équivalent ASCII dans le code source
function emailEncode($email) {
$nb_caractere = strlen($email);
for ($a = 0; $a < $nb_caractere; $a ++) {
$ord = ord(substr($email, $a, 1) );
$email_encode .= '&#'.$ord.';';
}
return $email_encode;
}