We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • UAPI Functions - DirectoryProtection::list_directories
Skip to end of metadata
Go to start of metadata

Description

This function returns the leech protection settings of the subdirectories in a directory.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/DirectoryProtection/list_directories?dir=%2Fhome%2Fexample%2Fexample.com


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Retrieve a list of indexed directories for the /home/example/example.com directory.
$list_directories = $cpanel->uapi(
    'DirectoryProtection', 'list_directories',
    array(
        'dir'    		   => '/home/example/example.com',
  )
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
Retrieve a list of indexed directories for the /home/example/example.com directory.
my $list_directories = $cpliveapi->uapi(
    'DirectoryProtection', 'list_directories',
    {
        'dir'   		   => '/home/example/example.com',
    }
);


Note:

For more information, read our Guide to the LiveAPI System.

 

 Command Line
uapi --user=username DirectoryProtection list_directories dir=%2Fhome%2Fexample%2Fexample.com


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
   "messages":null,
   "warnings":null,
   "status":1,
   "metadata":{

   },
   "data":{
      "children":[
         {
            "path":"/home/example/example.com/example",
            "state":{
               "has_leech_protection":0
            }
         }
      ],
      "parent":{
         "state":{
            "has_leech_protection":0
         },
         "path":"/home/example"
      },
      "home":{
         "path":"/home/example",
         "state":{
            "has_leech_protection":0
         }
      },
      "current":{
         "path":"/home/example/example.com",
         "state":{
            "has_leech_protection":0
         }
      }
   },
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
dirstring

Required

The directory for which to return leech protection information.

A valid absolute path or relative directory path in the user's home directory./home/example/example.com

Returns

ReturnTypeDescriptionPossible valuesExample
currenthashThe user's current directory and its leech protection information.This hash contains the state hash and path return.

state

hash

The current directory's leech protection information.

The function returns this value in the current hash.

This hash contains the has_leech_protection return.

has_leech_protection

Boolean

The current directory's leech protection status.

The function returns this value in the state hash.

  • 1 — Leech protection is enabled.
  • 0 — Leech protection is disabled.
1 

path 

string

The current directory's path.

The function returns this value in the current hash.

A valid absolute directory path.

/home/example/example.com 
home hashThe user's home directory and its leech protection information.This hash contains the state hash and path return.

state 

hash

The home directory's leech protection information.

The function returns this value in the home hash.

This hash contains the has_leech_protection return.

has_leech_protection

Boolean

The home directory's leech protection status.

The function returns this value in the state hash.

  • 1 — Leech protection is enabled.
  • 0 — Leech protection is disabled.
1 

path 

string

The home directory's path.

The function returns this value in the home hash.

A valid absolute directory path./home/example 
parent hashThe parent directory of the current directory and its leech protection information.This hash contains the state hash and path return.

state 

hash

The parent directory's leech protection information.

The function returns this value in the parent hash.

This hash contains the has_leech_protection return.

has_leech_protection

Boolean

The parent directory's leech protection status.

The function returns this value in the state hash.

  • 1 — Leech protection is enabled.
  • 0 — Leech protection is disabled.
1 

path

string

The parent directory's directory path.

The function returns this value in the parent hash.

A valid absolute directory path./home/example
children array of hashes

A list of subdirectories and their leech protection information.

Note:

The function returns this hash for each subdirectory in a directory.

This array of hashes contains the state hash and path returns.

state

hash

The subdirectory's leech protection information.

The function returns this value in the children array of hashes.

This hash contains the has_leech_protection return.

has_leech_protection

Boolean

The directory's leech protection status.

The function returns this value in the state hash.

  • 1 — Leech protection is enabled.
  • 0 — Leech protection is disabled.
1

path

string

The subdirectory's directory path.

The function returns this value in the children array of hashes.

A valid absolute directory path./home/example/example.com/cgi-bin