5 Commits
Author SHA1 Message Date
ArkHostandGitHub 1bf993dc35 v1.3
- Missing hostname parameter in API call
- Wrong parameter name (os_id vs os)
- Fixed error handling and customer-facing error messages
2025-07-18 14:18:18 +02:00
ArkHostandGitHub 8690d950cf Update README.md 2025-06-26 21:02:37 +02:00
ArkHostandGitHub ff46183b04 Update README.md 2025-06-26 20:49:37 +02:00
ArkHostandGitHub 2f11be0027 Add files via upload 2025-06-26 20:47:39 +02:00
ArkHostandGitHub 172a76aa60 Update README.md 2025-06-20 01:02:43 +02:00
7 changed files with 68 additions and 15 deletions
+12 -1
View File
@@ -15,9 +15,20 @@ A WHMCS server module for VPS management with multi-language support.
## Requirements
- WHMCS 7.0+
- WHMCS 8.9+
- PHP 7.4+
- VPSag API access
## Screenshots
### Main Interface
![Main Dashboard](screenshots/vpsag1.png)
### Analytics Dashboard
![Settings](screenshots/vpsag2.png)
### Configuration Panel
![Analytics](screenshots/vpsag3.png)
## Changelog
+26 -8
View File
@@ -3,14 +3,15 @@
* WHMCS Server Module - VPSAG
*
* @package WHMCS
* @version 1.2
* @version 1.3
* @copyright Copyright (c) ArkHost 2025
* @author ArkHost <support@arkhost.com>
* @link https://arkhost.com
*/
if (!defined('WHMCS')) {
exit(header('Location: https://arkhost.com'));
http_response_code(403);
exit('Access denied');
}
use WHMCS\Config\Setting;
@@ -54,7 +55,8 @@ function ArkhostVPSAG_API(array $params) {
break;
case 'Order':
$url .= 'order/plan';
$planId = ArkhostVPSAG_GetOption($params, 'planid');
$url .= 'order/' . $planId;
$method .= 'POST';
$billingCycles = array(
@@ -67,9 +69,9 @@ function ArkhostVPSAG_API(array $params) {
);
$data += array(
'plan_id' => ArkhostVPSAG_GetOption($params, 'planid'),
'hostname' => $params['domain'] ?? 'vps.example.com',
'notify_url' => Setting::getValue('SystemURL') . '/modules/servers/ArkhostVPSAG/callback.php',
'os_id' => ArkhostVPSAG_GetOption($params, 'osid'),
'os' => ArkhostVPSAG_GetOption($params, 'osid'),
'billing_term' => $billingCycles[$params['model']['billingcycle']] ?? 1,
);
break;
@@ -483,6 +485,22 @@ function ArkhostVPSAG_CreateAccount(array $params) {
$params['action'] = 'Order';
$create = ArkhostVPSAG_API($params);
// Validate API response - the API function already handles status=0 errors
// but we need to ensure we have a valid vps_id
if (!is_array($create) || !isset($create['vps_id']) || empty($create['vps_id'])) {
if (is_array($create)) {
logActivity('VPSAG Order Failed - Invalid Response: ' . json_encode($create));
} else {
logActivity('VPSAG Order Failed - Non-array response: ' . gettype($create));
}
throw new Exception('Invalid response from API');
}
// Ensure vps_id is numeric and valid
if (!is_numeric($create['vps_id']) || $create['vps_id'] <= 0) {
throw new Exception('Invalid response from API');
}
$params['model']->serviceProperties->save([
'vpsag|VPSAG ID' => 'VPSAG-' . $create['vps_id'],
]);
@@ -741,13 +759,13 @@ function ArkhostVPSAG_ClientArea(array $params) {
// Check if VPS ID is available
$vpsId = $params['model']->serviceProperties->get('vpsag');
if (empty($vpsId)) {
throw new Exception('VPS ID not found in service properties. This service may not be properly provisioned yet.');
throw new Exception('Service not properly provisioned');
}
// Get clean VPS ID
$cleanVpsId = ArkhostVPSAG_GetVPSID($params);
if (empty($cleanVpsId)) {
throw new Exception('Invalid VPS ID format: ' . $vpsId . '. Expected format: VPS-xxxxx or VPSAG-xxxxx');
throw new Exception('Invalid VPS ID format');
}
// Get server info and operating systems data
@@ -756,7 +774,7 @@ function ArkhostVPSAG_ClientArea(array $params) {
// Check if server info is valid
if (!is_array($serverInfo) || empty($serverInfo)) {
throw new Exception('Unable to retrieve server information from API. VPS ID: ' . $vpsId);
throw new Exception('Unable to retrieve server information from API');
}
$params['action'] = 'Operating Systems - Server';
+28 -5
View File
@@ -9,7 +9,8 @@
*/
if (empty($_POST)) {
exit(header('Location: https://arkhost.com'));
http_response_code(400);
exit('Bad Request');
}
require_once '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.php';
@@ -19,10 +20,29 @@ use WHMCS\Database\Capsule;
$_POST = array_map('html_entity_decode', $_POST);
$customField = Capsule::table('tblcustomfieldsvalues')->where('value', 'VPSAG-' . $_POST['server_id'])->first();
$service = WHMCS\Service\Service::find($customField->relid);
// Look for the service by VPSAG ID in service properties
$serviceProperty = Capsule::table('tblservice_properties')
->where('property', 'vpsag|VPSAG ID')
->where('value', 'VPSAG-' . $_POST['server_id'])
->first();
if (!$service) exit(header('Location: https://arkhost.com'));
if (!$serviceProperty) {
// Fallback: try to find in custom fields for backward compatibility
$customField = Capsule::table('tblcustomfieldsvalues')->where('value', 'VPSAG-' . $_POST['server_id'])->first();
if ($customField) {
$service = WHMCS\Service\Service::find($customField->relid);
} else {
http_response_code(404);
exit('Service not found');
}
} else {
$service = WHMCS\Service\Service::find($serviceProperty->service_id);
}
if (!$service) {
http_response_code(404);
exit('Service not found');
}
$server = Capsule::table('tblservers')->where('id', $service->server)->first();
@@ -37,7 +57,10 @@ foreach ($_POST as $key => $value) {
$rawSig .= hash('sha512', decrypt($server->password));
$signature = hash('sha256', $rawSig);
if ($_POST['sig'] != $signature) exit(header('Location: https://arkhost.com'));
if ($_POST['sig'] != $signature) {
http_response_code(403);
exit('Invalid signature');
}
$params = array(
'serverusername' => $server->username,
@@ -8,5 +8,6 @@
* @link https://arkhost.com
*/
header('Location: https://arkhost.com');
http_response_code(403);
exit('Access denied');
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 KiB