We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33372
    • 1,611 Posts
    Nice tip - seems like you ought to also add the check to be sure that you are logged into the manager at the top (and then this could easily be a plug-and-play module).
      "Things are not what they appear to be; nor are they otherwise." - Buddha

      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
      • 22098
      • 218 Posts
      yups! sure thing wink
        • 16496
        • 11 Posts
        This is very cool!!

        Added the ’config.inc.php’ but how to check if the user is logged into the manager?
          • 33372
          • 1,611 Posts
          Try this:
          if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 16496
            • 11 Posts
            :-\ Well it locks SQLbuddy completely. I cannot access it either from the manager nor using the direct link.
              • 33372
              • 1,611 Posts
              I haven’t looked at the SQLBuddy code, but that code works for modules loaded within the MODx Manager. Is that what you’re doing? Do you see the error in the output code?
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 16496
                • 11 Posts
                Yep!
                The module code:
                $siteurl = $modx->config['site_url'];
                header ("Location: $siteurl/assets/modules/sqlbuddy/index.php");
                


                The SQL Buddy config.php file:
                <?
                if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
                
                include_once(dirname(__FILE__).'/../../../manager/includes/config.inc.php');
                ...
                

                I recieve the following error:
                "INCLUDE_ORDERING_ERROR
                Please use the MODx Content Manager instead of accessing this file directly."
                  • 33372
                  • 1,611 Posts
                  Oh. You’re not including the file from within the module; you’re forwarding to it. I don’t think that it will work this way...

                  You could try checking for a valid manager session cookie, but that really wouldn’t be all that secure so I’d try including the file instead.
                    "Things are not what they appear to be; nor are they otherwise." - Buddha

                    "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                    Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                    • 16496
                    • 11 Posts
                    grin Got it working with the usual include command.
                    $sql = $modx->config['base_path'] . "manager/sqlbuddy/index.php";
                    include($sql);
                    

                    But in order for this to work you need to change two lines in the functions.php file:
                    line 163: redirect("login.php?timeout=1");
                    ...
                    line 165: redirect("login.php");
                    

                    Should be changed to:
                    line 163: redirect("sqlbuddy/login.php?timeout=1");
                    ...
                    line 165: redirect("sqlbuddy/login.php");
                    

                    About the check if the user is logged into the manager. There are some problems, since the code uses ’redirects’ and there is a go and back between pages, specially with index.php.
                    This means that the first time index.php is executed the value IN_MANAGER_MODE is true. The second time is undefined and the check fails. So that is why you cannot access it either from the manager nor using the direct link.
                      • 25551 ☆ A M B ☆
                      • 1,231 Posts
                      Nice find.... simple to setup.
                        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                        AugmentBLU - MODX Partner

                        BLUcart - MODX Revolution E-Commerce & Shopping Cart