Jump to content

Email Obfuscator Module


12345j
 Share

Recommended Posts

I think you are talking about a different issue than joey102030 as you are using PageTable.

My complete code:

$kuvaus = '';
$tapahtumat = $pages->find("template=tapahtuma, sort=paivamaara");
foreach($tapahtumat as $tapahtuma) {
  $kuvaus .= $tapahtuma->render();
  }
Link to comment
Share on other sites

  • 10 months later...

I have some kind of database in processwire that contains a whole lot of pages with addresses. These addresses are output in a table by a template that gets all the relevant information from these pages. To obfuscate the email addresses coming out of the database I use this module.

Something seems to go wrong though, because the part in the <a> tag is not obfuscated, only the link part. This is what the source code of the page looks like:

<a href='mailto:blb.op.biel-bienne@erz.be.ch' class='link_mail'><span style="unicode-bidi:bidi-override; direction: rtl;" class="email-obfuscator-unreverse">hc.eb.zre@enneib-leib.po.blb</span></a>

And this is the line from the template, that outputs the email address:

if($l->adr_email) $out .= "<a href='mailto:$l->adr_email' class='link_mail'>$l->adr_email</a> <br>";

The module is configured so that the javascript is being inserted before the </body> tag.

Link to comment
Share on other sites

I think actually the problem is in the details. The module's regex doesn't seem to account for href=' only for href="

So this should be:

if($l->adr_email) $out .= "<a href=\"mailto:$l->adr_email\" class='link_mail'>$l->adr_email</a> <br>";

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

A minor feature request: make the loading of the JavaScript optional. This could be achieved emptying the script_location field, but the module uses the default value when doing this.

I load the JS dynamically using JS, that's why I have a need for this.

Link to comment
Share on other sites

Ok, thanks. It's not the first time I got into this trap, these two modules are easy to mix :)

It seems that EMO also has an issue in what I try to achieve. It adds an inline script at the bottom that tries to call a function which is unavailable if I load the module's JS manually.

It seems that there are two PMs to make :)

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

I encounter problems using this module and jquery datatables together.

Datatables is used to filter and paginate big address lists.

The problem: EmailObfuscator works nicely on the first page of the paginated addresses. But it doesn't on the following pages of the paginated address table.

Email addresses on the first page are correctly resolved to links like "mailto:name@domain.com". From the second page of the paginated table onward links keep the "GOSPAM:" prefix and the email address is following in reverse.

jquery and datatables scripts are called before the </body> tag, as is EmailObfuscator.

My script for the datatables looks like this:

		$("#myTable").DataTable( {	
		paging:   true,
	  	lengthChange: false,
		pageLength: 5,
		pagingType: "simple_numbers",
		info: false,
		responsive: true,
		language: {
				search: "_INPUT_",
                zeroRecords:    "Ihre Suche ergab kein Resultat<br>Votre recherche n'a pas reçu des resultats",
				searchPlaceholder: "Tabelle filtern nach … / filtrer le tableau pour …",
				paginate: {
            		previous: '‹',
            		next:     '›'
       			 },
        aria: {
            paginate: {
                previous: 'Previous',
                next:     'Next'
            }
        }
		 }
		});

Thanks for help.

Link to comment
Share on other sites

Thanks Macrura

I am not sure how to do this though …

Would this be correct?

	$("#myTable").DataTable( {	
		paging:   true,
	  	lengthChange: false,
		pageLength: 5,
		pagingType: "simple_numbers",
		info: false,
		responsive: true,
		language: {
				search: "_INPUT_",
                zeroRecords:    "Ihre Suche ergab kein Resultat<br>Votre recherche n'a pas reçu des resultats",
				searchPlaceholder: "Tabelle filtern nach … / filtrer le tableau pour …",
				paginate: {
            		previous: '‹',
            		next:     '›'
       			 },
        aria: {
            paginate: {
                previous: 'Previous',
                next:     'Next'
            }
        }
		 }
		"drawCallback": (function() {
	// restore mailto: links
	$("a[href^='GOSPAM:']").each(function(){
		var email = $(this).attr("href").substr(7);
		// replace email with its reversed version
		email = email.split("").reverse().join("");
		// replace "GOSPAM:" with "mailto:"
		$(this).attr("href","mailto:" + email);			
	}); 
	
	$(".email-obfuscator-unreverse").each(function() {
		$(this).replaceWith($(this).text().split("").reverse().join(""));
	});
});
		});

 

Link to comment
Share on other sites

Hmm …

I just became aware, that this problem doesn't occur on my local installation, only on the live server.

And with the drawCallback function on the live server, pagination doesn't work any more.

Link to comment
Share on other sites

No you asked in the correct forum, I meant the other guys. ;) 

Unfortunately I also don't have an answer to your problem, except that if the result are loaded via ajax, the JS needs to be executed again somehow after load.

Link to comment
Share on other sites

I am releaved! :)

I think the problem is that dataTables modifies the DOM when you navigate to another table page. So the obfuscator only «sees» the addresses of the first table page and resolves them to their correct email address.

So I thought it was a good idea to call EmailObfuscator before the </head> tag instead of the </body> tag. But this doesn't work either. In this case not even the emails of the first table page are being resolved.

Link to comment
Share on other sites

You seem to have the callback wrong. It should be a funtion not a self executing closure... (function(){}) ... dont just copy the code into the callback.

A callback in this case is usually always just a anonymous function. Example:

callback: function(){ ... code.... },

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...