mirror of
https://gitlab.com/ArkHost/WHMCS-ArkHost-HetznerVPS.git
synced 2026-07-24 07:45:53 +02:00
v1.2.1
This commit is contained in:
@@ -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 <support@arkhost.com>
|
||||
* @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'];
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* WHMCS Server Module - Hetzner VPS Hooks
|
||||
*
|
||||
* @package WHMCS
|
||||
* @version 1.2.1
|
||||
* @copyright Copyright (c) ArkHost 2025
|
||||
* @author ArkHost <support@arkhost.com>
|
||||
* @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 <<<HTML
|
||||
<style>
|
||||
/* 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;
|
||||
}
|
||||
</style>
|
||||
HTML;
|
||||
});
|
||||
|
||||
@@ -756,4 +756,66 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Wait for WHMCS jQuery to be ready and use it
|
||||
jQuery(document).ready(function($) {
|
||||
// Inject custom icons into sidebar action buttons
|
||||
$('.list-group-item').each(function() {
|
||||
var $link = $(this);
|
||||
var href = $link.attr('href');
|
||||
|
||||
if (!href) return;
|
||||
|
||||
// Add custom Font Awesome icons based on action
|
||||
if (href.indexOf('modop=custom&a=Start') !== -1) {
|
||||
// Prepend play icon to Start button
|
||||
$link.html('<i class="fa fa-play"></i> ' + $link.text().trim());
|
||||
|
||||
// Intercept click to use our API
|
||||
$link.off('click').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
ArkHostHetznerVPS_API('Start', true);
|
||||
return false;
|
||||
});
|
||||
} else if (href.indexOf('modop=custom&a=Stop') !== -1) {
|
||||
// Prepend stop icon to Stop button
|
||||
$link.html('<i class="fa fa-stop"></i> ' + $link.text().trim());
|
||||
|
||||
$link.off('click').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
confirmStop();
|
||||
return false;
|
||||
});
|
||||
} else if (href.indexOf('modop=custom&a=Reboot') !== -1) {
|
||||
// Prepend sync icon to Restart button
|
||||
$link.html('<i class="fa fa-sync"></i> ' + $link.text().trim());
|
||||
|
||||
$link.off('click').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
confirmRestart();
|
||||
return false;
|
||||
});
|
||||
} else if (href.indexOf('modop=custom&a=Shutdown') !== -1) {
|
||||
// Prepend power-off icon to Shutdown button
|
||||
$link.html('<i class="fa fa-power-off"></i> ' + $link.text().trim());
|
||||
|
||||
$link.off('click').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
confirmShutdown();
|
||||
return false;
|
||||
});
|
||||
} else if (href.indexOf('modop=custom&a=VNC') !== -1) {
|
||||
// Prepend desktop icon to VNC button
|
||||
$link.html('<i class="fa fa-desktop"></i> ' + $link.text().trim());
|
||||
// Open VNC in new tab
|
||||
$link.attr('target', '_blank');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{$WEB_ROOT}/modules/servers/ArkHostHetznerVPS/template/script.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user