diff --git a/agent/ajax.php b/agent/ajax.php index 3d8331ae..eec7bdd2 100644 --- a/agent/ajax.php +++ b/agent/ajax.php @@ -700,6 +700,34 @@ if (isset($_GET['client_duplicate_check'])) { echo json_encode($response); } +if (isset($_GET['contact_email_check'])) { + enforceUserPermission('module_client', 2); + + $email = sanitizeInput($_GET['email']); + $domain = sanitizeInput(substr($_GET['email'], strpos($_GET['email'], '@') + 1)); + + $response['message'] = ""; // default + + if (strlen($email) >= 3) { + + // 1. Duplicate check + $sql_contacts = mysqli_query($mysqli, "SELECT contact_email FROM contacts WHERE contact_email = '$email' LIMIT 1"); + if (mysqli_num_rows($sql_contacts) > 0) { + while ($row = mysqli_fetch_array($sql_contacts)) { + $response['message'] = " Potential duplicate: " . nullable_htmlentities($row['contact_email']) . " already exists."; + } + } + + // 2. MX record check + if (!checkdnsrr($domain, 'MX')) { + $response['message'] = " E-mail domain invalid."; + } + + } + + echo json_encode($response); +} + if (isset($_GET['ai_reword'])) { header('Content-Type: application/json'); diff --git a/agent/modals/contact/contact_add.php b/agent/modals/contact/contact_add.php index 69db0a7e..9e5df3ba 100644 --- a/agent/modals/contact/contact_add.php +++ b/agent/modals/contact/contact_add.php @@ -148,7 +148,10 @@ ob_start();
- + + +
+
@@ -339,6 +342,23 @@ $(document).ready(function() { }); + +