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 - 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:
    1
    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:
    1
    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:

Loading...

Share This Page