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
  • cPanel API 1 Functions - LeechProtect::enable
Skip to end of metadata
Go to start of metadata


This function enables leech protection on a directory.


cPanel API 1 is deprecated. We strongly recommend that you do not use cPanel API 1. However, no equivalent function exists in our newer APIs.


In cPanel & WHM version 76 and later, when you disable the Web Server role, the system disables this function.


 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$enable_leech = $cpanel->api1('LeechProtect','enable', array('/home/username/public_html/protected_directory/','100','http://elsewhere.example.com/','user@example.com','0') ); // Call the function.


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.
my $enable_leech = $cpliveapi->api1('LeechProtect', 'enable', ['/home/username/public_html/protected_directory/','100','http://elsewhere.example.com/','user@example.com','0']); # Call the function.


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


 cPanel Tag System (deprecated)


In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We provide this example to help developers move from the old cPanel tag system to our LiveAPI system. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

<cpanel Module="LeechProtect::enable ( $FORM('dir','numhits','badurl','email',killcompro'))">
 Command Line
cpapi1 --user=username LeechProtect enable /home/username/public_html/protected_directory/ 100 http://elsewhere.example.com/ user@example.com 0


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


 Output (plaintext)
LeechProtection enabled for public_html/protected_directory


ParameterTypeDescriptionPossible valuesExample


The directory's path.

A valid full file path.

The number of times that a user can log in to a resource before leech protection triggers.

This parameter defaults to 4 .

A positive integer.



A URL to redirect visitors to when leech protection triggers.

A valid URL that exists.http://elsewhere.example.com/
emailstringAn email address to alert when leech protection triggers.A valid email address.user@example.com
killcomprostringWhether to disable the account that triggers leech protection.
  • 1 — Disable.
  • 0 — Do not disable.


This function returns a confirmation message.