Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation



integrationblogcta.jpg

Mime Module Documentation

This module allows users to create and manage redirects.

The functions within this module may or may not be governed by a feature list. The required feature list may vary from function to function, to review a total list of the available features sets on a cPanel server, please see "Feature Manager" in WHM.

Mime::add_hotlink

API Version: 1 - Click here for documentation
Syntax: Mime::add_hotlink( urls, exts, redirect, direct )
Description: Add hotlink protection to a specified site. This will redirect users to another URL if they come to a file with a specified extension, but haven't been referred by an allowed URL.
Parameters:  
  urls (string)
  This parameter allows you to specify URLs that are allowed to hotlink to your site. Specify multiple URLs by separating them with newline characters (e.g., http://example.com/).
  exts (string)
  File types that should use hotlink protection. Specify multiple extensions by passing a comma-separated list to this parameter (e.g., jpg,jpeg,gif,png,bmp).
  redirect (string)
  The URL to which users who violate the hotlinking policy will be sent (e.g., http://example.com/badhotlinker).
  direct (boolean (optional))
  Allow users to directly visit files with matching extensions. The default value is off (0).
Returns:  
 
This function does not produce any output.

Mime::add_handler

API Version: 1 - Click here for documentation
Syntax: Mime::add_handler( ext, handler )
Description: Add an apache MIME type handler for a specific file extension.
Parameters:  
  ext (string)
  The file extension for which to add a MIME handler (e.g., ".txt").
  handler (string)
  A string containing the handler to add (e.g., "text/plain").
Returns:  
 
This function does not produce any output.

Mime::del_redirect

API Version: 1 - Click here for documentation
Syntax: Mime::del_redirect( src, domain, docroot )
Description: Remove a redirect from an account's .htaccess file. This function requires access to the 'redirect' feature. This function is not available in demo mode.
Parameters:  
  src (string)
  The specific page that redirects visitors. This value is the section of the URL to the right of the 3rd / (e.g., this/page if the URL was configured for http://www.example.com/this/page).
  domain (string)
  The domain that redirects visitors.
  docroot (string)
  The document root of the domain that contains the .htaccess file to be changed (e.g., /home/user/public_html/example.com).
Returns:  
 
This function does not produce any output if it is successful.

Mime::linkallownull

API Version: 1 - Click here for documentation
Syntax: Mime::linkallownull( )
Description: Print whether direct requests to images and other specified file types are allowed.
Returns:  
 
Returns "checked" if direct requests are allowed. If direct requests are not allowed, this function does not produce any output.

Mime::del_hotlink

API Version: 1 - Click here for documentation
Syntax: Mime::del_hotlink( )
Description: Disable hotlink protection. This function requires access to the 'hotlink' feature. This function is not available in demo mode.
Returns:  
 
This function does not produce any output.

Mime::add_mime

API Version: 1 - Click here for documentation
Syntax: Mime::add_mime( type, ext )
Description: Add a MIME type for Apache. The MIME type will be added to the account's .htaccess file, and not added server-wide. This function requires access to the 'mime' feature. It is not available in demo mode.
Parameters:  
  type (string)
  The MIME type to add, in the format of application/type (e.g., application/javascript).
  ext (string)
  The file extension to associate with the MIME type. This value may start with a dot (e.g. .).
Returns:  
 
This function will not generate any output if it is successful.

Mime::del_handler

API Version: 1 - Click here for documentation
Syntax: Mime::del_handler( ext )
Description: Delete an Apache MIME type handler for a specific file extension.
Parameters:  
  ext (string)
  The file extension for which to delete the MIME handler (e.g., .txt).
Returns:  
 
This function does not produce any output.

Mime::linkexts

API Version: 1 - Click here for documentation
Syntax: Mime::linkexts( )
Description: List extensions protected by hotlink protection. This function requires access to the 'hotlink' feature.
Returns:  
 
The output should resemble the following:
jpg,jpeg,gif,png,bmp

Mime::linkrurl

API Version: 1 - Click here for documentation
Syntax: Mime::linkrurl( )
Description: Print the URL to which hotlinkers will be redirected, if hotlink protection is enabled. This function requires access to the 'hotlink' feature.
Returns:  
 
The output should resemble the following:
http://www.example.com

Mime::linkurls

API Version: 1 - Click here for documentation
Syntax: Mime::linkurls( )
Description: Print URLs that are allowed to access protected images. This function requires access to the 'hotlink' feature.
Returns:  
 
The output should resemble the following:
http://www.example.com

Mime::linkenable

API Version: 1 - Click here for documentation
Syntax: Mime::linkenable( )
Description: Print whether hotlink protection is enabled. This function requires access to the 'hotlink' feature.
Returns:  
 
This function will return either:

'enabled' or 'disabled'.

Mime::add_redirect

API Version: 1 - Click here for documentation
Syntax: Mime::add_redirect( src, type, url, domain, wildcard, rdwww )
Description: Add a redirect to your .htaccess file. This function requires access to the 'redirects' feature. This function is not available in demo mode.
Parameters:  
  src (string)
  This parameter adds a specified page to the end of the domain to be redirected (e.g., http://www.example.com/specific-page).
  type (string)
  Whether the redirect is a temporary or permanent redirect. This parameter only accepts 2 values: permanent or temporary.
  url (string)
  The URL to which to redirect, in the following format: http://www.example.com.
  domain (string)
  The domain to which the redirect will apply (e.g., example.com). To redirect all domains associated with the cPanel account, use a period followed by an asterisk (.*).
  wildcard (boolean)
  Specifying 1 to this parameter applies the redirect to all subdomains of the specified domain.
  rdwww (integer)
  Specifying 0 or leaving this parameter undefined will cause the function to create redirects for domains with and without www.*. Specifying a 1 to this parameter causes the function to only add redirects for domains that do not start with www.*. Specifying a 2 to this parameter causes the function to only add redirects for domains that begin with www.*.
Returns:  
 
This function does not produce any output if it is successful.

Mime::del_mime

API Version: 1 - Click here for documentation
Syntax: Mime::del_mime( type )
Description: Remove a MIME type handler from an account's .htaccess file. This function requires access to the 'mime' feature. This function is not available in demo mode.
Parameters:  
  type (string)
  The MIME type to remove, formatted as follows: application/type (e.g., application/javascript).
Returns:  
 
This function does not produce any output.

Topic revision: r2 - 27 Mar 2012 - 18:52:24 - Main.JenniferDoubrava