Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

flush cphulk with api1 (xmlapi.php) not working

Discussion in 'Security' started by techdruid, Jul 20, 2015.

  1. techdruid

    techdruid Member

    Joined:
    Jan 16, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    I'm trying to use a script to whitelist, and then flush the cphulk block for a specific IP address. I've found plenty of documentation for the API1 example of doing this, but nothing seems to work when using the xmlapi.php module. The following is the current code I'm using. Anyone have insight as to why this won't work?

    Code:
    <?php
    
    include_once("xmlapi.php");
    
    
    $config['cpanel_ip']    = 'localhost';
    $config['cpanel_user']  = 'root';
    $config['cpanel_pass']  = 'MYPASSWORD';
    
    echo "Creating object\n";
    
    $c = new xmlapi($config['cpanel_ip']);
    echo "Autenticating\n";
    $c->password_auth($config['cpanel_user'], $config['cpanel_pass']);
    echo "Setting output\n";
    $c->set_output('array');
    
    $ar = array('ip'=>'192.168.1.1');
    
    echo "Making the call\n";
    $res = $c->api1_query('SOMEUSER','cPHulk','flush_cphulk_login_history_for_ips',$ar);
    echo "-- Result --\n";
    print_r($res);
    echo "-- done --\n"
    
    ?>
    
    The output is as follows.

    Code:
    # php -q t.php
    Creating object
    Autenticating
    Setting output
    Making the call
    -- Result --
    Array
    (
        [module] => cPHulk
        [func] => flush_cphulk_login_history_for_ips
        [type] => event
        [source] => module
        [apiversion] => 1
        [data] => Array
            (
                [0] => Array
                    (
                    )
    
            )
    
        [event] => Array
            (
                [reason] => cPHulk::flush_cphulk_login_history_for_ips() failed: Can't use string ("") as a subroutine ref while "strict refs" in use at cpanel.pl line 1740.
    
                [result] => 0
            )
    
        [postevent] => Array
            (
                [result] => 1
            )
    
        [preevent] => Array
            (
                [result] => 1
            )
    
        [error] => cPHulk::flush_cphulk_login_history_for_ips() failed: Can't use string ("") as a subroutine ref while "strict refs" in use at cpanel.pl line 1740.
    
    )
    -- done --
    
    
    Please note that I had tried using "root" as parameter number 1 to api1_query, but that failed with a message about not being associated with a cpanel account. So I had to replace it with a customers username, even though I don't believe that should be necessary to flush the IP's.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,887
    Likes Received:
    1,814
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice