update fix deadcode, security
This commit is contained in:
@@ -83,80 +83,6 @@ class PleskDomainService
|
||||
return false;
|
||||
}
|
||||
|
||||
public function updateDomain(DnsServer $server, int $pleskDomainId, array $data = []): array|false
|
||||
{
|
||||
$this->lastError = null;
|
||||
|
||||
if (empty($pleskDomainId) || empty($data)) {
|
||||
$this->lastError = 'Invalid request';
|
||||
return false;
|
||||
}
|
||||
|
||||
$param = [
|
||||
'name' => $data['domain_name'],
|
||||
'description' => '',
|
||||
'hosting_type' => 'virtual',
|
||||
'hosting_settings' => [
|
||||
'ftp_login' => $data['ftp_login'] ?? str_replace('.', '_', $data['domain_name']),
|
||||
'ftp_password' => $data['ftp_password'] ?? Str::random(12),
|
||||
],
|
||||
'plan' => ['name' => $data['plan'] ?? 'Default Domain'],
|
||||
];
|
||||
|
||||
if (!empty($data['ip_addresses'])) {
|
||||
$param['ip_addresses'] = $data['ip_addresses'];
|
||||
$param['ipv4'] = $data['ip_addresses'];
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->plesk->client($server, 30)
|
||||
->put($this->plesk->url($server, 'domains', "/{$pleskDomainId}"), $param);
|
||||
|
||||
$responseData = $response->json();
|
||||
|
||||
Log::info('Response Plesk API Updated', ['data' => $responseData]);
|
||||
|
||||
if ($response->successful() && isset($responseData['id'], $responseData['guid'])) {
|
||||
return $responseData;
|
||||
}
|
||||
|
||||
$this->lastError = $responseData['message'] ?? 'Plesk domain update failed';
|
||||
} catch (RequestException $e) {
|
||||
$this->lastError = $e->response?->json('message') ?? $e->getMessage();
|
||||
Log::error('Plesk domain update failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'response' => $e->response?->body(),
|
||||
'data' => $param,
|
||||
]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function removeDomain(DnsServer $server, int $pleskDomainId): bool
|
||||
{
|
||||
try {
|
||||
$response = $this->plesk->client($server, 30)
|
||||
->delete($this->plesk->url($server, 'domains', "/{$pleskDomainId}"));
|
||||
|
||||
if ($response->successful()) {
|
||||
Log::info('Xoá domain thành công', ['plesk_id' => $pleskDomainId, 'status' => $response->status()]);
|
||||
return true;
|
||||
}
|
||||
|
||||
Log::error('Xoá domain thất bại', [
|
||||
'plesk_id' => $pleskDomainId,
|
||||
'status' => $response->status(),
|
||||
'response' => $response->body(),
|
||||
]);
|
||||
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Exception khi xoá domain', ['plesk_id' => $pleskDomainId, 'error' => $e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDomainInfo(DnsServer $server, string $domain = ''): array|false
|
||||
{
|
||||
if (empty($domain)) {
|
||||
|
||||
Reference in New Issue
Block a user