opensmtpdadmin/admin/create-domain.php

66 lines
1.9 KiB
PHP

<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: create-domain.php
//
// Template File: admin_create-domain.tpl
//
// Template Variables:
//
// tMessage
// tDomain
// tDescription
// tAliases
// tMailboxes
// tMaxquota
// tDefaultaliases
//
// Form POST \ GET Variables:
//
// fDomain
// fDescription
// fAliases
// fMailboxes
// fMaxquota
// fDefaultaliases
//
require_once '../functions.inc.php';
include '../languages/' . check_language() . '.lang';
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$list_domains = list_domains();
$domain = strtolower(filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN));
$description = filter_input(INPUT_POST, 'description', FILTER_CALLBACK, array('options' => 'htmlspecialchars'));
$aliases = filter_input(INPUT_POST, 'aliases', FILTER_VALIDATE_INT);
$mailboxes = filter_input(INPUT_POST, 'mailboxes', FILTER_VALIDATE_INT);
if (!in_array($domain, array_column($list_domains, 'domain'))) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("INSERT INTO domain (domain,description,aliases,mailboxes,created,modified) VALUES (?,?,?,?,NOW(),NOW())");
$sth->bindParam(1, $domain, PDO::PARAM_STR);
$sth->bindParam(2, $description, PDO::PARAM_STR);
$sth->bindParam(3, $aliases, PDO::PARAM_INT);
$sth->bindParam(4, $mailboxes, PDO::PARAM_INT);
$sth->execute();
$message = $PALANG['pAdminCreate_domain_result_succes'] . "<br />($domain)</br />";
} catch(PDOException $e) {
$message = $PALANG['pAdminCreate_domain_result_error'] . "<br />($domain)<br />";
}
} else {
$message = $PALANG['pAdminCreate_domain_domain_text_error'];
}
}
include '../templates/header.tpl';
include '../templates/admin_menu.tpl';
include '../templates/admin_create-domain.tpl';
include '../templates/footer.tpl';
?>