Quick Installation
- Purchase the module and download
haikhavan_panels_collab-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_panels_collab/andmodules/servers/haikhavan_panels_collab/. - 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 Multi-Panel, Docker & Email Collaboration, and assign administrator role access.
Version: 1.0.0
Compatibility: WHMCS 8.x / 9.x (tested on WHMCS 9.1.2) • PHP 8.1 / 8.2 / 8.3
Module Type: Dual Architecture — WHMCS Server Provisioning Module + Companion Addon Module
External Dependencies: Zero Composer packages, zero external CDNs
Technical Documentation — Haikhavan Multi-Panel, Docker & Email Collaboration (haikhavan_panels_collab)
Version: 1.0.0
Namespace: Haikhavan\PanelsCollab\
Target Runtime: WHMCS 8.x / 9.1.2, PHP 8.1–8.3, MySQL 8.0+ / MariaDB 10.6+
1. Architecture Overview
haikhavan_panels_collab implements a dual WHMCS Server + Companion Addon architecture sharing a single PSR-4 library under modules/addons/haikhavan_panels_collab/lib/.
+-------------------------------------------------------------------------+
| WHMCS 9.1.2 Core Runtime |
+------------------------------------+------------------------------------+
| Server Provisioning Module | Companion Addon Module |
| modules/servers/haikhavan_panels_collab| modules/addons/haikhavan_panels_collab|
| - MetaData / ConfigOptions | - config / activate / upgrade |
| - TestConnection | - AdminController (5-tab UI+AJAX) |
| - Create/Suspend/Unsuspend/Term | - ClientController (Hub + Manage) |
| - ChangePackage / UsageUpdate | - hooks.php (5 WHMCS Hooks) |
| - AdminCustomButtonArray (5 ops) | - Dual-load guarded clientarea() |
+-----------------+------------------+-----------------+------------------+
| |
+----------------+-------------------+
v
+--------------------------------------------------+
| Haikhavan\PanelsCollab\PlatformOrchestrator |
| - Account Lifecycle (Panel / Docker / Collab) |
| - Panel Resource CRUD & Runtime Settings |
| - Docker Deploy / Power / Logs / Auto-Heal OOM |
| - Collaboration Seat CRUD & Reclamation |
| - Extra #1: Unused License Seat Cost Optimizer |
| - Extra #2: Container Health & OOM Watchdog |
| - Extra #3: Fleet Telemetry & Metrics Aggregator|
+------------------------+-------------------------+
v
+--------------------------------------------------+
| Haikhavan\PanelsCollab\Drivers\DriverFactory |
| (implements PlatformDriverInterface) |
+--------------------------------------------------+
| PleskDriver | DirectAdminDriver | PortainerDocker|
| GoogleWorkspaceDriver | Microsoft365Driver |
| ZimbraCarbonioDriver | LocalSandboxDriver |
+------------------------+-------------------------+
v
+--------------------------------------------------+
| Haikhavan\PanelsCollab\Database (7 Tables) |
| Capsule ORM + AES-256-CBC/HMAC-SHA256 Vault |
+--------------------------------------------------+
Dual-Load Function Guard (PHP Case-Insensitivity Safety)
Because PHP function names are case-insensitive, WHMCS Server Module haikhavan_panels_collab_ClientArea(array $params) and Addon Module haikhavan_panels_collab_clientarea(array $vars) share the exact same symbol name if both files are loaded in the same request. Both files wrap their definition in if (!function_exists(...)) and inspect !empty($params['serviceid']) to route seamlessly:
- When
$params['serviceid']is present (WHMCS Product Details view): renders the Server Moduletemplates/clientarea.tploverview tab with live account summary and deep-link into the Companion Addon hub. - When
$params['serviceid']is absent (index.php?m=haikhavan_panels_collab): delegates toClientController::dispatch($vars).
2. Database Schema (mod_hk_pc_*)
All 7 tables are created idempotently during haikhavan_panels_collab_activate() and haikhavan_panels_collab_upgrade() via WHMCS\Database\Capsule::schema().
| Table | Purpose | Key Columns |
|---|---|---|
mod_hk_pc_backends |
Encrypted API endpoints & driver registry | id, name, driver_type (idx), endpoint_url, username, credentials_encrypted, is_default, status, last_test_at, last_test_status, last_test_message |
mod_hk_pc_accounts |
Unified tenant/hosting/container accounts | id, userid (idx), serviceid (idx), backend_id (idx), platform_mode (panel|docker|collab), driver_type, domain_or_tenant (idx), plan_label, seat_limit, seats_used, seat_cost_usd, storage_limit_gb, storage_used_gb, php_version, ssl_active, status, external_id |
mod_hk_pc_panel_resources |
Plesk & DirectAdmin domains, mailboxes, DBs | id, account_id (idx), res_type (domain|mailbox|database), name, value_meta, quota_mb, status |
mod_hk_pc_containers |
Portainer / Docker containers & telemetry | id, account_id (idx), container_id, name, image, ports_mapping, env_json, cpu_limit, ram_limit_mb, ram_used_mb, restart_count, oom_killed, state, logs_text |
mod_hk_pc_collab_users |
GWS / M365 / Zimbra mailboxes, admins, groups | id, account_id (idx), email (idx), full_name, role (user|admin|group), aliases_csv, license_sku, quota_gb, used_gb, last_login_days_ago, status |
mod_hk_pc_watchdog_alerts |
Active & resolved OOM / restart alerts | id, account_id (idx), alert_type (oom_killed|high_restarts), severity, resource_name, monthly_savings_usd, message, resolved, created_at |
mod_hk_pc_audit_log |
Complete lifecycle & security audit trail | id, userid, adminid, account_id, action, details, status, ip_address, created_at |
3. Platform Driver Architecture
Every platform backend implements Haikhavan\PanelsCollab\Drivers\PlatformDriverInterface and extends AbstractPlatformDriver (which provides hardened cURL transport with TLS verification, latency measurement, JSON decoding, and encrypted credential decryption).
Interface Contract
interface PlatformDriverInterface
{
public static function getMetadata(): array;
public function testConnection(): array;
public function provisionAccount(array $payload): array;
public function setAccountStatus(string $externalId, string $status): array;
public function terminateAccount(string $externalId): array;
public function generateSsoUrl(string $externalId, string $domain): array;
}
Supported Drivers (DriverFactory::REGISTRY)
| Driver Slug | Class | Mode | Live API Transport |
|---|---|---|---|
local_sandbox |
LocalSandboxDriver |
all |
Built-in zero-latency simulator for testing & demos |
plesk |
PleskDriver |
panel |
Plesk Obsidian REST API v2 (/api/v2/server, X-API-Key) |
directadmin |
DirectAdminDriver |
panel |
DirectAdmin JSON API (/CMD_API_SHOW_ADMINS?json=yes, Basic Auth) |
portainer |
PortainerDockerDriver |
docker |
Portainer API v2 (/api/status, X-API-Key) |
google_workspace |
GoogleWorkspaceDriver |
collab |
Google Admin SDK (/admin/directory/v1/users, OAuth2 Bearer) |
microsoft_365 |
Microsoft365Driver |
collab |
Microsoft Graph API (/v1.0/organization, OAuth2 Bearer) |
zimbra_carbonio |
ZimbraCarbonioDriver |
collab |
Zimbra / Zextras Carbonio Admin API (/service/admin/soap) |
4. WHMCS Server Module Callbacks
Implemented in modules/servers/haikhavan_panels_collab/haikhavan_panels_collab.php:
haikhavan_panels_collab_MetaData()— Declares APIVersion1.1,RequiresServer => true, SSO labels.haikhavan_panels_collab_ConfigOptions()— Exposes 8 product configuration fields (Platform Driver,Platform Mode,Seat / Container Limit,Storage Quota (GB),Wholesale Seat Cost ($/mo),Default PHP Version,Enable AutoSSL,Enable OOM / Restart Watchdog).haikhavan_panels_collab_TestConnection()— Tests the active default backend driver.haikhavan_panels_collab_CreateAccount()— CallsPlatformOrchestrator::provisionAccount()and bindsserviceid+userid.haikhavan_panels_collab_SuspendAccount()/UnsuspendAccount()— Updates account status on driver & local state + logs audit entry.haikhavan_panels_collab_TerminateAccount()— Cascading cleanup of account, panel resources, containers, collaboration users, and alerts.haikhavan_panels_collab_ChangePackage()— Dynamically updatesseat_limitandstorage_limit_gbon WHMCS upgrade/downgrade.haikhavan_panels_collab_AdminCustomButtonArray()— Registers 5 admin service actions:Run OOM Watchdog,Scan Unused Seats,Toggle AutoSSL,Switch PHP 8.3,Generate Panel SSO.haikhavan_panels_collab_UsageUpdate()— Syncstblhosting.diskusage&tblhosting.disklimitand executes the Container OOM Watchdog across all linked services.haikhavan_panels_collab_ClientArea()— Dual-guarded service details overview tab (templates/clientarea.tpl).
5. WHMCS Hooks (hooks.php)
ClientAreaPrimaryNavbar: Injects top-level Panels, Docker & Email navigation link for authenticated clients with active accounts.ClientAreaPrimarySidebar: Adds quick-launch sidebar item under Service Details Actions linking directly to the client's platform control page.AdminClientServicesTabFields: Displays live platform summary badge (Mode, Driver, Seats/Containers, Storage, Status, Manage button) inside WHMCS Admin -> Client Profile -> Products/Services.AdminHomeWidgets: Renders the Multi-Panel, Docker & Email Fleet dashboard widget (Haikhavan\PanelsCollabHomeWidget) showing total accounts, active containers, open OOM alerts, and recoverable monthly seat savings.DailyCronJob: Automatically executesPlatformOrchestrator::runContainerWatchdog()andPlatformOrchestrator::analyzeUnusedSeats()daily, logging summary telemetry tomod_hk_pc_audit_log.
6. Value-Add Engines
Unused License Seat Cost Optimizer (PlatformOrchestrator::analyzeUnusedSeats())
- Evaluates every
platform_mode = 'collab'tenant againstinactive_seat_days(default30days). - Flags individual non-group mailboxes with
last_login_days_ago >= thresholdasinactive_mailboxfindings with per-seat wholesale savings (seat_cost_usd). - Flags tenants with
>= 3unassigned seats (seat_limit - seats_used) asunallocated_seatsright-sizing opportunities. - One-click Reclaim deletes the inactive seat, decrements
seats_used, resolves linked alerts, and records exact monthly savings in the audit log.
Container Health & OOM Watchdog (PlatformOrchestrator::runContainerWatchdog())
- Inspects every container in
mod_hk_pc_containersfor:oom_killed = 1(criticalseverity)restart_count >= oom_restart_threshold(default5,warningseverity)- Memory utilization
ram_used_mb / ram_limit_mb >= 0.90(warningseverity)
- Persists deduplicated alerts into
mod_hk_pc_watchdog_alerts. - 1-Click Auto-Heal (
docker_action = 'heal_oom'): Automatically increasesram_limit_mbby +256 MB (or +50%), resetsoom_killed = 0, restarts the container intorunningstate, appends recovery entries tologs_text, and marks open watchdog alerts resolved.
7. Security Model
- Credential Encryption at Rest: Backend API keys/tokens are encrypted using AES-256-CBC paired with HMAC-SHA256 authentication (
Encrypt-then-MAC), keyed via SHA-256 derivation of WHMCS$cc_encryption_hashwith a random 16-byte IV per record. Verification uses constant-timehash_equals(). - CSRF Protection: Both
AdminControllerandClientControllergenerate 48-char CSPRNG session tokens (bin2hex(random_bytes(24))) validated viahash_equals()on all state-mutating AJAX requests (headerX-HK-PC-CSRFor POSTcsrf_token). Missing or invalid tokens returnHTTP 403. - Strict Client Tenant Isolation: Every Client Area view and AJAX endpoint validates ownership via
requireOwned($userId, $accountId)(WHERE id = ? AND userid = ?) before executing reads or mutations. Cross-tenant requests returnHTTP 403. - SQL Injection & XSS Defense: All queries use parameterized WHMCS Capsule query builders; all Admin PHP templates escape via
htmlspecialchars(..., ENT_QUOTES, 'UTF-8')and all Client Smarty templates apply|escape/|escape:'javascript'and|intval. - Zero External Assets: All CSS, JavaScript, and HTML5 Canvas charts load strictly from local module files (
modules/addons/haikhavan_panels_collab/assets/).