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!

cPanel API - list denied ip's

Discussion in 'cPanel Developers' started by maakum, Jul 1, 2010.

  1. maakum

    maakum Registered

    Joined:
    Dec 18, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    151
    There is
    DenyIp::adddenyip and
    DenyIp::deldenyip

    But is there a way to get the denied ip's listed?
     
  2. cPanelCraig

    cPanelCraig Member
    Staff Member

    Joined:
    Apr 29, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    51
    Hello,

    There currently is no way by calling into the API that you can retrieve the IP address list. The list has to be parsed out of the .htaccess files via your own code.

    The key thing to remember when parsing the files is that the denied IP addresses will be appended to the end of the file.

    I've attached an archive containing a helper class that will scrape all the "deny from" lines which are outside of any containers. It will return an array to the caller in the form:

    Code:
    Array
    (
        [0] => Array
            (
                [line] => 24
                [ip] => 1.1.1.1
            )
    
        [1] => Array
            (
                [line] => 25
                [ip] => 2.2.2.2
            )
    
    )
    
    Once you obtain the list of IP addresses, you can then call into the API to add or remove them.
     

    Attached Files:

    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