×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: email cloaking?

email cloaking? 14 years 5 months ago #7143

  • LeFunk
  • LeFunk's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 0
Is there already a simple way to cloak emails in comments?

Otherwise I am worried whether the emails that my guests share in forums will be picked up by spambots and other nasty stuff.

The code for finding emails is

function cloak_emails ($comment)
{
preg_match_all("/\b\w+\@\w+[\.\w+]+\b/", $comment, $email);

and the code for cloaking them in Joomla is

$emcloaked = JHTML::_('Email.cloak',$email);
echo $emcloaked;

I just don't know where and how I should insert them in compojoom :(
It would be reasonable to cloak them already while saving, so it would not run all the time when the comments are viewed.

email cloaking? 14 years 5 months ago #7144

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
In the template i'm creating I have some JavaScript that checks the E-Mail field to make sure it's in a valid format, it could be easily modified to string-replace any matching This email address is being protected from spambots. You need JavaScript enabled to view it. text from tcomment field on submission.
if (document.getElementById("temail").value.search(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,9}$/i) == -1) { //E-Mail not valid } else { //E-Mail is OK }

Are regular expressions in PHP the same as JavaScript? Probably not... I'm still learning PHP :unsure:

email cloaking? 14 years 5 months ago #7147

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
The email that the people write in the e-mail field is never visible on the site.

Do you want to clock e-mails in the content of the comment?

email cloaking? 14 years 5 months ago #7149

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
Daniel Dimitrov wrote:

The email that the people write in the e-mail field is never visible on the site.

Do you want to clock e-mails in the content of the comment?


That's exactly what he wants :) I was giving an example of the JavaScript temail code from this template only, it could be used in the template JavaScript if LeFunk knew how I thought.

But yes, he just want's to get an idea of where to insert the code. I suppose in Beta2 it'd go somewhere in comment.class.php - in the function insertNewPost() or function editPost()...? Or is there a better place to put it?
  • Page:
  • 1
Time to create page: 0.100 seconds