From 3813fbf8f22c615fddf3051079953fbd9056c7b2 Mon Sep 17 00:00:00 2001 From: wrongecho Date: Thu, 6 Nov 2025 10:41:52 +0000 Subject: [PATCH] When adding a domain, flag if no SOA record exists (prevents most sub-domains) --- agent/ajax.php | 21 +++++++++++++++++++++ agent/modals/contact/contact_add.php | 2 +- agent/modals/domain/domain_add.php | 22 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/agent/ajax.php b/agent/ajax.php index eec7bdd2..4a37f0e0 100644 --- a/agent/ajax.php +++ b/agent/ajax.php @@ -971,3 +971,24 @@ if (isset($_GET['ai_ticket_summary'])) { echo $summary; // nl2br to convert newlines to
, htmlspecialchars to prevent XSS } + +// Stops people trying to use sub-domains in the domains tracker +if (isset($_GET['apex_domain_check'])) { + enforceUserPermission('module_support', 2); + + $domain = sanitizeInput($_GET['domain']); + + $response['message'] = ""; // default + + if (strlen($domain) >= 4) { + + // SOA record check + // This isn't 100%, as sub-domains can have their own SOA but will capture 99% + if (!checkdnsrr($domain, 'SOA')) { + $response['message'] = " Domain name is invalid."; + } + + } + + echo json_encode($response); +} diff --git a/agent/modals/contact/contact_add.php b/agent/modals/contact/contact_add.php index 9e5df3ba..a6a919c4 100644 --- a/agent/modals/contact/contact_add.php +++ b/agent/modals/contact/contact_add.php @@ -349,7 +349,7 @@ $(document).ready(function() { //Send a GET request to ajax.php as ajax.php?contact_email_check=true&email=email jQuery.get( "ajax.php", - {contact_email_check: 'email', email: email}, + {contact_email_check: 'true', email: email}, function(data) { //If we get a response from ajax.php, parse it as JSON const contact_check_data = JSON.parse(data); diff --git a/agent/modals/domain/domain_add.php b/agent/modals/domain/domain_add.php index e8273d36..7a36a543 100644 --- a/agent/modals/domain/domain_add.php +++ b/agent/modals/domain/domain_add.php @@ -65,7 +65,10 @@ ob_start();
- + + +
+
@@ -193,6 +196,23 @@ ob_start(); + +