Skip to content

Commit 9f9e46d

Browse files
authored
Merge pull request #497 from openprovider/V5.9.4-release
V5.9.4 release
2 parents 10d2e6e + 001b425 commit 9f9e46d

16 files changed

Lines changed: 1001 additions & 15 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
## v5.9.4
3+
4+
###### Features and improvements
5+
- Added support for deleting individual DNS records.
6+
- Introduced a dedicated DNSSEC management implementation and removed the dependency between DNS Management and DNSSEC Management client area buttons.
7+
28
## v5.9.3
39

410
###### Bugfixes

docs/DNSSEC_for_clients.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DNSSEC page for end users
22

3-
- Navigate to the **target client profile > domains** select the desired domain and under **Management Tools** activate **"DNS Management"**
4-
<img src="img/DNS Management.png" style="zoom: 67%;" />
3+
- Navigate to the **target client profile > domains** select the desired domain and enable **"DNSSEC Management"** checkbox.
4+
<img src="img/DNSSEC management checkbox.png" style="zoom: 67%;" />
55
- The below option will appear in the domain details page of the chosen domain
66

77
<img src="img/DNSSEC management.png" alt="Screenshot_20210203_183243" style="zoom: 67%;" />
133 KB
Loading

modules/registrars/openprovider/Controllers/Hooks/ClientAreaPrimarySidebarController.php

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use OpenProvider\API\ApiHelper;
66
use OpenProvider\WhmcsRegistrar\helpers\DNS;
77
use OpenProvider\WhmcsRegistrar\helpers\DomainFullNameToDomainObject;
8+
use OpenProvider\WhmcsRegistrar\helpers\DnssecManagement;
89
use WHMCS\Database\Capsule;
910

1011
/**
@@ -16,6 +17,7 @@
1617
class ClientAreaPrimarySidebarController
1718
{
1819
const DNSSEC_PAGE_NAME = '/dnssec.php';
20+
const DNS_MANAGEMENT_PAGE_NAME = '/dnsmanagement.php';
1921

2022
/**
2123
* @var ApiHelper
@@ -29,6 +31,8 @@ public function __construct(ApiHelper $apiHelper)
2931

3032
public function show($primarySidebar)
3133
{
34+
$this->ensureDnsManagementPageExists();
35+
3236
$this->replaceDnsMenuItem($primarySidebar);
3337

3438
$this->addDNSSECMenuItem($primarySidebar);
@@ -43,7 +47,12 @@ private function replaceDnsMenuItem($primarySidebar)
4347
if (!$dnsManagement = $domainDetailsManagement->getChild('Manage DNS Host Records'))
4448
return;
4549

46-
if ($url = DNS::getDnsUrlOrFail($_REQUEST['domainid'])) {
50+
$domainId = $_REQUEST['domainid'] ?? $_REQUEST['id'] ?? null;
51+
if (!$domainId) {
52+
return;
53+
}
54+
55+
if ($url = DNS::getDnsUrlOrFail($domainId)) {
4756
// Update the URL.
4857
$dnsManagement->setUri($url);
4958

@@ -57,7 +66,10 @@ private function replaceDnsMenuItem($primarySidebar)
5766
</script>
5867
<a href=\'#\' style=\'display:none;\'>';
5968
$dnsManagement->setLabel($label);
69+
return;
6070
}
71+
// Fallback to custom DNS Management page if single-domain DNS URL is not available
72+
$dnsManagement->setUri("dnsmanagement.php?domainid={$domainId}");
6173
}
6274

6375
private function addDNSSECMenuItem($primarySidebar)
@@ -82,14 +94,43 @@ private function addDNSSECMenuItem($primarySidebar)
8294
$domainId = isset($_REQUEST['domainid']) ? $_REQUEST['domainid'] : $_REQUEST['id'];
8395
$isDomainEnabled = Capsule::table('tbldomains')
8496
->where('id', $domainId)
85-
->select('status', 'dnsmanagement', 'domain')
97+
->select('status','domain')
8698
->first();
8799

88-
if ($isDomainEnabled->dnsmanagement != 1){
100+
if (!$isDomainEnabled) {
101+
return;
102+
}
103+
104+
$dnssecMgmt = DnssecManagement::getFlag((int)$domainId); // 0/1
105+
if ($dnssecMgmt !== 1) {
89106
return;
90107
}
91108

92109
$domain = DomainFullNameToDomainObject::convert($isDomainEnabled->domain);
110+
$tld = null;
111+
if (is_object($domain) && method_exists($domain, 'getExtension')) {
112+
$tld = $domain->getExtension();
113+
} else {
114+
$labels = array_values(array_filter(explode('.', strtolower($isDomainEnabled->domain))));
115+
if (count($labels) > 1) {
116+
array_shift($labels);
117+
$tld = implode('.', $labels);
118+
}
119+
}
120+
121+
if (empty($tld)) {
122+
logModuleCall('openprovider', 'supportsDnssec', ['domain' => $isDomainEnabled->domain], null, 'Could not derive TLD', null);
123+
return;
124+
}
125+
126+
try {
127+
if (!$this->apiHelper->supportsDnssec($tld)) {
128+
return;
129+
}
130+
} catch (\Exception $e) {
131+
return;
132+
}
133+
93134
try {
94135
$op_domain = $this->apiHelper->getDomain($domain);
95136
} catch (\Exception $e) {
@@ -109,4 +150,42 @@ private function addDNSSECMenuItem($primarySidebar)
109150
->setOrder(100);
110151
}
111152
}
112-
}
153+
154+
private function ensureDnsManagementPageExists()
155+
{
156+
$rootDir = $GLOBALS['whmcsAppConfig']->getRootDir();
157+
$destination = $rootDir . self::DNS_MANAGEMENT_PAGE_NAME;
158+
159+
// Check if dnsmanagement.php file exists in the root directory
160+
if (file_exists($destination) && !empty(trim((string) @file_get_contents($destination)))) {
161+
return;
162+
}
163+
164+
$source = $rootDir . "/modules/registrars/openprovider/custom-pages" . self::DNS_MANAGEMENT_PAGE_NAME;
165+
166+
// Explicitly check source exists
167+
if (!file_exists($source)) {
168+
logModuleCall(
169+
'openprovider nl',
170+
'copydnsmanagementfile',
171+
['source' => $source, 'destination' => $destination],
172+
"Source dnsmanagement.php not found. Please upload it manually.",
173+
null,
174+
null
175+
);
176+
return;
177+
}
178+
179+
// copy
180+
if (!copy($source, $destination)) {
181+
logModuleCall(
182+
'openprovider nl',
183+
'copydnsmanagementfile',
184+
['source' => $source, 'destination' => $destination],
185+
"Failed to copy dnsmanagement.php to WHMCS root directory. Please upload it manually.",
186+
null,
187+
null
188+
);
189+
}
190+
}
191+
}

0 commit comments

Comments
 (0)