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

This function enables hotlink protection for a site. If visitors arrive at a specific filetype through a URL that the allowed list does not include, hotlink protection redirects users to another URL.

Warning:

cPanel API 1 is deprecated. Do not use this function. Instead, we strongly recommend that you use the following newer functions:


 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$add_hotlink = $cpanel->api1('Mime', 'add_hotlink', array('http://example.com','jpg,jpeg,gif,png,bmp',"http://goaway.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 $add_hotlink = $cpliveapi->api1('Mime', 'add_hotlink', ['http://example.com','jpg,jpeg,gif,png,bmp',"http://goaway.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="Mime::add_hotlink( $FORM('urls','exts','redirect','direct') )">
 Command Line
cpapi1 --user=username Mime add_hotlink http://example.com jpg,jpeg,gif,png,bmp http://goaway.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 (none)

This function does not return output.

ParameterTypeDescriptionPossible ValuesExample
urls
string

Required

The URL or URLs that may hotlink to your site.

One or more valid URLs, separated by newline characters.http://example.com
exts
string

Required

The file types to protect from hotlinks.

A comma-separated list of valid file extensions.
jpg.jpeg,gif,png,bmp
redirect
string

Required

The URL to which to redirect hotlink protection violators.

Any valid URL.http://goaway.com
direct
BooleanWhether to allow users to directly visit a file with a matching extension.
  • 1 — Allow.
  • 0 — Do not allow.
0

This function does not return output.