Quick Installation
- Purchase the module and download
haikhavan_cpanel_extended-ioncube-8.2-1.0.0-install.zipfrom your VPSrv Client Area Downloads. - Upload and extract the ZIP into your WHMCS root directory so files land in
modules/addons/haikhavan_cpanel_extended/andmodules/servers/haikhavan_cpanel_extended/. - Verify PHP 8.2–8.4 with ionCube PHP Loader 14+ / 15.5+ is enabled on your server.
- Go to System Settings → Addon Modules in WHMCS Admin, click Activate next to Haikhavan cPanel Extended & Quota Guard, and assign administrator role access.
Module Slug: haikhavan_cpanel_extended
Version: 1.0.0
Namespace: Haikhavan\CpanelExtended\
Components: Dual Server Provisioning Module (modules/servers/haikhavan_cpanel_extended/) + Companion Addon (modules/addons/haikhavan_cpanel_extended/)
1. Architecture & File Inventory
modules/
├── servers/haikhavan_cpanel_extended/
│ ├── whmcs.json # WHMCS whmcs-servers schema 1.0 manifest
│ ├── haikhavan_cpanel_extended.php # Server provisioning callbacks (MetaData, ConfigOptions, TestConnection, Create/Suspend/Unsuspend/Terminate, ChangePackage, ChangePassword, AdminCustomButtonArray, UsageUpdate, SSO, ClientArea)
│ └── templates/overview.tpl # Embedded Product Details ClientArea template
└── addons/haikhavan_cpanel_extended/
├── whmcs.json # WHMCS whmcs-addons schema 1.0 manifest
├── haikhavan_cpanel_extended.php # Addon entry point (_config, _activate, _deactivate, _upgrade, _output, _clientarea)
├── hooks.php # 6 WHMCS hooks (Navbar, Sidebar, Admin Services Tab, Admin Home Widget, DailyCronJob, AfterModuleCreate)
├── lib/
│ ├── Database.php # 7-table Capsule schema installer, AES-256-CBC+HMAC token encryption, state & audit helpers
│ ├── WhmApiClient.php # WHM API v1 / cPanel UAPI HTTP client + complete Sandbox Simulator
│ ├── QuotaGuardService.php # 75%/90%/98% Quota Notifications Engine, 6-check Security Hygiene Auditor, Auto-Harden & Fleet Overview
│ ├── AdminController.php # CSRF-guarded Admin Fleet & Quota Guard SPA controller
│ └── ClientController.php # CSRF-guarded Embedded cPanel Workbench & UAPI AJAX controller
├── templates/
│ ├── admin/dashboard.php # 5-tab Admin Fleet Load, Accounts, Quota Guard, WHM Servers, Backups & Audit UI
│ └── client/panel.tpl # 9-tab Embedded Client Area cPanel Workbench Smarty template
└── assets/
├── css/haikhavan_cpanel_extended.css # Scoped zero-CDN stylesheet (.hkcp-*)
└── js/haikhavan_cpanel_extended.js # Zero-CDN High-DPI Canvas Fleet Bandwidth & Multi-Server Node Load charts
Dual-Module Coexistence Design: Because PHP function names are case-insensitive and both the server module (
haikhavan_cpanel_extended_ClientArea) and addon module (haikhavan_cpanel_extended_clientarea) share the slughaikhavan_cpanel_extended, both entry points guard declaration withif (!function_exists(...))and inspectisset($params['serviceid'])to dispatch cleanly whether WHMCS loads one or both files in the same PHP process.
2. Database Schema (mod_hk_cp_*)
| Table | Purpose | Key Columns & Indexes |
|---|---|---|
mod_hk_cp_servers |
Multi-server WHM fleet inventory & telemetry | id PK, whmcs_server_id INDEX, name, hostname, ip_address, port (2087), username, api_token_encrypted (AES-256-CBC+HMAC), load_1m, load_5m, cpu_pct, ram_pct, disk_used_gb, disk_total_gb, accounts_count, whm_version, status |
mod_hk_cp_accounts |
Managed cPanel accounts linked to Haikhavan | id PK, service_id UNIQUE, client_id INDEX, server_id INDEX, domain INDEX, username INDEX, package_name, status, disk_used_mb/disk_limit_mb, bw_used_mb/bw_limit_mb, inodes_used/inodes_limit, emails_used/emails_limit, php_version, php_ini_json, autossl_status, ssl_expiry_date, security_score, security_report_json, state_json |
mod_hk_cp_quota_rules |
Hosting Quota Notifications rules | id PK, name, metric INDEX (disk|bandwidth|inodes|email), warn_pct (75), high_pct (90), critical_pct (98), notify_email, open_ticket, auto_suspend_at_critical, upgrade_cta_label, cooldown_hours, enabled INDEX |
mod_hk_cp_quota_alerts |
Triggered quota notifications & resolution state | id BIGINT PK, account_id INDEX, service_id INDEX, client_id INDEX, rule_id, metric INDEX, level (warning|high|critical), used_pct, used_label, limit_label, status INDEX, message, triggered_at |
mod_hk_cp_quota_history |
Daily quota & load snapshots (UNIQUE(account_id, recorded_date)) |
account_id, service_id, recorded_date, disk_used_mb, bw_used_mb, inodes_used, emails_used, load_avg |
mod_hk_cp_backups |
On-demand & scheduled account backup snapshots | id PK, account_id INDEX, service_id INDEX, client_id INDEX, backup_type (full|homedir|mysql|email), filename, size_mb, status, created_at |
mod_hk_cp_audit_log |
Immutable operational & security audit log | id BIGINT PK, admin_id, client_id, service_id, action INDEX, status, summary, details_json, ip_address, created_at |
3. Server Module Callbacks (modules/servers/haikhavan_cpanel_extended/haikhavan_cpanel_extended.php)
haikhavan_cpanel_extended_MetaData()— APIVersion1.1, ports2086/2087, Service & Admin SSO labels.haikhavan_cpanel_extended_ConfigOptions()— Package, Disk MB, Bandwidth MB, Inodes, Max Emails, Default PHP, AutoSSL, App Installer.haikhavan_cpanel_extended_TestConnection($params)— WHM API v1versionping (or Sandbox verification).haikhavan_cpanel_extended_CreateAccount/SuspendAccount/UnsuspendAccount/TerminateAccount/ChangePackage/ChangePassword— Full WHM lifecycle + localmod_hk_cp_accountssynchronization.haikhavan_cpanel_extended_AdminCustomButtonArray()—Run Quota Scan,Security Hygiene Audit,On-Demand Backup,Renew AutoSSL.haikhavan_cpanel_extended_UsageUpdate($params)— Updates WHMCStblhosting.diskusage/disklimit/bwusage/bwlimitand runsQuotaGuardService::evaluateAccount().haikhavan_cpanel_extended_ServiceSingleSignOn/AdminSingleSignOn— WHMcreate_user_session/ Sandbox SSO redirect.haikhavan_cpanel_extended_ClientArea($params)— ReturnstabOverviewReplacementTemplate => templates/overview.tplembedding the full 9-tab cPanel workbench natively inside Product Details.
4. Quota Guard Engine & Security Hygiene Scoring
4.1 Hosting Quota Notifications (QuotaGuardService::evaluateAccount)
Evaluates percentage utilization across disk, bandwidth, inodes, and email against enabled rules (warn_pct=75, high_pct=90, critical_pct=98), deduplicating alerts per (account_id, metric, level) over cooldown_hours. Surfaces active alerts directly at the top of the Client Area panel with a 1-click upgrade.php?type=package&id=<service_id> CTA, and optionally executes localAPI('ModuleSuspend') at critical thresholds when auto_suspend_at_critical=1.
4.2 Account Security & Hygiene Audit (QuotaGuardService::runSecurityAudit)
Computes a 0–100 score (Grades A+, A, B, C, D) across 6 controls:
- PHP Runtime EOL Check (
-22pts if PHP< 8.1) - SSL / AutoSSL Validity & Expiry (
-25pts expired/inactive,-10pts< 15 days) - Outbound Email Authentication (SPF & DMARC) (
-10to-18pts if missing) - File Permissions &
display_errors(-15pts open0777perms,-8ptsdisplay_errors=On) - Backup Recency (
-10pts if no verified snapshot within 7 days) - Quota Headroom (
-10pts if peak disk or inode usage>= 90%)
1-Click Auto-Harden (autoHardenAccount) automatically upgrades EOL PHP to 8.3, sets display_errors=Off, repairs open permissions, enforces SPF/DMARC, renews AutoSSL (+90d), and recalculates the score.
5. Security, Hooks & AJAX API
- Token Encryption: WHM API tokens are encrypted at rest with
AES-256-CBC+HMAC-SHA256Encrypt-then-MAC (v1:) keyed via WHMCS$cc_encryption_hash. - CSRF & Tenant Ownership: Every Admin (
hkcp_admin_csrf/X-HK-CP-CSRF) and Client (hkcp_client_csrf/X-HK-CP-CSRF) POST operation enforces timing-safehash_equals()validation (HTTP403on mismatch). Client UAPI operations strictly verifymod_hk_cp_accounts.client_id === $_SESSION['uid']. - WHMCS Hooks:
ClientAreaPrimaryNavbar,ClientAreaPrimarySidebar,AdminClientServicesTabFields,AdminHomeWidgets,DailyCronJob,AfterModuleCreate. - Admin AJAX Ops:
seed_demo,sync_fleet,save_server,delete_server,save_quota_rule,delete_quota_rule,alert_status,run_audit,auto_harden,create_backup,run_autossl. - Client AJAX Ops:
add_email,delete_email,webmail_sso,add_forwarder,add_domain,add_redirect,create_db,delete_db,add_ftp,add_cron,delete_cron,update_php,run_autossl,create_backup,restore_backup,install_app,run_audit,auto_harden.