From a87a206c04f091a11297f2131e69e81818b3dc14 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 30 Aug 2025 16:16:55 +0100 Subject: [PATCH] Add better error handling for dodgy whois results --- user/post/client.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/user/post/client.php b/user/post/client.php index 1567fcfa..5cc2b4aa 100644 --- a/user/post/client.php +++ b/user/post/client.php @@ -90,11 +90,14 @@ if (isset($_POST['add_client'])) { $mx = sanitizeInput($records['mx']); $whois = sanitizeInput($records['whois']); - // Add domain record - mysqli_query($mysqli, "INSERT INTO domains SET domain_name = '$website', domain_registrar = 0, domain_webhost = 0, domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_client_id = $client_id"); - - //Extended Logging - $extended_log_description .= ", domain $website added"; + // Add domain record info using whois, or not + try { + mysqli_query($mysqli, "INSERT INTO domains SET domain_name = '$website', domain_registrar = 0, domain_webhost = 0, domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_client_id = $client_id"); + $extended_log_description .= ", domain $website added"; //Extended Logging + } catch (Exception $e) { + $extended_log_description .= ", domain not added"; //Extended Logging + logApp("Client", "warning", "Failed to add domain $website during client creation (usually a whois result error)"); + } // Get inserted ID (for linking certificate, if exists) $domain_id = mysqli_insert_id($mysqli);