prevent creation of lists with the address of existing accounts and the other way around

This commit is contained in:
hmrhkr committed 2021-11-10 15:55:10 +01:00
1 parent bf56072f20
commit f203bec567
3 files changed
+52 -23

No files matched your search

+18 -6
View File
@@ -59,13 +59,25 @@ if ($_SESSION['log'] == 1) {
$newlistsource = $_POST['newlistsource'];
$newlistsourceexp = explode('@', $newlistsource);
if ($newlistsource != $oldlistsource) {
$abfrage = "UPDATE `alias_details` SET `source` = :source WHERE `id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':source' => $newlistsource, ':alias_id' => $_POST['editlistid']));
// check if an account with same address exists
$abfrage = "SELECT 1 FROM `accounts` WHERE `username` = :username AND `domain` = :domain";
$sth = $dbh->prepare($abfrage);
$sth->execute(array(':username' => $newlistsourceexp[0], ':domain' => $newlistsourceexp[1]));
$result = $sth->fetchAll();
if ($result[0][1] !== 1) {
$abfrage = "UPDATE `alias_details` SET `source` = :source WHERE `id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':source' => $newlistsource, ':alias_id' => $_POST['editlistid']));
$abfrage = "UPDATE `aliases` SET `source_username` = :source_username, `source_domain` = :source_domain WHERE `alias_id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':source_username' => $newlistsourceexp[0], ':source_domain' => $newlistsourceexp[1], ':alias_id' => $_POST['editlistid']));
$abfrage = "UPDATE `aliases` SET `source_username` = :source_username, `source_domain` = :source_domain WHERE `alias_id` LIKE :alias_id";
$result = $dbh->prepare($abfrage);
$result->execute(array(':source_username' => $newlistsourceexp[0], ':source_domain' => $newlistsourceexp[1], ':alias_id' => $_POST['editlistid']));
}
else {
$newlistsource = $oldlistsource;
$newlistsourceexp = explode('@', $newlistsource);
}
}
}
else {