opensmtpdadmin/admin/edit-domain.php
2022-08-18 14:01:52 +02:00

80 lines
2.3 KiB
PHP

<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: edit-domain.php
//
// Template File: admin_edit-domain.tpl
//
// Template Variables:
//
// tDescription
// tAliases
// tMailboxes
// tMaxquota
// tActive
//
// Form POST \ GET Variables:
//
// fDescription
// fAliases
// fMailboxes
// fMaxquota
// fActive
//
require("../variables.inc.php");
require("../config.inc.php");
require("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$domain = escape_string($_GET['domain']);
$domain_properties = get_domain_properties($domain);
$tDescription = $domain_properties['description'];
$tAliases = $domain_properties['aliases'];
$tMailboxes = $domain_properties['mailboxes'];
$tMaxquota = $domain_properties['maxquota'];
$tTransport = $domain_properties['transport'];
$tBackupmx = $domain_properties['backupmx'];
$tActive = $domain_properties['active'];
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$domain = escape_string($_GET['domain']);
$fDescription = escape_string($_POST['fDescription']);
$fAliases = escape_string($_POST['fAliases']);
$fMailboxes = escape_string($_POST['fMailboxes']);
if (isset($_POST['fMaxquote']) ? $fMaxquota = escape_string($_POST['fMaxquota']) : $fMaxquota = "0");
if (isset($_POST['fTransport'])) $fTransport = escape_string($_POST['fTransport']);
if (isset($_POST['fBackupmx'])) $fBackupmx = escape_string($_POST['fBackupmx']);
if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']);
if ($fBackupmx == "on") {
$fAliases = -1;
$fMailboxes = -1;
$fMaxquota = -1;
$fBackupmx = 1;
} else {
$fBackupmx = 0;
}
$fActive = ($fActive == "on" ? 1 : 0);
$result = db_query("UPDATE domain SET description='$fDescription',aliases='$fAliases',mailboxes='$fMailboxes',maxquota='$fMaxquota',transport='$fTransport',backupmx='$fBackupmx',active='$fActive',modified=NOW() WHERE domain='$domain'");
if ($result['rows'] == 1) {
header("Location: list-domain.php");
} else {
$tMessage = $PALANG['pAdminEdit_domain_result_error'];
}
}
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
include("../templates/admin_edit-domain.tpl");
include("../templates/footer.tpl");
?>