Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-09-16 16:13:12

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Encoded email addresses (obfuscation)

There is a simpler way to accomplish such the subject thing, unfortunately pages within TXP are rendering into UTF-8 characters (converted):

<a href="mailto:user&commat;domain&period;com">user&commat;domain&period;com</a>

That is rendering as this:

<a href="mailto:user@domain.com">user@domain.com</a>

Without any obfuscation 😭

So, here is an another (a little bit complex) way. Copy/Past into an email form:

<txp:if_yield name="email"><txp:variable name="email" value='<txp:yield name="email" />' /><txp:php>
global $variable;

for ($i = 0; $i < strlen($variable['email']); $i++) {
	$variable['encoded'] .= '&#'.ord($variable['email'][$i]).';';
}

</txp:php><txp:if_yield name="link"><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;<txp:variable name="encoded" />"><txp:variable name="encoded" /></a><txp:else /><txp:variable name="encoded" /></txp:if_yield><txp:variable name="email" value="" /></txp:if_yield>
<txp:variable name="encoded" value="" />

Note: the last variable is required to remove its content (in a multiple use case of this shortcode into a same article).

<txp::email email="user@domain.com" />

<txp::email email='<txp:author_email />' link />

The link attribute is optional and governs the rendering of a full cliquable link.

😉

Last edited by Pat64 (2020-09-16 16:16:16)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#2 2020-09-16 16:52:57

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,091
Website Mastodon

Re: Encoded email addresses (obfuscation)

i still use Enkoder from Dan Benjamin although it’s no longer available. i use the old code and so far no spam.


…. texted postive

Offline

#3 2020-09-16 17:40:01

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Encoded email addresses (obfuscation)

bici wrote #325915:

i still use Enkoder from Dan Benjamin although it’s no longer available. i use the old code and so far no spam.

I did too, and I made a plugin out of the standalone php version of the algorithm. You can get it here and use it just like the built-in tag. See the docs for attributes and options.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2020-09-16 18:59:03

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,091
Website Mastodon

Re: Encoded email addresses (obfuscation)

jakob wrote #325916:

You can get it here and use it just like the built-in tag.

THANKS! I was not aware of yr plugin,


…. texted postive

Offline

#5 2020-09-17 14:48:35

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: Encoded email addresses (obfuscation)

jakob wrote #325916:

I made a plugin out of the standalone php version of the algorithm. You can get it here and use it just like the built-in tag.

More thanks – I didn’t know about the plugin either. I used Enkoder years ago when it had a web page. It really works. Great to have this for Textpattern.

Offline

Board footer

Powered by FluxBB