Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5

Nouveau plugin : obfuscation automatique d'email
#17

Grosse amélioration du plugin :
Il ne convertit plus les {mailto} préexistants, ce qui laisse au rédacteur la possibilité de convertir des adresses spécifiques (pour Jce Smile .
Il encode les mails comprenant des subjects et autres attributs comme cc, bcc (mais ne les utilise pas. Si vous souhaitez cet ajout, contactez-moi).
Ex :
  • <a href='mailtoConfusedomeone@example.com?Subject=Hello%20again'> Send Mail</a>
  • <a href="mailto:chose@bidule.fr?subject=Coucou&amp;cc=cc1@bidule.fr&amp;bcc=cc2@bidule.fr">ici</a>
  • <a class="test" href="mailto:blabla@truc.com">double</a>
  • <a href="mailto:BLAbla@truc.com" class="test">test</a>
  • seul@domaine.com
Télécharger le plugin pour cmsms 1.11 svn 8200+ (à dézipper dans le répertoire plugins).
OU code pour 1.11 svn 8200+
Code :
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://www.cmsmadesimple.org
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Put this file into the 'plugins' directory and name it 'prefilter.nonbreaking_characters.php'
# The plugin encode all email adresses into javascript
#
# It convert :
# <a href='mailto:someone@example.com?Subject=Hello%20again'> Send Mail</a></p>
# <a href="mailto:chose@bidule.fr?subject=Coucou&amp;cc=cc1@bidule.fr&amp;bcc=cc2@bidule.fr">ici</a></p>
# <a class="test" href="mailto:blabla@truc.com">double</a></p>
# <a href="mailto:BLAbla@truc.com" class="test">test</a>
# seul@domaine.com
#
# It does not convert {mailto address="nom@domaine.com" text="smarty" encode="javascript"}
#
# Requirements : cmsms 1.11 svn 8200+

function smarty_prefilter_protect_email($tpl_output, &$template)
{
    $smarty = $template->smarty;
    $result = explode(':', $smarty->_current_file);
    if (count($result) > 0)
    {
        if( startswith($result[0],'tmp_') ) $result[0] = 'template';
        if ($result[0] == 'content' || $result[0] == 'globalcontent' || $result[0] == 'template' || strlen($result[0]) == '40')
        // evaluated template a disparu depuis cmsms 1.10.3 et a été remplacé par une string de 40 caractères
        // Si un global content block pose problème, vous empêcher le plugin d'y entrer en ajoutant || $result[1] == 'nom du GCB' dans la condition ci-dessus
        {        
            $patterns = array ('#<a.+href=["\']mailto:([a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4})\b\??[^"\']*["\'][^>]*>([^<]+)</a>#iU',
                   '#([a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4})\b(?!\?|&|"|\'])#iU');
            // Vous pouvez remplacer la valeur de text : {mailto address="$1" text="email" encode=javascript}
            // et utiliser d'autres attributs : {mailto address="$1" text="email" encode="hex" subject="Hello to you!"}
            // voir doc smarty : http://www.smarty.net/docs/en/language.function.mailto.tpl
            $replace = array ('{mailto address="$1" text="$2" encode="javascript"}', '{mailto address="$0" text="$0" encode="javascript"}');
            $tpl_output = preg_replace($patterns, $replace, $tpl_output);        
        }
    }    
    return $tpl_output;        
}

function smarty_cms_about_prefilter_protect_email()
{
    ?>
    <p>Author: Jean le Chauve&lt; (http://www.cmsmadesimple.fr/forum) &gt;</p>
    <p>Version: 1.0</p>
    <p>
    Change History:<br/>
    None
    </p>
    <?php
}
?>

Télécharger le plugin pour cmsms 1.10.3 et inférieurs (à dézipper dans le répertoire plugins).
OU code pour 1.10.3 et versions inférieures
Code :
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://www.cmsmadesimple.org
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Put this file into the 'plugins' directory and name it 'prefilter.nonbreaking_characters.php'
# The plugin encode all email adresses into javascript
#
# It convert :
# <a href='mailto:someone@example.com?Subject=Hello%20again'> Send Mail</a></p>
# <a href="mailto:chose@bidule.fr?subject=Coucou&amp;cc=cc1@bidule.fr&amp;bcc=cc2@bidule.fr">ici</a></p>
# <a class="test" href="mailto:blabla@truc.com">double</a></p>
# <a href="mailto:BLAbla@truc.com" class="test">test</a>
# seul@domaine.com
#
# It does not convert {mailto address="nom@domaine.com" text="smarty" encode="javascript"}
#
# Requirements : cmsms 1.10.3 max.

function smarty_cms_prefilter_protect_email($tpl_output, &$smarty)
{
    $result = explode(':', $smarty->_current_file);
    if (count($result) > 0)
    {
        if ($result[0] == 'content' || $result[0] == 'temporary template' || $result[0] == 'globalcontent' || $result[0] == 'evaluated template')
        // Si un global content block pose problème, vous pouvez empêcher le plugin d'y entrer en ajoutant || $result[1] == 'nom du GCB' dans la condition ci-dessus
        {        
            $patterns = array ('#<a.+href=["\']mailto:([a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4})\b\??[^"\']*["\'][^>]*>([^<]+)</a>#iU',
                   '#([a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4})\b(?!\?|&|"|\'])#iU');
            // Vous pouvez remplacer la valeur de text. Ex. : {mailto address="$1" text="email" encode=javascript}
            // et utiliser d'autres attributs : {mailto address="$1" text="email" encode="hex" subject="Hello to you!"}
            // voir doc smarty : http://www.smarty.net/docs/en/language.function.mailto.tpl
            $replace = array ('{mailto address="$1" text="$2" encode="javascript"}', '{mailto address="$0" text="$0" encode="javascript"}');
            $tpl_output = preg_replace($patterns, $replace, $tpl_output);        
        }
    }    
    return $tpl_output;        
}

function smarty_cms_about_prefilter_protect_email()
{
    ?>
    <p>Author: Jean le Chauve&lt; (http://www.cmsmadesimple.fr/forum) &gt;</p>
    <p>Version: 1.0</p>
    <p>
    Change History:<br/>
    None
    </p>
    <?php
}
?>

Enjoy Smile
Répondre


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)