The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

flush cphulk with api1 (xmlapi.php) not working

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

  1. techdruid

    techdruid Member
    PartnerNOC

    Joined:
    Jan 16, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    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:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page