WP File Manager
Current Path:
/
home
/
argothem
/
www
/
organecyberpresse
/
plugins
/
auto
/
mailcrypt
/
v3.1.1
/
Name
Action
..
install.log
Edit
lang
mailcrypt-xx.svg
Edit
mailcrypt_fonctions.php
Edit
paquet.xml
Edit
Editing: mailcrypt_fonctions.php
<?php /** * Plugin MailCrypt */ if (!defined('_ECRIRE_INC_VERSION')) { return; } function mailcrypt_post_propre($texte) { return mailcrypt($texte); } function mailcrypt_defines() { static $ok = null; if (is_null($ok)) { $ok = true; // tip visible onMouseOver (title) // jQuery replacera ensuite le '@' comme ceci : title.replace(/\.\..t\.\./,'[\x40]') if (!defined('_MAILCRYPT_AROBASE_JS')) { define('_MAILCRYPT_AROBASE_JS', '..åt..'); } if (!defined('_MAILCRYPT_AROBASE_JSQ')) { define('_MAILCRYPT_AROBASE_JSQ', preg_quote(_MAILCRYPT_AROBASE_JS, ',')); } // span ayant l'arobase en background if (!defined('_MAILCRYPT_AROBASE')) { define('_MAILCRYPT_AROBASE', '<span class=\'mcrypt\'> ' . _T('mailcrypt:chez') . ' </span>'); } if (!defined('_MAILCRYPT_CARACTERES_LIENS')) { define('_MAILCRYPT_CARACTERES_LIENS', '\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\.\{\|\}\~a-zA-Z0-9'); } if (!defined('_MAILCRYPT_REGEXPR')) { define('_MAILCRYPT_REGEXPR', ',\b([' . _MAILCRYPT_CARACTERES_LIENS . ']+)@([a-zA-Z][a-zA-Z0-9-.]*\.[a-zA-Z]+(\?[' . _MAILCRYPT_CARACTERES_LIENS . ']*)?),'); } if (!defined('_MAILCRYPT_FONCTION_JS_LANCER_LIEN')) { define('_MAILCRYPT_FONCTION_JS_LANCER_LIEN', 'mc_lancerlien'); } } } function mailcrypt_affichage_final($texte) { if ( $GLOBALS['html'] && strpos($texte, 'mc_lancerlien') !== false ) { $js = <<<js <script type="text/javascript">/*<![CDATA[*/ function mc_lancerlien(a,b){x='ma'+'ilto'+':'+a+'@'+b.replace(/\.\..t\.\./g,'@'); return x;} jQuery(function(){ jQuery('.mcrypt').empty().append('@'); jQuery('a.spip_mail').attr('title',function(i, val) { if(val) return val.replace(/\.\..t\.\./g,'@');}); });/*]]>*/</script> js; if ($p = stripos($texte, '</body>')) { $texte = substr_replace($texte, $js, $p, 0); } } return $texte; } function mailcrypt_facteur_pre_envoi($facteur) { $facteur->Body = maildecrypt($facteur->Body); $facteur->AltBody = maildecrypt($facteur->AltBody); return $facteur; } function mailcrypt_echappe($matches) { return code_echappement($matches[0], 'MAILCRYPT'); } function mailcrypt_protection_lien($matches) { $m1 = $matches[1]; $m2 = $matches[2]; $m2 = preg_replace(',\@,', _MAILCRYPT_AROBASE_JS, $m2); // Il faut aussi tenir compte des ecritures du type mailto:toto@toto.org,titi@titi.org ou mailto:toto@toto.org?cc=tata@tata.org return '"#' . $m1 . '#mc#' . $m2 . '#" title="' . $m1 . _MAILCRYPT_AROBASE_JS . $m2 . '" onclick="location.href=' . _MAILCRYPT_FONCTION_JS_LANCER_LIEN . '(\'' . $m1 . '\',\'' . $m2 . '\'); return false;"'; } /** * Crypte le texte * * @param string $texte * Le texte à décripter * @return string */ function mailcrypt($texte) { if (strpos($texte, '@') === false) { return $texte; } mailcrypt_defines(); // echappement des 'input' au cas ou le serveur y injecte des mails persos if (strpos($texte, '<in') !== false) { $texte = preg_replace_callback(',<input [^<]+/>,Umsi', 'mailcrypt_echappe', $texte); } // echappement des 'protoc://login:mdp@site.ici' afin ne pas les confondre avec un mail if (strpos($texte, '://') !== false) { $texte = preg_replace_callback(',[a-z0-9]+://[' . _MAILCRYPT_CARACTERES_LIENS . ']+:[' . _MAILCRYPT_CARACTERES_LIENS . ']+@,Umsi', 'mailcrypt_echappe', $texte); } // echappement des domaines .htm/.html : ce ne sont pas des mails if (strpos($texte, '.htm') !== false) { $texte = preg_replace_callback(',href=(["\'])[^>]*@[^>]*\.html?\\1,', 'mailcrypt_echappe', $texte); } // protection des liens HTML $texte = preg_replace_callback(",[\"\']mailto:([^@\"']+)@([^\"']+)[\"\'],", 'mailcrypt_protection_lien', $texte); // retrait des titles en doublon... un peu sale, mais en attendant mieux ? $texte = preg_replace(',title="[^"]+' . _MAILCRYPT_AROBASE_JSQ . '[^"]+"([^>]+title=[\"\']),', '$1', $texte); if (strpos($texte, '@') === false) { return echappe_retour($texte, 'MAILCRYPT'); } // protection de tout le reste... $texte = preg_replace(_MAILCRYPT_REGEXPR, '$1' . _MAILCRYPT_AROBASE . '$2', $texte); return echappe_retour($texte, 'MAILCRYPT'); } /** * Décrypte le texte * * @param string $texte * Le texte à décripter * @return string */ function maildecrypt($texte) { if (strpos($texte, 'mcrypt') === false && strpos($texte, 'mc_lancerlien') === false && strpos($texte, '#mc') === false) { return $texte; } // Traiter les <span class="mcrypt">chez</span> $texte = preg_replace(',<span class=\'mcrypt\'>(.*)</span>,U', '@', $texte); $texte = preg_replace(',<span class="mcrypt">(.*)</span>,U', '@', $texte); mailcrypt_defines(); // Traiter les liens HTML $texte = preg_replace( ',href="#(\S+)#mc#(\S+)#" title="(\S+)' . _MAILCRYPT_AROBASE_JSQ . '(\S+)" onclick="location.href=' . _MAILCRYPT_FONCTION_JS_LANCER_LIEN . '(.+)",U', 'href="mailto:$3@$4"', $texte ); // Traiter les liens texte $texte = preg_replace(',#(\S+)#mc#(\S+)#,U', 'mailto:$1@$2', $texte); $texte = preg_replace(',(\S+) ' . _T('mailcrypt:chez') . ' (\S+),U', '$1@$2', $texte); // Supprimer l'appel du javascript $texte = preg_replace(',<script type=\'text/javascript\'(.*)mailcrypt.js(.*)</script>,U', '', $texte); // Nettoyer les eventuels _MAILCRYPT_AROBASE_JSQ restants (lien avec destinataires mutiples) $texte = preg_replace(',_MAILCRYPT_AROBASE_JSQ,', '@', $texte); return $texte; }