We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50574
    • 70 Posts
    Hello

    Rev 2.3.5 || php5.4 || mysql 5.1.73

    I'm trying to add a 'tablet' tag into the mobiledetection plugin but when I save the changes the manager goes awry (see attached images 'md_error' & 'md_error2').
    Clicking the 'save' button then tries to resave the file with the same result. The duplicate button brings up the duplication window but isn't usable. The Help button shows the help pop-up but with no content and the close button throws me out to my preview site (www.domain.com/?). If I refresh the page it all loads correctly but without any changes I have made.

    I thought it might have been to do with my reworked code but I've also had the same error when loading the plugin page and pressing 'save' without actually altering anything.

    I looked into the php mod_security issue but seeing as it's only this plugin that I'm getting the error on (I can save all other kinds of elements/resources) I presume it's more to do with that than the server. Does anyone know if there is anything I can do/research?

    Thanks

    This question has been answered by BobRay. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can save the original plugin code OK?
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 50574
        • 70 Posts
        Afraid not. If I open the plugin and click save without doing anything it does the same.
        I've had it before with some MigX TVs but I wasn't able to nail the solution down. One had a mistake in the input fields code I had created and another was an error with a text area element that I had put some html into (I think it was an error in the html that was causing the problem).
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, it installed fine here and I can save the plugin (even some minor modifications I made to it) with no problem. So the only thing that comes to mind is in fact some kind of mod_security issue. I've run into some pretty odd issues with that on different servers.

          About the only thing you can do is trial-and-error to pin down just what is causing it. Start with copying the code to a text editor, then saving it empty. Then start adding small sections of code until it stops working.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Or... you can put the whole thing in a separate .php file in the core/components/mobiledetection/ folder, and just use a single include() in the actual plugin code.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              The first thing I did was to download the latest mdetect.php file, and put it in core/components/mobiledetection/lib/, instead of in assets. There shouldn't be any .php or other executables in assets. Then I changed the path of the include in the plugin to MODX_CORE_PATH . components/mobiledetedtion/lib/mdetect.php

              http://blog.mobileesp.com/?page_id=20 - the source URL in the plugin comments is obsolete, google code has been shut down so it's on github now.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 50574
                • 70 Posts
                Thanks Susan.
                I tried changing the mdetect.php plugin as suggested but couldn't save the plugin after changing the file path.
                I then tried reinstalling the plugin, then uninstalling and reinstalling to no avail.

                I have just removed all the code and re-input it line by line and have found a few lines that were causing the error when I saved the file. I'm not sure why because my php knowledge isn't too hot but something may jump out at you or another forum member?

                Line 138
                $delete_node = preg_quote($delete_node);

                Line 140-141
                $modx->resource->_output = preg_replace($pattern,'',$modx->resource->_output);
                $preserve_node = preg_quote($preserve_node);

                Line 143
                $modx->resource->_output = preg_replace($pattern,'',$modx->resource->_output);

                Line 145
                $modx->resource->_output = preg_replace($pattern,'',$modx->resource->_output);

                And finally Line 192 (the mdetect path)
                include("assets/components/mobiledetection/mdetect.php");
                • discuss.answer
                  • 3749
                  • 24,544 Posts
                  I wouldn't rule out an issue with mod_security, which often objects to specific sections of specific MODX objects. On one site, for example, a page containing the word 'casino' wouldn't save due to mod_security. JavaScript code is sometime the trigger.

                  Another possibility, if the plugin contains any JS code, is that that code is conflicting with some of the Manager code.

                  Also, make sure you have the compress_js and compress_css System Settings off.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    It's time to talk to your hosting provider's support desk. They can look at their security logs and tell you if that's what the problem is. It sure looks like a mod_security issue to me.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 50574
                      • 70 Posts
                      Yep. It was that cheeky little mod_security again.
                      Thanks for all the responses.