System Settings -> Addon Modules -> Activate -> Configure. * * API key handling: WHMCS encrypts password-type addon fields in tbladdonmodules; * the server module calls decrypt() on read (see lib/PowerDns/Config.php). */ if (! defined('WHMCS')) { exit('This file cannot be accessed directly'); } /** * Load the server module's PowerDNS classes on demand. Done inside functions rather * than at file scope so the WHMCS addon list still works if the server module is * absent (e.g., uninstalled while the addon is still activated). Returns true when * the classes are available. */ function virtfusiondns_load_server_libs(): bool { $base = __DIR__ . '/../../servers/VirtFusionDirect/lib/'; $files = [ 'Curl.php', 'Log.php', 'Cache.php', 'PowerDns/Config.php', 'PowerDns/IpUtil.php', 'PowerDns/Client.php', ]; foreach ($files as $f) { if (! is_file($base . $f)) { return false; } require_once $base . $f; } return true; } /** * WHMCS addon metadata. */ function VirtFusionDns_config() { return [ 'name' => 'VirtFusion DNS', 'description' => 'Adds reverse DNS (PTR) management to the VirtFusionDirect server module using a PowerDNS HTTP API. Zones must already exist in PowerDNS; the addon never creates zones. Requires the VirtFusionDirect server module.', 'version' => '1.0', 'author' => 'VirtFusionDirect', 'language' => 'english', 'fields' => [ 'enabled' => [ 'FriendlyName' => 'Enable rDNS Sync', 'Type' => 'yesno', 'Description' => 'Master switch. When off, the server module skips every PowerDNS call.', ], 'endpoint' => [ 'FriendlyName' => 'PowerDNS API Endpoint', 'Type' => 'text', 'Size' => '60', 'Default' => 'http://ns1.example.com:8081', 'Description' => 'Scheme + host + port (no path). The /api/v1/... path is appended automatically.', ], 'apiKey' => [ 'FriendlyName' => 'PowerDNS API Key', 'Type' => 'password', 'Size' => '60', 'Description' => 'X-API-Key. Stored encrypted by WHMCS; decrypted only server-side when PowerDNS is called.', ], 'serverId' => [ 'FriendlyName' => 'PowerDNS Server ID', 'Type' => 'text', 'Size' => '20', 'Default' => 'localhost', 'Description' => 'Almost always "localhost" (the PowerDNS API server identifier, not a hostname).', ], 'defaultTtl' => [ 'FriendlyName' => 'Default PTR TTL (seconds)', 'Type' => 'text', 'Size' => '10', 'Default' => '3600', 'Description' => 'TTL applied to PTR records created by the module.', ], 'cacheTtl' => [ 'FriendlyName' => 'Cache TTL (seconds)', 'Type' => 'text', 'Size' => '10', 'Default' => '60', 'Description' => 'How long zone lists and DNS-resolution results are cached. Minimum 10s.', ], ], ]; } /** * Called when the addon is activated. No schema to create — settings live in tbladdonmodules. */ function VirtFusionDns_activate() { return [ 'status' => 'success', 'description' => 'VirtFusion DNS activated. Fill in the endpoint + API key in the addon configuration, then use the Test Connection button on the addon page.', ]; } /** * Called when the addon is deactivated. Settings preserved (re-activating restores them). */ function VirtFusionDns_deactivate() { return [ 'status' => 'success', 'description' => 'VirtFusion DNS deactivated. Server lifecycle PowerDNS calls will now be skipped. Settings are preserved.', ]; } /** * Admin status page — rendered by WHMCS when the addon is clicked from the Addons menu. * * Shows a settings summary, a Test Connection button (calls PowerDNS ping), the current * zone count, and a recent log extract filtered to PowerDNS-related entries. */ function VirtFusionDns_output($vars) { if (! virtfusiondns_load_server_libs()) { echo '
modules/servers/VirtFusionDirect/. ';
echo 'Install or restore that module and reload this page.';
echo 'Reverse DNS management for the VirtFusionDirect server module. All PTR writes happen through the VirtFusion server lifecycle (create, rename, terminate) and through the client-area Reverse DNS panel. Forward DNS (A/AAAA) is verified before every PTR write; mismatches are skipped and logged.
'; echo '| Status | ' . $enabledBadge . ' |
|---|---|
| Endpoint | ' . ($endpoint ?: 'not set') . ' |
| API Key | ' . $keyBadge . ' |
| Server ID | ' . $serverId . ' |
| Default PTR TTL | ' . $ttl . 's |
| Cache TTL | ' . $cacheTtl . 's |
Calls GET /api/v1/servers/' . $serverId . ' and, on success, lists available zones.
webserver=yes, api=yes).*.in-addr.arpa / *.ip6.arpa) for your IP ranges must exist in PowerDNS already — the addon never creates zones.api-allow-from must include the WHMCS host\'s IP.