LicenTra Documentation
Complete guide to installation, integration and usage of the LicenTra PHP license management system
Introduction
LicenTra is a powerful PHP license manager script that solves the #1 developers' problem - pirated and nulled copies of their software. The PHP license system works with all types of PHP scripts (applications, plugins, templates) developed in any PHP framework or without it. The main license system features include, but are not limited, to:
- Truly invisible, continuous code protection;
- Remote license management in real time;
- One installation for unlimited products, clients and licenses;
- Lifetime, time-expiring and feature-limited licenses;
- IP address and (sub.)domain based restrictions;
- Different number of concurrent installations for every license;
- Blocked installation for users without active licenses;
- No need to enter any serial number or key during installation;
- Automatic license generator for instant activations;
- Automatic license verification every X days/weeks/months/years;
- Forced license check between automatic verifications;
- Expiring license, updates and support contract notifications;
- Licensing server block and nullroute protection;
- User data storage in MySQL database or file with any extension;
- Remote data and database removal from user's machine;
- Detailed reports of every installation and license verification;
- Full API access for complete automation;
- Guaranteed protection from software piracy since 2006;
- A real-time monitoring and defense of licenser itself;
- Super-easy integration into any PHP-based application;
- Support for all 3rd party PHP obfuscators (encoders);
- Fully customizable notifications in any language;
- Unmatched performance and background updates;
Now, when you know what LicenTra offers, it's time to start using it.
File Structure
File structure of the installation package
LicenTra/
├── index.php (premium landing page)
├── apl_config.php (MySQL connection settings and cronjob debug switch)
├── apl_settings.php (global settings loader, security headers, CSRF protection)
├── apl_ver.php (product version information)
├── apl_epv_ver.php (Envato Purchase Verification plugin version information)
├── apl_cronjob.php (scheduled tasks - reminder emails and database cleanup)
├── SCRIPT/ (core LicenTra files to be integrated into your protected scripts)
├── apl_admin/ (administration dashboard)
├── apl_api/ (REST-like API endpoints)
├── apl_callbacks/ (license verification and version check callbacks)
├── apl_install/ (installer)
├── apl_modules/ (core modules)
├── apl_scripts/ (utility scripts - Envato license/support updaters)
├── apl_templates/ (Twig templates)
├── assets/ (landing page static assets)
├── dist/ (compiled admin dashboard assets)
├── lib/ (3rd party libraries - Twig, SwiftMailer, jQuery, Bootstrap, html-compress-twig)
├── plugins/ (frontend plugins)
└── src/ (Twig template engine source files)
Note: /src directory contains the Twig template engine source code (3rd party library); it is used by /lib and should not be confused with the source files of LicenTra itself. Never edit or remove it.
Installation
Important!
Delete the /apl_install directory from your server after installation - a publicly accessible installer is a serious security risk.
The MySQL connection details are stored in plain text in apl_config.php. Keep the file out of the web root if possible, or at least make sure directory permissions prevent direct downloads.
The administration dashboard has its own login system, so an additional htaccess password on /apl_admin is optional; always use a strong administrator password instead.
Server Requirements
Before installation make sure your server meets the following requirements:
- PHP 8.x or higher;
- MySQLi extension with the mysqlnd driver (
mysqli_stmt_get_resultfunction); - cURL extension (used for license verifications and the Envato API);
- OpenSSL extension (used for license data encryption).
Installation Steps
Create MySQL database
Setup new MySQL database and user, add user to database (grant all the privileges).
Configure connection
Open apl_config.php file and update it with MySQL connection details ($DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $DB_PORT). This will be done automatically by the installer if the file is writable.
Upload files
Upload all files to your server (usually files should be uploaded to /httpdocs, /public_html or /yourdomain.com directory).
Run the installer
Launch the installer at http://www.yourdomain.com/apl_install. Enter database credentials and create your administrator account (first name, last name, email, password). The installer will create all database tables, write the credentials to apl_config.php and set the installation URL.
Access dashboard
Delete /apl_install directory from server and access administration dashboard at http://www.yourdomain.com/apl_admin. Login with the email and password you set during installation.
Security
Set a strong administrator password during installation and keep your login credentials safe. Review the security settings in Settings » Security (failed login limits, whitelisted IP access, banned hosts) after the first login.
Cronjob (Optional)
Important!
Setup cronjob to be executed once a day. Running it less often might cause a delay of reminder emails.
Always test if cronjob works properly by enabling cronjob debug.
Cronjob Setup
The application uses one daily cronjob for scheduled background tasks. The cronjob performs two things every time it runs:
- Checks client's license, updates, and support expiration dates and sends reminder emails;
- Performs an automatic database cleanup (removes old callbacks, reports and other records according to the current cleanup settings).
The cronjob file is named apl_cronjob.php and located in the root directory of your LicenTra installation. The way cronjob should be executed depends on server configuration; therefore, always contact your hosting provider for more assistance. Usually, command will look like this:
php /path/to/licentra/apl_cronjob.php
For example, if your server runs cPanel (the most popular hosting panel), your account username is someuser and application is installed on /somedir directory inside /public_html, cronjob command will be:
php /home/someuser/public_html/somedir/apl_cronjob.php
This is just an example; working command depends on your server configuration.
Cronjob Debug
The best way to check if everything works as expected is to enable cronjob debug feature by opening apl_config.php file and changing CRONJOB_DEBUG value to true, so it looks like:
define("CRONJOB_DEBUG", true);
Once enabled, a separate email will be sent to you every time cronjob is launched. If cronjob runs once a day, it may take up to 24 hours for email to be sent. If no email is received after that (or you receive email with errors), contact your hosting provider for assistance. If everything seems to be good, just change CRONJOB_DEBUG value back to false; the application will reliably operate on its own from now.
Licenses Management
Before your script can be protected, a corresponding product needs to be added via LicenTra dashboard first. Step-by-step instructions on how to add/edit/remove products/clients/licenses are available in LicenTra itself, so you can learn about any feature right in the administration dashboard. Just click the Help & Support icon in the right upper bar and select Help Section for detailed examples.
Administration Dashboard
LicenTra comes with a complete administration dashboard located at /apl_admin. Every part of the license management workflow is covered by a dedicated module:
| Module | Purpose |
|---|---|
| Dashboard | Overview of products, clients, licenses, installations and callbacks with activity charts and expiring support/updates reminders. |
| Products | Add, edit and manage the products you sell. Each product gets a unique ID used in APL_PRODUCT_ID. Optionally link a product to an Envato item ID (product_envato_id) for the Envato plugin. |
| Clients | Add, edit and manage registered clients and their status. |
| Licenses | Issue, suspend, renew, extend updates/support or cancel licenses. Supports personal (email-based) and anonymous (code-based) licenses. |
| Installations | View every installation of your protected scripts with its domain, IP address and status. |
| Callbacks | Monitor every license verification, installation, uninstallation and version check callback in real time. |
| API Keys | Create and manage API keys with IP restrictions and per-function permissions used by /apl_api (see API Reference). |
| Banned Hosts | Automatically or manually ban IP addresses that repeatedly fail license verification or try to crack the system. |
| Reports | Detailed reports of every license, cracking and system event with smart charts and Excel/PDF export. |
| Notifications & Emails | Customize the response notifications returned to protected scripts and the reminder email templates that are sent to clients. |
| Settings | General, security, email and cleanup settings plus advanced options (whitelisted access, smart reports, smart tables, API status, Envato API token, etc.). |
| Extra Tools » Configuration Generator | Automatically generates a ready-to-use apl_core_configuration.php file for your protected script with a random encryption salt. |
| Search | Global search across products, clients, licenses, installations, callbacks, banned hosts and reports. |
Integration and Usage
LicenTra is suitable for both beginner and professional developers. As a result, its setup depends on your personal needs. For example, basic protection requires just inclusion of licensing module and single call of license verification function in your script. If that's not enough, call additional functions and reap the benefits of advanced protection to verify authenticity of script's files, force data removal from user's server, validate updates, and perform other tasks. No matter your needs, the complete integration is as easy as:
- Including LicenTra files in your application
- Configuring license verification settings
- Calling LicenTra functions in your code
- Encoding your application (optional)
Both basic and advanced modes are fully compatible, which means you can start with basic integration and expand it at any time. In other words, once you need more options, just call additional LicenTra functions without breaking existing functionality of your code.
Attention: for your convenience, advanced guide covers all the aspects of basic protection as well, so jump to this one if you plan starting with advanced protection right away.
Attention: see working scripts in /SCRIPT directory for real-life examples on how to use every feature LicenTra offers.
Basic Protection
Ready to start? The basic integration guide protect your script in about 5 minutes - perfect for developers with basic PHP skills.
Advanced Protection
Want to squeeze every bit of the license manager script? Check out the advanced protection guide for extreme guard and versatility.
API Reference
Automate your license management with the REST-like API - create clients, licenses, products and search your database.
Envato Purchase Verification
LicenTra ships with the optional Envato Purchase Verification plugin (apl_epv_ver.php) for developers selling their products on Envato marketplaces (CodeCanyon, ThemeForest, etc.). The plugin verifies users' purchase codes directly against the Envato API and automatically creates licenses for verified purchases.
Features
- Purchase code validation against the Envato API;
- One-click license activation from your script using
aplVerifyEnvatoPurchase(); - Seamless cancellation flow - cancelled Envato sales deactivate the license automatically;
- Automatic support expiration update from the Envato API.
Setup
Configure Envato API token
Go to Settings » Advanced in the administration dashboard and enter your Envato API token into the ENVATO_API_TOKEN field.
Link products to Envato
In Products, edit your product and set its Envato item ID. The plugin only creates licenses for products that have a matching Envato item ID.
Enable in your script
Call aplVerifyEnvatoPurchase() (see Advanced Protection) with the user's Envato purchase code during installation.
Schedule automatic updaters
The utility scripts /apl_scripts/license_update_envato.php and /apl_scripts/support_update_envato.php check all Envato licenses for cancellation and refresh support expiration dates. Run them as a daily cronjob.
How it works
When aplVerifyEnvatoPurchase() is called from the protected script, LicenTra contacts the Envato API (https://api.envato.com/v3/market/author/sale) with the submitted purchase code. If the purchase exists and belongs to a product with a matching Envato item ID, an anonymous code-based license (with license_envato = 1) is created automatically. The license limit is always 1, no matter how many times the same purchase code was used.
If a license is later cancelled at Envato, the license_update_envato.php script marks it as inactive; support_update_envato.php keeps the license_support_date synchronized with the supported_until value returned by the Envato API.