Initial commit
This commit is contained in:
commit
386bf42a35
|
@ -0,0 +1,2 @@
|
|||
config.inc.php
|
||||
/admin/.htpasswd
|
|
@ -0,0 +1,13 @@
|
|||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
|
@ -0,0 +1,4 @@
|
|||
## OpenSMTPD Admin
|
||||
|
||||
Fork of Postfix Admin 2.1.0 (released in 2007)
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright (c) 2022 Mischa Peters <mischa @ high5.nl>
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
use 5.024;
|
||||
use strict;
|
||||
use warnings;
|
||||
use autodie;
|
||||
use Getopt::Std;
|
||||
use DBI;
|
||||
|
||||
my $db_type = 'MariaDB';
|
||||
my $db_host = '';
|
||||
my $db_user = '';
|
||||
my $db_pass = '';
|
||||
my $db_name = '';
|
||||
|
||||
getopts('dv');
|
||||
our($opt_d, $opt_v);
|
||||
|
||||
my $email = "";
|
||||
my $from = "";
|
||||
my %ooo;
|
||||
my $dbh = DBI->connect("DBI:$db_type:$db_name:$db_host", "$db_user", "$db_pass", {RaiseError => 1});
|
||||
sub do_query {
|
||||
my ($query) = @_;
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute;
|
||||
return $sth;
|
||||
}
|
||||
|
||||
open (my $fh, '>', "/tmp/virtualvacation.log") if ($opt_d);
|
||||
select(STDOUT);
|
||||
$|++;
|
||||
select($fh);
|
||||
$|++;
|
||||
print STDOUT "register|filter|smtp-in|rcpt-to\n";
|
||||
print STDOUT "register|filter|smtp-in|mail-from\n";
|
||||
print STDOUT "register|filter|smtp-in|data-line\n";
|
||||
print STDOUT "register|ready\n";
|
||||
|
||||
while (my $line = <>) {
|
||||
next if ($line =~ m/^config/);
|
||||
chomp $line;
|
||||
print $fh "$line\n" if ($opt_v);
|
||||
if ($line =~ m/filter/) {
|
||||
my ($stream, $version, $timestamp, $subsystem, $event, $sid, $token, $data) = split /\|/, $line;
|
||||
if ($line =~ m/mail-from/) {
|
||||
$from = $data;
|
||||
print STDOUT "filter-result|$sid|$token|proceed\n";
|
||||
}
|
||||
if ($line =~ m/rcpt-to/) {
|
||||
$email = $data;
|
||||
$ooo{$sid} = 1;
|
||||
print $fh "Virtual Vacation: created session $sid\n";
|
||||
print STDOUT "filter-result|$sid|$token|proceed\n";
|
||||
}
|
||||
if ($line =~ m/data-line/) {
|
||||
if (!$data) { $data = ""; }
|
||||
if ($data =~ m/^precedence:\s+(bulk|list|junk)/i) { $ooo{$sid} = 0; }
|
||||
if ($data =~ m/^x-loop:\s+opensmtpd\ admin\ virtual\ vacation/i) { $ooo{$sid} = 0; }
|
||||
print STDOUT "filter-dataline|$sid|$token|$data\n";
|
||||
}
|
||||
if ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 1) {
|
||||
print $fh "Virtual Vacation: To: $email, From: $from\n" if ($opt_d);
|
||||
my $query = qq{SELECT subject,body FROM vacation WHERE email='$email' and active=1};
|
||||
my $sth = do_query($query);
|
||||
my $rv = $sth->rows;
|
||||
if ($rv == 1) {
|
||||
my @row = $sth->fetchrow_array;
|
||||
print $fh "Virtual Vacation: Found OOO for $email\n" if ($opt_d);
|
||||
$query = qq{SELECT cache FROM vacation WHERE email='$email' AND FIND_IN_SET('$from',cache)};
|
||||
$sth = do_query ($query);
|
||||
$rv = $sth->rows;
|
||||
if ($rv == 0) {
|
||||
$query = qq{UPDATE vacation SET cache=CONCAT(cache,',','$from') WHERE email='$email'};
|
||||
$sth = do_query($query);
|
||||
print $fh "Virtual Vacation: Sending OOO to $from\n" if ($opt_d);
|
||||
open my $fh_email, "|-", "/usr/sbin/sendmail -t";
|
||||
print $fh_email "From: $email\n";
|
||||
print $fh_email "To: $from\n";;
|
||||
print $fh_email "Subject: $row[0]\n";
|
||||
print $fh_email "X-Loop: OpenSMTPD Admin Virtual Vacation\n";
|
||||
print $fh_email "Content-Type: text/plain; charset=utf-8\n\n";
|
||||
print $fh_email "$row[1]\n";
|
||||
close $fh_email;
|
||||
}
|
||||
delete $ooo{$sid};
|
||||
print $fh "Virtual Vacation: removed session $sid\n" if ($opt_d);
|
||||
}
|
||||
} elsif ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 0) {
|
||||
delete $ooo{$sid};
|
||||
print $fh "Virtual Vacation: removed session $sid\n" if ($opt_d);
|
||||
}
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
0;
|
|
@ -0,0 +1,8 @@
|
|||
AuthUserFile /usr/local/www/mailadmin.high5.net/admin/.htpasswd
|
||||
AuthGroupFile /dev/null
|
||||
AuthName "Postfix Admin"
|
||||
AuthType Basic
|
||||
|
||||
<limit GET POST>
|
||||
require valid-user
|
||||
</limit>
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: backup.php
|
||||
//
|
||||
// Template File: -none-
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
umask(077);
|
||||
$path = "/tmp/";
|
||||
$filename = "opensmtpadmin-" . date("Ymd") . "-" . getmypid() . ".sql";
|
||||
$backup = $path . $filename;
|
||||
|
||||
$header = "#\n# OpenSMTPD Admin $version\n# Date: " . date("D M j G:i:s T Y") . "\n#\n";
|
||||
|
||||
if (!$fh = fopen($backup, 'w')) {
|
||||
$tMessage = "<div class=\"error_msg\">Cannot open file ($backup)</div>";
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/message.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
} else {
|
||||
fwrite($fh, $header);
|
||||
|
||||
$tables = array('admin','alias','domain','domain_admins','log','mailbox','vacation');
|
||||
|
||||
for ($i = 0 ; $i < count($tables) ; ++$i) {
|
||||
$result = db_query("SHOW CREATE TABLE $tables[$i]");
|
||||
if ($result['rows'] > 0) {
|
||||
while ($row = db_array($result['result'])) {
|
||||
fwrite ($fh, "$row[1]\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0 ; $i < count($tables) ; ++$i) {
|
||||
$result = db_query("SELECT * FROM $tables[$i]");
|
||||
if ($result['rows'] > 0) {
|
||||
while ($row = db_assoc($result['result'])) {
|
||||
foreach ($row as $key => $val) {
|
||||
$fields[] = $key;
|
||||
$values[] = $val;
|
||||
}
|
||||
|
||||
fwrite($fh, "INSERT INTO ". $tables[$i] . " (". implode (',',$fields) . ") VALUES ('" . implode ('\',\'',$values) . "')\n");
|
||||
$fields = array();
|
||||
$values = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Disposition: attachment; filename=\"$filename\"");
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Content-Length: " . filesize("$backup"));
|
||||
header("Content-Description: OpenSMTPD Admin");
|
||||
$download_backup = fopen("$backup", "r");
|
||||
unlink("$backup");
|
||||
fpassthru($download_backup);
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,95 @@
|
|||
<?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();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text'];
|
||||
$tDomains = array();
|
||||
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_create-admin.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$fUsername = escape_string($_POST['fUsername']);
|
||||
$fPassword = escape_string($_POST['fPassword']);
|
||||
$fPassword2 = escape_string($_POST['fPassword2']);
|
||||
if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
|
||||
|
||||
if (!check_email($fUsername)) {
|
||||
$error = 1;
|
||||
$tUsername = escape_string($_POST['fUsername']);
|
||||
if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
|
||||
$pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text_error1'];
|
||||
}
|
||||
|
||||
if (empty($fUsername) or admin_exist($fUsername)) {
|
||||
$error = 1;
|
||||
$tUsername = escape_string($_POST['fUsername']);
|
||||
if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
|
||||
$pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text_error2'];
|
||||
}
|
||||
|
||||
if (empty($fPassword) or ($fPassword != $fPassword2)) {
|
||||
$error = 1;
|
||||
$tUsername = escape_string($_POST['fUsername']);
|
||||
if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
|
||||
$pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text'];
|
||||
$pAdminCreate_admin_password_text = $PALANG['pAdminCreate_admin_password_text_error'];
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
$password = pacrypt("$fPassword");
|
||||
$pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text'];
|
||||
|
||||
|
||||
$result = db_query("INSERT INTO admin (username,password,created,modified) VALUES ('$fUsername','$password',NOW(),NOW())");
|
||||
if ($result['rows'] != 1) {
|
||||
$tMessage = $PALANG['pAdminCreate_admin_result_error'] . "<br />($fUsername)<br />";
|
||||
} else {
|
||||
if (!empty($tDomains[0])) {
|
||||
for ($i = 0; $i < count($tDomains); $i++) {
|
||||
$domain = $tDomains[$i];
|
||||
$result = db_query("INSERT INTO domain_admins (username,domain,created) VALUES ('$fUsername','$domain',NOW())");
|
||||
}
|
||||
}
|
||||
$tMessage = $PALANG['pAdminCreate_admin_result_succes'] . "<br />($fUsername)</br />";
|
||||
}
|
||||
}
|
||||
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_create-admin.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,107 @@
|
|||
<?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
|
||||
// tDomain
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fAddress
|
||||
// fGoto
|
||||
// fDomain
|
||||
//
|
||||
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") {
|
||||
$pCreate_alias_goto_text = $PALANG['pCreate_alias_goto_text'];
|
||||
|
||||
if (isset($_GET['domain'])) $tDomain = escape_string($_GET['domain']);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$pCreate_alias_goto_text = $PALANG['pCreate_alias_goto_text'];
|
||||
|
||||
$fAddress = escape_string($_POST['fAddress']) . "@" . escape_string($_POST['fDomain']);
|
||||
$fAddress = strtolower($fAddress);
|
||||
$fGoto = escape_string($_POST['fGoto']);
|
||||
$fGoto = strtolower($fGoto);
|
||||
$fDomain = escape_string($_POST['fDomain']);
|
||||
|
||||
if (!preg_match('/@/',$fGoto)) {
|
||||
$fGoto = $fGoto . "@" . escape_string($_POST['fDomain']);
|
||||
}
|
||||
|
||||
if (!check_alias($fDomain)) {
|
||||
$error = 1;
|
||||
$tAddress = escape_string($_POST['fAddress']);
|
||||
$tGoto = $fGoto;
|
||||
$tDomain = $fDomain;
|
||||
$pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error3'];
|
||||
}
|
||||
|
||||
if (empty($fAddress) or !check_email($fAddress))
|
||||
{
|
||||
$error = 1;
|
||||
$tAddress = escape_string($_POST['fAddress']);
|
||||
$tGoto = $fGoto;
|
||||
$tDomain = $fDomain;
|
||||
$pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error1'];
|
||||
}
|
||||
|
||||
if (empty($fGoto) or !check_email($fGoto))
|
||||
{
|
||||
$error = 1;
|
||||
$tAddress = escape_string($_POST['fAddress']);
|
||||
$tGoto = $fGoto;
|
||||
$tDomain = $fDomain;
|
||||
$pCreate_alias_goto_text = $PALANG['pCreate_alias_goto_text_error'];
|
||||
}
|
||||
|
||||
if (escape_string($_POST['fAddress']) == "*") $fAddress = "@" . escape_string($_POST['fDomain']);
|
||||
|
||||
$result = db_query("SELECT * FROM alias WHERE address='$fAddress'");
|
||||
if ($result['rows'] == 1) {
|
||||
$error = 1;
|
||||
$tAddress = escape_string($_POST['fAddress']);
|
||||
$tGoto = $fGoto;
|
||||
$tDomain = $fDomain;
|
||||
$pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error2'];
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
if (preg_match('/^\*@(.*)$/', $fGoto, $match)) $fGoto = "@" . $match[1];
|
||||
|
||||
$result = db_query("INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW())");
|
||||
if ($result['rows'] != 1) {
|
||||
$tDomain = $fDomain;
|
||||
$tMessage = $PALANG['pCreate_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />";
|
||||
} else {
|
||||
db_log($CONF['admin_email'], $fDomain, "create alias", "$fAddress -> $fGoto");
|
||||
|
||||
$tDomain = $fDomain;
|
||||
$tMessage = $PALANG['pCreate_alias_result_succes'] . "<br />($fAddress -> $fGoto)</br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/create-alias.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,97 @@
|
|||
<?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("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$tAliases = $CONF['aliases'];
|
||||
$tMailboxes = $CONF['mailboxes'];
|
||||
$tMaxquota = $CONF['maxquota'];
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$fDomain = escape_string($_POST['fDomain']);
|
||||
!empty($_POST['fDescription']) ? $fDescription = escape_string($_POST['fDescription']) : $fDescription = "No Description";
|
||||
$fAliases = escape_string($_POST['fAliases']);
|
||||
$fMailboxes = escape_string($_POST['fMailboxes']);
|
||||
!empty($_POST['fMaxquota']) ? $fMaxquota = escape_string($_POST['fMaxquota']) : $fMaxquota = "0";
|
||||
!empty($_POST['fTransport']) ? $fTransport = escape_string($_POST['fTransport']) : $fTransport = "virtual";
|
||||
if (isset($_POST['fDefaultaliases'])) $fDefaultaliases = escape_string($_POST['fDefaultaliases']);
|
||||
isset($_POST['fBackupmx']) ? $fBackupmx = escape_string($_POST['fBackupmx']) : $fBackupmx = "0";
|
||||
|
||||
if (empty($fDomain) or domain_exist($fDomain)) {
|
||||
$error = 1;
|
||||
$tDomain = escape_string($_POST['fDomain']);
|
||||
$tDescription = escape_string($_POST['fDescription']);
|
||||
$tAliases = escape_string($_POST['fAliases']);
|
||||
$tMailboxes = escape_string($_POST['fMailboxes']);
|
||||
if (isset($_POST['fMaxquota'])) $tMaxquota = escape_string($_POST['fMaxquota']);
|
||||
if (isset($_POST['fTransport'])) $tTransport = escape_string($_POST['fTransport']);
|
||||
if (isset($_POST['fDefaultaliases'])) $tDefaultaliases = escape_string($_POST['fDefaultaliases']);
|
||||
if (isset($_POST['fBackupmx'])) $tBackupmx = escape_string($_POST['fBackupmx']);
|
||||
$pAdminCreate_domain_domain_text = $PALANG['pAdminCreate_domain_domain_text_error'];
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
$tAliases = $CONF['aliases'];
|
||||
$tMailboxes = $CONF['mailboxes'];
|
||||
$tMaxquota = $CONF['maxquota'];
|
||||
|
||||
if ($fBackupmx == "on") {
|
||||
$fAliases = -1;
|
||||
$fMailboxes = -1;
|
||||
$fMaxquota = -1;
|
||||
$fBackupmx = 1;
|
||||
} else {
|
||||
$fBackupmx = 0;
|
||||
}
|
||||
|
||||
$result = db_query("INSERT INTO domain (domain,description,aliases,mailboxes,maxquota,transport,backupmx,created,modified) VALUES ('$fDomain','$fDescription',$fAliases,$fMailboxes,$fMaxquota,'$fTransport',$fBackupmx,NOW(),NOW())");
|
||||
if ($result['rows'] != 1) {
|
||||
$tMessage = $PALANG['pAdminCreate_domain_result_error'] . "<br />($fDomain)<br />";
|
||||
} else {
|
||||
if ($fDefaultaliases == "on") {
|
||||
foreach ($CONF['default_aliases'] as $address=>$goto) {
|
||||
$address = $address . "@" . $fDomain;
|
||||
$result = db_query("INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$address','$goto','$fDomain',NOW(),NOW())");
|
||||
}
|
||||
}
|
||||
$tMessage = $PALANG['pAdminCreate_domain_result_succes'] . "<br />($fDomain)</br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_create-domain.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,191 @@
|
|||
<?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");
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: delete.php
|
||||
//
|
||||
// Template File: message.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fTable
|
||||
// fWhere
|
||||
// fDelete
|
||||
// fDomain
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if (isset($_GET['table'])) $fTable = escape_string($_GET['table']);
|
||||
if (isset($_GET['where'])) $fWhere = escape_string($_GET['where']);
|
||||
if (isset($_GET['delete'])) $fDelete = escape_string($_GET['delete']);
|
||||
if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
|
||||
|
||||
if (empty($fTable)) {
|
||||
$error = 1;
|
||||
}
|
||||
|
||||
if ($fTable == "domain") {
|
||||
$result_domain = db_delete("domain",$fWhere,$fDelete);
|
||||
$result_domain_admins = db_delete("domain_admins",$fWhere,$fDelete);
|
||||
$result_alias = db_delete("alias",$fWhere,$fDelete);
|
||||
$result_mailbox = db_delete("mailbox",$fWhere,$fDelete);
|
||||
$result_log = db_delete("log",$fWhere,$fDelete);
|
||||
if ($CONF['vacation'] == "YES") {
|
||||
$result_vacation = db_delete("vacation",$fWhere,$fDelete);
|
||||
}
|
||||
|
||||
if (!($result_domain == 1) and ($result_domain_admins >= 0) and ($result_alias >= 0) and ($result_mailbox >= 0) and ($result_vacation >= 0)) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pAdminDelete_domain_error'];
|
||||
} else {
|
||||
$url = "list-domain.php";
|
||||
}
|
||||
}
|
||||
|
||||
if ($fTable == "admin") {
|
||||
$result_admin = db_delete("admin",$fWhere,$fDelete);
|
||||
$result_domain_admins = db_delete("domain_admins",$fWhere,$fDelete);
|
||||
|
||||
if (!($result_admin == 1) and ($result_domain_admins >= 0)) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pAdminDelete_admin_error'];
|
||||
} else {
|
||||
$url = "list-admin.php";
|
||||
}
|
||||
}
|
||||
|
||||
if ($fTable == "alias" or $fTable == "mailbox") {
|
||||
$result = db_query("DELETE FROM alias WHERE address='$fDelete' AND domain='$fDomain'");
|
||||
if ($result['rows'] != 1) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (alias)!</div>";
|
||||
} else {
|
||||
$url = "list-virtual.php?domain=$fDomain";
|
||||
db_log($CONF['admin_email'], $fDomain, "delete alias", $fDelete);
|
||||
}
|
||||
|
||||
$result = db_query("SELECT * FROM mailbox WHERE username='$fDelete' AND domain='$fDomain'");
|
||||
if ($result['rows'] == 1) {
|
||||
$result = db_query("DELETE FROM mailbox WHERE username='$fDelete' AND domain='$fDomain'");
|
||||
if ($result['rows'] != 1) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (mailbox)!</div>";
|
||||
} else {
|
||||
$url = "list-virtual.php?domain=$fDomain";
|
||||
db_query("DELETE FROM vacation WHERE email='$fDelete' AND domain='$fDomain'");
|
||||
db_log($CONF['admin_email'], $fDomain, "delete mailbox", $fDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
header("Location: $url");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/message.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-active.php
|
||||
//
|
||||
// Template File: message.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fUsername
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if (isset($_GET['username'])) $fUsername = escape_string($_GET['username']);
|
||||
|
||||
$result = db_query("UPDATE admin SET active=1-active WHERE username='$fUsername'");
|
||||
if ($result['rows'] != 1) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pAdminEdit_admin_result_error'];
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
header("Location: list-admin.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/message.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-active.php
|
||||
//
|
||||
// Template File: message.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fDomain
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
|
||||
|
||||
$result = db_query("UPDATE domain SET active=1-active WHERE domain='$fDomain'");
|
||||
if ($result['rows'] != 1) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pAdminEdit_domain_result_error'];
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
header("Location: list-domain.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/message.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-active.php
|
||||
//
|
||||
// Template File: message.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fUsername
|
||||
// fDomain
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if (isset($_GET['username'])) $fUsername = escape_string($_GET['username']);
|
||||
if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']);
|
||||
|
||||
$result = db_query("UPDATE mailbox SET active=1-active WHERE username='$fUsername' AND domain='$fDomain'");
|
||||
if ($result['rows'] != 1) {
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pEdit_mailbox_result_error'];
|
||||
} else {
|
||||
db_log($CONF['admin_email'], $fDomain, "edit active", $fUsername);
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
header("Location: list-virtual.php?domain=$fDomain");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/message.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-admin.php
|
||||
//
|
||||
// Template File: admin_edit-admin.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") {
|
||||
$username = escape_string($_GET['username']);
|
||||
|
||||
$list_domains = list_domains();
|
||||
$tDomains = list_domains_for_admin($username);
|
||||
|
||||
$result = db_query("SELECT * FROM admin WHERE username='$username'");
|
||||
if ($result['rows'] == 1) {
|
||||
$row = db_array($result['result']);
|
||||
$tActive = $row['active'];
|
||||
}
|
||||
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_edit-admin.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$username = escape_string($_GET['username']);
|
||||
$fPassword = escape_string($_POST['fPassword']);
|
||||
$fPassword2 = escape_string($_POST['fPassword2']);
|
||||
$fActive = escape_string($_POST['fActive']);
|
||||
if (isset($_POST['fDomains'])) $tDomains = $_POST['fDomains'];
|
||||
|
||||
$list_domains = list_domains();
|
||||
|
||||
if ($fPassword != $fPassword2) {
|
||||
$error = 1;
|
||||
$tActive = escape_string($_POST['fActive']);
|
||||
$tDomains = escape_string($_POST['fDomains']);
|
||||
$pAdminEdit_admin_password_text = $PALANG['pAdminEdit_admin_password_text_error'];
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
if (empty($fPassword) and empty($fPassword2)) {
|
||||
if ($fActive == "on") $fActive = 1;
|
||||
$result = db_query("UPDATE admin SET modified=NOW(),active='$fActive' WHERE username='$username'");
|
||||
} else {
|
||||
$password = pacrypt($fPassword);
|
||||
if ($fActive == "on") $fActive = 1;
|
||||
$result = db_query("UPDATE admin SET password='$password',modified=NOW(),active='$fActive' WHERE username='$username'");
|
||||
}
|
||||
|
||||
if (count($tDomains) > 0) {
|
||||
for ($i = 0; $i < count($tDomains); $i++) {
|
||||
$domain = $tDomains[$i];
|
||||
$result_domains = db_query("INSERT INTO domain_admins (username,domain,created) VALUES ('$username','$domain',NOW())");
|
||||
}
|
||||
}
|
||||
|
||||
if ($result['rows'] == 1) {
|
||||
if (isset($tDomains[0])) {
|
||||
$result = db_query("DELETE FROM domain_admins WHERE username='$username'");
|
||||
for ($i = 0; $i < count($tDomains); $i++) {
|
||||
$domain = $tDomains[$i];
|
||||
$result = db_query("INSERT INTO domain_admins (username,domain,created) VALUES ('$username','$domain',NOW())");
|
||||
}
|
||||
}
|
||||
header("Location: list-admin.php");
|
||||
} else {
|
||||
$tMessage = $PALANG['pAdminEdit_admin_result_error'];
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_edit-admin.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-alias.php
|
||||
//
|
||||
// Template File: edit-alias.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
// tGoto
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fAddress
|
||||
// fDomain
|
||||
// fGoto
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$fAddress = escape_string($_GET['address']);
|
||||
$fDomain = escape_string($_GET['domain']);
|
||||
|
||||
$result = db_query("SELECT * FROM alias WHERE address='$fAddress' AND domain='$fDomain'");
|
||||
if ($result['rows'] == 1) {
|
||||
$row = db_array($result['result']);
|
||||
$tGoto = $row['goto'];
|
||||
} else {
|
||||
$tMessage = $PALANG['pEdit_alias_address_error'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$pEdit_alias_goto = $PALANG['pEdit_alias_goto'];
|
||||
|
||||
$fAddress = escape_string($_GET['address']);
|
||||
$fAddress = strtolower($fAddress);
|
||||
$fDomain = escape_string($_GET['domain']);
|
||||
$fGoto = escape_string($_POST['fGoto']);
|
||||
$fGoto = strtolower($fGoto);
|
||||
|
||||
if (empty($fGoto)) {
|
||||
$error = 1;
|
||||
$tGoto = $fGoto;
|
||||
$tMessage = $PALANG['pEdit_alias_goto_text_error1'];
|
||||
}
|
||||
|
||||
$goto = preg_replace('/\\\r\\\n/', ',', $fGoto);
|
||||
$goto = preg_replace('/\r\n/', ',', $goto);
|
||||
$goto = preg_replace('/[\s]+/i', '', $goto);
|
||||
$goto = preg_replace('/\,*$/', '', $goto);
|
||||
$array = preg_split('/,/', $goto);
|
||||
|
||||
for ($i = 0; $i < count($array); $i++) {
|
||||
if (in_array("$array[$i]", $CONF['default_aliases'])) continue;
|
||||
if (empty($array[$i])) continue;
|
||||
if (!check_email($array[$i]))
|
||||
{
|
||||
$error = 1;
|
||||
$tGoto = $goto;
|
||||
$tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$array[$i]</div>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
$result = db_query("UPDATE alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'");
|
||||
if ($result['rows'] != 1) {
|
||||
$tMessage = $PALANG['pEdit_alias_result_error'];
|
||||
} else {
|
||||
db_log($CONF['admin_email'], $fDomain, "edit alias", "$fAddress -> $goto");
|
||||
|
||||
header("Location: list-virtual.php?domain=$fDomain");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/edit-alias.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,79 @@
|
|||
<?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");
|
||||
?>
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: edit-mailbox.php
|
||||
//
|
||||
// Template File: edit-mailbox.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
// tName
|
||||
// tQuota
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fUsername
|
||||
// fDomain
|
||||
// fPassword
|
||||
// fPassword2
|
||||
// fName
|
||||
// fQuota
|
||||
// fActive
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$fUsername = escape_string($_GET['username']);
|
||||
$fDomain = escape_string($_GET['domain']);
|
||||
|
||||
$result = db_query("SELECT * FROM mailbox WHERE username='$fUsername' AND domain='$fDomain'");
|
||||
if ($result['rows'] == 1) {
|
||||
$row = db_array($result['result']);
|
||||
$tName = $row['name'];
|
||||
$tQuota = $row['quota'] / $CONF['quota_multiplier'];
|
||||
$tActive = $row['active'];
|
||||
} else {
|
||||
$tMessage = $PALANG['pEdit_mailbox_login_error'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$pEdit_mailbox_password_text = $PALANG['pEdit_mailbox_password_text_error'];
|
||||
$pEdit_mailbox_quota_text = $PALANG['pEdit_mailbox_quota_text'];
|
||||
|
||||
$fUsername = escape_string($_GET['username']);
|
||||
$fUsername = strtolower($fUsername);
|
||||
$fDomain = escape_string($_GET['domain']);
|
||||
|
||||
$fPassword = escape_string($_POST['fPassword']);
|
||||
$fPassword2 = escape_string($_POST['fPassword2']);
|
||||
$fName = escape_string($_POST['fName']);
|
||||
if (isset($_POST['fQuota'])) $fQuota = escape_string($_POST['fQuota']);
|
||||
if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']);
|
||||
|
||||
if ($fPassword != $fPassword2)
|
||||
{
|
||||
$error = 1;
|
||||
$tName = $fName;
|
||||
$tQuota = $fQuota;
|
||||
$tActive = $fActive;
|
||||
$pEdit_mailbox_password_text = $PALANG['pEdit_mailbox_password_text_error'];
|
||||
}
|
||||
|
||||
if ($CONF['quota'] == "YES") {
|
||||
if (!check_quota($fQuota, $fDomain)) {
|
||||
$error = 1;
|
||||
$tName = $fName;
|
||||
$tQuota = $fQuota;
|
||||
$tActive = $fActive;
|
||||
$pEdit_mailbox_quota_text = $PALANG['pEdit_mailbox_quota_text_error'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($error != 1) {
|
||||
if (!empty($fQuota)) {
|
||||
$quota = $fQuota * $CONF['quota_multiplier'];
|
||||
} else {
|
||||
$quota = 0;
|
||||
}
|
||||
|
||||
if ($fActive == "on") {
|
||||
$fActive = 1;
|
||||
} else {
|
||||
$fActive = 0;
|
||||
}
|
||||
|
||||
if (empty($fPassword) and empty($fPassword2)) {
|
||||
$result = db_query("UPDATE mailbox SET name='$fName',quota='$quota',modified=NOW(),active='$fActive' WHERE username='$fUsername' AND domain='$fDomain'");
|
||||
} else {
|
||||
$password = pacrypt($fPassword);
|
||||
$result = db_query("UPDATE mailbox SET password='$password',name='$fName',quota='$quota',modified=NOW(),active='$fActive',scheme='' WHERE username='$fUsername' AND domain='$fDomain'");
|
||||
}
|
||||
|
||||
if ($result['rows'] != 1) {
|
||||
$tMessage = $PALANG['pEdit_mailbox_result_error'];
|
||||
} else {
|
||||
db_log($CONF['admin_email'], $fDomain, "edit mailbox", $fUsername);
|
||||
header("Location: list-virtual.php?domain=$fDomain");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/edit-mailbox.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: index.php
|
||||
//
|
||||
// Template File: -none-
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
header ("Location: list-domain.php");
|
||||
exit;
|
||||
?>
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: list-admin.php
|
||||
//
|
||||
// Template File: list-admin.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
$list_admins = list_admins();
|
||||
|
||||
if (!empty($list_admins)) {
|
||||
$list_admins_count = count($list_admins);
|
||||
if ((is_array($list_admins) and $list_admins_count > 0)) {
|
||||
for ($i = 0; $i < $list_admins_count; $i++) {
|
||||
$admin_properties[$i] = get_admin_properties($list_admins[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_list-admin.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
//
|
||||
// OpenSMTPD Admin
|
||||
// by Mischa Peters <mischa at high5 dot nl>
|
||||
// Copyright (c) 2022 High5!
|
||||
// License Info: LICENSE.TXT
|
||||
//
|
||||
// File: list-domain.php
|
||||
//
|
||||
// Template File: admin_list-domain.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fUsername
|
||||
//
|
||||
require("../variables.inc.php");
|
||||
require("../config.inc.php");
|
||||
require("../functions.inc.php");
|
||||
include("../languages/" . check_language() . ".lang");
|
||||
|
||||
$list_admins = list_admins();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if (isset($_GET['username'])) {
|
||||
$fUsername = escape_string($_GET['username']);
|
||||
|
||||
$list_domains = list_domains_for_admin($fUsername);
|
||||
if ($list_domains != 0) {
|
||||
for ($i = 0; $i < count($list_domains); $i++) {
|
||||
$domain_properties[$i] = get_domain_properties($list_domains[$i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$list_domains = list_domains();
|
||||
if ((is_array($list_domains) and count($list_domains) > 0)) {
|
||||
for ($i = 0; $i < count($list_domains); $i++) {
|
||||
$domain_properties[$i] = get_domain_properties($list_domains[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$fUsername = escape_string($_POST['fUsername']);
|
||||
|
||||
$list_domains = list_domains_for_admin($fUsername);
|
||||
if (!empty($list_domains)) {
|
||||
for ($i = 0; $i < count($list_domains); $i++) {
|
||||
$domain_properties[$i] = get_domain_properties($list_domains[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
include("../templates/header.tpl");
|
||||
include("../templates/admin_menu.tpl");
|
||||
include("../templates/admin_list-domain.tpl");
|
||||
include("../templates/footer.tpl");
|
||||
?>
|
127
127