<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CLASS NAME: EMAILCRYPT //
// FILE NAME : CLASS_EMAILCRYPT.INC.PHP //
// LANGUAGE : PHP //
// AUTHOR : Julien PACHET //
// EMAIL : j|u|l|i|e|n| [@] |p|a|c|h|e|t.c|o|m //
// VERSION : 1.0 //
// CREATION : 14/10/2004 //
// LICENCE : GNU/GPL //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// What the class does: //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// * Help writing crypted email link into html file with javascript code, //
// with a view to block spam bot to harvest email adress //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Changelog: //
// ---------- //
// Date Version Actions //
// ------------------------------------------------------------------------------------------------------ //
// past procedural version of crypting email link //
// 14/10/2004 1.0 Class creation and test //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Need to work: //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// None //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
class emailcrypt {
var $crypted_text;
/*
* javascript crypting. Very very thanks to: http://www.lashampoo.com/pages/Cryptage.html
* a little bit modified
*/
function _js_crypt ($text) { // Dynamicaly crypt text with javascript
//$html." "; // for a bug??
$html =chunk_split( bin2hex($text ),2,'%');
$html ='%'.substr($html,0,strlen($html)-1);
$html=chunk_split($html,54,"'+'");
$html= substr($html,0,strlen($html)-6);
$res= "<script type=\"text/javascript\" language=\"JavaScript\">\n";
$res.="\t<!--\n\t\t document.write(unescape('$html'));\n\t //-->\n";
$res.="</script>\n";
return $res;
}
/*
* emailcrypt: the constructor
* @param email: the email address
* @param text: the text or picture or anithing else to display
* @param crypt: true if you want to crypt email address
*/
function emailcrypt($email,$text,$crypt=true) {
$temp="<a href='mailto:$email'>$text</a>";
$this->crypted_text=($crypt)?$this->_js_crypt($temp):$temp;
}
/*
* get: return the text of crypted email address, you have to insert in the web page
*/
function get() {
return $this->crypted_text;
}
}
?>