We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30564
    • 60 Posts
    Hi all,

    Anyone know of an approach which could be used with MODx to obfuscate the whole page output, whilst retaining javascript functionality [mooTools etc.] This is a client request their aim being to make their design difficult [not impossible] to replicate [editing et al] via off-line browsers such as HTTrack simply downloading the generated source.

    I know we could have a long discussion about the fruitfulness or effectiveness of such techniques, however that’s not the aim of this thread, I hope grin .

    Regards
      • 20413
      • 2,877 Posts
      Interesting!  smiley
      Found this: http://www.voormedia.com/en/tools/html-obfuscate-scrambler.php

      //But it probably would be tricky to use for the whole page output...
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 30564
        • 60 Posts
        ^ Thanks for that. Another thought, is there a way to get MODx to strip new lines from its output? It might then be possiblle to provide a level of comfort to the client, whilst retaining a simpler approach, thereby reducing compatibility issues.

        Thoughts?

        Regards
          • 9130
          • 171 Posts
          It’s pretty easy to build a plugin the removes all newlines from the output (or scramble it any other way you like). I’d be careful though as anything beyond basic stuff will most likely destroy any search engines ability to index your site not to mention compatibility with different web browsers or mobile devices.
            • 30564
            • 60 Posts
            It’s pretty easy.. Mayhap for you smiley could anyone point me as to where I might review this process, noting that I’m not laying any claim to programmatic skills? ... anything beyond basic ... Don’t disagree with that, but client is less concerned about those factors [site is not aimed at serendipitous access].

            Regards
              • 9130
              • 171 Posts
              Create a new plugin, use the code below (copied almost straight out of MODx documentation) and set its configuration to run on the OnWebPagePrerender event.
              <?php
              $e = $modx->Event; 
              
              switch ($e->name) { 
              	case "OnWebPagePrerender":
                              //This does the actual replace
                              $modx->documentOutput = str_replace( "\n", "", $modx->documentOutput);
              		break;
              
              	default : 
              		return; // stop here - this is very important. 
              		break; 
              }
              ?>

              * Note that I have not tested this in any way.
                • 30564
                • 60 Posts
                Many thanks. I’ll give this a try and report back, though if anyone has a more ’secure’ facility, still be interested to hear.

                Initial Run:
                I get the following back though the page displays and the source is still ’new lined’.

                [error] PHP Parse error:  syntax error, unexpected '<' in ../manager/includes/document.parser.class.inc.php(745) : eval()'d code on line 1


                Regards
                  • 16610
                  • 634 Posts
                  Remove first (<?php ) and last (?>) line from Etals example code. Then it should work.
                    Mikko Lammi, Owner at Maagit
                    • 30564
                    • 60 Posts
                    ^ Thanks. Excising the php tags removed the error. However, the pages still render normally in view page source.

                    Regards
                      • 19667
                      • 26 Posts
                      I believe \r\n will do the trick.