diff --git a/README.md b/README.md index da0bdcc..1a87534 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,15 @@ WHMCS server module for Hetzner Cloud VPS management. ## Installation 1. Upload files to `/path/to/whmcs/modules/servers/ArkHostHetznerVPS/` -2. Create server and add it to a server group: +2. Upload `hooks.php` to `/path/to/whmcs/includes/hooks/` (for enhanced UI) +3. Create server and add it to a server group: - Setup → Products/Services → Servers → Create New Group - Name: `Hetzner Cloud` - Type: `ArkHostHetznerVPS` - Hostname: `localhost` - Username: Hetzner Project ID (optional) - Password: Hetzner Cloud API Token -3. Create products: +4. Create products: - Setup → Products/Services → Products/Services → Create New Product - Type: `VPS/Dedicated Server` - Module: `ArkHostHetznerVPS` @@ -337,4 +338,60 @@ Free and open source. Commercial support available. Check out our other WHMCS modules at [arkhost.com/whmcs-modules.php](https://arkhost.com/whmcs-modules.php "https://arkhost.com/whmcs-modules.php") +## Changelog + +### v1.2.1 +**Added:** +- Shutdown button functionality (graceful server shutdown) +- Enhanced backup permission detection (automatically detects Hetzner-enabled backups) +- Improved Actions sidebar with custom Font Awesome icons +- VNC console opens in new tab +- hooks.php for cleaner UI (hides default WHMCS elements) + +**Fixed:** +- Backup creation/deletion API response format +- Shutdown action now properly whitelisted in ClientAreaAPI + +### v1.2.0 +**Added:** +- Cloud-init support (optional per-product YAML configuration) +- CX Gen3 server types: CX23, CX33, CX43, CX53 +- OS images: Debian 13, AlmaLinux 10, Rocky 10, CentOS Stream 10, openSUSE 15, Fedora 41/42 +- Password expiration (72-hour visibility window) + +**Fixed:** +- API pagination - server types and OS images now show all available options (per_page=50) +- Password reset timestamp tracking +- Password display in client area after reset + +**Documentation:** +- Cloud-init configuration examples +- Updated server types and OS lists + +### v1.1.1 +**Fixed:** +- Firewall rules now accept source 0.0.0.0/0 for all IPs +- "ANY" protocol creates both TCP and UDP rules automatically +- Outbound firewall rules now use correct destination_ips field + +**Added:** +- Incoming/Outgoing direction support for firewall rules +- Proper CIDR notation validation (supports /0, /4, /8, /16, etc.) + +**Improved:** +- Removed description/note field from firewall interface +- Changed "Source/Destination" column to "IP/CIDR" for clarity +- Translated all firewall column headers to all supported languages +- Cleaned up unused language strings + +### v1.1 +**Fixed:** +- Firewall Display: Removed fake "default open" rules that didn't exist in Hetzner dashboard +- Firewall Creation: Fixed "name already used" error with unique timestamp naming +- Firewall Association: Fixed API errors when attaching firewalls to servers +- API Compatibility: Corrected data formats for Hetzner API (ports as strings, proper server object structure) + +### v1.0 +- Initial release + © 2025 ArkHost diff --git a/modules/servers/ArkHostHetznerVPS/ArkHostHetznerVPS.php b/modules/servers/ArkHostHetznerVPS/ArkHostHetznerVPS.php index 4fa5e78..e93bd93 100644 --- a/modules/servers/ArkHostHetznerVPS/ArkHostHetznerVPS.php +++ b/modules/servers/ArkHostHetznerVPS/ArkHostHetznerVPS.php @@ -3,7 +3,7 @@ * WHMCS Server Module - Hetzner VPS * * @package WHMCS - * @version 1.1.1 + * @version 1.2.1 * @copyright Copyright (c) ArkHost 2025 * @author ArkHost * @link https://arkhost.com @@ -903,7 +903,7 @@ function ArkHostHetznerVPS_API(array $params) { $responseData = curl_exec($curl); $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - + $responseData = json_decode($responseData, true); if ($statusCode === 0) throw new Exception('cURL Error: ' . curl_error($curl)); @@ -1529,7 +1529,7 @@ function ArkHostHetznerVPS_ClientAreaAPI(array $params) { try { $action = App::getFromRequest('api'); - $actions = array('Server Info', 'Graphs', 'Reinstall', 'Reboot', 'Stop', 'Start', 'IPv4 Addresses', 'Hostname rDNS', 'Create backup', 'Delete backup', 'List backups', 'Restore backup', 'Get Firewall rules', 'Add Firewall rules', 'Delete Firewall rule', 'Commit Firewall rules', 'ISO Images', 'Load ISO', 'Eject ISO', 'Reset root', 'Create Snapshot', 'List Snapshots', 'Server Metrics', 'Rescue Mode', 'Disable Rescue Mode', 'GetFloatingIPStatus', 'AssignFloatingIP', 'UnassignFloatingIP', 'SetFloatingIPReverseDNS'); + $actions = array('Server Info', 'Graphs', 'Reinstall', 'Reboot', 'Stop', 'Shutdown', 'Start', 'IPv4 Addresses', 'Hostname rDNS', 'Create backup', 'Delete backup', 'List backups', 'Restore backup', 'Get Firewall rules', 'Add Firewall rules', 'Delete Firewall rule', 'Commit Firewall rules', 'ISO Images', 'Load ISO', 'Eject ISO', 'Reset root', 'Create Snapshot', 'List Snapshots', 'Server Metrics', 'Rescue Mode', 'Disable Rescue Mode', 'GetFloatingIPStatus', 'AssignFloatingIP', 'UnassignFloatingIP', 'SetFloatingIPReverseDNS'); $results = array('result' => 'success'); if (in_array($action, $actions)) { @@ -1542,22 +1542,39 @@ function ArkHostHetznerVPS_ClientAreaAPI(array $params) { if (in_array($action, $backupActions)) { // Check if backups are enabled either via module settings or configurable options $backupsEnabled = false; - + // Check module product settings if (isset($params['backups']) && $params['backups'] == 'on') { $backupsEnabled = true; } - + // Check configurable options if (isset($params['configoptions']['Backups']) && $params['configoptions']['Backups'] == 'Yes') { $backupsEnabled = true; } - + + // If not enabled in WHMCS settings, check if backups are actually enabled on Hetzner's side if (!$backupsEnabled) { - return array( + try { + $serverInfoParams = $params; + $serverInfoParams['action'] = 'Server Info'; + $serverInfoResult = ArkHostHetznerVPS_API($serverInfoParams); + + // Check if the server has backups enabled (indicated by backup_window being set) + if (isset($serverInfoResult['server']['backup_window']) && $serverInfoResult['server']['backup_window'] !== null) { + $backupsEnabled = true; + } + } catch (Exception $e) { + // If we can't check, assume not enabled + $backupsEnabled = false; + } + } + + if (!$backupsEnabled) { + return array('jsonResponse' => array( 'result' => 'error', 'message' => 'Backups are not enabled for this service. Please upgrade your plan to enable backups.' - ); + )); } } @@ -2046,6 +2063,7 @@ function ArkHostHetznerVPS_ClientAreaCustomButtonArray() { $_LANG['Start'] => 'Start', $_LANG['Stop'] => 'Stop', $_LANG['Restart'] => 'Reboot', + $_LANG['Shutdown'] => 'Shutdown', $_LANG['VNC'] => 'VNC', ); } @@ -2094,7 +2112,7 @@ function ArkHostHetznerVPS_ClientArea(array $params) { if (!is_array($response) || !isset($response['server'])) { throw new Exception('Unable to retrieve server information from API'); } - + // Extract server data from Hetzner response $serverInfo = $response['server']; diff --git a/modules/servers/ArkHostHetznerVPS/hooks.php b/modules/servers/ArkHostHetznerVPS/hooks.php new file mode 100644 index 0000000..6deb566 --- /dev/null +++ b/modules/servers/ArkHostHetznerVPS/hooks.php @@ -0,0 +1,73 @@ + + * @link https://arkhost.com + */ + +use WHMCS\Database\Capsule; + +/** + * Hide default WHMCS product details and cog icons for ArkHostHetznerVPS products + * Injects CSS early to prevent flash of content + */ +add_hook('ClientAreaHeadOutput', 1, function($vars) { + // Only run on product details page + if (!isset($_GET['action']) || $_GET['action'] !== 'productdetails') { + return ''; + } + + // Get the service ID from the request + $serviceId = isset($_GET['id']) ? (int) $_GET['id'] : 0; + if (!$serviceId) { + return ''; + } + + // Check if this service uses the ArkHostHetznerVPS module + try { + $service = Capsule::table('tblhosting') + ->where('id', $serviceId) + ->first(); + + if (!$service || $service->servertype !== 'ArkHostHetznerVPS') { + return ''; + } + } catch (Exception $e) { + return ''; + } + + // Inject CSS early in the HEAD to prevent flash + // This works for both active and suspended services + return << + /* Hide WHMCS default product details (Domain, Username, Server Name, IP, Visit Website) for ArkHostHetznerVPS */ + #domain > .row:nth-child(2), + #domain > .row:nth-child(3), + #domain > .row:nth-child(4) { + display: none !important; + } + #domain > br { + display: none !important; + } + #domain > p { + display: none !important; + } + + /* Hide cog icons from custom action buttons IMMEDIATELY */ + .list-group-item[href*="modop=custom"] i.fa-cog, + .list-group-item[href*="modop=custom"] i.fas.fa-cog, + .list-group-item[href*="modop=custom"] .fa-cog, + .list-group-item[href*="modop=custom"] i.fa-wrench, + a[href*="modop=custom"] i.fa-cog, + a[href*="modop=custom"] i.fas.fa-cog, + a[href*="modop=custom"] .fa-cog { + display: none !important; + } + +HTML; +}); + diff --git a/modules/servers/ArkHostHetznerVPS/template/clientarea_direct.tpl b/modules/servers/ArkHostHetznerVPS/template/clientarea_direct.tpl index 8e81624..eafba68 100644 --- a/modules/servers/ArkHostHetznerVPS/template/clientarea_direct.tpl +++ b/modules/servers/ArkHostHetznerVPS/template/clientarea_direct.tpl @@ -756,4 +756,66 @@ + +