We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39074
    • 2 Posts
    Hello.
    I have an external management interface for some products. I want to create a link to this in the manager interface in modx revolution and use manager authentication for my external script. I put this lines in the beginning of the script. Is this sufficient for security?

    <?php
    define('__ROOT__', dirname(__FILE__));
    require_once(__ROOT__.'\config.core.php'); 
    
    require_once MODX_CORE_PATH.'/model/modx/modx.class.php';
    $modx = new modX();
    $modx->initialize('mgr');
    $modx->getService('error','error.modError');
    
    if (!$modx || !($modx instanceof modX)) { die('No direct access allowed'); }
    if (!$modx->user || !$modx->user->hasSessionContext('mgr')) { die ('Please make sure you are logged in to the MODX Manager'); }
    
    ?>
    


    If not, where could I find an CMP example which use smarty without extjs and without ajax with return in the same page after committing some db queries (update, insert, etc.)?

    Thank a lot!
      • 3749
      • 24,544 Posts
      Does that actually work? I wouldn't expect the current user to have a session context in a new instantiation of MODX without logging in *after* MODX is instantiated.

      Also, I think line 10 is always going to pass, since you've just created the MODX object.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 39074
        • 2 Posts
        Yes. If I am logged in the manager the scripts works. When I log out, it stops working, displaying the error message.

        And yes. I'm afraid that line 10 is useless smiley