Software Licensing
Latest Release | Current Version | Included in WHMCS |
---|---|---|
N/A | N/A | No |
The WHMCS licensing addon module allows you to license your own web applications for selling to end users. You can generate local license keys and configure periodic remote checking to ensure secure licensing for your products.
Make certain that you are using the correct licensing addon module:
- The Software Licensing addon allows you to generate and check licenses for software products that you develop.
- The cPanel Licensing addon automates purchases of cPanel & WHM licenses through Manage2.
Activation
You must first purchase this addon. Then, you can activate it through the Admin Area.
To do this:
- Purchase the addon in the WHMCS Marketplace.
- Go to Configuration () > System Settings > Addon Modules.
- Click Activate for the addon.
- Click Configure.
- Configure the following settings:
- Public License Verification Tool — Check to enable a verification page that visitors can use to check whether a domain is licensed to use your software.
- You can customize the appearance of the page using the
/modules/addons/licensing/licenseverify.tpl
file. - This page will be available at
http://www.example.com/whmcs/index.php?m=licensing
, wherehttp://www.example.com/whmcs/
is the location of your WHMCS installation.
- You can customize the appearance of the page using the
- Maximum Allowed Reissues — Enter the maximum number of times that a client can reissue a license.
- Auto Logs Prune — Set the length of time to retain license access logs.
- Public License Verification Tool — Check to enable a verification page that visitors can use to check whether a domain is licensed to use your software.
- Select the admin role groups that will have access to this addon.
- Click Save Changes.
Using this Addon
To set up a licensing product:
- Create a product at Configuration () > System Settings > Products/Services.
- In the Module Settings tab, choose License Software.
- Configure the following options:
- Key Length — The length of the randomly generated key.
- Key Prefix — The beginning of the license key. You can use this to validate an applicable key.
- Allow Reissue — Whether a client can reissue the license from the Client Area.
- Allow Domain Conflict, Allow IP Conflict, and Allow Directory Conflict — Check to disable location verification for matching domains, IP addresses, or directories, respectively. If you do not disable them, WHMCS will use the valid values in the service record to verify the license’s location.
- Support/Updates Addon — See below.
- Free Trial — Check to prevent clients from using more than one licence of this product on the same domain. If a client tries to order a second copy of this product and use it on the same domain as a previous service, the system will automatically suspend it with the reason
Duplicate Free Trial Use
.
License Statuses
Licenses use the following statuses:
- Reissued — The license is ready to use.If a license’s status is Reissued, the system will save the domain, IP adddress, and directory during the next license check.
- Suspended — The license is suspended and the user cannot use it.
- Active — The license is in use with a valid domain, IP address, and installation path.
- Expired — The license has reached its expiration date and the user cannot use it.
Module Commands
You can use the following module commands when managing licensing products in the Products/Services tab of the client’s profile:
Module Command | Description | Sets License Status To |
---|---|---|
Create | Generate a license key for the product. The Create module command does not generate a username or password. | Reissued |
Suspend | Suspend the license. | Suspended |
Terminate | Expire the license. | Expired |
Reissue | Clears the saved license domain, IP address, and directory. | Reissued |
Revoke | Remove the license key and allow reuse of the license number in the future. | N/A |
Manage | View or edit the license’s domain, IP address, and directory. | N/A |
Managing Licenses
To manage licenses, go to Addons > Licenses Manager. You can view a list of issued license keys, search for keys, and update their associated domains, IP addresses, and directories.
Addons
You can assign addon products to your licensing products for purchase with the initial order or at a later date. For example, you may want to create addons for installation and upgrade services.
Support and Updates Addons
When you check Support/Updates Addon during the creation of a licensing product, the system will require the client to have an active Support/Updates addon in order to receive support and download the related products. You can sell Support/Updates addons using any of WHMCS’s supported billing cycles.
For example, you could create a Support/Updates addon that is free with the initial license purchase and requires paid renewal when it expires.
To do this:
- Create your licensing product, making sure to check Support/Updates Addon.
- Go to Configuration () > System Settings > Product Addons.
- Click Add New.
- Enter the name, description, price, and recurring cycle.Do not check Show on Order.
- Check the desired licensing product in the Applicable Products section for the addon.
- Go to Configuration () > System Settings > Products/Services.
- Edit the licensing product.
- In the Module Settings tab, select the addon that you just created for Support/Updates Addon.
- Click Save Changes.
Integrating License Check Code
The addon’s license check code is in the /modules/servers/licensing/check_sample_code.php
file. You choose how to integrate that code into your software products.
Users can enter their license keys during your installation process or by pasting the key into a file. You can load that key in your software product before calling the check_license
function to validate it.
Each time that a license check succeeds, it returns a local key. You can store that local key in your database or a local file for use on subsequent page loads. We recommend storing it in a database for ease of use.
- The local key is an encrypted version of the license check data that prevents the license check from calling your server on every page load.
- The local key is always empty on the first check your client makes.
To integrate the license check, perform these steps:
- Copy and paste the license check code from the
check_sample_code.php
file into the top of the file you want to protect. - Enter the system URL from your WHMCS installation in the
$whmcsurl
variable. - Customize the
$licensing_secret_key
variable to ensure your local keys are different from other licensing addon users. - Optionally, change the
$localkeydays
and$allowcheckfaildays
variables if you want to change how often a remote license check is made. - Ensure that your code performs the following actions:
- Retrieve the license key and local key from the database or file storage.
- Call the
check_license
function. - Perform the desired actions in accordance with the results of the
check_license
function. For sample if statements, see thecheck_sample_code.php
file. - Store the local key that the license check returns.
Using Product Addons
If the licensing product has any purchased addons, the $results
array that the check_license
function returns will include a pipe-separated addons
string with addon details. For example:
[addons] => name=Test Addon;nextduedate=2017-12-26;status=Active
For example, you could use this data to restrict access to certain features or to customize other behavior.
The following code example processes this string into an $addons
array:
$tempresults = explode("|",$results["addons"]);
foreach ($tempresults AS $tempresult) {
$tempresults2 = explode(";",$tempresult);
$temparr = array();
foreach ($tempresults2 AS $tempresult) {
$tempresults3 = explode("=",$tempresult);
$temparr[$tempresults3[0]] = $tempresults3[1];
}
$addons[] = $temparr;
}
Using Configurable Options
If the licensing product has any configurable options, the $results
array that the check_license
function returns will include a pipe-separated configoptions
string with option details. For example:
[configoptions] => Test=0|Test 002=
For example, you could use this data to limit the software to a particular number of users.
The following code example processes this string into a $cconfigoptions
array:
$tempresults = explode("|",$results["configoptions"]);
foreach ($tempresults AS $tempresult) {
$tempresults2 = explode("=",$tempresult);
$temparr = array();
foreach ($tempresults2 AS $key => $value) {
$temparr[$key] = $value;
}
$configoptions[] = $temparr;
}
Change Log
Licensing Addon v3.0
Release Date: 9th February 2012
New Features Added:
- Free Trial Option
- Public License Verification Tool
- Banned Domains
- Intelligent Search Integration
- Added Maximum Allowed Reissues Limit
- Auto Logs Prune
Last modified: November 19, 2024