Hooking into cPanel Functionality
There are numerous ways to hook into cPanel's APIs.
- cPanel function hooks — This method is preferred.
- Script hooks — The best way to hook into cPanel's update or account provisioning systems.
- The CustomEventHandler — This method is the most powerful.
cPanel function hooks
cPanel function hooks are basically scripts that reside in
/usr/local/cpanel/hooks/__MODULENAME__/__FUNCTION__NAME__ and are executed whenever the API event that corresponds to its name occurs.
cPanel function hooks work by being passed XML formatted data from the API via
STDIN. These are run 100% as a separate process, so function hooks can be written in any language and are generally safe. If a function hook fails, it will not break the cPanel interface.
- Read more about cPanel function hooks here.
Script hooks
Script hooks are used to hook into certain system-level functions, such as service upgrades and account management. These run as their own scripts executed by the script performing the action. This is the best way to hook into cPanel's update or account provisioning system.
- Read more about script hooks here.
CustomEventHandler
CustomEventHandler is a Perl module that can be created at
/usr/local/cpanel/Cpanel/CustomEventHandler.pm. The
event() method inside of this module will be executed every time a cPanel API call is made. The
event() method is passed a variety of data, including parameters being passed to the API call and data returned by the API call.
The real value in CustomEventHandlers is that, rather than being executed as separate processes, they are executed as part of the API call. If you wish to deny or modify an event, CustomEventHandler is probably the best method.
- Read more about the
CustomEventHandler here.
EasyApache Hooks
Easyapache hooks are a way of hooking into the Apache/PHP build process. These offer no type of blocking ability, however they do allow for modules to be built within the EasyApache process.
- Read more about EA3 hooks here.
Topic revision: r3 - 17 Aug 2011 - 15:26:15 - Main.JustinSchaefer