We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21255
    • 215 Posts
    To add some more security to MODx I would recommend to insert the following lines in index.php just after line 50:

    // Secure variables from outside
    foreach(array('HTTP_REFERER','HTTP_USER_AGENT') as $outside) {
      $_SERVER[$outside] = preg_replace("/[^A-Za-z0-9_\-\,\.\/\s]/", "", $_SERVER[$outside]);
      if(strlen($_SERVER[$outside])>255) $_SERVER[$outside] = substr(0,255,$_SERVER[$outside]);
    }
    if(isset($_GET['q'])) $_GET['q'] = preg_replace("/[^A-Za-z0-9_\-\.\/]/", "", $_GET['q']);
    
    // Never allow request via get and post contain snippets, javascript or php
    $modxtags = array('@<script[^>]*?>.*?</script>@si',
                      '@&#(\d+);@e',
                      '@\[\[(.*?)\]\]@si',
                      '@\[!(.*?)!\]@si',
                      '@\[\~(.*?)\~\]@si',
                      '@\[\((.*?)\)\]@si',
                      '@{{(.*?)}}@si',
                      '@\[\*(.*?)\*\]@si');
    foreach($_POST as $key => $value) {
      $_POST[$key] = preg_replace($modxtags,"", $value);
    }
    foreach($_GET as $key => $value) {
      $_GET[$key] = preg_replace($modxtags,"", $value);
    }
    // End of modification
    



    It isn’t substantially tested, but it’s a good start.
      • 32963
      • 1,732 Posts
      Very cool script indeed. We can certainly add it but for now you can make it into a plugin

      You can use the OnWebPageInit to execute the code and the OnSiteSettingsRender event to add an option to the system settings.
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 25663 MODX Staff
        • 12,272 Posts
        Very cool idea. Thanks.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 32241
          • 1,495 Posts
          I think this is one of the usefull improvement to be added to the core.

          Thanks for the contribution netnoise.
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 33453
            • 141 Posts
            Quote from: xwisdom at Jan 16, 2006, 09:51 AM

            You can use the OnWebPageInit to execute the code and the OnSiteSettingsRender event to add an option to the system settings.
            Can you explain the use of the OnSiteSettingsRender event in a bit more detail please Raymond?

            Thanks.
              • 32963
              • 1,732 Posts
              Quote from: zenmaster at Jan 21, 2006, 10:56 AM

              Can you explain the use of the OnSiteSettingsRender event in a bit more detail please Raymond?

              Thanks.

              Hi,

              Sorry for not being able to respond until now.

              The OnSiteSettingsRender event is triggered whenever someone clicks on the System settings menu link. This will allow a developer to add custom system preferences to the Site Settings Tab.

              One good example of this is the FCKEditor Plugin even though it makes use of another System Settings event.
                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.
                • 32241
                • 1,495 Posts
                Wow, this is cool, I just know this functionality. I’ll make sure that I migrate my hack for site setting to plugin instead.
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                  • 25663 MODX Staff
                  • 12,272 Posts
                  netnoise, did you ever commit this to your branch in SVN or test this some more?
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 21255
                    • 215 Posts
                    The patch is currently used on a production server (so it’s tested), but I think it actually doesn’t work with multidimensional $_POST-arrays. I’m working on it and will try to commit it to my branch... ("Try to", because I’m still doing a bit hard working with svn on the Linux-commandline ;-)
                      • 31337
                      • 258 Posts
                      Netnoise,

                      I sent you a PM about this. Let me know when you’re available to talk about it.

                      If you need help with SVN command line stuff, I’d be happy to help with it grin