MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Jul 05, 2009, 09:33 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search via SMF
or Google:
modx forums
all of modxcms.com
web
MODxCMS.com
Forums
Help
Login
Register
News
:Donate to MODx:
Donations
MODx Community Forums
»
Add-ons, Extensions & Elements
»
Module, Plugin & Snippet Usage
»
[Plugin] Email Link Obfuscator
Pages: [
1
]
2
Go Down
« Previous topic
Next topic »
Print
Author
Topic: [Plugin] Email Link Obfuscator (Read 11182 times)
0 Members and 1 Guest are viewing this topic.
cyberk
Jr. Member
Posts: 44
Andrew Berkowitz
[Plugin] Email Link Obfuscator
«
on:
Jan 26, 2006, 01:51 AM »
First day playing with MODx and very impressed.
Here's a little plugin to obfuscate email links with Javascript.
It basically scours the page for mailto: email links, and if it finds one it obfuscates it before sending the result to the browser. Yes, this is kind of a brute force method, but for our clients we find it's MUCH easier to just let them enter email addresses as normal and to obfuscate them on-the-fly than making them remember to enter one via some sort of snippet code. I suppose this could easily be re-written as a Snippet to let you choose which bits of content you wanted to scour for obfuscation, but as a plug-in it's set it and forget it for the entire site.
To install:
1. Create a new Plugin named whatever you want (i.e. Email Obfuscator).
2. Under System Events, check the OnWebPagePrerender event.
3. Save and enjoy.
Assuming everything works right, all the regular email links on every page on your site should be obfuscated with Javascript. No guarantees as to the spambot-proofness of the actual obfuscation, and please note that it does NOT obfuscate email addresses that are written outside a mailto: link.
And with all that said, here's the plugin:
Code:
function replaceEntities($str) {
$str=html_entity_decode($str);
for ($i = 0 ; $i < strlen($str) ; $i++) {
$strreplaced = $strreplaced . "&#" . ord($str{$i}) . ";";
}
return $strreplaced;
}
function emailaddress($matches) {
$strNewAddress = replaceEntities($matches[1]);
$strText = replaceEntities($matches[2]);
$arrEmail = explode("@",$strNewAddress);
$strTag = "<script language='Javascript' type='text/javascript'>" . "\r";
$strTag = $strTag . "<!--" . "\r";
$strTag = $strTag . "document.write('<a href=\"mai');" . "\r";
$strTag = $strTag . "document.write('lto');" . "\r";
$strTag = $strTag . "document.write(':" . $arrEmail[0] . "');" . "\r";
$strTag = $strTag . "document.write('@');" . "\r";
$strTag = $strTag . "document.write('" . $arrEmail[1] . "\">');" . "\r";
$strTag = $strTag . "document.write('" . $strText . "<\/a>');" . "\r";
$strTag = $strTag . "// -->" . "\r";
$strTag = $strTag . "</script><noscript>" . $arrEmail[0] . " at " . "\r";
$strTag = $strTag . str_replace("."," dot ",$arrEmail[1]) . "</noscript>";
return $strTag;
}
$modx->documentOutput=preg_replace_callback("#<a[^>]*mailto:([^'\" ]*)['\" ]>([^<]*)</a>#i","emailaddress",$modx->documentOutput);
«
Last Edit: Mar 20, 2006, 12:34 PM by cyberk
»
Logged
Commodore64
Moderators
Posts: 93
Re: [Plugin] Email Link Obfuscator
«
Reply #1 on:
Jan 26, 2006, 02:58 AM »
I had to replace the occurrences of "documentContent" with "documentOutput"
After that, the plugin worked like a charm. Very cool
Logged
sottwell
Documentation Team
Posts: 8,837
Re: [Plugin] Email Link Obfuscator
«
Reply #2 on:
Jan 26, 2006, 03:25 AM »
A plugin on the first day? Ooooh! Always very happy to see a professional join the community! (your site is really nice, too!)
Logged
sottwell.com has moved to a lovely Solaris 10 server!
Log in
username guest, password guestuser.
Templates are now becoming available at
http://sottwell.com/templates.html
davidm
MODx evangelist
Marketing & Design Team
Posts: 7,026
Software is like sex, it's better when it's free !
Re: [Plugin] Email Link Obfuscator
«
Reply #3 on:
Jan 26, 2006, 03:30 AM »
Yeah, nice one, and on your first day pretty amazing...
Amazing we have
two
antibot plugins in the same week
And Susan, thanks for attracting our attention on cyberk's website : indeed very very nice ! Waow... And also : I very much like your approach of webdesign, first class
...glad to have you there !
«
Last Edit: Jan 26, 2006, 03:37 AM by davidm
»
Logged
.:
nodeo.net
: Pour un web libre, moderne et ouvert ! ::
david-molliere.net
:
Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web
:.
***
Forums modxcms.fr
Participez ŕ l'élaboration du site MODx francophone !
***
! Nouveau !
En live, ne manquez pas les news de modxcms.fr sur Twitter
! Nouveau !
MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.
Config :
Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)
Réalisations sous MODx :
|
pargade-notaires.fr
|
soleil.info
|
gican.asso.fr
|
michelez-notaires.com
|
amadom.gerondicap.com
|
jocelyne-violet.net
cyberk
Jr. Member
Posts: 44
Andrew Berkowitz
Re: [Plugin] Email Link Obfuscator
«
Reply #4 on:
Jan 26, 2006, 10:10 AM »
Thanks, all!
Can someone explain the difference between documentContent and documentOutput? Both seem to work equally well for me here?
Logged
OpenGeek
MODx Co-Founder
Foundation
Posts: 5,814
damn accurate caricatures...
Re: [Plugin] Email Link Obfuscator
«
Reply #5 on:
Jan 26, 2006, 10:29 AM »
$modx->documentContent is used internally by the parser to store the output of a document, and can be retrieved dynamically from the DB or from the cache, depending on certain settings. However, the final portion of the parsing process, which is responsible for parsing uncached snippet tags and replacing any remaining placeholders in the content, uses $modx->documentOutput to collect the final bits of uncached page data and merge it into the $modx->documentContent. Then it checks to see if the $modx->documentContent was generated from the database (vs. retrieved from cache), and if so, it caches the $modx->documentContent while still outputting the $modx->documentOutput.
In other words, $modx->documentContent is the potentially cacheable content for a page, while $modx->documentOutput represents the final output to be delivered following final processing that occurs on all pages, regardless of the cacheability.
Logged
Jason Coward
MODx Co-Founder
xPDO Founder
CTO @
Collabpad
work
productively.
work
intelligently.
work
together
.
MODx
Development
|
SVN
|
Fisheye
xPDO
Development
|
SVN
|
Fisheye
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
Frank Zappa
cyberk
Jr. Member
Posts: 44
Andrew Berkowitz
Re: [Plugin] Email Link Obfuscator
«
Reply #6 on:
Jan 26, 2006, 10:31 AM »
Thanks, Jason!
I updated the code above.
Logged
Kunal Kapoor
Full Member
Posts: 145
Effective, Functional, Standards Compliant
Re: [Plugin] Email Link Obfuscator
«
Reply #7 on:
Jan 28, 2006, 09:07 AM »
This plugin works a treat. Thanks a lot. This should be added to the
REPOSITORY
. This is much easier to use than
my little snippet
.
Logged
Kunal Kapoor
Technical Director
Limesharp Internet Limited
- Effective, Functional, Standards Compliant
IRC
Nick:
KingKoopa
Skype
ID:
KingKoopa16
Djamoer
Emeritus
Posts: 1,495
No one can limit a man other than the man himself.
Re: [Plugin] Email Link Obfuscator
«
Reply #8 on:
Jan 28, 2006, 10:04 AM »
Thanks for bringing this up. Link added.
Thanks for the great plugin as well. I'm looking forward to all your new invention with MODx
Logged
Wendy Novianto (
DJAMOER Solution and Design
)
Search
|
Download Latest Release
|
General Support
About MODx
|
Documentation
|
Bugs/Wishlist
|
FORUM RULES
dernier_recours
Member
Posts: 83
Re: [Plugin] Email Link Obfuscator
«
Reply #9 on:
Mar 19, 2006, 11:40 AM »
The plugin does not allow rendering of special characters. For example, <a href="mailto:email@email.com">événement</a> will be shown as a link
événement
.
Logged
at the edge of dawn,
you ask yourself if your shadow did follow you down
all night long
Aikdo
Jr. Member
Posts: 43
Re: [Plugin] Email Link Obfuscator
«
Reply #10 on:
Mar 20, 2006, 09:36 AM »
AMAZING snippit my only thing would be with any sort of bot would not have Javascript enabled and so your comment about spambot proofness is good in the fact it would only obscure it against your end user... shame really i really like the idea...
Logged
zi
MODx Special Forces /
Administrator
Posts: 3,329
May Peace Be On You
Re: [Plugin] Email Link Obfuscator
«
Reply #11 on:
Mar 20, 2006, 10:30 AM »
This plugin is very good!
..and it would be great if someone adds the functionality asked
2 posts up here
.
Thanks for sharing.
regards,
zi
Logged
Subscribe to
MODx Commercial Support Plans
Share and Explore websites made in MODx
--------------------------------------------------
Follow me on Twitter
My Blog
,
Resource Center
ziworks | Custom/Free MODx Templates
cyberk
Jr. Member
Posts: 44
Andrew Berkowitz
Re: [Plugin] Email Link Obfuscator
«
Reply #12 on:
Mar 20, 2006, 12:40 PM »
Quote from: dernier_recours on Mar 19, 2006, 11:40 AM
The plugin does not allow rendering of special characters. For example, <a href="mailto:email@email.com">événement</a> will be shown as a link
événement
.
Great catch. I've fixed the plug-in to handle special characters correctly.
The code in the original post has been fixed. Either replace code with fixed code, or simply add this line:
$str=html_entity_decode($str);
as the first line in the replaceEntities function. That's the only change necessary.
Thanks!
Logged
Colin
Full Member
Posts: 188
I love MODx!
Re: [Plugin] Email Link Obfuscator
«
Reply #13 on:
Apr 11, 2006, 07:54 PM »
This may be a stupid question, but that's never stopped me before: what happens if the visitor has JS disabled?
Logged
cyberk
Jr. Member
Posts: 44
Andrew Berkowitz
Re: [Plugin] Email Link Obfuscator
«
Reply #14 on:
Apr 12, 2006, 09:09 AM »
Quote from: Colin on Apr 11, 2006, 07:54 PM
This may be a stupid question, but that's never stopped me before: what happens if the visitor has JS disabled?
It will display "name at address dot com"
At least, I'm pretty sure that's what it does.
Logged
Pages: [
1
]
2
Go Up
Print
« Previous topic
Next topic »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Important News
=> Security Notices
-----------------------------
Commercial Support
-----------------------------
=> [CS] About Commercial Support
-----------------------------
Development & Coding
-----------------------------
=> Commercial Inquiries & Bounties
=> Core Code
===> MODx Next
===> xPDO
=> Module, Plugin & Snippet Creation and Modification
=> In Development
=> Templates
-----------------------------
Add-ons, Extensions & Elements
-----------------------------
=> Module, Plugin & Snippet Usage
=> General Repository Items Support
=> Navigation & Tagging/Taxonomy
===> Wayfinder & DropMenu
=> Creating & Repurposing Content
===> Ditto
===> Jot
===> Front-end Document Management
=> Users, Authentication & Personalization
===> WebloginPE
===> WebLogin, WebSignup and WebChangePwd
=> Rich Text Editors & File Browser
===> TinyMCE
===> FCKeditor
===> MCPuck File Browser
=> Forms, Form Processing & Anti-Spam
===> eForm
=> Search
===> AjaxSearch
=> E-business
=> Polls, Calendars, Address Book and Community
=> Third-party integrations
=> Images, Videos & Podcasts
===> MaxiGallery
=> Manager, Parser & the Core
===> Backup & Versioning
===> Doc Finder
===> ManagerManager
===> PHx
=> Templates
-----------------------------
Support
-----------------------------
=> Release Support
===> 0.9.6.3
===> 0.9.6.2
===> 0.9.6.1
===> 0.9.6
===> 0.9.5 and earlier
=> General Support
===> MODx 101
===> E-Commerce, E-Marketing, Analytics & SEO
===> Hosting Experiences
===> IIS / Windows Hosting Issues
=> Documentation, Tips & Tricks
===> Documentation Suggestions & Corrections
-----------------------------
General Discussions
-----------------------------
=> General MODx Discussions
=> Webworker Lounge
=> Wishlist
=> You and Your Sites
=> modxcms.com Discussions and Suggestions
=> Off-topic
-----------------------------
International Support & Translations
-----------------------------
=> Internationalization
=> Bulgarian
===> Поддръжка
=====> Често задавани въпроси
=====> Инсталация
=====> Модули, Плъгини, Снипети и код
=====> Дизайн и Шаблони
===> Документация, Ръководства и Превод
=====> Документация
=====> Ръководства
=====> Превод
===> Общество
=====> Съобщения
=====> Представете се
=====> Представете сайта си
=====> Дискусии извън MODx
=> Chinese
=> Czech
===> Oznámení
=====> Důleitá oznámení/novinky
=====> Bezpečnost
===> Komunita
=====> Oznámení
=====> Představte se, prosím
=====> Ukázky práce
=====> Různé aneb cokoli co se jinam nehodí
===> Podpora
=====> FAQ (často kladené otázky)
=====> Instalace
=====> Moduly, pluginy, "snippets & code" (ablony zdrojových kódů)
=====> Design & ablony
===> Dokumentace, tutoriály (návody) a překlady
=====> Dokumentace
=====> Tutoriály (návody)
=====> Překlady (lokalizace)
=> Dutch
===> Ondersteuning
=====> Veel gestelde vragen
=====> Modules, Plugins, Snippets & Code
=====> Design & Templates
===> Documentatie, Tutorials en Vertalingen
=====> Documentatie
=====> Tutorials
=====> Vertalingen
===> Community
=====> Aankondigingen
=====> Stel jezelf voor
=====> Site Showcase
=====> De stamkroeg
=> Filipino
===> Suporta
=====> Kadalasang tanong
=====> Instalasyon
=====> Moduler, Maidadagdag, Karagdagang mga Code
=====> Desenyo at Templates
===> Dokumentasyon, Mga Turo, Mga Salin
=====> Dokumentasyon
=====> Mga Turo
=====> Mga Salin
===> Kumunidad
=====> Anunsyo
=====> Ipakilala ang sarili
=====> Ang Galing ng pinoy
=====> Tsismisan atbp
=> Finnish
===> Tuki
=====> UKK
=====> Asennus
=====> Moduulit, liitännäiset, koodinpätkät
=====> Ulkoasu/Sivustopohjat
===> Dokumentaatio, oppaat ja käännökset
=====> Dokumentaatio
=====> Käännökset
=====> Oppaat
===> Yhteisö
=====> Tiedotteet
=====> Esittele itsesi
=====> MODx sivustosi
=====> Kahvihuone
=> French
===> Support
=====> FAQ
=====> Installation
=====> Module, plugin, snippets
=====> Design/Templates
===> Documentation, Tutoriels et Traductions
=====> Documentation
=====> Traduction
=====> Tutoriels
===> Communauté
=====> Annonces
=====> Présentez vous
=====> Vos sites
=====> Le Bistrot Français
=> German
===> Support (de)
=====> FAQ (de)
=====> Installation (de)
=====> Module, Plugins, Snippets & Code (de)
=====> Design & Templates (de)
===> Dokumentation, Tutorials und Übersetzung
=====> Dokumentation
=====> Tutorials (de)
=====> Übersetzung
===> Community (de)
=====> Ankündigungen
=====> Stellt Euch vor
=====> Beispielseiten
=====> Off Topic / Verschiedenes
=> Hebrew
===> הכרזה
=====> חדשות חשובות
=====> אבטחה
===> תמיכה
=====> התקנה
=====> תיעוד, מדריכים ותרגומים
=====> עיצוב ותבניות
=====> שאלות נפוצות
===> תיעוד, מדריכים ותרגומים
=====> תיעוד
=====> מדריכים
=====> תרגומים
===> קהילה
=====> הודעות
=====> הצג את עצמך
=====> אתרים לדוגמא
=====> כללי
=> Irish
=> Italian
===> Supporto
=====> FAQ
=====> Installazione
=====> Moduli, Plugin, Snippet e altro codice
=====> Web Design e Template
===> Documentazione, Tutorial e Traduzione
=====> Documentazione
=====> Tutorial
=====> Traduzione
===> Comunitŕ
=====> Annunci
=====> Presentazioni
=====> Siti in vetrina
=====> Chiacchiere in libertŕ
=> Japanese
===> サポート
=====> 良くある質問
=====> インストール
=====> モジュール・プラグイン・スニペット・本体
=====> デザインやテンプレート
===> マニュアル・テュートリアル・翻訳
=====> マニュアル
=====> 事例集、テュートリアル
=====> 日本語化
===> コミュニティ
=====> お知らせ
=====> MODxサイト展示場
=====> 自己紹介
=====> 雑談
=====> 国産リソース
=> Persian - فارسي
===> پشتيباني
=====> راهنما
=====> نصب
=====> ماژول , پلاگین ها , کد ها و جزییات
=====> طراحی و قالب ها
===> مستند سازی , آموزش ها و ترجمه ها
=====> مستند سازی
=====> آموزش ها
=====> ترجمه ها
===> انجمن ها
=====> اخبار
=====> معرفی کردن خود
=====> نمایش دادن سایت ها
=====> بحث های عمومی و سایر موضوعات
=> Polish
===> Wsparcie
=====> FAQ
=====> Instalacja
=====> Moduły, pluginy, snipety i kod
=====> Wygląd i szablony
===> Dokumentacja, tutoriale i tłumaczenie
=====> Dokumentacja
=====> Tutoriale
=====> Tłumaczenie
===> Społeczność
=====> Ogłoszenia
=====> Przedstaw się
=====> Twój serwis WWW
=====> Hyde Park
=> Portuguese
===> Suporte
=====> FAQ - Dúvidas Frequentes
=====> Instalaçăo
=====> Módulos, Plugins, Snippets e Código
=====> Design e Templates
===> Documentaçăo, Guias e Traduçőes
=====> Documentaçăo
=====> Guias
=====> Traduçőes
===> Comunidade
=====> Anúncios
=====> Apresente-se!
=====> Bar da esquina (fora de tópico)
=====> Portfólio de Sites
=> Russian
===> Поддержка
=====> ЧАВО (FAQ)
=====> Установка
=====> Модули, плагины, сниппеты и код
=====> Дизайны и шаблоны
===> Документация, Уроки, Перевод
=====> Документация
=====> Уроки
=====> Перевод
===> Сообщество
=====> Объявления
=====> Представьтесь публике
=====> Галерея сайтов
=====> Диван
=> Scandanavian
===> Support
=====> Frĺgor och svar
=====> Installation
=====> Moduler, plugins, snippets och kod
=====> Design & sidmallar
===> Dokumentation, guider och översättningar
=====> Dokumentation
=====> Guider
=====> Översättningar
===> Webbgemenskap
=====> Meddelanden
=====> Presentera dig själv
=====> Visa upp dina webbsidor
=====> Ordet fritt
=> Slovak
=> Spanish
===> Soporte
=====> FAQ
=====> Instalación
=====> Modulos, Plugins, Snippets & Código
=====> Diseńo y plantillas
===> Documentación, Tutoriales y Traducciones
=====> Documentatción
=====> Tutoriales
=====> Traducciones
===> Comunidad
=====> Anuncios
=====> Presentaciones personales
=====> Muestra de sitios
=====> El Café
=> Swedish
=> TÜRKÇE (Turkish)
===> Destek
=====> SSS
=====> Kurulum
=====> Modüller, Pluginler, Snippetlar & Kodlar
=====> Dizayn & Temalar
===> Belgeleme, Eğitmenler ve Çeviri
=====> Belgeleme
=====> Eğitmenler
=====> Çeviri
===> Topluluk
=====> Duyurular
=====> Kendinizi Tanıtın
=====> Site Vitrini
=====> Konu Dışı