Technical Documentation v1.0.0 WHMCS 9.1.x · PHP 8.2–8.4

Haikhavan Software Licensing, Localization & Client 360°

Complete architecture reference, installation guide, database schema, hooks, and troubleshooting.

Quick Installation

  1. Purchase the module and download haikhavan_licensing_i18n-ioncube-8.2-1.0.0-install.zip from your VPSrv Client Area Downloads.
  2. Upload and extract the ZIP into your WHMCS root directory so files land in modules/addons/haikhavan_licensing_i18n/.
  3. Verify PHP 8.2–8.4 with ionCube PHP Loader 14+ / 15.5+ is enabled on your server.
  4. Go to System Settings → Addon Modules in WHMCS Admin, click Activate next to Haikhavan Software Licensing, Localization & Client 360°, and assign administrator role access.

Version: 1.0.0 | Platform: WHMCS 9.1.2+ (PHP 8.1–8.4, MySQL 8.0/8.4) | Module Type: WHMCS Addon Module + Signed REST API

A unified, zero-CDN utility suite for WHMCS combining domain/IP/directory-bound software licensing with HMAC-SHA256 remote verification, a 7-language WHMCS Translation Override Studio, and a single-pane Client 360° Profile Viewer with real-time piracy telemetry.


Technical Documentation — Haikhavan Software Licensing, Localization & Client 360° (haikhavan_licensing_i18n)

1. Architecture Overview

haikhavan_licensing_i18n is a standalone, PSR-4-autoloaded (MgLicensingI18nPro\) WHMCS 9.1.2+ Addon Module with zero external CDN dependencies and zero third-party composer requirements.

modules/addons/haikhavan_licensing_i18n/
├── haikhavan_licensing_i18n.php    # Module config, activate/deactivate, Admin & Client entrypoints
├── api.php                      # Standalone HMAC-SHA256 Remote Verification & Release Manifest API
├── hooks.php                    # 7 WHMCS hooks (4 service lifecycle + navbar + client summary + home widget)
├── whmcs.json                   # WHMCS 9 module manifest
├── lib/
│   ├── Database.php             # 8 mod_hk_lic_* tables, signing secret generator, audit logger, seeder
│   ├── LicenseService.php       # Key gen, HMAC signing, local_key builder, verification engine, telemetry
│   ├── LocalizationService.php  # 7-language coverage engine, CRUD, safe var_export() lang/overrides/ exporter
│   ├── Client360Service.php     # Multi-table WHMCS client aggregator, LTV/risk scorer, VIP notes CRUD
│   ├── AdminController.php      # 5-tab Admin Studio + 11 CSRF-protected AJAX endpoints
│   └── ClientController.php     # Client Area License & Release Portal + 3 CSRF-protected AJAX endpoints
├── templates/
│   ├── admin/dashboard.php      # 5-tab Admin workspace
│   └── client/portal.tpl        # Smarty Client Area template
└── assets/
    ├── css/haikhavan_licensing_i18n.css
    └── js/haikhavan_licensing_i18n.js  # Zero-CDN Retina Canvas charts & AJAX UI bindings

2. Database Schema (8 Tables)

All tables are prefixed with mod_hk_lic_ and created idempotently on activation via WHMCS\Database\Capsule::schema().

Table Purpose Key Columns & Indexes
mod_hk_lic_products Licensable software catalog product_slug (UNIQUE), latest_version, sha256_checksum, local_key_days, linked_pid (IDX)
mod_hk_lic_licenses Issued software license keys license_key (UNIQUE), product_id (IDX), userid (IDX), service_id (IDX), status (IDX), valid_domains, valid_ips, valid_dirs, last_checkin_at, expires_at
mod_hk_lic_checkins Verification telemetry & piracy alerts license_id (IDX), license_key (IDX), domain, ip_address, outcome (IDX), alert_flag (IDX), response_ms, created_at (IDX)
mod_hk_lic_releases SHA-256 verified release manifest product_id (IDX), version, channel, download_url, sha256_checksum, min_php, download_count
mod_hk_lic_locales Supported localization packs locale_code (UNIQUE), display_name, native_name, rtl, enabled, last_exported_at
mod_hk_lic_translations Key-value language overrides UNIQUE(locale_code, string_key), english_source, translated_value, context_group, status
mod_hk_lic_client_notes Admin Client 360° VIP & Risk tags userid (IDX), tag, risk_level, summary, created_by, created_at
mod_hk_lic_audit_log Immutable operations & API audit log actor, action (IDX), target_type, target_id, details, ip_address, created_at (IDX)

3. Remote Verification API & Cryptographic Signing (api.php)

Endpoint & Actions

  • URL: /modules/addons/haikhavan_licensing_i18n/api.php
  • Formats: Accepts application/json body, application/x-www-form-urlencoded POST, or GET query parameters.
Action Required Params HTTP Status Codes Behavior
verify (default) license_key, optional domain, ip, dir, version 200 Valid, 401 Missing key, 403 Invalid domain/IP/dir or suspended/revoked/expired, 404 Unknown key Validates bindings, auto-binds if status=reissued or unbound, logs check-in telemetry (alert_flag=1 on mismatch/abuse), returns HMAC-SHA256 signature + signed offline local_key.
releases license_key 200 OK, 401 Missing key, 403 Inactive/unknown key Returns product release manifest array with version, channel, download_url, sha256_checksum, and HMAC-SHA256 signature.

Signature & Local Key Verification

  1. Every response includes X-Haikhavan-Signature HTTP header and hmac_sha256 JSON field computed as:
    $expected = hash_hmac('sha256', json_encode($response['data'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), $signingSecret);
    hash_equals($expected, $response['hmac_sha256']);
    
  2. Offline local_key is a URL-safe base64 envelope containing {"payload":{...,"valid_until":<unix_ts>},"sig":"<hmac_sha256>"} so remote software can verify license state offline for local_key_days before requiring an online check-in.

4. WHMCS Hooks (7 Registered Hooks)

Hook Trigger Action
AfterModuleCreate New WHMCS service provisioned Issues bound license if linked_pid matches product and auto_provision_licenses=on.
AfterModuleSuspend Service suspended Transitions linked license(s) to suspended.
AfterModuleUnsuspend Service unsuspended Reactivates suspended license(s) back to active.
AfterModuleTerminate Service terminated Permanently transitions linked license(s) to revoked.
ClientAreaPrimaryNavbar Client Area render Adds Software Licenses link under Services for authenticated clients.
AdminAreaClientSummaryPage Admin client profile load Injects Client 360° Quick Banner with LTV, active licenses, Risk Score badge, and deep-link.
AdminHomeWidgets Admin Dashboard load Renders Licensing Telemetry, Localization & Client 360° 5-KPI summary widget.

5. Security Controls

  • CSRF Protection: All Admin (10 write ops) and Client (3 write ops) AJAX mutations require a session-bound 48-char CSPRNG token verified via hash_equals(); invalid/missing tokens return HTTP 403.
  • Client Ownership Isolation: Client AJAX endpoints check $_SESSION['uid'] (401 if unauthenticated) and scope all license/release lookups strictly to userid = $_SESSION['uid'].
  • Safe Language File Export: LocalizationService::sanitizeLocale() restricts filenames to a strict 7-locale allowlist (polish, german, french, spanish, dutch, italian, arabic), preventing path traversal; all PHP string literals are serialized via var_export() to eliminate PHP code injection.
  • XSS Prevention: All Admin outputs escape via htmlspecialchars(..., ENT_QUOTES, 'UTF-8'); all Client Smarty templates use |escape.

6. AJAX Endpoints Reference

  • Admin (addonmodules.php?module=haikhavan_licensing_i18n&ajax=1&op=...): telemetry (GET), preview_locale (GET), issue_license, transition_license, update_bindings, add_release, save_translation, add_translation_key, export_locale, add_client_note, delete_client_note, simulate_verify (all POST + CSRF).
  • Client (index.php?m=haikhavan_licensing_i18n&ajax=1&op=...): reissue_license, get_local_key, track_download (all POST + Auth + CSRF).