From e0668245c655ec049f49c171f7c6f6777bf4f3e9 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 19 Jan 2026 15:15:23 -0700 Subject: [PATCH] Prevent duplicate domain names --- core/domains/domain_edit.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/domains/domain_edit.php b/core/domains/domain_edit.php index ea6283a487..ba00f1f0cc 100644 --- a/core/domains/domain_edit.php +++ b/core/domains/domain_edit.php @@ -105,6 +105,21 @@ $msg = ''; if (empty($domain_name)) { $msg .= $text['message-required'].$text['label-name']."
\n"; } //if (empty($domain_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + + //check for a duplicate domain name + if ($action == 'add') { + $sql = "select count(*) from v_domains "; + $sql .= "where domain_name = :domain_name "; + $sql .= "and destination_type = 'inbound' "; + $parameters['domain_name'] = $domain_name; + $num_rows = $database->select($sql, $parameters, 'column'); + if ($num_rows > 0) { + $msg .= $text['message-duplicate']."
\n"; + } + unset($sql, $parameters, $num_rows); + } + + //show the message if it's not empty if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php";