opensmtpdadmin/admin/create-domain.php

66 lines
1.9 KiB
PHP
Raw Normal View History

2022-08-18 14:01:52 +02:00
<?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
//
2022-09-02 23:06:08 +02:00
require_once '../functions.inc.php';
include '../languages/' . check_language() . '.lang';
2022-08-18 14:01:52 +02:00
if ($_SERVER['REQUEST_METHOD'] == "POST") {
2022-09-02 23:06:08 +02:00
$list_domains = list_domains();
2022-08-18 14:01:52 +02:00
2022-09-02 23:06:08 +02:00
$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 />";
2022-08-18 14:01:52 +02:00
}
2022-09-02 23:06:08 +02:00
} else {
$message = $PALANG['pAdminCreate_domain_domain_text_error'];
2022-08-18 14:01:52 +02:00
}
}
2022-09-02 23:06:08 +02:00
include '../templates/header.tpl';
include '../templates/admin_menu.tpl';
include '../templates/admin_create-domain.tpl';
include '../templates/footer.tpl';
2022-08-18 14:01:52 +02:00
?>