├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── boot.php ├── install.php ├── lang └── de_de.lang ├── lib └── rex_email_obfuscator.php ├── package.yml ├── pages ├── config.php ├── help.changelog.php ├── help.license.php ├── help.readme.php └── index.php ├── uninstall.php └── update.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Email Obfuscator - Changelog 2 | ============================ 3 | 4 | ### Version 2.0.0 - 15. März 2017 5 | 6 | * Portierung zu REDAXO 5 7 | * Templates und Artikel können vom Verschlüsseln ausgeschlossen werden 8 | * Attribute in den a-Tags bleiben nun erhalten 9 | * Bei leerer NoScript Message wird die Ausgabe von dem `noscript` Tag unterdrückt 10 | 11 | ### Version 1.6.0 - 25. Oktober 2014 12 | 13 | * Updatefähigkeit für REDAXO 4.6 hergestellt. Einstellungen werden jetzt im Data-Ordner gespeichert. 14 | 15 | ### Version 1.5.1 - 23. August 2014 16 | 17 | * Addon ab 1.5.1 nur noch für REDAXO 4.5+ 18 | * Späte OUTPUT_FILTER Registrierung, so dass andere Addons (opf_lang, String Table etc.) vorab Ersetzungen durchführen können, thx@ceekay82 19 | 20 | ### Version 1.5.0 - 25. Oktober 2013 21 | 22 | * Fixed: Email-Adressen wurden innerhalb Input-Tags fälschlicherweise verschleiert 23 | * Fixed: EMail-Adressen mit z.B. `.co.uk` Endung wurden nicht korrekt verschleiert 24 | * Man kann in der `config.inc.php` den Hinweistext ändern, der erscheint wenn JavaScript deaktiviert ist. 25 | * Man kann in der `config.inc.php` für die NoScript Meldung ein Key für das String Table Addon angeben (so mehrsprachiger Hinweistext möglich). 26 | 27 | ### Version 1.3.0 - 22. September 2013 28 | 29 | * Fixed #7: Manche nackten Email-Adressen wurden nicht ersetzt insbesondere wenn diese zwischen einem HTML-Tag standen (z.B. `

foo@bar.de

`) 30 | 31 | ### Version 1.2.6 - 26. Mai 2013 32 | 33 | * Ersetzung sollte jetzt auch bei einem Title-Attribut in Anchor-Tag sowie bei gleichlautendem Email- und Linktext funktionieren (#1) 34 | 35 | ### Version 1.2.5 - 13. März 2013 36 | 37 | * AddOn Name geändert in `Email Obfuscator` 38 | * License und Changelog hinzugefügt 39 | * CSS Methode standardmäßig abgeschaltet 40 | 41 | ### Version 1.2.2 - 08. November 2012 42 | 43 | * Hinweis für benötigten Style wenn man die CSS Methode nutzt ergänzt 44 | * Unnötige Tags die für die XHTML Validierung nötig waren wurden entfernt 45 | 46 | ### Version 1.1.0 - 08. Juni 2012 47 | 48 | * Der ausgespuckte Code validiert jetzt sauber 49 | * Das Benutzerrecht protect_my_email[] wurde hinzugefügt 50 | 51 | ### Version 1.0.0 - 07. Dezember 2010 52 | 53 | 54 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Friends Of REDAXO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ⚠️ Die Funktionalität dieses Addons wurde in das Addon [emailobfuscator](https://github.com/FriendsOfREDAXO/emailobfuscator) integriert und wird an dieser Stelle nicht länger gepflegt. 2 | 3 | 4 | Email Obfuscator AddOn für REDAXO 5 5 | =================================== 6 | 7 | Durch dieses Addon werden alle Email-Adressen automatisch so verschleiert, dass sie von Spambots nicht mehr erkannt werden können. Dabei ist es egal ob die Email-Adressen sich in einem Template oder einem Block/Modul befinden. 8 | 9 | Email-Adressen können mit oder ohne Anchor-Tag angegeben werden. Die folgenden Bespiele sind also möglich: 10 | 11 | * `foo@gmx.de` 12 | * `Foo's EMail Adresse>` 13 | 14 | Um die Email-Adressen zu schützen, werden die Techniken "CSS display:none" und "ROT13 Encryption" angewendet. Diese können weiter unten ein- oder ausgeschaltet werden. Weitere Informationen zu den Techniken in diesem Artikel: [Nine ways to obfuscate e-mail addresses compared](http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared) 15 | 16 | __Wichtiger Hinweis:__ die CSS Display None Methode benötigt diesen Style: `span.hide { display: none; }` 17 | 18 | Features 19 | -------- 20 | 21 | * Vollautomatisches Verschleiern der Email-Adressen mit bewährten Algorithmen 22 | * Sowohl nackte als auch Email-Adressen in einem A-Tag werden berücksichtigt 23 | * Mehrere Verschleierungs-Methoden zur Auswahl 24 | 25 | Hinweise 26 | -------- 27 | 28 | * Getestet mit REDAXO 5.2 29 | * Addon-Ordner lautet: `email_obfuscator` 30 | * Die CSS Methode benötigt diesen Eintrag in Ihrem Stylesheet: `span.hide { display: none; }` 31 | 32 | Changelog 33 | --------- 34 | 35 | siehe CHANGELOG.md 36 | 37 | Lizenz 38 | ------ 39 | 40 | MIT, siehe LICENSE.md 41 | 42 | Credits 43 | ------- 44 | 45 | * Danke an WordPress für die `make_clickable()` Funktion :) 46 | * Danke an [Xong](https://github.com/xong) für die Hilfe zu RegEx 47 | -------------------------------------------------------------------------------- /boot.php: -------------------------------------------------------------------------------- 1 | hasConfig('javascriptmethod')) { 5 | $this->setConfig('javascriptmethod', 1); 6 | } 7 | 8 | if (!$this->hasConfig('nojavascriptmethod')) { 9 | $this->setConfig('nojavascriptmethod', 0); 10 | } 11 | 12 | if (!$this->hasConfig('noscript_msg')) { 13 | $this->setConfig('noscript_msg', 'Bitte JavaScript aktivieren um die Email-Adresse sichtbar zu machen! / Please activate JavaScript to see email address!'); 14 | } 15 | 16 | if (!$this->hasConfig('articles')) { 17 | $this->setConfig('articles'); 18 | } 19 | 20 | if (!$this->hasConfig('templates')) { 21 | $this->setConfig('templates'); 22 | } 23 | -------------------------------------------------------------------------------- /lang/de_de.lang: -------------------------------------------------------------------------------- 1 | 2 | email_obfuscator_title = Email Obfuscator 3 | email_obfuscator_main_title = Email Obfuscator 4 | email_obfuscator_help = Hilfe 5 | email_obfuscator_help_readme = Readme 6 | email_obfuscator_help_changelog = Changelog 7 | email_obfuscator_help_license = Lizenz 8 | 9 | email_obfuscator_config = Einstellungen 10 | email_obfuscator_config_save = Einstellungen speichern 11 | email_obfuscator_config_saved = Einstellungen wurden gespeichert! 12 | 13 | email_obfuscator_config_javascriptmethod = JavaScript ROT13 Encryption Methode 14 | email_obfuscator_config_nojavascriptmethod = CSS "display:none" Methode - (siehe Readme für benötigten Style!) 15 | email_obfuscator_config_noscript_msg = Hinweis wenn JavaScript deaktiviert 16 | email_obfuscator_config_articles = Artikel ausschließen 17 | email_obfuscator_config_templates = Templates ausschließen 18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/rex_email_obfuscator.php: -------------------------------------------------------------------------------- 1 | getSubject(); 5 | $whitelistTemplates = rex_addon::get('email_obfuscator')->getConfig('templates', []); 6 | $whitelistArticles = rex_addon::get('email_obfuscator')->getConfig('articles', ''); 7 | 8 | if ($whitelistArticles != '') { 9 | $whitelistArticles = explode(',', $whitelistArticles); 10 | } else { 11 | $whitelistArticles = []; 12 | } 13 | 14 | if (!is_null(rex_article::getCurrent()) && !in_array(rex_article::getCurrent()->getTemplateId(), $whitelistTemplates) && !in_array(rex_article::getCurrentId(), $whitelistArticles)) { 15 | $javascriptmethod = rex_addon::get('email_obfuscator')->getConfig('javascriptmethod'); 16 | $nojavascriptmethod = rex_addon::get('email_obfuscator')->getConfig('nojavascriptmethod'); 17 | $atPos = strpos($content, '@'); 18 | 19 | if ($atPos === false || (!$javascriptmethod && !$nojavascriptmethod)) { 20 | // nothing to do 21 | return $content; 22 | } 23 | 24 | // wrap anchor tag around email-adresses that don't have already an anchor tag around them 25 | $content = self::makeEmailClickable($content); 26 | 27 | // replace all email addresses (now all wrapped in anchor tag) with spam aware version 28 | $content = preg_replace_callback('`\]+)href\=\"mailto\:([^">]+)\"([^>]*)\>(.*?)\<\/a\>`ism', function ($m) { 29 | return self::encodeEmail($m[2], $m[4], $m[1], $m[3]); 30 | }, $content); 31 | 32 | } 33 | 34 | // done! 35 | return $content; 36 | } 37 | 38 | public static function encodeEmail($email, $text = "", $attributesBeforeHref = '', $attributesAfterHref = '') { 39 | if (empty($text)) { 40 | $text = $email; 41 | } 42 | 43 | $attributesBeforeHref = trim($attributesBeforeHref); 44 | $attributesAfterHref = trim($attributesAfterHref); 45 | 46 | if ($attributesBeforeHref != '') { 47 | $attributesBeforeHref = str_replace('"', '\\"', $attributesBeforeHref); 48 | $attributesBeforeHref = $attributesBeforeHref; 49 | } 50 | 51 | if ($attributesAfterHref != '') { 52 | $attributesAfterHref = str_replace('"', '\\"', $attributesAfterHref); 53 | $attributesAfterHref = ' ' . $attributesAfterHref; 54 | } 55 | 56 | $encoded = ''; 57 | $javascriptmethod = rex_addon::get('email_obfuscator')->getConfig('javascriptmethod'); 58 | $nojavascriptmethod = rex_addon::get('email_obfuscator')->getConfig('nojavascriptmethod'); 59 | 60 | if ($javascriptmethod) { 61 | // javascript version 62 | $encoded_mail_tag = str_rot13('' . $text . ''); 63 | $encoded = ""; 68 | } 69 | 70 | // for users who have javascript disabled 71 | $exploded_email = explode("@", $email); 72 | 73 | if ($javascriptmethod && !$nojavascriptmethod) { 74 | $noscriptMsg = rex_addon::get('email_obfuscator')->getConfig('noscript_msg'); 75 | 76 | if ($noscriptMsg != '') { 77 | $encoded .= ''; 78 | } 79 | } else { 80 | if ($javascriptmethod && $nojavascriptmethod) { 81 | $encoded .= ''; 94 | } 95 | } 96 | 97 | return $encoded; 98 | } 99 | 100 | // found here: http://zenverse.net/php-function-to-auto-convert-url-into-hyperlink/ 101 | public static function makeEmailClickable($ret) { 102 | $ret = ' ' . $ret; 103 | // in testing, using arrays here was found to be faster 104 | $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', 'rex_email_obfuscator::_make_email_clickable_cb', $ret); 105 | 106 | // this one is not in an array because we need it to run last, for cleanup of accidental links within links 107 | $ret = preg_replace("#(]+?>|>))]+?>([^>]+?)#i", "$1$3", $ret); 108 | $ret = trim($ret); 109 | 110 | return $ret; 111 | } 112 | 113 | protected static function _make_email_clickable_cb($matches) { 114 | $email = $matches[2] . '@' . $matches[3]; 115 | 116 | return $matches[1] . "$email"; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /package.yml: -------------------------------------------------------------------------------- 1 | package: email_obfuscator 2 | version: '2.0.0' 3 | author: RexDude 4 | supportpage: http://www.redaxo.org/de/forum/ 5 | load: late 6 | page: 7 | title: 'translate:title' 8 | perm: admin[] 9 | icon: rex-icon fa-envelope 10 | subpages: 11 | config: { title: 'translate:config' } 12 | help: 13 | title: 'translate:help' 14 | subpages: 15 | readme: { title: 'translate:help_readme' } 16 | changelog: { title: 'translate:help_changelog' } 17 | license: { title: 'translate:help_license' } 18 | conflicts: 19 | packages: 20 | emailobfuscator: '*' 21 | -------------------------------------------------------------------------------- /pages/config.php: -------------------------------------------------------------------------------- 1 | setConfig(rex_post('config', [ 9 | ['javascriptmethod', 'int'], 10 | ['nojavascriptmethod', 'int'], 11 | ['noscript_msg', 'string'], 12 | ['articles', 'string'], 13 | ['templates', 'array[int]'] 14 | ])); 15 | 16 | echo rex_view::success($this->i18n('config_saved')); 17 | } 18 | 19 | // js metjod 20 | $formElements = []; 21 | $n = []; 22 | $n['label'] = ''; 23 | $n['field'] = 'getConfig('javascriptmethod') == '1' ? ' checked="checked"' : '') . ' value="1" />'; 24 | $formElements[] = $n; 25 | 26 | $fragment = new rex_fragment(); 27 | $fragment->setVar('elements', $formElements, false); 28 | $content .= $fragment->parse('core/form/checkbox.php'); 29 | 30 | // no js method 31 | $formElements = []; 32 | $n = []; 33 | $n['label'] = ''; 34 | $n['field'] = 'getConfig('nojavascriptmethod') == '1' ? ' checked="checked"' : '') . ' value="1" />'; 35 | $formElements[] = $n; 36 | 37 | $fragment = new rex_fragment(); 38 | $fragment->setVar('elements', $formElements, false); 39 | $content .= $fragment->parse('core/form/checkbox.php'); 40 | 41 | // js msg 42 | $formElements = []; 43 | $n = []; 44 | $n['label'] = ''; 45 | $n['field'] = ''; 46 | $formElements[] = $n; 47 | 48 | $fragment = new rex_fragment(); 49 | $fragment->setVar('elements', $formElements, false); 50 | $content .= $fragment->parse('core/form/container.php'); 51 | 52 | 53 | // whitelist stuff 54 | $formElements = []; 55 | $n = []; 56 | $n['label'] = ''; 57 | $n['field'] = rex_var_linklist::getWidget(1, 'config[articles]', $this->getConfig('articles')); 58 | $formElements[] = $n; 59 | 60 | $n = []; 61 | $n['label'] = ''; 62 | $select = new rex_select(); 63 | $select->setId('email_obfuscator-config-templates'); 64 | $select->setMultiple(); 65 | $select->setSize(10); 66 | $select->setAttribute('class', 'form-control'); 67 | $select->setName('config[templates][]'); 68 | $select->addSqlOptions('SELECT `name`, `id` FROM `' . rex::getTablePrefix() . 'template` ORDER BY `name` ASC'); 69 | $select->setSelected($this->getConfig('templates')); 70 | $n['field'] = $select->get(); 71 | $formElements[] = $n; 72 | 73 | $fragment = new rex_fragment(); 74 | $fragment->setVar('elements', $formElements, false); 75 | $content .= $fragment->parse('core/form/form.php'); 76 | 77 | 78 | // Save-Button 79 | $formElements = []; 80 | $n = []; 81 | $n['field'] = ''; 82 | $formElements[] = $n; 83 | 84 | $fragment = new rex_fragment(); 85 | $fragment->setVar('elements', $formElements, false); 86 | $buttons = $fragment->parse('core/form/submit.php'); 87 | $buttons = ' 88 |
89 | ' . $buttons . ' 90 |
91 | '; 92 | 93 | // Ausgabe Formular 94 | $fragment = new rex_fragment(); 95 | $fragment->setVar('class', 'edit'); 96 | $fragment->setVar('title', $this->i18n('config')); 97 | $fragment->setVar('body', $content, false); 98 | $fragment->setVar('buttons', $buttons, false); 99 | $output = $fragment->parse('core/page/section.php'); 100 | 101 | $output = ' 102 |
103 | 104 | ' . $output . ' 105 |
106 | '; 107 | 108 | echo $output; 109 | 110 | ?> 111 | 112 | -------------------------------------------------------------------------------- /pages/help.changelog.php: -------------------------------------------------------------------------------- 1 | getPath('CHANGELOG.md')); 3 | 4 | $parsedown = new Parsedown(); 5 | $content = $parsedown->text($file); 6 | 7 | $fragment = new rex_fragment(); 8 | $fragment->setVar('title', $this->i18n('help_changelog')); 9 | $fragment->setVar('body', $content, false); 10 | 11 | echo $fragment->parse('core/page/section.php'); 12 | -------------------------------------------------------------------------------- /pages/help.license.php: -------------------------------------------------------------------------------- 1 | getPath('LICENSE.md')); 3 | 4 | $parsedown = new Parsedown(); 5 | $content = $parsedown->text($file); 6 | 7 | $fragment = new rex_fragment(); 8 | $fragment->setVar('title', $this->i18n('help_license')); 9 | $fragment->setVar('body', $content, false); 10 | 11 | echo $fragment->parse('core/page/section.php'); 12 | -------------------------------------------------------------------------------- /pages/help.readme.php: -------------------------------------------------------------------------------- 1 | getPath('README.md')); 3 | 4 | $parsedown = new Parsedown(); 5 | $content = $parsedown->text($file); 6 | 7 | $fragment = new rex_fragment(); 8 | $fragment->setVar('title', $this->i18n('help_readme')); 9 | $fragment->setVar('body', $content, false); 10 | 11 | echo $fragment->parse('core/page/section.php'); 12 | -------------------------------------------------------------------------------- /pages/index.php: -------------------------------------------------------------------------------- 1 | i18n('title')); 4 | 5 | $subpage = rex_be_controller::getCurrentPagePart(2); 6 | 7 | include rex_be_controller::getCurrentPageObject()->getSubPath(); 8 | -------------------------------------------------------------------------------- /uninstall.php: -------------------------------------------------------------------------------- 1 |