From f47c5cca8430107a9a65a2abcb805ee50b91e9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Stehl=C3=ADk?= Date: Mon, 4 Dec 2023 18:40:53 +0100 Subject: [PATCH] Fix domain edit for .eu and other domains. --- cron_domain_refresher.php | 8 ++++++++ functions.php | 5 ++++- post/domain.php | 14 ++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cron_domain_refresher.php b/cron_domain_refresher.php index d7ddcb3a..109e9fc6 100644 --- a/cron_domain_refresher.php +++ b/cron_domain_refresher.php @@ -55,6 +55,14 @@ if ($row) { $txt = sanitizeInput($records['txt']); $whois = sanitizeInput($records['whois']); + if ( + $expire === 'NULL' + && $row['domain_expire'] !== null + && (new DateTime($row['domain_expire'])) >= (new DateTime()) + ) { + $expire = $row['domain_expire']; + } + // Update the domain mysqli_query($mysqli, "UPDATE domains SET domain_name = '$domain_name', domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois' WHERE domain_id = $domain_id"); } diff --git a/functions.php b/functions.php index bf2abf41..b471d80b 100644 --- a/functions.php +++ b/functions.php @@ -380,9 +380,12 @@ function getDomainExpirationDate($name) { if (is_array($response['expiration_date'])) { $expiry = new DateTime($response['expiration_date'][1]); } - else { + elseif (isset($response['expiration_date'])) { $expiry = new DateTime($response['expiration_date']); } + else { + return "NULL"; + } return $expiry->format('Y-m-d'); } diff --git a/post/domain.php b/post/domain.php index 7470fd48..6fcd249a 100644 --- a/post/domain.php +++ b/post/domain.php @@ -70,15 +70,13 @@ if (isset($_POST['edit_domain'])) { $registrar = intval($_POST['registrar']); $webhost = intval($_POST['webhost']); $expire = sanitizeInput($_POST['expire']); - if (empty($expire)) { - $expire = "NULL"; - } else { - $expire = "'" . $expire . "'"; - } - $client_id = intval($_POST['client_id']); - // Update domain expiry date - $expire = getDomainExpirationDate($name); + if (empty($expire) || (new DateTime($expire)) < (new DateTime())) { + // Update domain expiry date + $expire = getDomainExpirationDate($name); + } + + $client_id = intval($_POST['client_id']); // Update NS, MX, A and WHOIS records/data $records = getDomainRecords($name);