Child pages
  • cPanel API 1 Functions - LeechProtect::enable
Skip to end of metadata
Go to start of metadata

Description

This function enables leech protection on a directory.

Warning:

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.

Important:

In cPanel & WHM version 76 and later, when you disable the WebServer role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 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.


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.
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.


Note:

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

 

 cPanel Tag System (deprecated)


Warning:

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


Notes:

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

    /usr/local/cpanel/bin/cpapi1

 Output (plaintext)
LeechProtection enabled for public_html/protected_directory

Parameters

ParameterTypeDescriptionPossible valuesExample
dirstring

Required

The directory's path.

A valid full file path.
/home/username/public_html/protected_directory/
numhitsinteger

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.

100
badurlstring

Required

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.
0

Returns

This function returns a confirmation message.