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.

cPanel api 2 for mysql remote whitelist

Discussion in 'cPanel Developers' started by gruant2000lewis, May 21, 2015.

  1. gruant2000lewis

    Joined:
    May 21, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    Is there a cPanel API 2 function for adding ip address to the mysql remote connection whitelist ?
     
  2. gruant2000lewis

    Joined:
    May 21, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    Awesome ! Thank you very much.
     
  3. gruant2000lewis

    Joined:
    May 21, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    I have one more question, I notice in the docs that This function only returns a reason value if it failed.
    I want to test my logic for failure.... is there a value that I can put in it that WILL produce a failure? Just wanted to get a failure so I can make sure that end is covered.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. gruant2000lewis

    Joined:
    May 21, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    Sorry for being a pest. I thought I had this all working but I have now hit another issue.

    Using this...
    $newdomain = "12.345.45.678";
    $myemails = $xmlapi->api2_query($account, "MysqlFE", "authorizehost", array('host'=>$newdomain) );

    I am able to add 12.345.45.678 to my access hosts list through the above code. I logged into cPanel to verify. But when I test the connection, I actually have no access.
    If I remove the ip address manually in cPanel....then manually add it again in cPanel.....then my connection works.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Does it work if you use the function directly in your web browser (e.g. with the WHM API (JSON) example on the document provided earlier)?

    Thank you.
     
  7. gruant2000lewis

    Joined:
    May 21, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Website Owner
    I have never tried that, and not even sure how to structure that. I have always used the method that I showed above. Does that json method still use the xmlapi.php file?

    I tried looking for a basic implementation, but couldn't find an example.

    This is the basic way I am doing it currently.

    Code:
    <?php
    require_once("xmlapi.php");
    $ip = 'website ip address here';
    $account = 'cpanel username here';
    $domain = 'mysite.com';
    $passwd = 'cpanel password here';
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($account, $passwd);
    $xmlapi->set_port(2083);
    $xmlapi->set_output("simplexml");
    
    $newAuthIP = "123.45.67.890";  <----- sanitized value from a form post
    $myemails = $xmlapi->api2_query($account, "MysqlFE", "authorizehost", array('host'=>$newAuthIP) );
    ?>
    
    
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm referring to the "WHM API (JSON)" example listed at:

    cPanel API 2 Functions - MysqlFE::authorizehost

    It's simply a method of determining if it's an issue with the function or with how you have developed your custom script.

    Thank you.
     
Loading...

Share This Page