prevent creation of lists with the address of existing accounts and the other way around
This commit is contained in:
1 parent
bf56072f20
commit
f203bec567
3 files changed
+52
-23
No files matched your search
+24
-14
@@ -25,21 +25,31 @@ session_start();
|
||||
if ($_SESSION['log'] == 1 && $_SESSION['admin']) {
|
||||
if (!isset($_POST['newlistislist'])) $islist = 0; // wenn die checkbox nicht ausgewählt wurde ist die Post Variable nicht gesetzt, dass stört die Datenbank, deshalb wird Null eingertragen
|
||||
else $islist = $_POST['newlistislist'];
|
||||
$eintrag = "INSERT INTO `alias_details` (`name`, `owners`, `destinations`, `security`, `islist`) VALUES (:newlistname, :owners, :destinations, :security, :islist)"; // Aliasdaten in MailServer DB eintragen
|
||||
$sth = $dbh->prepare($eintrag);
|
||||
$sth->execute(array(':newlistname' => $_POST['newlistname'], ':owners' => $_POST['newlistowners'], ':destinations' => $_POST['newlistdestinations'], ':security' => $_POST['newlistsecurity'], ':islist' => $islist));
|
||||
$newlistid = $dbh->lastInsertID();
|
||||
foreach (explode(' ', $_POST['newlistowners']) as $maillistowner) {
|
||||
$maillistownerex = explode('@', $maillistowner);
|
||||
$eintrag = "INSERT INTO `alias_owner` (`alias_id`, `owner_username`, `owner_domain`) VALUES (:aliasid, :owner_username, :owner_domain)"; // Aliasdaten in MailServer DB eintragen
|
||||
|
||||
// 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' => $_POST['newlistsourceadress'], ':domain' => $_POST['newlistsourcedomain']));
|
||||
$result = $sth->fetchAll();
|
||||
// only create the list if no account with the same adress exists
|
||||
if ($result[0][1] !== 1) {
|
||||
$newlistsource = $_POST['newlistsourceadress'] . '@' . $_POST['newlistsourcedomain'];
|
||||
$eintrag = "INSERT INTO `alias_details` (`name`, `owners`, `source`, `destinations`, `security`, `islist`) VALUES (:newlistname, :owners, :source, :destinations, :security, :islist)"; // Aliasdaten in MailServer DB eintragen
|
||||
$sth = $dbh->prepare($eintrag);
|
||||
$sth->execute(array(':aliasid' => $newlistid, ':owner_username' => $maillistownerex[0], ':owner_domain' => $maillistownerex[1]));
|
||||
}
|
||||
foreach (explode(' ', $_POST['newlistdestinations']) as $maillistdestination) {
|
||||
$maillistdestinationex = explode('@', $maillistdestination);
|
||||
$eintrag = "INSERT INTO `aliases` (`alias_id`, `source_username`, `source_domain`, `destination_username`, `destination_domain`) VALUES (:aliasid, :source_username, :source_domain, :destination_username, :destination_domain)"; // Aliasdaten in MailServer DB eintragen
|
||||
$sth = $dbh->prepare($eintrag);
|
||||
$sth->execute(array(':aliasid' => $newlistid, ':source_username' => $_POST['newlistsourceadress'], ':source_domain' => $_POST['newlistsourcedomain'], ':destination_username' => $maillistdestinationex[0], ':destination_domain' => $maillistdestinationex[1]));
|
||||
$sth->execute(array(':newlistname' => $_POST['newlistname'], ':owners' => $_POST['newlistowners'], ':source' => $newlistsource, ':destinations' => $_POST['newlistdestinations'], ':security' => $_POST['newlistsecurity'], ':islist' => $islist));
|
||||
$newlistid = $dbh->lastInsertID();
|
||||
foreach (explode(' ', $_POST['newlistowners']) as $maillistowner) {
|
||||
$maillistownerex = explode('@', $maillistowner);
|
||||
$eintrag = "INSERT INTO `alias_owner` (`alias_id`, `owner_username`, `owner_domain`) VALUES (:aliasid, :owner_username, :owner_domain)"; // Aliasdaten in MailServer DB eintragen
|
||||
$sth = $dbh->prepare($eintrag);
|
||||
$sth->execute(array(':aliasid' => $newlistid, ':owner_username' => $maillistownerex[0], ':owner_domain' => $maillistownerex[1]));
|
||||
}
|
||||
foreach (explode(' ', $_POST['newlistdestinations']) as $maillistdestination) {
|
||||
$maillistdestinationex = explode('@', $maillistdestination);
|
||||
$eintrag = "INSERT INTO `aliases` (`alias_id`, `source_username`, `source_domain`, `destination_username`, `destination_domain`) VALUES (:aliasid, :source_username, :source_domain, :destination_username, :destination_domain)"; // Aliasdaten in MailServer DB eintragen
|
||||
$sth = $dbh->prepare($eintrag);
|
||||
$sth->execute(array(':aliasid' => $newlistid, ':source_username' => $_POST['newlistsourceadress'], ':source_domain' => $_POST['newlistsourcedomain'], ':destination_username' => $maillistdestinationex[0], ':destination_domain' => $maillistdestinationex[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Location: maillistsettings.php");
|
||||
|
||||
Reference in new issue
Block a user