Author Topic: Temp fix for mdcr.js on specific page only?  (Read 204 times)

Offline contactjw

  • Posts: 119
Temp fix for mdcr.js on specific page only?
« on: July 17, 2017, 12:22:25 AM »
Just wondered if the code in red I added to the beginning of the modules/output_filter/filters/filterEmail.php code could have any adverse affects? Did it so the mdcr.js file would only be loaded on the page where I'm using it. Everything seems to be working OK but since I'm a novice at php thought I'd better ask about it just in case. 

    function doFilterEmail($content) {
        $aFilterSettings = getOutputFilterSett ings();
        $key = preg_replace('=^.*?filter([^\.\/\\\\]+)(\.[^\.]+)?$=is', '\1', __FILE__);
        if ($aFilterSettings[$key] && PAGE_TITLE == 'Contact') {
            if (
                $aFilterSettings['OutputFilterMode'] == 0 &&
                $aFilterSettings['at_replacement'] == '@' &&
                $aFilterSettings['dot_replacement'] == '.'
            ) {
                return $content;
            }

Offline DarkViper

  • Core Development
  • *****
  • Posts: 2838
  • Gender: Female
Re: Temp fix for mdcr.js on specific page only?
« Reply #1 on: July 17, 2017, 12:02:09 PM »
Quote
 if ($aFilterSettings[$key] && PAGE_TITLE == 'Contact') {

This solution works, but....
insert a second, third, fourth page containing an email address...  you have to change the code of the filter again.. again... (depending on page_id is also unhandy)
change the title of the page....   you have to change the code of the filter again..
On each update the modification goes lost...

Ok, the actual situation is: when address obfuscation is activated, the filter inserts the link of mdcr.js on all pages.

I modified the filter in this kind:
Depending on whether actually an email address is encrypted on one page, mdcr.js will be inserted or even not.
Thus, the filter is independent of the content of each page. There are no code changes required. There are no problems with future updates or changes to the pages.

The modified filter is included in WB-2.10.1. But you can downlod from SVN and use it without sideeffects.
filters/filterEmail.php

Manuela
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are ... but you can not leave them like that !!" :-P
Ein einziger Buchstabendreher kann einen ganzen Satz urinieren.

Offline contactjw

  • Posts: 119
Re: Temp fix for mdcr.js on specific page only?
« Reply #2 on: July 18, 2017, 01:53:44 AM »
Seems to be working fine. Thanks so much Manuela! (Y)

Offline contactjw

  • Posts: 119
Re: Temp fix for mdcr.js on specific page only?
« Reply #3 on: August 12, 2017, 09:17:07 PM »
Manuela, I did discover a problem after all. Even though everything else works as it should, when I click on the email link nothing happens. When I view the page source of the page with the email link it seems the mdcr.js file isn't showing up. Seems like the  mdcr.js file should be loaded on the page where it's being utilized, shouldn't it?  :?

Offline jacobi22

  • Global Moderator
  • *****
  • Posts: 4374
  • Gender: Male
    • Jacobi22
Re: Temp fix for mdcr.js on specific page only?
« Reply #4 on: August 13, 2017, 12:49:07 PM »
for a test, make a rollback to the original file - see instruction at the end of this post

https://forum.WebsiteBaker.org/index.php/topic,30402.msg212078.html#msg212078
Und obwohl es so aussieht wie früher, alles gewohnt und so vertraut, ist doch alles anders, ist es irgendwie anders unter der Haut
Kuult - Unter der Haut

Offline contactjw

  • Posts: 119
Re: Temp fix for mdcr.js on specific page only?
« Reply #5 on: August 13, 2017, 07:20:39 PM »
I've already reverted back to the original file and it works fine. Am using the code I posted at the beginning of this topic so it only loads on the page I want it. So it's not a problem right now. I can wait for the next revision of 2.10 and hopefully whatever the problem I'm having with the new file will be sorted out.