Bacelo Posted September 28, 2016 Share Posted September 28, 2016 19 hours ago, Roope said: Hello @Barcelo! So email addresses are replaced by text set in module config but conversion back to email doesn't kick in, right? Double check that emo.js is really present because it sounds like there's the issue here. Maybe consider adding modules config url to the file path: <?php echo '<script src=" . $config->urls->modules . EmailObfuscation/emo.min.js"></script>'; ?> I think you meant this : <?php echo '<script src="' . $config->urls->siteModules . 'EmailObfuscation/emo.min.js"></script>'; ?> This works fine as before - the script gets included just fine. But, none of the included E-Mails addresses are replaced with any text and elements at all. They are still untouched present in plain text. So I guess, that the module is "stuck" somehow or not recognized / executed at all during page rendering. Could another module might interfere? (of course caching is not active ) (Processwire V 2.7.2) Link to comment Share on other sites More sharing options...
Roope Posted September 29, 2016 Author Share Posted September 29, 2016 On 9/27/2016 at 11:13 PM, Macrura said: Feature request: one thing that would be cool is to be able to enable this only for some templates, instead of disable; because i only need it on the contact page, so i'd need to disable like 30 templates, rather than enable 1, the way it is currently; Is there any way of conditionally loading this module by the API? One of the really critical issues here is that the module is still not able to skip stuff like twitter handle (e.g. @processwire) Thanks @Macrura - I'll try look into these shortly! On 9/28/2016 at 11:30 AM, Bacelo said: I think you meant this : <?php echo '<script src="' . $config->urls->siteModules . 'EmailObfuscation/emo.min.js"></script>'; ?> This works fine as before - the script gets included just fine. But, none of the included E-Mails addresses are replaced with any text and elements at all. They are still untouched present in plain text. So I guess, that the module is "stuck" somehow or not recognized / executed at all during page rendering. Could another module might interfere? (of course caching is not active ) (Processwire V 2.7.2) Sorry, I meant $config->urls->siteModules... And is should read your other post mo carefully since you already mentioned that script block is not included in the end of the document so it's not about js script surely. Don't know what other module could be blocking this but what other 3rd party modules you have installed? Link to comment Share on other sites More sharing options...
Bacelo Posted September 30, 2016 Share Posted September 30, 2016 Thank you Roope for supporting. Actually I have the following site modules installed at the project: AllInOneMinify DiagnoseDatabase DiagnoseFiles DiagnoseImagehandling DiagnoseModules DiagnosePhp DiagnoseWebserver EmailObfuscation FormBuilder ImageExtra InputfieldFormBuilderFile JqueryDataTables MarkupMenuBuilder MarkupSEO ProCache (not active) ProcessDatabaseBackups ProcessDiagnostics ProcessFormBuilder ProcessMenuBuilder ProcessPageListerPro ProcessProCache ProcessWireUpgrade ProcessWireUpgradeCheck TemplateEngineFactory TemplateEngineProcesswire Link to comment Share on other sites More sharing options...
Roope Posted September 30, 2016 Author Share Posted September 30, 2016 Not that I'm familiar with all of thease but first that pops out from the list is TemplateEngineFactory. I haven't used it and have no idea about the logic behind the scenes but if you could temporarily uninstall it and see what happens. Link to comment Share on other sites More sharing options...
Macrura Posted September 30, 2016 Share Posted September 30, 2016 slightly off-topic, but just wanted to mention that i was able to solve my problem (loading emo on all pages, and it thinking that the twitter handle in the header was an email address) by just using a hanna code for the email addresses (like [[emo email=mail@example.com]]); I have a function in my templates that does the email address replacement. Not trying to discount the utility of this module as it can provide global coverage for email addresses, but possibly for some users who only need to replace a few emails in some specific places, then the shortcode can be useful. Also, if you had a specific field holding the email address, then you could obfuscate it with the same function directly in the template output... Link to comment Share on other sites More sharing options...
Robin S Posted September 30, 2016 Share Posted September 30, 2016 9 hours ago, Macrura said: i was able to solve my problem (loading emo on all pages, and it thinking that the twitter handle in the header was an email address) I don't experience this problem with this module - for me only email addresses are obfuscated, not twitter handles. name@testing.com <- this would be obfuscated @testing <- this is untouched Link to comment Share on other sites More sharing options...
Macrura Posted September 30, 2016 Share Posted September 30, 2016 ok right, well the main problem i was having was more that i didn't want EMO active on every page of the site, so i loaded the JS myself only on the page i needed it, where there were email addresses. But it was still finding something it thought was an email on the homepage, and then adding the script tag and thus JS error on the page, plus the overhead of the plugin running on that page. the obfuscation function i'm using works on each email you trigger it on, so only where you want.. Link to comment Share on other sites More sharing options...
Roope Posted October 3, 2016 Author Share Posted October 3, 2016 OK, thanks guys! Like @Robin S posted, we either have never experienced any problems with twitter (or any other some) handles. Can you @Macrura plese give me more detalied example about false positives you faced with? I was thinking that maybe I could add new 'execution method' to the module config where one could select whether to exclude/include email auto obfuscation at selected templates/pages or go full manual by using public method ever when needed. This would definitely be more flexible than the current route we have in use. 1 Link to comment Share on other sites More sharing options...
Macrura Posted October 3, 2016 Share Posted October 3, 2016 I figured out what it was, it was an embedded Constant Contact sign up form that had the words: Please enter your email address in name@email.com format this is actually inside a <script> tag. In any case your suggestion about the execution method would be really great, because when you know you only need the script to operate on 1 page, and leave the rest of the site untouched, it's really the safest way on a large project where you don't want things to break... 1 Link to comment Share on other sites More sharing options...
Bacelo Posted October 5, 2016 Share Posted October 5, 2016 On 30.9.2016 at 10:55 AM, Roope said: Not that I'm familiar with all of thease but first that pops out from the list is TemplateEngineFactory. I haven't used it and have no idea about the logic behind the scenes but if you could temporarily uninstall it and see what happens. Actually I can't unistall the module "TemplateEngineFactory" as the template relies on this I'll continue having a deeper look into and try to cut it down. Link to comment Share on other sites More sharing options...
Roope Posted October 24, 2016 Author Share Posted October 24, 2016 New version is now available at GitHub. Added new option to exclude/include module execution at selected templates/pages + new $sanitizer->emo() method to manually control obfuscation for given string. Please go ahead and try it out! 1 Link to comment Share on other sites More sharing options...
PWaddict Posted January 12, 2017 Share Posted January 12, 2017 How can I re-initiate it via AJAX? Link to comment Share on other sites More sharing options...
Roope Posted January 12, 2017 Author Share Posted January 12, 2017 4 hours ago, PWaddict said: How can I re-initiate it via AJAX? Currently this is not possible. Link to comment Share on other sites More sharing options...
tpr Posted January 13, 2017 Share Posted January 13, 2017 The module is set to "autoload' => true, is this surely needed? In my quick test 'autoload' => 'template!=admin' works too. 1 Link to comment Share on other sites More sharing options...
teppo Posted January 13, 2017 Share Posted January 13, 2017 1 hour ago, tpr said: The module is set to "autoload' => true, is this surely needed? In my quick test 'autoload' => 'template!=admin' works too. This module was launched before 2.3.1, which introduced conditional autoloading. Aforementioned change seems reasonable, but means dropping support for 2.2. ... although dropping support for 2.2 at this point doesn't seem like such a huge issue 3 Link to comment Share on other sites More sharing options...
Roope Posted January 17, 2017 Author Share Posted January 17, 2017 On 1/13/2017 at 9:34 AM, tpr said: The module is set to "autoload' => true, is this surely needed? In my quick test 'autoload' => 'template!=admin' works too. On 1/13/2017 at 11:27 AM, teppo said: This module was launched before 2.3.1, which introduced conditional autoloading. Aforementioned change seems reasonable, but means dropping support for 2.2. ... although dropping support for 2.2 at this point doesn't seem like such a huge issue To be honest, I've missed the whole world of conditional autoloading of PW modules... Dropping off support for 2.2 isn't any issue. There will be older perfecly functional emo releases available if someone needs it. So I think I'll go ahead and make this change same time I'll add PW namespace to the module - which should happen pretty soon. Thanks for the notice! 2 Link to comment Share on other sites More sharing options...
tpr Posted January 17, 2017 Share Posted January 17, 2017 Thanks! 1 minute ago, Roope said: To be honest, I've missed the whole world of conditional autoloading of PW modules... So did I until recently Link to comment Share on other sites More sharing options...
Zeka Posted March 23, 2017 Share Posted March 23, 2017 Hi @Roope Looks like module doesn't work when template cache is on. It loads var emo_addr = new Array(); emo_addr[0] = "fA1PLjJh83r7WD9s+apZEH5RTFM0uYwS2Ge6bxVOktKvIndQC4qBUycoim.NlXgz"; emo_addr[1] = "sJL2Tc4GuoWX8VHn0yXx05jt0182Mh3xF6Ue05jt0haQ9VxdFVXfFRxxTO3QYoWdTcXn7OHG86mt0VFQ+JHmF53q0oYB7VDQ0pmyTZCQTZif"; if(window.addLoadEvent) addLoadEvent(emo_replace()); just for first time after cache timeout, but cache is saved without it. Can somebody confirm it? And one small feature request: could you change "Replate text string" input from text to text Multilanguage field. Link to comment Share on other sites More sharing options...
ottogal Posted April 25, 2017 Share Posted April 25, 2017 On 1.10.2016 at 0:40 AM, Macrura said: the obfuscation function i'm using works on each email you trigger it on, so only where you want.. Hi @Macrura, would you mind to reveal more details of your obfuscation function? I would highly appreciate it. Link to comment Share on other sites More sharing options...
Macrura Posted April 25, 2017 Share Posted April 25, 2017 I'm using this function in places, seems to work well: /** * Given an email address render the obfuscated version * * @param $strEmail - an email address * */ function createMailto($strEmail) { $strNewAddress = ''; for($intCounter = 0; $intCounter < strlen($strEmail); $intCounter++){ $strNewAddress .= "&#" . ord(substr($strEmail,$intCounter,1)) . ";"; } $arrEmail = explode("@", $strNewAddress); $strTag = "<script type='text/javascript'>\n"; $strTag .= "<!--\n"; $strTag .= "document.write('<a href=\"mai');\n"; $strTag .= "document.write('lto');\n"; $strTag .= "document.write(':" . $arrEmail[0] . "');\n"; $strTag .= "document.write('@');\n"; $strTag .= "document.write('" . $arrEmail[1] . "\">');\n"; $strTag .= "document.write('" . $arrEmail[0] . "');\n"; $strTag .= "document.write('@');\n"; $strTag .= "document.write('" . $arrEmail[1] . "<\/a>');\n"; $strTag .= "// -->\n"; $strTag .= "</script><noscript>" . $arrEmail[0] . " at \n"; $strTag .= str_replace("."," dot ",$arrEmail[1]) . "</noscript>"; return $strTag; } also works well in a hanna code, and doesn't require any additional js files 3 Link to comment Share on other sites More sharing options...
ottogal Posted April 25, 2017 Share Posted April 25, 2017 Thank you very much! EDIT: Works like a charm! 1 Link to comment Share on other sites More sharing options...
Roope Posted April 25, 2017 Author Share Posted April 25, 2017 11 hours ago, ottogal said: Hi @Macrura, would you mind to reveal more details of your obfuscation function? I would highly appreciate it. You can do this with EMO too: At module settings page set "Obfuscation mode" to "Obfuscate manually..." (OR adjust exclude/include templates/pages settings to have auto obfuscation enabled only where needed). Then on a page template obfuscate only the parts of markup you want by using $sanitizer->emo() method. // obfuscate single email address echo $sanitizer->emo('hello@world.com'); // obfuscate email addresses from a body field output echo $sanitizer->emo($page->body); Also make sure that you are using the 1.1.x version since this feature was added to the latest release (1.1.0). 1 Link to comment Share on other sites More sharing options...
Roope Posted April 25, 2017 Author Share Posted April 25, 2017 On 3/23/2017 at 7:15 PM, Zeka said: Hi @Roope Looks like module doesn't work when template cache is on. It loads var emo_addr = new Array(); emo_addr[0] = "fA1PLjJh83r7WD9s+apZEH5RTFM0uYwS2Ge6bxVOktKvIndQC4qBUycoim.NlXgz"; emo_addr[1] = "sJL2Tc4GuoWX8VHn0yXx05jt0182Mh3xF6Ue05jt0haQ9VxdFVXfFRxxTO3QYoWdTcXn7OHG86mt0VFQ+JHmF53q0oYB7VDQ0pmyTZCQTZif"; if(window.addLoadEvent) addLoadEvent(emo_replace()); just for first time after cache timeout, but cache is saved without it. Can somebody confirm it? And one small feature request: could you change "Replate text string" input from text to text Multilanguage field. Hello @Zeka! Sorry for massive delay but I just quickly tested EMO with built-in cache and was able to repeat yor issue. Cache file had emails as plain text and both EMO scripts were missing. On a public page it was still allright (emails obfuscated) so I don't know why it wasn't really using cached version? Switch to ProCache worked as excepted - cached page, which was obfuscated. I'm really lost with PW built-in cache since I'm so used to work with Ryans ProCache module and it has never had any issues running together with EMO. So for now my best bet for you is to get that - in a meantime we'll see if there is something we can about this. Multilanguage support is already in my TODO list, if I just could find the time... Thanks for the notice! 1 Link to comment Share on other sites More sharing options...
Robin S Posted July 6, 2017 Share Posted July 6, 2017 Hi @Roope, Love this module - it's used in all my sites. Is it possible to disable the module on some pages via a hook? I need to disable the obfuscation when a particular GET variable is present. Link to comment Share on other sites More sharing options...
Roope Posted July 6, 2017 Author Share Posted July 6, 2017 9 hours ago, Robin S said: Hi @Roope, Love this module - it's used in all my sites. Is it possible to disable the module on some pages via a hook? I need to disable the obfuscation when a particular GET variable is present. Hello! Yes, I think something like this on your page template should work. $page->addHookBefore('render', function($event) { if(wire('input')->get->myvar) { $emo = wire('modules')->get('EmailObfuscation'); $emo->mode = $emo::modeManual; } }); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now