Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Email Obfuscation


Go to End


17 Posts   7415 Views

Avatar
ollyp

Community Member, 3 Posts

14 September 2009 at 11:48pm

So I am trying to get some Email obfuscation, this is not for forms but to replace mailto: links.
I have tried the hidemailto module with no success so just want a sanity check on my new idea.

Linking to a redirect page?
Set up a redirect page where the redirect url is the mailto link.
Obviously this needs a separate page for each e-mail address, but will this work? If the redirect happens in the php there will be no source code with the address in plain text.
I have tried opening the page in text editors to get the source and they fail.
I know this is obviously not the best way to go about this, but I have no idea what other options I have.

Olly

Avatar
dalesaurus

Community Member, 283 Posts

15 September 2009 at 3:41am

I'm not sure where you're coming from. Do you want to automatically replace any entered email addresses in the CMS Content Editor with some sort of system? Or do you want to build a system you can statically link to from your pages (ie site.com/email/userid)?

I think the simplest thing would be to generate images with the email text in it and just insert those inline when needed. Here is an example to get your running: http://www.weberdev.com/get_example-4655.html

Avatar
dhensby

Community Member, 253 Posts

15 September 2009 at 4:43am

I take it you want something like this: http://www.braemoor.co.uk/software/obfuscator.shtml - Script at: http://www.braemoor.co.uk/software/_private/obfuscate.js

I reckon you have two options:

1. Create a new fieldtype and then either with JS in the CMS or just with the 'onSave' method or some such, store the obfuscated e-mail address.

2. In the content function simply do a preg_replace for all <a> with href="mailto:*" in and parse the e-mail address bit through the obfuscator function.

Avatar
Sean

Forum Moderator, 922 Posts

18 September 2009 at 4:32pm

Edited: 27/10/2009 2:31pm

Have a look in the Email.php class in your SilverStripe installations.

There's a handy static function in there called "obfuscate". The first parameter to this function is the email address to obfuscate, the second is the method to obfuscate with. 'visible' is the default, but there's also a very handy one called 'direction' that is very good.

Use this for sending obfuscated emails to the templates from your controller. e.g.:

function MyObfuscatedEmail() {
	return Email::obfuscate('my@email.com', 'direction');
}

Hope this helps.

Sean

Avatar
geist

Community Member, 7 Posts

27 October 2009 at 10:24am

When I add "function MyObfuscatedEmail()" to my Page_Controller and I call $MyObfuscatedEmail in my Page.ss, Silverstripe only returns "Fatal error: Call to undefined method Email::obsfucate() in Page.php".

So, there are two possibilities:
1. This is not the way to.
2. I haven't understand Silverstripe yet

If its the second possibility: Who can help me...?

Avatar
Mo

Community Member, 541 Posts

27 October 2009 at 12:09pm

Looks like a typo, should be:

function MyObfuscatedEmail() {
   return Email::obfuscate('my@email.com', 'direction');
}

Avatar
geist

Community Member, 7 Posts

27 October 2009 at 4:03pm

I have to apologize...

Thank you.

Avatar
tobych

Community Member, 97 Posts

31 October 2009 at 2:58pm

Folks,

I'm looking for an example of the HTML you'd use when using this function.

Toby

Go to Top