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

    Any attempt to save a cURL code in a snippets doesn't get saved, if I click save severeal times, the manager is down for about a minute.

    what i am adding is like:
    $url = 'http://domain.com/Receiver.php';
    
    $user = 'someusername';
    $pw = 'somepassword';
    $auth_key = 'YourSecretAuthKey';
    
    $fields = array(
                'auth'=>urlencode($auth_key),
                'user'=>urlencode($user),
                'pw'=>urlencode($pw)
            );
    
    // Init. string
    $fields_string = '';
    // URL-ify stuff
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');
    
    //open connection
    $ch = curl_init();
    
    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
    
    //execute post
    $result = curl_exec($ch);
    
    //close connection
    curl_close($ch);
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Sounds like a suhosin or mod_security issue; if your server has one of those active it might block attempts to save content with "mail" or "curl" or in some cases "casino" and other words the server admins want to block for spam prevention or security issues.
        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
        • 38237
        • 83 Posts
        Thanks Susan for your response.
        How to fix that, I have full control on the environment?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          See if mod_security or suhosin is enabled, and disable it for yourdomain/manager/

          It's mostly useful for front-end forms, to prevent spammers and hackers from trying to post form data containing bad stuff.
            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
            • 38237
            • 83 Posts
            Tried the below in an .htaccess file placed in the manager folder, but no luck?! What else should i check? or should i go for adding my code directly to the DB?

            <IfModule mod_security.c>
            SecRuleEngine Off
            SecFilterInheritance Off
            SecFilterEngine Off
            SecFilterScanPOST Off
            SecRuleRemoveById 300015 3000016 3000017
            </IfModule>
              • 3749
              • 24,544 Posts
              Possibly your host has things set up to ignore mod_security changes in .htaccess.
                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