mirror of
https://gitlab.com/ArkHost/WHMCS-ArkhostVPSAG.git
synced 2026-07-24 07:45:55 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bf993dc35 | ||
|
|
8690d950cf | ||
|
|
ff46183b04 | ||
|
|
2f11be0027 | ||
|
|
172a76aa60 |
@@ -15,9 +15,20 @@ A WHMCS server module for VPS management with multi-language support.
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- WHMCS 7.0+
|
- WHMCS 8.9+
|
||||||
- PHP 7.4+
|
- PHP 7.4+
|
||||||
|
- VPSag API access
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
### Main Interface
|
||||||
|

|
||||||
|
|
||||||
|
### Analytics Dashboard
|
||||||
|

|
||||||
|
|
||||||
|
### Configuration Panel
|
||||||
|

|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
* WHMCS Server Module - VPSAG
|
* WHMCS Server Module - VPSAG
|
||||||
*
|
*
|
||||||
* @package WHMCS
|
* @package WHMCS
|
||||||
* @version 1.2
|
* @version 1.3
|
||||||
* @copyright Copyright (c) ArkHost 2025
|
* @copyright Copyright (c) ArkHost 2025
|
||||||
* @author ArkHost <support@arkhost.com>
|
* @author ArkHost <support@arkhost.com>
|
||||||
* @link https://arkhost.com
|
* @link https://arkhost.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('WHMCS')) {
|
if (!defined('WHMCS')) {
|
||||||
exit(header('Location: https://arkhost.com'));
|
http_response_code(403);
|
||||||
|
exit('Access denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
use WHMCS\Config\Setting;
|
use WHMCS\Config\Setting;
|
||||||
@@ -54,7 +55,8 @@ function ArkhostVPSAG_API(array $params) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Order':
|
case 'Order':
|
||||||
$url .= 'order/plan';
|
$planId = ArkhostVPSAG_GetOption($params, 'planid');
|
||||||
|
$url .= 'order/' . $planId;
|
||||||
$method .= 'POST';
|
$method .= 'POST';
|
||||||
|
|
||||||
$billingCycles = array(
|
$billingCycles = array(
|
||||||
@@ -67,9 +69,9 @@ function ArkhostVPSAG_API(array $params) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$data += array(
|
$data += array(
|
||||||
'plan_id' => ArkhostVPSAG_GetOption($params, 'planid'),
|
'hostname' => $params['domain'] ?? 'vps.example.com',
|
||||||
'notify_url' => Setting::getValue('SystemURL') . '/modules/servers/ArkhostVPSAG/callback.php',
|
'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,
|
'billing_term' => $billingCycles[$params['model']['billingcycle']] ?? 1,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@@ -483,6 +485,22 @@ function ArkhostVPSAG_CreateAccount(array $params) {
|
|||||||
$params['action'] = 'Order';
|
$params['action'] = 'Order';
|
||||||
$create = ArkhostVPSAG_API($params);
|
$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([
|
$params['model']->serviceProperties->save([
|
||||||
'vpsag|VPSAG ID' => 'VPSAG-' . $create['vps_id'],
|
'vpsag|VPSAG ID' => 'VPSAG-' . $create['vps_id'],
|
||||||
]);
|
]);
|
||||||
@@ -741,13 +759,13 @@ function ArkhostVPSAG_ClientArea(array $params) {
|
|||||||
// Check if VPS ID is available
|
// Check if VPS ID is available
|
||||||
$vpsId = $params['model']->serviceProperties->get('vpsag');
|
$vpsId = $params['model']->serviceProperties->get('vpsag');
|
||||||
if (empty($vpsId)) {
|
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
|
// Get clean VPS ID
|
||||||
$cleanVpsId = ArkhostVPSAG_GetVPSID($params);
|
$cleanVpsId = ArkhostVPSAG_GetVPSID($params);
|
||||||
if (empty($cleanVpsId)) {
|
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
|
// Get server info and operating systems data
|
||||||
@@ -756,7 +774,7 @@ function ArkhostVPSAG_ClientArea(array $params) {
|
|||||||
|
|
||||||
// Check if server info is valid
|
// Check if server info is valid
|
||||||
if (!is_array($serverInfo) || empty($serverInfo)) {
|
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';
|
$params['action'] = 'Operating Systems - Server';
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (empty($_POST)) {
|
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';
|
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);
|
$_POST = array_map('html_entity_decode', $_POST);
|
||||||
|
|
||||||
$customField = Capsule::table('tblcustomfieldsvalues')->where('value', 'VPSAG-' . $_POST['server_id'])->first();
|
// Look for the service by VPSAG ID in service properties
|
||||||
$service = WHMCS\Service\Service::find($customField->relid);
|
$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();
|
$server = Capsule::table('tblservers')->where('id', $service->server)->first();
|
||||||
|
|
||||||
@@ -37,7 +57,10 @@ foreach ($_POST as $key => $value) {
|
|||||||
$rawSig .= hash('sha512', decrypt($server->password));
|
$rawSig .= hash('sha512', decrypt($server->password));
|
||||||
$signature = hash('sha256', $rawSig);
|
$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(
|
$params = array(
|
||||||
'serverusername' => $server->username,
|
'serverusername' => $server->username,
|
||||||
|
|||||||
@@ -8,5 +8,6 @@
|
|||||||
* @link https://arkhost.com
|
* @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 |
Reference in New Issue
Block a user