From b75306b262e2bc53440e69710094e37c09a3f66f Mon Sep 17 00:00:00 2001 From: Jon Morby Date: Thu, 19 Feb 2026 12:37:38 +0000 Subject: [PATCH 1/5] Removed hard coded references to port 2087 - This is an internal IP bound port which is not meant to be customer facing. The customer facing URL is normally on port 443 (which proxies to 2087) and secured with a valid SSL (the IP bound port 2087 uses a self signed certificate) --- apis/enhance_api.php | 7 +++---- config/enhance.php | 7 +++---- views/default/admin_service_info.pdt | 17 +++++++++++------ views/default/client_service_info.pdt | 17 +++++++++++------ 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/apis/enhance_api.php b/apis/enhance_api.php index 22d3535..a448335 100644 --- a/apis/enhance_api.php +++ b/apis/enhance_api.php @@ -51,9 +51,8 @@ public function __construct($server_label, $hostname, $org_id, $api_token) $this->org_id = $org_id; $this->api_token = $api_token; - // Construct API URL with port 2087 if not already specified - $port = (strpos($hostname, ':') !== false) ? '' : ':2087'; - $this->apiUrl = 'https://' . $hostname . $port . '/api'; + // Construct API URL + $this->apiUrl = 'https://' . $hostname . '/api'; } /** @@ -933,4 +932,4 @@ public function testConnection() // Test with the known working endpoint return $this->apiRequest('version', [], 'GET'); } -} +} \ No newline at end of file diff --git a/config/enhance.php b/config/enhance.php index f4c0c5f..edbcd39 100644 --- a/config/enhance.php +++ b/config/enhance.php @@ -21,7 +21,7 @@ Please note: If you have purchased more than 1 hosting service from us, login to the panel using the original password. You can manage your website through the Enhance control panel: -Panel URL: https://{module.hostname}:2087 +Panel URL: https://{module.hostname} SSH Access (for advanced users): Host: {module.hostname} @@ -40,7 +40,7 @@ Password: {service.password}

Please note: If you have purchased more than 1 hosting service from us, login to the panel using the original password.

You can manage your website through the Enhance control panel:
-Panel URL: https://{module.hostname}:2087

+Panel URL: https://{module.hostname}

SSH Access (for advanced users):
Host: {module.hostname}
Username: {service.username}
@@ -48,5 +48,4 @@

You may also manage your service through our client area by clicking the "Manage" button next to the service on your Dashboard.

Thank you for your business!

' ] -]); - +]); \ No newline at end of file diff --git a/views/default/admin_service_info.pdt b/views/default/admin_service_info.pdt index 815a448..a69aaa9 100644 --- a/views/default/admin_service_info.pdt +++ b/views/default/admin_service_info.pdt @@ -8,21 +8,26 @@ - username) ? $this->Html->safe($service_fields->username) : null); ?> - customer_email) ? $this->Html->safe($service_fields->customer_email) : null); ?> - password) ? $this->Html->safe($service_fields->password) : null); ?> + username) ? $this->Html->safe($service_fields->username) : null); ?> + + customer_email) ? $this->Html->safe($service_fields->customer_email) : null); ?> + + password) ? $this->Html->safe($service_fields->password) : null); ?> + - _('Enhance.service_info.option_login');?> + _('Enhance.service_info.option_login'); ?> - _('Enhance.service_info.option_login');?> + _('Enhance.service_info.option_login'); ?> - + \ No newline at end of file diff --git a/views/default/client_service_info.pdt b/views/default/client_service_info.pdt index 98b256f..2dd07b1 100644 --- a/views/default/client_service_info.pdt +++ b/views/default/client_service_info.pdt @@ -12,18 +12,23 @@ - username) ? $this->Html->safe($service_fields->username) : null); ?> - customer_email) ? $this->Html->safe($service_fields->customer_email) : null); ?> - password) ? $this->Html->safe($service_fields->password) : null); ?> + username) ? $this->Html->safe($service_fields->username) : null); ?> + + customer_email) ? $this->Html->safe($service_fields->customer_email) : null); ?> + + password) ? $this->Html->safe($service_fields->password) : null); ?> + - _('Enhance.service_info.option_login');?> + _('Enhance.service_info.option_login'); ?> - _('Enhance.service_info.option_login');?> + _('Enhance.service_info.option_login'); ?> @@ -31,4 +36,4 @@ - + \ No newline at end of file From af9138bbc6e07054f89926be5e3da7094cb6c558 Mon Sep 17 00:00:00 2001 From: Luis Mendoza Date: Thu, 12 Mar 2026 18:06:56 -0300 Subject: [PATCH 2/5] Fix ModuleClientMeta passing row ID instead of module ID --- enhance.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/enhance.php b/enhance.php index 2de77c2..8024484 100644 --- a/enhance.php +++ b/enhance.php @@ -507,12 +507,12 @@ public function addService( $existing_org_id_obj = $this->ModuleClientMeta->get( $vars['client_id'], 'enhance_org_id', - $row->id + $row->module_id ); $existing_login_id_obj = $this->ModuleClientMeta->get( $vars['client_id'], 'enhance_login_id', - $row->id + $row->module_id ); // Extract values from objects (ModuleClientMeta returns objects with ->value property) @@ -622,7 +622,7 @@ public function addService( if (!$existing_org_id && $customer_org_id && isset($response['login_id'])) { $this->ModuleClientMeta->set( $vars['client_id'], - $row->id, + $row->module_id, 0, [ ['key' => 'enhance_org_id', 'value' => $customer_org_id, 'encrypted' => 0], @@ -1326,7 +1326,7 @@ public function tabChangePassword( $existing_login_id_obj = $this->ModuleClientMeta->get( $service->client_id, 'enhance_login_id', - $row->id + $row->module_id ); if (isset($existing_login_id_obj->value)) { @@ -1415,7 +1415,7 @@ public function tabClientChangePassword( $existing_login_id_obj = $this->ModuleClientMeta->get( $service->client_id, 'enhance_login_id', - $row->id + $row->module_id ); if (isset($existing_login_id_obj->value)) { From 533ab4e30448b850c42eea516018f9a51bca69a3 Mon Sep 17 00:00:00 2001 From: Luis Mendoza Date: Mon, 16 Mar 2026 17:38:49 -0300 Subject: [PATCH 3/5] Implement changeServicePackage for subscription upgrade/downgrade --- enhance.php | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/enhance.php b/enhance.php index 2de77c2..7b8af17 100644 --- a/enhance.php +++ b/enhance.php @@ -754,6 +754,78 @@ public function editService($package, $service, array $vars = null, $parent_pack return $return; } + /** + * Updates the package for the service on the remote server. Sets Input errors on failure, + * preventing the service's package from being changed. + * + * @param stdClass $package_from A stdClass object representing the current package + * @param stdClass $package_to A stdClass object representing the new package + * @param stdClass $service A stdClass object representing the current service + * @param stdClass $parent_package A stdClass object representing the parent + * service's selected package (if the current service is an addon service) + * @param stdClass $parent_service A stdClass object representing the parent + * service of the service being changed (if the current service is an addon service) + * @return mixed null to maintain the existing meta fields + * @see Module::getModule() + * @see Module::getModuleRow() + */ + public function changeServicePackage( + $package_from, + $package_to, + $service, + $parent_package = null, + $parent_service = null + ) { + if (($row = $this->getModuleRow())) { + // Only update the subscription if the plan has changed + if ($package_from->meta->package != $package_to->meta->package) { + $api = $this->getApi( + $row->meta->server_label, + $row->meta->hostname, + $row->meta->org_id, + $row->meta->api_token + ); + + $service_fields = $this->serviceFieldsToObject($service->fields); + + // Resolve customer_org_id from service fields, falling back to ModuleClientMeta + $customer_org_id = isset($service_fields->customer_org_id) ? $service_fields->customer_org_id : null; + if (!$customer_org_id) { + if (!isset($this->ModuleClientMeta)) { + Loader::loadModels($this, ['ModuleClientMeta']); + } + $meta = $this->ModuleClientMeta->get($service->client_id, 'enhance_org_id', $row->module_id); + $customer_org_id = $meta ? $meta->value : null; + } + + if (isset($customer_org_id) && isset($service_fields->subscription_id)) { + $this->log($row->meta->hostname . '|changeServicePackage', 'Changing subscription: ' . $service_fields->subscription_id . ' to plan: ' . $package_to->meta->package, 'input', true); + + $response = $api->updateCustomerSubscription( + $customer_org_id, + $service_fields->subscription_id, + ['planId' => intval($package_to->meta->package)] + ); + + $success = false; + + if (($errors = $response->errors())) { + $this->Input->setErrors(['api' => $errors]); + } else { + $success = true; + } + + $this->log($row->meta->hostname . '|changeServicePackage', 'Change package result: ' . ($success ? 'success' : 'failed'), 'output', $success); + } else { + $this->log($row->meta->hostname . '|changeServicePackage', 'Missing customer_org_id or subscription_id', 'output', false); + $this->Input->setErrors(['api' => ['Missing required service fields for package change']]); + } + } + } + + return null; + } + /** * Suspends the service on the remote server. Sets Input errors on failure, * preventing the service from being suspended. From 87813afebb7b1edaf76c675486253a31284d8a43 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Tue, 30 Jun 2026 16:04:27 -0600 Subject: [PATCH 4/5] Fix HTML link target in admin_service_info.pdt --- views/default/admin_service_info.pdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/default/admin_service_info.pdt b/views/default/admin_service_info.pdt index 0828285..7b84e54 100644 --- a/views/default/admin_service_info.pdt +++ b/views/default/admin_service_info.pdt @@ -30,7 +30,7 @@ _('Enhance.service_info.option_login'); ?> + : ''; ?>" target="_blank">_('Enhance.service_info.option_login'); ?> From f6351502f9f80e13a4bdc7af1384b0bd3a1a0410 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Tue, 30 Jun 2026 16:52:43 -0600 Subject: [PATCH 5/5] Added upgrade task for PR #12 --- config.json | 2 +- enhance.php | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/config.json b/config.json index a54de2a..7679f50 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "version": "2.0.1", + "version": "2.1.0", "name": "Enhance.name", "description": "Enhance.description", "authors": [ diff --git a/enhance.php b/enhance.php index 85eeb49..061d4cf 100644 --- a/enhance.php +++ b/enhance.php @@ -42,9 +42,27 @@ public function install() */ public function upgrade($current_version) { -//// if (version_compare($current_version, '1.1.0', '<')) { -//// // Preform actions here such as re-adding cron tasks, setting new meta fields, and more -//// } + if (version_compare($current_version, '2.1.0', '<')) { + if (!isset($this->ModuleManager)) { + Loader::loadModels($this, ['ModuleManager']); + } + if (!isset($this->Record)) { + Loader::loadComponents($this, ['Record']); + } + + // Client meta was stored under the module row ID instead of the + // module ID. Re-key the affected records to the correct module ID. + $modules = $this->ModuleManager->getByClass('enhance'); + foreach ($modules as $module) { + $rows = $this->ModuleManager->getRows($module->id); + foreach ($rows as $row) { + $this->Record->where('module_id', '=', $row->id) + ->where('module_row_id', '=', 0) + ->where('key', 'in', ['enhance_org_id', 'enhance_login_id']) + ->update('module_client_meta', ['module_id' => $module->id]); + } + } + } } /**