ns/ & ht/: check that domain isn't already used

This commit is contained in:
Miraty 2022-08-30 00:37:37 +02:00
parent 9be11ea27a
commit 247c814d5d
2 changed files with 6 additions and 0 deletions

View File

@ -41,6 +41,9 @@ checkDomainFormat($_POST['domain']);
if ($dirsStatuses[$_POST['dir']] !== false)
userError("Wrong value for <code>dir</code>.");
if (query('select', 'sites', ['domain' => $_POST['domain']], 'domain') !== [])
userError("Ce domaine existe déjà sur ce service.");
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
$nginxConf = 'server {

View File

@ -12,6 +12,9 @@ switchToFormProcess();
$_POST['domain'] = formatAbsoluteDomain($_POST['domain']);
if (query('select', 'zones', ['zone' => $_POST['domain']], 'zone') !== [])
userError("Cette zone existe déjà sur ce service.");
$db = new PDO('sqlite:' . DB_PATH);
$stmt = $db->prepare("INSERT INTO zones(zone, username) VALUES(:zone, :username)");