consolidated add/edit into single file
This commit is contained in:
parent
cd5bb24122
commit
cb0c422ebb
|
@ -1,91 +0,0 @@
|
|||
<?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';
|
||||
|
||||
$list_domains = list_domains();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT) ?? 'new';
|
||||
if ($action == 'edit') {
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$description = $list_domains[$domain_key]['description'];
|
||||
$aliases = $list_domains[$domain_key]['aliases'];
|
||||
$mailboxes = $list_domains[$domain_key]['mailboxes'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT) ?? 'new';
|
||||
$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'];
|
||||
}
|
||||
|
||||
if (in_array($domain, array_column($list_domains, 'domain')) && $action == 'edit') {
|
||||
try {
|
||||
$dbh = connect_db();
|
||||
$sth = $dbh->prepare("UPDATE domain SET description=?,aliases=?,mailboxes=?,modified=NOW() WHERE domain=?");
|
||||
$sth->bindParam(1, $description, PDO::PARAM_STR);
|
||||
$sth->bindParam(2, $aliases, PDO::PARAM_INT);
|
||||
$sth->bindParam(3, $mailboxes, PDO::PARAM_INT);
|
||||
$sth->bindParam(4, $domain, PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
header("Location: list-domain.php");
|
||||
} catch(PDOException $e) {
|
||||
$message = $PALANG['pAdminEdit_domain_result_error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include '../templates/header.tpl';
|
||||
include '../templates/admin_menu.tpl';
|
||||
include '../templates/admin_add-domain.tpl';
|
||||
include '../templates/footer.tpl';
|
||||
?>
|
|
@ -1,65 +0,0 @@
|
|||
<?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';
|
||||
?>
|
|
@ -1,61 +0,0 @@
|
|||
<?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("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
$list_domains = list_domains();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$action = filter_input(INPUT_GET, 'action', FILTER_DEFAULT);
|
||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_VALIDATE_DOMAIN);
|
||||
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
|
||||
$description = $list_domains[$domain_key]['description'];
|
||||
$aliases = $list_domains[$domain_key]['aliases'];
|
||||
$mailboxes = $list_domains[$domain_key]['mailboxes'];
|
||||
}
|
||||
|
||||
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']);
|
||||
|
||||
|
||||
$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_add-domain.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -1,43 +0,0 @@
|
|||
<div id="edit_form">
|
||||
<form name="create_domain" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<?php if ($action == 'edit') { ?>
|
||||
<td colspan="3"><h3><?php print $PALANG['pAdminEdit_domain_welcome']; ?></h3></td>
|
||||
<?php } else { ?>
|
||||
<td colspan="3"><h3><?php echo $PALANG['pAdminCreate_domain_welcome']; ?></h3></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_domain'] . ":"; ?></td>
|
||||
<?php if ($action == 'edit') { ?>
|
||||
<td><input class="flat" type="hidden" name="domain" value="<?php echo $domain ?? ''; ?>" /><?php print $domain; ?></td>
|
||||
<?php } else { ?>
|
||||
<td><input class="flat" type="text" name="domain" value="<?php echo $domain ?? ''; ?>" /></td>
|
||||
<td> </td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_description'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="description" value="<?php echo $description ?? ''; ?>" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_aliases'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="aliases" value="<?php echo $aliases ?? ALIASES; ?>" /></td>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_aliases_text']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_mailboxes'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="mailboxes" value="<?php echo $mailboxes ?? MAILBOXES; ?>" /></td>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_mailboxes_text']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pAdminCreate_domain_button']; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="standout"><?php echo $message ?? ' '; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
|
@ -1,35 +0,0 @@
|
|||
<div id="edit_form">
|
||||
<form name="create_domain" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="3"><h3><?php echo $PALANG['pAdminCreate_domain_welcome']; ?></h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_domain'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="domain" value="<?php echo $domain ?? ''; ?>" /></td>
|
||||
<td><?php echo $pAdminCreate_domain_domain_text; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_description'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="description" value="<?php echo $description ?? ''; ?>" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_aliases'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="aliases" value="<?php echo $aliases ?? ALIASES; ?>" /></td>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_aliases_text']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_mailboxes'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="mailboxes" value="<?php echo $mailboxes ?? MAILBOXES; ?>" /></td>
|
||||
<td><?php echo $PALANG['pAdminCreate_domain_mailboxes_text']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pAdminCreate_domain_button']; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="standout"><?php echo $message ?? ''; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
|
@ -1,35 +0,0 @@
|
|||
<div id="edit_form">
|
||||
<form name="edit_domain" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="3"><h3><?php print $PALANG['pAdminEdit_domain_welcome']; ?></h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pAdminEdit_domain_domain'] . ":"; ?></td>
|
||||
<td><?php print $domain; ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pAdminEdit_domain_description'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="description" value="<?php print $description ?? ''; ?>" /></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pAdminEdit_domain_aliases'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="aliases" value="<?php print $aliases; ?>" /></td>
|
||||
<td><?php print $PALANG['pAdminEdit_domain_aliases_text']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pAdminEdit_domain_mailboxes'] . ":"; ?></td>
|
||||
<td><input class="flat" type="text" name="mailboxes" value="<?php print $mailboxes; ?>" /></td>
|
||||
<td><?php print $PALANG['pAdminEdit_domain_mailboxes_text']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="hlp_center"><input type="submit" class="button" name="submit" value="<?php print $PALANG['pAdminEdit_domain_button']; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="standout"><?php print $message; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
Loading…
Reference in New Issue