remove admin_create- files

This commit is contained in:
mischa 2022-09-02 21:27:44 +00:00
parent 6504b8e509
commit e44315ff44
5 changed files with 0 additions and 386 deletions

View File

@ -1,77 +0,0 @@
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: create-admin.php
//
// Template File: admin_create-admin.tpl
//
//
// Template Variables:
//
// tMessage
// tUsername
// tDomains
//
// Form POST \ GET Variables:
//
// fUsername
// fPassword
// fPassword2
// fDomains
//
require("../variables.inc.php");
require("../config.inc.php");
require("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
$list_domains = list_domains();
$list_admins = list_admins();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$username = filter_input(INPUT_POST, 'username', FILTER_VALIDATE_EMAIL);
$password1 = filter_input(INPUT_POST, 'password1', FILTER_DEFAULT);
$password2 = filter_input(INPUT_POST, 'password2', FILTER_DEFAULT);
$domains = filter_input_array(INPUT_POST, array('domains' => array('filter' => FILTER_VALIDATE_DOMAIN, 'flags' => FILTER_REQUIRE_ARRAY)));
if (empty($username) || in_array($username, array_column($list_admins, 'username'))) {
$message = $PALANG['pAdminCreate_admin_username_error'];
}
if (empty($password1) or ($password1 != $password2)) {
$message = $PALANG['pAdminCreate_admin_password_error'];
}
if (empty($domains['domains'])) {
$message = $PALANG['pAdminCreate_admin_domain_error'];
}
if (empty($message)) {
$hashed = bcrypt($password1);
try {
$dbh = connect_db();
$sth = $dbh->prepare("INSERT INTO admin (username,password,created,modified) VALUES (?,?,NOW(),NOW())");
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->bindParam(2, $hashed, PDO::PARAM_STR);
$sth->execute();
foreach ($domains['domains'] as $row) {
$sth = $dbh->prepare("INSERT INTO domain_admins (username,domain,created) VALUES (?,?,NOW())");
$sth->bindParam(1, $username, PDO::PARAM_STR);
$sth->bindParam(2, $row, PDO::PARAM_STR);
$sth->execute();
}
$message = $PALANG['pAdminCreate_admin_result_succes'] . "<br />($username)</br />";
} catch(PDOException $e) {
$message = $PALANG['pAdminCreate_admin_result_error'] . "<br />($username)<br />";
}
}
}
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
include("../templates/admin_create-admin.tpl");
include("../templates/footer.tpl");
?>

View File

@ -1,73 +0,0 @@
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: create-alias.php
//
// Template File: create-alias.tpl
//
// Template Variables:
//
// tMessage
// tAddress
// tGoto
// domain
//
// Form POST \ GET Variables:
//
// address
// fGoto
// domain
//
require("../variables.inc.php");
require("../config.inc.php");
require("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
$list_domains = list_domains();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$address = strtolower(filter_input(INPUT_POST, 'address', FILTER_DEFAULT));
$domain = filter_input(INPUT_POST, 'domain', FILTER_VALIDATE_DOMAIN);
$goto = strtolower(filter_input(INPUT_POST, 'goto', FILTER_DEFAULT));
$domain_key = array_search($domain, array_column($list_domains, 'domain'));
$from = filter_var($address . '@' . $domain, FILTER_VALIDATE_EMAIL);
if (!str_contains($goto, '@')) {
$goto = $goto . "@" . $domain;
}
$goto = filter_var($goto, FILTER_VALIDATE_EMAIL);
if ($list_domains[$domain_key]['alias_count'] < 0 || $list_domains[$domain_key]['alias_count'] >= $list_domains[$domain_key]['aliases']) {
$message = $PALANG['pCreate_alias_address_text_error2'];
}
if (empty($address) || empty($goto)) {
$message = $PALANG['pCreate_alias_address_text_error1'];
}
if (empty($message)) {
try {
$dbh = connect_db();
$sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())");
$sth->bindParam(1, $from, PDO::PARAM_STR);
$sth->bindParam(2, $goto, PDO::PARAM_STR);
$sth->bindParam(3, $domain, PDO::PARAM_STR);
$sth->execute();
logging(ADMIN_EMAIL, $domain, "create alias", "$from -> $goto");
$message = $PALANG['pCreate_alias_result_succes'] . "<br />($from -> $goto)</br />";
$address = '';
$goto = '';
} catch(PDOException $e) {
$message = $PALANG['pCreate_alias_result_error'] . "<br />($from -> $goto) - $e<br />";
}
}
}
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
include("../templates/create-alias.tpl");
include("../templates/footer.tpl");
?>

View File

@ -1,191 +0,0 @@
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: create-mailbox.php
//
// Template File: create-mailbox.tpl
//
// Template Variables:
//
// tMessage
// tUsername
// tName
// tQuota
// tDomain
//
// Form POST \ GET Variables:
//
// fUsername
// fPassword
// fPassword2
// fName
// fQuota
// fDomain
// fActive
// fMail
//
require("../variables.inc.php");
require("../config.inc.php");
require("../functions.inc.php");
include("../languages/" . check_language() . ".lang");
$list_domains = list_domains();
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$tQuota = $CONF['maxquota'];
$pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text'];
$pCreate_mailbox_name_text = $PALANG['pCreate_mailbox_name_text'];
$pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text'];
if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
include("../templates/create-mailbox.tpl");
include("../templates/footer.tpl");
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text'];
$pCreate_mailbox_name_text = $PALANG['pCreate_mailbox_name_text'];
$pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text'];
$fUsername = escape_string($_POST['fUsername']) . "@" . escape_string($_POST['fDomain']);
$fUsername = strtolower($fUsername);
$fPassword = escape_string($_POST['fPassword']);
$fPassword2 = escape_string($_POST['fPassword2']);
isset($_POST['fName']) ? $fName = escape_string($_POST['fName']) : $fName = "No Name";
$fDomain = escape_string($_POST['fDomain']);
isset($_POST['fQuota']) ? $fQuota = escape_string($_POST['fQuota']) : $fQuota = "0";
isset($_POST['fActive']) ? $fActive = escape_string($_POST['fActive']) : $fActive = "1";
if(isset($_POST['fMail'])) $fMail = escape_string($_POST['fMail']);
if (!check_mailbox($fDomain)) {
$error = 1;
$tUsername = escape_string($_POST['fUsername']);
$tName = $fName;
$tQuota = $fQuota;
$tDomain = $fDomain;
$pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error3'];
}
if (empty($fUsername) or !check_email($fUsername)) {
$error = 1;
$tUsername = escape_string($_POST['fUsername']);
$tName = $fName;
$tQuota = $fQuota;
$tDomain = $fDomain;
$pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1'];
}
if (empty($fPassword) or ($fPassword != $fPassword2)) {
if ($CONF['generate_password'] == "YES") {
$fPassword = generate_password();
} else {
$error = 1;
$tUsername = escape_string($_POST['fUsername']);
$tName = $fName;
$tQuota = $fQuota;
$tDomain = $fDomain;
$pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text_error'];
}
}
if ($CONF['quota'] == "YES") {
if (!check_quota($fQuota, $fDomain)) {
$error = 1;
$tUsername = escape_string($_POST['fUsername']);
$tName = $fName;
$tQuota = $fQuota;
$tDomain = $fDomain;
$pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text_error'];
}
}
$result = db_query("SELECT * FROM alias WHERE address='$fUsername'");
if ($result['rows'] == 1) {
$error = 1;
$tUsername = escape_string($_POST['fUsername']);
$tName = $fName;
$tQuota = $fQuota;
$tDomain = $fDomain;
$pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error2'];
}
if ($error != 1) {
$password = pacrypt($fPassword);
if ($CONF['domain_path'] == "YES") {
if ($CONF['domain_in_mailbox'] == "YES") {
$maildir = $fDomain . "/" . $fUsername . "/";
} else {
$maildir = $fDomain . "/" . escape_string($_POST['fUsername']) . "/";
}
} else {
$maildir = $fUsername . "/";
}
if (!empty($fQuota)) {
$quota = $fQuota * $CONF['quota_multiplier'];
} else {
$quota = 0;
}
if ($fActive == "on") {
$fActive = 1;
} else {
$fActive = 0;
}
$result = db_query("INSERT INTO alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','vmail','$fDomain',NOW(),NOW(),'$fActive')");
if ($result['rows'] != 1) {
$tDomain = $fDomain;
$tMessage = $PALANG['pAlias_result_error'] . "<br />($fUsername -> $fUsername)</br />";
}
$result = db_query("INSERT INTO mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$fActive')");
if ($result['rows'] != 1) {
$tDomain = $fDomain;
$tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />";
} else {
db_log($CONF['admin_email'], $fDomain, "create mailbox", $fUsername);
$tDomain = $fDomain;
$tMessage = $PALANG['pCreate_mailbox_result_succes'] . "<br />($fUsername";
if ($CONF['generate_password'] == "YES") {
$tMessage .= " / $fPassword)</br />";
} else {
$tMessage .= ")</br />";
}
$tQuota = $CONF['maxquota'];
if ($fMail == "on") {
$fTo = $fUsername;
$fSubject = $PALANG['pSendmail_subject_text'];
$fHeaders = "From: " . $CONF['admin_email'] . "\r\n";
$fHeaders .= "Content-Type: text/plain; charset=utf-8\r\n";
$fBody = $CONF['welcome_text'];
if (!mail($fTo, $fSubject, $fBody, $fHeaders)) {
$tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />";
} else {
$tMessage .= "<br />" . $PALANG['pSendmail_result_succes'] . "<br />";
}
}
}
}
include("../templates/header.tpl");
include("../templates/admin_menu.tpl");
include("../templates/create-mailbox.tpl");
include("../templates/footer.tpl");
}
?>

View File

@ -1,41 +0,0 @@
<div id="edit_form">
<form name="create_admin" method="post">
<table>
<tr>
<td colspan="2"><h3><?php echo $PALANG['pAdminCreate_admin_welcome']; ?></h3></td>
</tr>
<tr>
<td><?php echo $PALANG['pAdminCreate_admin_username'] . ":"; ?></td>
<td><input class="flat" type="text" name="username" value="<?php echo $username ?? ''; ?>" /></td>
</tr>
<tr>
<td><?php echo $PALANG['pAdminCreate_admin_password1'] . ":"; ?></td>
<td><input class="flat" type="password" name="password1" /></td>
</tr>
<tr>
<td><?php echo $PALANG['pAdminCreate_admin_password2'] . ":"; ?></td>
<td><input class="flat" type="password" name="password2" /></td>
</tr>
<tr>
<td><?php echo $PALANG['pAdminCreate_admin_address'] . ":"; ?></td>
<td>
<select name="domains[]" size="10" multiple="multiple">
<?php
foreach ($list_domains as $row) {
echo '<option value="' . $row['domain'] . '"';
if (isset($domains['domains']) && in_array($row['domain'], $domains['domains'])) echo ' selected';
echo ">" . $row['domain'] . "</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" class="hlp_center"><input class="button" type="submit" name="submit" value="<?php echo $PALANG['pAdminCreate_admin_button']; ?>" /></td>
</tr>
<tr>
<td colspan="2" class="standout"><?php echo $message ?? '&nbsp;'; ?></td>
</tr>
</table>
</form>
</div>

View File

@ -73,9 +73,7 @@ if (count($list_mailbox) > 0) {
print " <tr class=\"header\">\n"; print " <tr class=\"header\">\n";
print " <td>" . $PALANG['pAdminList_virtual_mailbox_username'] . "</td>\n"; print " <td>" . $PALANG['pAdminList_virtual_mailbox_username'] . "</td>\n";
print " <td>" . $PALANG['pAdminList_virtual_mailbox_name'] . "</td>\n"; print " <td>" . $PALANG['pAdminList_virtual_mailbox_name'] . "</td>\n";
if ($CONF['quota'] == 'YES') print " <td>" . $PALANG['pAdminList_virtual_mailbox_quota'] . "</td>\n";
print " <td>" . $PALANG['pAdminList_virtual_mailbox_modified'] . "</td>\n"; print " <td>" . $PALANG['pAdminList_virtual_mailbox_modified'] . "</td>\n";
print " <td>" . $PALANG['pAdminList_virtual_mailbox_active'] . "</td>\n";
print " <td colspan=\"2\">&nbsp;</td>\n"; print " <td colspan=\"2\">&nbsp;</td>\n";
print " </tr>\n"; print " </tr>\n";
@ -84,8 +82,6 @@ if (count($list_mailbox) > 0) {
print " <td>" . $row['username'] . "</td>\n"; print " <td>" . $row['username'] . "</td>\n";
print " <td>" . $row['name'] . "</td>\n"; print " <td>" . $row['name'] . "</td>\n";
print " <td>" . $row['modified'] . "</td>\n"; print " <td>" . $row['modified'] . "</td>\n";
$active = ($row['active'] == 1) ? $PALANG['YES'] : $PALANG['NO'];
print " <td><a href=\"edit-active.php?username=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\">" . $active . "</a></td>\n";
print " <td><a href=\"edit-mailbox.php?username=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n"; print " <td><a href=\"edit-mailbox.php?username=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n";
print " <td><a href=\"delete.php?table=mailbox" . "&delete=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $PALANG['del'] . "</a></td>\n"; print " <td><a href=\"delete.php?table=mailbox" . "&delete=" . urlencode($row['username']) . "&domain=" . $list_domains[$selected_domain]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $row['username'] . "')\">" . $PALANG['del'] . "</a></td>\n";
print " </tr>\n"; print " </tr>\n";