commit 386bf42a35e2603fdac0b26723a4d0e4e6bda7b8 from: mischa date: Thu Aug 18 12:01:52 2022 UTC Initial commit commit - /dev/null commit + 386bf42a35e2603fdac0b26723a4d0e4e6bda7b8 blob - /dev/null blob + 8e49dc8c193673617a760778a40a5ab010c6065e (mode 644) --- /dev/null +++ .gitignore @@ -0,0 +1,2 @@ +config.inc.php +/admin/.htpasswd blob - /dev/null blob + f708343d81fee1acdfff35834591488ab2c97f24 (mode 644) --- /dev/null +++ LICENSE.TXT @@ -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. +# blob - /dev/null blob + c42e60093ad87a269b4d5b9bb25488d03be41435 (mode 644) --- /dev/null +++ README.md @@ -0,0 +1,4 @@ +## OpenSMTPD Admin + +Fork of Postfix Admin 2.1.0 (released in 2007) + blob - /dev/null blob + c50ed759c7e7dae5266f497af3a9146d87fbc59b (mode 755) --- /dev/null +++ VIRTUAL_VACATION/vacation.pl @@ -0,0 +1,110 @@ +#!/usr/bin/env perl +# +# Copyright (c) 2022 Mischa Peters +# +# 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; blob - /dev/null blob + 4dc0a29c1dab8aec43a9dd43eee77cb1eecbec15 (mode 644) --- /dev/null +++ admin/.htaccess @@ -0,0 +1,8 @@ +AuthUserFile /usr/local/www/mailadmin.high5.net/admin/.htpasswd +AuthGroupFile /dev/null +AuthName "Postfix Admin" +AuthType Basic + + +require valid-user + blob - /dev/null blob + 2996e681a5ec8179d671394838e08e4d828ea4dd (mode 644) --- /dev/null +++ admin/backup.php @@ -0,0 +1,78 @@ + +// 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 = "
Cannot open file ($backup)
"; + 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); +} +?> blob - /dev/null blob + fa28d2fca200acdc3a03579bd6d78d6d5b382085 (mode 644) --- /dev/null +++ admin/create-admin.php @@ -0,0 +1,95 @@ + +// 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'] . "
($fUsername)
"; + } 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'] . "
($fUsername)
"; + } + } + + include("../templates/header.tpl"); + include("../templates/admin_menu.tpl"); + include("../templates/admin_create-admin.tpl"); + include("../templates/footer.tpl"); +} +?> blob - /dev/null blob + 6c54a20be4d06984f5e0b38ba4a22742bee208f2 (mode 644) --- /dev/null +++ admin/create-alias.php @@ -0,0 +1,107 @@ + +// 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'] . "
($fAddress -> $fGoto)
"; + } else { + db_log($CONF['admin_email'], $fDomain, "create alias", "$fAddress -> $fGoto"); + + $tDomain = $fDomain; + $tMessage = $PALANG['pCreate_alias_result_succes'] . "
($fAddress -> $fGoto)
"; + } + } +} +include("../templates/header.tpl"); +include("../templates/admin_menu.tpl"); +include("../templates/create-alias.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + cd5ed76efe610f1286d548fd3e5542f7f0c9fb26 (mode 644) --- /dev/null +++ admin/create-domain.php @@ -0,0 +1,97 @@ + +// 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'] . "
($fDomain)
"; + } 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'] . "
($fDomain)
"; + } + } +} +include("../templates/header.tpl"); +include("../templates/admin_menu.tpl"); +include("../templates/admin_create-domain.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + 22815262041f5c5956f691a060e43f77d2c2dfb1 (mode 644) --- /dev/null +++ admin/create-mailbox.php @@ -0,0 +1,191 @@ + +// 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'] . "
($fUsername -> $fUsername)
"; + } + + $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'] . "
($fUsername)
"; + } else { + + db_log($CONF['admin_email'], $fDomain, "create mailbox", $fUsername); + + $tDomain = $fDomain; + $tMessage = $PALANG['pCreate_mailbox_result_succes'] . "
($fUsername"; + if ($CONF['generate_password'] == "YES") { + $tMessage .= " / $fPassword)
"; + } else { + $tMessage .= ")
"; + } + + + $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 .= "
" . $PALANG['pSendmail_result_error'] . "
"; + } else { + $tMessage .= "
" . $PALANG['pSendmail_result_succes'] . "
"; + } + } + } + } + + include("../templates/header.tpl"); + include("../templates/admin_menu.tpl"); + include("../templates/create-mailbox.tpl"); + include("../templates/footer.tpl"); +} +?> blob - /dev/null blob + a36a41f0d9a0ddd9445c89ed8d9d20bc65a658f3 (mode 644) --- /dev/null +++ admin/delete.php @@ -0,0 +1,101 @@ + +// 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'] . "$fDelete (alias)!"; + } 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'] . "$fDelete (mailbox)!"; + } 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"); +?> blob - /dev/null blob + dce19d10cfeff328b8c4925f51a3033b66149cbb (mode 644) --- /dev/null +++ admin/edit-active-admin.php @@ -0,0 +1,43 @@ + +// 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"); +?> blob - /dev/null blob + 88dca998d5e5dab9b8bf07fbf48f5e57a2f5b3f7 (mode 644) --- /dev/null +++ admin/edit-active-domain.php @@ -0,0 +1,43 @@ + +// 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"); +?> blob - /dev/null blob + 63c1c6fce9ade700d2b1690e714e15e43e90e87f (mode 644) --- /dev/null +++ admin/edit-active.php @@ -0,0 +1,47 @@ + +// 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"); +?> blob - /dev/null blob + 97388aad49373b07d48fe7eb116761bca47ab20e (mode 644) --- /dev/null +++ admin/edit-admin.php @@ -0,0 +1,101 @@ + +// 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"); +} +?> blob - /dev/null blob + 79452236ce2d50f2094fb6085d2385fbeda9db6f (mode 644) --- /dev/null +++ admin/edit-alias.php @@ -0,0 +1,89 @@ + +// 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]"; + } + } + + 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"); +?> blob - /dev/null blob + 351ba00448d694c074ed164916d34b939d8de54d (mode 644) --- /dev/null +++ admin/edit-domain.php @@ -0,0 +1,79 @@ + +// 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"); +?> blob - /dev/null blob + 0d4baccbdb01eb4594639174302beea3cdcab84c (mode 644) --- /dev/null +++ admin/edit-mailbox.php @@ -0,0 +1,114 @@ + +// 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"); +?> blob - /dev/null blob + a11416a6d209dd64a130a20096f1d54a5af5472f (mode 644) --- /dev/null +++ admin/index.php @@ -0,0 +1,22 @@ + +// 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; +?> blob - /dev/null blob + e2f96c721e7581314c2a0f4c3c45c8d5063a1466 (mode 644) --- /dev/null +++ admin/list-admin.php @@ -0,0 +1,40 @@ + +// 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"); +?> blob - /dev/null blob + 185ba574954c51c7ca64f93005e8e3f41feb8bc4 (mode 644) --- /dev/null +++ admin/list-domain.php @@ -0,0 +1,61 @@ + +// 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"); +?> blob - /dev/null blob + 3f86a84ff7d40303e6544819f5f6c491b31d126c (mode 644) --- /dev/null +++ admin/list-virtual.php @@ -0,0 +1,127 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: list-virtual.php +// +// Template File: admin_list-virtual.tpl +// +// Template Variables: +// +// tMessage +// tAlias +// tMailbox +// +// Form POST \ GET Variables: +// +// fDomain +// +require("../variables.inc.php"); +require("../config.inc.php"); +require("../functions.inc.php"); +include("../languages/" . check_language() . ".lang"); + +$list_domains = list_domains(); + +$tAlias = array(); +$tMailbox = array(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $fDisplay = 0; + $page_size = $CONF['page_size']; + + if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']); + if (isset($_GET['limit'])) $fDisplay = escape_string($_GET['limit']); + + if ((is_array($list_domains) and count($list_domains) > 0)) if (empty($fDomain)) $fDomain = $list_domains[0]; + + $limit = get_domain_properties($fDomain); + + if ((is_array($list_domains) and count($list_domains) > 0)) if (empty($fDomain)) $fDomain = $list_domains[1]; + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } + + $result = db_query("$query"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tAlias[] = $row; + } + } + + $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tMailbox[] = $row; + } + } + + if (isset($limit)) { + if ($fDisplay >= $page_size) { + $tDisplay_back_show = 1; + $tDisplay_back = $fDisplay - $page_size; + } + if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { + $tDisplay_up_show = 1; + } + if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) { + $tDisplay_next_show = 1; + $tDisplay_next = $fDisplay + $page_size; + } + } +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fDisplay = 0; + $page_size = $CONF['page_size']; + + $fDomain = escape_string($_POST['fDomain']); + if (isset($_POST['limit'])) $fDisplay = escape_string($_POST['limit']); + + $limit = get_domain_properties($fDomain); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } + + $result = db_query("$query"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tAlias[] = $row; + } + } + + $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tMailbox[] = $row; + } + } + + if (isset($limit)) { + if ($fDisplay >= $page_size) { + $tDisplay_back_show = 1; + $tDisplay_back = $fDisplay - $page_size; + } + if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { + $tDisplay_up_show = 1; + } + if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) { + $tDisplay_next_show = 1; + $tDisplay_next = $fDisplay + $page_size; + } + } +} +include("../templates/header.tpl"); +include("../templates/admin_menu.tpl"); +include("../templates/admin_list-virtual.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + a600b2e9a1a5611d931232595747bb6906404ce4 (mode 644) --- /dev/null +++ admin/search.php @@ -0,0 +1,82 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: search.php +// +// Template File: search.tpl +// +// Template Variables: +// +// tAlias +// tMailbox +// +// Form POST \ GET Variables: +// +// fSearch +// +require("../variables.inc.php"); +require("../config.inc.php"); +require("../functions.inc.php"); +include("../languages/" . check_language() . ".lang"); + +$tAlias = array(); +$tMailbox = array(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + if (isset($_GET['search'])) $fSearch = escape_string($_GET['search']); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias WHERE alias.address LIKE '%$fSearch%' OR alias.goto LIKE '%$fSearch%' ORDER BY alias.address"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE '%$fSearch%' AND mailbox.maildir IS NULL ORDER BY alias.address"; + } + + $result = db_query("$query"); + + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tAlias[] = $row; + } + } + + $result = db_query("SELECT * FROM mailbox WHERE username LIKE '%$fSearch%' ORDER BY username"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tMailbox[] = $row; + } + } +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + if (isset($_POST['search'])) $fSearch = escape_string($_POST['search']); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias WHERE alias.address LIKE '%$fSearch%' OR alias.goto LIKE '%$fSearch%' ORDER BY alias.address"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE '%$fSearch%' AND mailbox.maildir IS NULL ORDER BY alias.address"; + } + + $result = db_query("$query"); + + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tAlias[] = $row; + } + } + + $result = db_query("SELECT * FROM mailbox WHERE username LIKE '%$fSearch%' ORDER BY username"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tMailbox[] = $row; + } + } +} +include("../templates/header.tpl"); +include("../templates/admin_menu.tpl"); +include("../templates/admin_search.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + 4f60f29896f962357b72773c63714cae32944c12 (mode 644) --- /dev/null +++ admin/viewlog.php @@ -0,0 +1,54 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: viewlog.php +// +// Template File: viewlog.tpl +// +// Template Variables: +// +// tMessage +// tLog +// +// Form POST \ GET Variables: +// +// 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") { + + if ((is_array($list_domains) and count($list_domains) > 0)) $fDomain = $list_domains[0]; + + $result = db_query("SELECT * FROM log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tLog[] = $row; + } + } +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fDomain = escape_string($_POST['fDomain']); + + $result = db_query("SELECT * FROM log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tLog[] = $row; + } + } +} +include("../templates/header.tpl"); +include("../templates/admin_menu.tpl"); +include("../templates/viewlog.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + c9c83978f5f0bb1d8df10e507e3cbb0317ba10a3 (mode 644) --- /dev/null +++ config.inc.php.sample @@ -0,0 +1,123 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: config.inc.php +// +if (preg_match("/config.inc.php/", $_SERVER['SCRIPT_NAME'])) { + header("Location: login.php"); + exit; +} + +// Language config +// Language files are located in './languages'. +$CONF['default_language'] = 'en'; + +// Database Config +// mysqli = MySQL 4.1 +// pgsql = PostgreSQL +$CONF['database_type'] = 'mysqli'; +$CONF['database_host'] = 'localhost'; +$CONF['database_user'] = 'opensmtpdadmin'; +$CONF['database_password'] = 'RandomStringOfChars'; +$CONF['database_name'] = 'opensmtpd'; +$CONF['database_prefix'] = ''; + +// Site Admin +// Define the Site Admins email address below. +// This will be used to send emails from to create mailboxes. +$CONF['admin_email'] = 'postmaster@change-this-to-your.domain.tld'; + +// Encrypt +$CONF['encrypt'] = 'bcrypt'; + +// Generate Password +// Generate a random password for a mailbox and display it. +// If you want to automagically generate paswords set this to 'YES'. +$CONF['generate_password'] = 'NO'; + +// Page Size +// Set the number of entries that you would like to see +// in one page. +$CONF['page_size'] = '25'; + +// Default Aliases +// The default aliases that need to be created for all domains. +$CONF['default_aliases'] = array ( + 'abuse' => 'abuse@change-this-to-your.domain.tld', + 'hostmaster' => 'hostmaster@change-this-to-your.domain.tld', + 'postmaster' => 'postmaster@change-this-to-your.domain.tld', + 'webmaster' => 'webmaster@change-this-to-your.domain.tld' +); + +// Mailboxes +// If you want to store the mailboxes per domain set this to 'YES'. +// Example: /usr/local/virtual/domain.tld/username@domain.tld +$CONF['domain_path'] = 'NO'; +// If you don't want to have the domain in your mailbox set this to 'NO'. +// Example: /usr/local/virtual/domain.tld/username +$CONF['domain_in_mailbox'] = 'YES'; + +// Default Domain Values +// Specify your default values below. Quota in MB. +$CONF['aliases'] = '10'; +$CONF['mailboxes'] = '10'; +$CONF['maxquota'] = '0'; + +// Quota +// When you want to enforce quota for your mailbox users set this to 'YES'. +$CONF['quota'] = 'NO'; +// You can either use '1024000' or '1048576' +$CONF['quota_multiplier'] = '1024000'; + +// Transport +// If you want to define additional transport options for a domain set this to 'YES'. +// Read the transport file of the OpenSMTPD documentation. +$CONF['transport'] = 'NO'; + +// Virtual Vacation +// If you want to use virtual vacation for you mailbox users set this to 'YES'. +$CONF['vacation'] = 'NO'; + +// Alias Control +// OpenSMTPD Admin inserts an alias in the alias table for every mailbox it creates. +// The reason for this is that when you want catch-all and normal mailboxes +// to work you need to have the mailbox replicated in the alias table. +// If you want to take control of these aliases as well set this to 'YES'. +$CONF['alias_control'] = 'NO'; + +// Special Alias Control +// Set to 'NO' if you don't want your domain admins to change the default aliases. +$CONF['special_alias_control'] = 'YES'; + +// Logging +// If you don't want logging set this to 'NO'; +$CONF['logging'] = 'YES'; + +// Header +$CONF['show_header_text'] = 'NO'; +$CONF['header_text'] = ':: OpenSMTPD Admin ::'; + +// Footer +// Below information will be on all pages. +// If you don't want the footer information to appear set this to 'NO'. +$CONF['show_footer_text'] = 'YES'; +$CONF['footer_text'] = 'Return to change-this-to-your.domain.tld!'; +$CONF['footer_link'] = 'http://change-this-to-your.domain.tld/'; + +// Welcome Message +// This message is send to every newly created mailbox. +// Change the text between EOM. +$CONF['welcome_text'] = << blob - /dev/null blob + 0dd2b61aa1e5685835172742b822614f9e94a5b6 (mode 644) --- /dev/null +++ create-alias.php @@ -0,0 +1,114 @@ + +// 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"); + +$SESSID_USERNAME = check_session(); +$list_domains = list_domains_for_admin($SESSID_USERNAME); + +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_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tAddress = escape_string($_POST['fAddress']); + $tGoto = $fGoto; + $tDomain = $fDomain; + $pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error1']; + } + + 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'] . "
($fAddress -> $fGoto)
\n"; + } else { + db_log($SESSID_USERNAME, $fDomain, "create alias", "$fAddress -> $fGoto"); + + $tDomain = $fDomain; + $tMessage = $PALANG['pCreate_alias_result_succes'] . "
($fAddress -> $fGoto)
\n"; + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/create-alias.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 29de1d6eea9d9c4c828767591acba0786163df58 (mode 644) --- /dev/null +++ create-mailbox.php @@ -0,0 +1,193 @@ + +// 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"); + +$SESSID_USERNAME = check_session(); +$list_domains = list_domains_for_admin($SESSID_USERNAME); + +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']); +} + +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']); + $fName = escape_string($_POST['fName']); + $fDomain = escape_string($_POST['fDomain']); + if (isset($_POST['fQuota'])) $fQuota = escape_string($_POST['fQuota']); + if (isset($_POST['fActive'])) $fActive = escape_string($_POST['fActive']); + if (isset($_POST['fMail'])) $fMail = escape_string($_POST['fMail']); + + if (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tUsername = escape_string($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; + } + + 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'] . "
($fUsername -> $fUsername)
"; + } + + $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'] . "
($fUsername)
"; + } else { + db_log($SESSID_USERNAME, $fDomain, "create mailbox", "$fUsername"); + + $tDomain = $fDomain; + $tMessage = $PALANG['pCreate_mailbox_result_succes'] . "
($fUsername"; + if ($CONF['generate_password'] == "YES") { + $tMessage .= " / $fPassword)
"; + } else { + $tMessage .= ")
"; + } + + $tQuota = $CONF['maxquota']; + + if ($fMail == "on") { + $fTo = $fUsername; + $fSubject = $PALANG['pSendmail_subject_text']; + $fHeaders = "From: " . $SESSID_USERNAME . "\r\n"; + $fHeaders .= "Content-Type: text/plain; charset=utf-8\r\n"; + $fBody = $CONF['welcome_text']; + + if (!mail($fTo, $fSubject, $fBody, $fHeaders)) { + $tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
"; + } else { + $tMessage .= "
" . $PALANG['pSendmail_result_succes'] . "
"; + } + } + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/create-mailbox.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 6fddc13292e78fa25154677d9f25b0303f89eb70 (mode 644) --- /dev/null +++ delete.php @@ -0,0 +1,75 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: delete.php +// +// Template File: message.tpl +// +// Template Variables: +// +// tMessage +// +// Form POST \ GET Variables: +// +// fDelete +// fDomain +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + if (isset($_GET['delete'])) $fDelete = escape_string($_GET['delete']); + if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']); + + if (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tMessage = $PALANG['pDelete_domain_error'] . "$fDomain!"; + } else { + + $result = db_query("DELETE FROM alias WHERE address='$fDelete' AND domain='$fDomain'"); + if ($result['rows'] != 1) { + $error = 1; + $tMessage = $PALANG['pDelete_delete_error'] . "$fDelete (alias)!"; + } else { + db_log($SESSID_USERNAME, $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'] . "$fDelete (mailbox)!"; + } else { + db_query("DELETE FROM vacation WHERE email='$fDelete' AND domain='$fDomain'"); + db_log($SESSID_USERNAME, $fDomain, "delete mailbox", $fDelete); + } + } + } + + if ($error != 1) { + header("Location: overview.php?domain=$fDomain"); + exit; + } + + include("./templates/header.tpl"); + include("./templates/menu.tpl"); + include("./templates/message.tpl"); + include("./templates/footer.tpl"); +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + include("./templates/header.tpl"); + include("./templates/menu.tpl"); + include("./templates/message.tpl"); + include("./templates/footer.tpl"); +} +?> blob - /dev/null blob + 1eba32a7e3a58ddd9b3fd0b8eb5ec03c0c377624 (mode 644) --- /dev/null +++ edit-active.php @@ -0,0 +1,54 @@ + +// 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"); + +$SESSID_USERNAME = check_session(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + if (isset($_GET['username'])) $fUsername = escape_string($_GET['username']); + if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']); + + if (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tMessage = $PALANG['pEdit_mailbox_domain_error'] . "$fDomain!"; + } else { + $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($SESSID_USERNAME, $fDomain, "edit active", $fUsername); + } + } + + if ($error != 1) { + header("Location: overview.php?domain=$fDomain"); + exit; + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/message.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 0c129c7cfea43b9431e9544e870a529b2c23ef32 (mode 644) --- /dev/null +++ edit-alias.php @@ -0,0 +1,101 @@ + +// 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"); + +$SESSID_USERNAME = check_session(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $fAddress = escape_string($_GET['address']); + $fDomain = escape_string($_GET['domain']); + + if (check_owner($SESSID_USERNAME, $fDomain)) { + $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 (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tGoto = $fGoto; + $tMessage = $PALANG['pEdit_alias_domain_error'] . "$fDomain"; + } + + 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/', ',', $fGoto); + $goto = preg_replace('/[\s]+/i', '', $goto); + $goto = preg_replace('/\,*$/', '', $goto); + $array = preg_split('/,/', $goto); + + if (!empty($array)) { $array_count = count($array); } + + for($i = 0; $i < $array_count; $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]"; + } + } + + 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($SESSID_USERNAME, $fDomain, "edit alias", "$fAddress -> $goto"); + + header("Location: overview.php?domain=$fDomain"); + exit; + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/edit-alias.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 11eb4b0a0716b2005472fa5fa0ff255978534f7a (mode 644) --- /dev/null +++ edit-mailbox.php @@ -0,0 +1,132 @@ + +// 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"); + +$SESSID_USERNAME = check_session(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $fUsername = escape_string($_GET['username']); + $fDomain = escape_string($_GET['domain']); + + if (check_owner($SESSID_USERNAME, $fDomain)) { + $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']; + } + + include("./templates/header.tpl"); + include("./templates/menu.tpl"); + include("./templates/edit-mailbox.tpl"); + include("./templates/footer.tpl"); +} + +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 (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tName = $fName; + $tQuota = $fQuota; + $tActive = $fActive; + $tMessage = $PALANG['pEdit_mailbox_domain_error'] . "$fDomain"; + } + + 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($SESSID_USERNAME, $fDomain, "edit mailbox", $fUsername); + + header("Location: overview.php?domain=$fDomain"); + exit; + } + } + + include("./templates/header.tpl"); + include("./templates/menu.tpl"); + include("./templates/edit-mailbox.tpl"); + include("./templates/footer.tpl"); +} +?> blob - /dev/null blob + 24c6ce2e0323cbcd98cf008f884f4ba30e6ba752 (mode 644) --- /dev/null +++ functions.inc.php @@ -0,0 +1,534 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: functions.inc.php +// +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); + +if(preg_match("/functions.inc.php/", $_SERVER['SCRIPT_NAME'])) { + header("Location: login.php"); + exit; +} + +$version = "1.0.0"; + +// +// check_session +// Action: Check if a session already exists, if not redirect to login.php +// Call: check_session() -or- check_user_session() +// +function check_session() { + session_start(); + if (!isset($_SESSION['sessid']['username'])) { + header("Location: login.php"); + exit; + } + $SESSID_USERNAME = $_SESSION['sessid']['username']; + return $SESSID_USERNAME; +} + +function check_user_session() { + session_start(); + if (!isset($_SESSION['userid']['username'])) { + header("Location: login.php"); + exit; + } + $USERID_USERNAME = $_SESSION['userid']['username']; + return $USERID_USERNAME; +} + +// +// check_language +// Action: checks what language the browser uses +// Call: check_language +// +function check_language() { + global $CONF; + // Currently only English is supported, no need to run through the check now. + return $CONF['default_language']; +} + +// +// check_string +// Action: checks if a string is valid and returns TRUE is this is the case. +// Call: check_string(string var) +// +function check_string($var) { + if (preg_match('/^([A-Za-z0-9 ]+)+$/', $var)) { + return true; + } else { + return false; + } +} + +// +// check_email +// Action: Checks if email is valid and returns TRUE if this is the case. +// Call: check_email(string email) +// +function check_email($email) { + if (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,10}$/i', trim($email))) { + return true; + } else { + return false; + } +} + +// +// escape_string +// Action: Escape a string +// Call: escape_string(string string) +// +function escape_string($string) { + global $CONF; + $escaped_string = $string; + return $escaped_string; +} + +// +// get_domain_properties +// Action: Get all the properties of a domain. +// Call: get_domain_properties(string domain) +// +function get_domain_properties($domain) { + global $CONF; + $list = array(); + + $result = db_query("SELECT COUNT(*) FROM alias WHERE domain='$domain'"); + $row = db_row($result['result']); + $list['alias_count'] = $row[0]; + + $result = db_query("SELECT COUNT(*) FROM mailbox WHERE domain='$domain'"); + $row = db_row($result['result']); + $list['mailbox_count'] = $row[0]; + if ($CONF['alias_control'] == "NO") { + $list['alias_count'] = $list['alias_count'] - $list['mailbox_count']; + } else { + $list['alias_count'] = $list['alias_count']; + } + + $result = db_query("SELECT * FROM domain WHERE domain='$domain'"); + $row = db_array($result['result']); + $list['description'] = $row['description']; + $list['aliases'] = $row['aliases']; + $list['mailboxes'] = $row['mailboxes']; + $list['maxquota'] = $row['maxquota']; + $list['transport'] = $row['transport']; + $list['backupmx'] = $row['backupmx']; + $list['created'] = $row['created']; + $list['modified'] = $row['modified']; + $list['active'] = $row['active']; + + if ($CONF['database_type'] == "pgsql") { + if ($row['active'] == "t") + { + $list['active'] = 1; + } else { + $list['active'] = 0; + } + + if ($row['backupmx'] == "t") { + $list['backupmx'] = 1; + } else { + $list['backupmx'] = 0; + } + } else { + $list['active'] = $row['active']; + $list['backupmx'] = $row['backupmx']; + } + return $list; +} + +// +// check_alias +// Action: Checks if the domain is still able to create aliases. +// Call: check_alias(string domain) +// +function check_alias($domain) { + $limit = get_domain_properties($domain); + if ($limit['aliases'] == 0) { + return true; + } + if ($limit['aliases'] < 0) { + return false; + } + if ($limit['alias_count'] >= $limit['aliases']) { + return false; + } else { + return true; + } +} + +// +// check_mailbox +// Action: Checks if the domain is still able to create mailboxes. +// Call: ceck_mailbox(string domain) +// +function check_mailbox($domain) { + $limit = get_domain_properties($domain); + if ($limit['mailboxes'] == 0) { + return true; + } + if ($limit['mailboxes'] < 0) { + return false; + } + if ($limit['mailbox_count'] >= $limit['mailboxes']) { + return false; + } else { + return true; + } +} + +// +// check_quota +// Action: Checks if the user is creating a mailbox with the correct quota +// Call: check_quota(string domain) +// +function check_quota($quota, $domain) { + $limit = get_domain_properties($domain); + if ($limit['maxquota'] == 0) { + return true; + } + if (($limit['maxquota'] < 0) and ($quota < 0)) { + return true; + } + if (($limit['maxquota'] > 0) and ($quota == 0)) { + return false; + } + if ($quota > $limit['maxquota']) { + return false; + } else { + return true; + } +} + +// +// check_owner +// Action: Checks if the admin is the owner of the domain. +// Call: check_owner(string admin, string domain) +// +function check_owner($username, $domain) { + $result = db_query("SELECT * FROM domain_admins WHERE username='$username' AND domain='$domain' AND active='1'"); + if ($result['rows'] != 1) { + return false; + } else { + return true; + } +} + +// +// list_domains_for_admin +// Action: Lists all the domains for an admin. +// Call: list_domains_for_admin(string admin) +// +function list_domains_for_admin($username) { + $list = array(); + + $result = db_query("SELECT * FROM domain LEFT JOIN domain_admins ON domain.domain=domain_admins.domain WHERE domain_admins.username='$username' AND domain.active='1' AND domain.backupmx='0' ORDER BY domain_admins.domain"); + if ($result['rows'] > 0) { + $i = 0; + while ($row = db_array($result['result'])) { + $list[$i] = $row['domain']; + $i++; + } + } + return $list; +} + +// +// list_domains +// Action: List all available domains. +// Call: list_domains() +// +function list_domains() { + $list = array(); + + $result = db_query("SELECT * FROM domain ORDER BY domain"); + if ($result['rows'] > 0) { + $i = 0; + while ($row = db_array($result['result'])) { + $list[$i] = $row['domain']; + $i++; + } + } + return $list; +} + +// +// admin_exist +// Action: Checks if the admin already exists. +// Call: admin_exist(string admin) +// +// was check_admin +// +function admin_exist($username) { + $result = db_query("SELECT * FROM admin WHERE username='$username'"); + if ($result['rows'] != 1) { + return false; + } else { + return true; + } +} + +// +// domain_exist +// Action: Checks if the domain already exists. +// Call: domain_exist(string domain) +// +function domain_exist($domain) { + $result = db_query("SELECT * FROM domain WHERE domain='$domain'"); + if ($result['rows'] != 1) { + return false; + } else { + return true; + } +} + +// +// list_admins +// Action: Lists all the admins +// Call: list_admins() +// +// was admin_list_admins +// +function list_admins() { + $list = array(); + + $result = db_query("SELECT * FROM admin ORDER BY username"); + if ($result['rows'] > 0) { + $i = 0; + while ($row = db_array($result['result'])) { + $list[$i] = $row['username']; + $i++; + } + } + return $list; +} + +// +// get_admin_properties +// Action: Get all the admin properties. +// Call: get_admin_properties(string admin) +function get_admin_properties($username) { + $list = array(); + + $result = db_query("SELECT COUNT(*) FROM domain_admins WHERE username='$username'"); + $row = db_row($result['result']); + $list['domain_count'] = $row[0]; + + $result = db_query("SELECT * FROM admin WHERE username='$username'"); + $row = db_array($result['result']); + $list['created'] = $row['created']; + $list['modified'] = $row['modified']; + $list['active'] = $row['active']; + return $list; +} + +// +// generate_password +// Action: Generates a random password +// Call: generate_password() +// +function generate_password() { + $password = substr(md5(mt_rand()), 0, 8); + return $password; +} + +// +// pacrypt +// Action: Encrypts password based on config settings +// Call: pacrypt(string cleartextpassword) +// +function pacrypt($pw, $pw_db="") { + global $CONF; + $password = ""; + + if ($CONF['encrypt'] == 'bcrypt') { + $options = ['cost' => 8]; + $password = password_hash($pw, PASSWORD_BCRYPT, $options); + $password = preg_replace('/\$2y\$/', '\$2b\$', $password); + } + return $password; +} + +// +// db_connect +// Action: Makes a connection to the database if it doesn't exist +// Call: db_connect() +// +$DEBUG_TEXT = "\n +

\n +Please check the documentation and website for more information.\n +

\n +"; + +function db_connect() { + global $CONF; + global $DEBUG_TEXT; + $link = ""; + + if ($CONF['database_type'] == "mysqli") { + if(function_exists("mysqli_connect")) { + $link = @mysqli_connect($CONF['database_host'], $CONF['database_user'], $CONF['database_password']) or die("

DEBUG INFORMATION:
Connect: " . mysqli_connect_error() . "$DEBUG_TEXT"); + $succes = @mysqli_select_db($link, $CONF['database_name']) or die("

DEBUG INFORMATION:
MySQLi Select Database: " . mysqli_error() . "$DEBUG_TEXT"); + } else { + print "

DEBUG INFORMATION:
MySQL 4.1 functions not available!
database_type = 'mysqli' in config.inc.php, are you using a different database? $DEBUG_TEXT"; + die; + } + } + + if ($CONF['database_type'] == "pgsql") { + if(function_exists("pg_connect")) { + $connect_string = "host=" . $CONF['database_host'] . " dbname=" . $CONF['database_name'] . " user=" . $CONF['database_user'] . " password=" . $CONF['database_password']; + $link = @pg_connect($connect_string) or die("

DEBUG INFORMATION:
Connect: " . pg_last_error() . "$DEBUG_TEXT"); + } else { + print "

DEBUG INFORMATION:
PostgreSQL functions not available!
database_type = 'pgsql' in config.inc.php, are you using a different database? $DEBUG_TEXT"; + die; + } + } + + if ($link) { + return $link; + } else { + print "DEBUG INFORMATION:
\n"; + print "Connect: Unable to connect to database
\n"; + print "
\n"; + print "Make sure that you have set the correct database type in the config.inc.php file
\n"; + print $DEBUG_TEXT; + die; + } +} + +// +// db_query +// Action: Sends a query to the database and returns query result and number of rows +// Call: db_query(string query) +// +function db_query($query) { + global $CONF; + global $DEBUG_TEXT; + $result = ""; + $number_rows = ""; + + $link = db_connect(); + + // database prefix workaround + if (!empty($CONF['database_prefix'])) { + if (preg_match("/^SELECT/i", $query)) { + $query = substr($query, 0, 14) . $CONF['database_prefix'] . substr($query, 14); + } else { + $query = substr($query, 0, 6) . $CONF['database_prefix'] . substr($query, 7); + } + } + + if ($CONF['database_type'] == "mysqli") $result = @mysqli_query($link, $query) or die("

DEBUG INFORMATION:
Invalid query: " . mysqli_error($link) . "$DEBUG_TEXT"); + if ($CONF['database_type'] == "pgsql") { + if (preg_match("/LIMIT/i", $query)) { + $search = "/LIMIT(\w+), (\w+)/"; + $replace = "LIMIT \$2 OFFSET \$1"; + $query = preg_replace($search, $replace, $query); + } + $result = @pg_query($link, $query) or die("

DEBUG INFORMATION:
Invalid query: " . pg_last_error() . "$DEBUG_TEXT"); + } + + if (preg_match("/^SELECT/i", $query)) { + // if $query was a SELECT statement check the number of rows with [database_type]_num_rows(). + if ($CONF['database_type'] == "mysqli") $number_rows = mysqli_num_rows($result); + if ($CONF['database_type'] == "pgsql") $number_rows = pg_num_rows($result); + } else { + // if $query was something else, UPDATE, DELETE or INSERT check the number of rows with + // [database_type]_affected_rows(). + if ($CONF['database_type'] == "mysqli") $number_rows = mysqli_affected_rows($link); + if ($CONF['database_type'] == "pgsql") $number_rows = pg_affected_rows($result); + } + + if ($CONF['database_type'] == "mysqli") mysqli_close($link); + if ($CONF['database_type'] == "pgsql") pg_close($link); + + $return = array( + "result" => $result, + "rows" => $number_rows + ); + return $return; +} + +// db_row +// Action: Returns a row from a table +// Call: db_row(int result) +// +function db_row($result) { + global $CONF; + $row = ""; + if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_row($result); + if ($CONF['database_type'] == "pgsql") $row = pg_fetch_row($result); + return $row; +} + +// db_array +// Action: Returns a row from a table +// Call: db_array(int result) +// +function db_array($result) { + global $CONF; + $row = ""; + if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_array($result); + if ($CONF['database_type'] == "pgsql") $row = pg_fetch_array($result); + return $row; +} + +// db_assoc +// Action: Returns a row from a table +// Call: db_assoc(int result) +// +function db_assoc($result) { + global $CONF; + $row = ""; + if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_assoc($result); + if ($CONF['database_type'] == "pgsql") $row = pg_fetch_assoc($result); + return $row; +} + +// +// db_delete +// Action: Deletes a row from a specified table +// Call: db_delete(string table, string where, string delete) +// +function db_delete($table,$where,$delete) { + $result = db_query("DELETE FROM $table WHERE $where='$delete'"); + if ($result['rows'] >= 1) { + return $result['rows']; + } else { + return true; + } +} + +// +// db_log +// Action: Logs actions from admin +// Call: db_log(string username, string domain, string action, string data) +// +function db_log($username, $domain, $action, $data) { + global $CONF; + if (!empty($_SERVER['HTTP_X_CLIENTIP'])) { + $REMOTE_ADDR = $_SERVER['HTTP_X_CLIENTIP']; + } else { + $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; + } + + if ($CONF['logging'] == 'YES') { + $result = db_query("INSERT INTO log (timestamp, username, domain, action, data) VALUES (NOW(), '$username ($REMOTE_ADDR)', '$domain', '$action', '$data')"); + if ($result['rows'] != 1) { + return false; + } else { + return true; + } + } +} +?> blob - /dev/null blob + 739ec212f73d7050cbab1d05763be2e351962ef9 (mode 644) Binary files /dev/null and images/arrow-l.png differ blob - /dev/null blob + 8d85a9132c8e13b50b20ff8403399f2b8bbdeff6 (mode 644) Binary files /dev/null and images/arrow-r.png differ blob - /dev/null blob + 63c33cedc83d6ca1de1ba5e42e750344cd4d61c5 (mode 644) Binary files /dev/null and images/arrow-u.png differ blob - /dev/null blob + 032abd6ff5dc8cffb91c1920e48bc1dd26368668 (mode 644) --- /dev/null +++ images/index.php @@ -0,0 +1,17 @@ + blob - /dev/null blob + 2e45b0c82aad45454eb80d94bd819d5373f3cf51 (mode 644) Binary files /dev/null and images/opensmtpdadmin.png differ blob - /dev/null blob + ea830bfb898e21400042d20ac7db62d10fb1a83f (mode 644) Binary files /dev/null and images/postbox.png differ blob - /dev/null blob + b60c4942d1fec3a7769246c8b40a977373764efa (mode 644) --- /dev/null +++ index.php @@ -0,0 +1,43 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: index.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +if (!file_exists(realpath("./setup.php"))) { + header ("Location: login.php"); + exit; +} else { + print <<< EOF + + +Welcome to OpenSMTPD Admin + + + + +

Welcome to OpenSMTPD Admin

+It seems that you are running this version of OpenSMTPD Admin for the first time.
+

+You can now run setup to make sure that all the functions are available for OpenSMTPD Admin to run.
+

+If you still encounter any problems please check the documentation and website for more information. +

+ + +EOF; +} +?> blob - /dev/null blob + f7692b819f249b36ee4c354fa686920dc755c3a9 (mode 644) --- /dev/null +++ languages/en.lang @@ -0,0 +1,295 @@ + +// +$PALANG['YES'] = 'YES'; +$PALANG['NO'] = 'NO'; +$PALANG['edit'] = 'edit'; +$PALANG['del'] = 'del'; +$PALANG['confirm'] = 'Are you sure you want to delete this?\n'; +$PALANG['confirm_domain'] = 'Do you really want to delete all records for this domain? This can not be undone!\n'; +$PALANG['check_update'] = 'Check for update'; + +$PALANG['pLogin_welcome'] = 'Mail admins login here to administer your domain.'; +$PALANG['pLogin_username'] = 'Login (email)'; +$PALANG['pLogin_password'] = 'Password'; +$PALANG['pLogin_button'] = 'Login'; +$PALANG['pLogin_username_incorrect'] = 'Your login is not correct. Make sure that you login with your email address.'; +$PALANG['pLogin_password_incorrect'] = 'Your password is not correct.'; +$PALANG['pLogin_login_users'] = 'Users click here to login to the user section.'; + +$PALANG['pMenu_overview'] = 'Overview'; +$PALANG['pMenu_create_alias'] = 'Add Alias'; +$PALANG['pMenu_create_mailbox'] = 'Add Mailbox'; +$PALANG['pMenu_sendmail'] = 'Send Email'; +$PALANG['pMenu_password'] = 'Password'; +$PALANG['pMenu_viewlog'] = 'View Log'; +$PALANG['pMenu_logout'] = 'Logout'; + +$PALANG['pMain_welcome'] = 'Welcome to OpenSMTPD Admin!'; +$PALANG['pMain_overview'] = 'List your aliases and mailboxes. You can edit / delete them from here.'; +$PALANG['pMain_create_alias'] = 'Create a new alias for your domain.'; +$PALANG['pMain_create_mailbox'] = 'Create a new mailbox for your domain.'; +$PALANG['pMain_sendmail'] = 'Send an email to one of your newly created mailboxes.'; +$PALANG['pMain_password'] = 'Change the password for your admin account.'; +$PALANG['pMain_viewlog'] = 'View the log files.'; +$PALANG['pMain_logout'] = 'Logout from the system'; + +$PALANG['pOverview_disabled'] = 'Disabled'; +$PALANG['pOverview_unlimited'] = 'Unlimited'; +$PALANG['pOverview_title'] = ':: Defined Domains'; +$PALANG['pOverview_up_arrow'] = 'Go Top'; +$PALANG['pOverview_right_arrow'] = 'Next Page'; +$PALANG['pOverview_left_arrow'] = 'Previus Page'; +$PALANG['pOverview_alias_title'] = ':: Alias'; +$PALANG['pOverview_mailbox_title'] = ':: Mailboxes'; +$PALANG['pOverview_button'] = 'Go'; +$PALANG['pOverview_welcome'] = 'Overview for '; +$PALANG['pOverview_alias_alias_count'] = 'Aliases'; +$PALANG['pOverview_alias_mailbox_count'] = 'Mailboxes'; +$PALANG['pOverview_alias_address'] = 'From'; +$PALANG['pOverview_alias_goto'] = 'To'; +$PALANG['pOverview_alias_modified'] = 'Last Modified'; +$PALANG['pOverview_mailbox_username'] = 'Email'; +$PALANG['pOverview_mailbox_name'] = 'Name'; +$PALANG['pOverview_mailbox_quota'] = 'Quota (MB)'; +$PALANG['pOverview_mailbox_modified'] = 'Last Modified'; +$PALANG['pOverview_mailbox_active'] = 'Active'; + +$PALANG['pOverview_get_domain'] = 'Domain'; +$PALANG['pOverview_get_aliases'] = 'Aliases'; +$PALANG['pOverview_get_mailboxes'] = 'Mailboxes'; +$PALANG['pOverview_get_quota'] = 'Mailbox Quota (MB)'; +$PALANG['pOverview_get_modified'] = 'Last Modified'; + +$PALANG['pDelete_delete_error'] = 'Unable to delete the entry '; +$PALANG['pDelete_domain_error'] = 'This domain is not yours '; + +$PALANG['pCreate_alias_welcome'] = 'Create a new alias for your domain.'; +$PALANG['pCreate_alias_address'] = 'Alias'; +$PALANG['pCreate_alias_address_text_error1'] = '
The ALIAS is not valid.'; +$PALANG['pCreate_alias_address_text_error2'] = '
This email address already exists, please choose a different one.'; +$PALANG['pCreate_alias_address_text_error3'] = '
You have reached your limit to create aliases.'; +$PALANG['pCreate_alias_goto'] = 'To'; +$PALANG['pCreate_alias_button'] = 'Add Alias'; +$PALANG['pCreate_alias_goto_text'] = 'Where the mail needs to be send to.'; +$PALANG['pCreate_alias_goto_text_error'] = 'Where the email needs to go.
The TO is not valid.'; +$PALANG['pCreate_alias_result_error'] = 'Unable to add the alias to the alias table.'; +$PALANG['pCreate_alias_result_succes'] = 'The alias has been added to the alias table.'; +$PALANG['pCreate_alias_catchall_text'] = 'To create a catch-all use an "*" as alias.
For domain to domain forwarding use "*@domain.tld" as to.'; + +$PALANG['pEdit_alias_welcome'] = 'Edit an alias for your domain.
One entry per line.'; +$PALANG['pEdit_alias_address'] = 'Alias'; +$PALANG['pEdit_alias_address_error'] = 'Unable to locate alias.'; +$PALANG['pEdit_alias_goto'] = 'To'; +$PALANG['pEdit_alias_goto_text_error1'] = 'You didn\'t enter anything at To'; +$PALANG['pEdit_alias_goto_text_error2'] = 'The email address that you have entered is not valid: '; +$PALANG['pEdit_alias_domain_error'] = 'This domain is not yours: '; +$PALANG['pEdit_alias_button'] = 'Edit Alias'; +$PALANG['pEdit_alias_result_error'] = 'Unable to modify the alias.'; + +$PALANG['pCreate_mailbox_welcome'] = 'Create a new mailbox for your domain.'; +$PALANG['pCreate_mailbox_username'] = 'Username'; +$PALANG['pCreate_mailbox_username_text_error1'] = '
The EMAIL is not valid.'; +$PALANG['pCreate_mailbox_username_text_error2'] = '
This email address already exists, please choose a different one.'; +$PALANG['pCreate_mailbox_username_text_error3'] = '
You have reached your limit to create mailboxes.'; +$PALANG['pCreate_mailbox_password'] = 'Password'; +$PALANG['pCreate_mailbox_password2'] = 'Password (again)'; +$PALANG['pCreate_mailbox_password_text'] = 'Password for POP3/IMAP'; +$PALANG['pCreate_mailbox_password_text_error'] = 'Password for POP3/IMAP
The passwords that you supplied don\'t match, or are empty.'; +$PALANG['pCreate_mailbox_name'] = 'Name'; +$PALANG['pCreate_mailbox_name_text'] = 'Full name'; +$PALANG['pCreate_mailbox_quota'] = 'Quota'; +$PALANG['pCreate_mailbox_quota_text'] = 'MB'; +$PALANG['pCreate_mailbox_quota_text_error'] = 'MB
The quota that you specified is to high.'; +$PALANG['pCreate_mailbox_active'] = 'Active'; +$PALANG['pCreate_mailbox_mail'] = 'Create mailbox'; +$PALANG['pCreate_mailbox_button'] = 'Add Mailbox'; +$PALANG['pCreate_mailbox_result_error'] = 'Unable to add the mailbox to the mailbox table.'; +$PALANG['pCreate_mailbox_result_succes'] = 'The mailbox has been added to the mailbox table.'; + +$PALANG['pEdit_mailbox_welcome'] = 'Edit a mailbox for your domain.'; +$PALANG['pEdit_mailbox_username'] = 'Username'; +$PALANG['pEdit_mailbox_username_error'] = 'Unable to locate mailbox.'; +$PALANG['pEdit_mailbox_password'] = 'New Password'; +$PALANG['pEdit_mailbox_password2'] = 'New Password (again)'; +$PALANG['pEdit_mailbox_password_text_error'] = 'The passwords that you supplied don\'t match.'; +$PALANG['pEdit_mailbox_name'] = 'Name'; +$PALANG['pEdit_mailbox_quota'] = 'Quota'; +$PALANG['pEdit_mailbox_quota_text'] = 'MB'; +$PALANG['pEdit_mailbox_quota_text_error'] = 'MB
The quota that you specified is to high.'; +$PALANG['pEdit_mailbox_domain_error'] = 'This domain is not yours: '; +$PALANG['pEdit_mailbox_button'] = 'Edit Mailbox'; +$PALANG['pEdit_mailbox_result_error'] = 'Unable to modify the mailbox.'; + +$PALANG['pPassword_welcome'] = 'Change your login password.'; +$PALANG['pPassword_admin'] = 'Login'; +$PALANG['pPassword_admin_text_error'] = 'The LOGIN that you supplied doesn\'t match a mailbox.'; +$PALANG['pPassword_password_current'] = 'Current Password'; +$PALANG['pPassword_password_current_text_error'] = 'You didn\'t supply your current password.'; +$PALANG['pPassword_password'] = 'New Password'; +$PALANG['pPassword_password2'] = 'New Password (again)'; +$PALANG['pPassword_password_text_error'] = 'The passwords that you supplied don\'t match, or are empty.'; +$PALANG['pPassword_button'] = 'Change Password'; +$PALANG['pPassword_result_error'] = 'Unable to change your password.'; +$PALANG['pPassword_result_succes'] = 'Your password has been changed.'; + +$PALANG['pViewlog_welcome'] = 'View the last 10 actions for '; +$PALANG['pViewlog_timestamp'] = 'Timestamp'; +$PALANG['pViewlog_username'] = 'Admin'; +$PALANG['pViewlog_domain'] = 'Domain'; +$PALANG['pViewlog_action'] = 'Action'; +$PALANG['pViewlog_data'] = 'Data'; + +$PALANG['pViewlog_button'] = 'Go'; +$PALANG['pViewlog_result_error'] = 'Unable to find the logs.'; + +$PALANG['pSendmail_welcome'] = 'Send an email.'; +$PALANG['pSendmail_admin'] = 'From'; +$PALANG['pSendmail_to'] = 'To'; +$PALANG['pSendmail_to_text_error'] = 'To is empty or is not a valid email address.'; +$PALANG['pSendmail_subject'] = 'Subject'; +$PALANG['pSendmail_subject_text'] = 'Welcome'; +$PALANG['pSendmail_body'] = 'Body'; +$PALANG['pSendmail_button'] = 'Send Message'; +$PALANG['pSendmail_result_error'] = 'Unable to create mailbox.'; +$PALANG['pSendmail_result_succes'] = 'The mailbox has been created.'; + +$PALANG['pAdminMenu_list_admin'] = 'Admin List'; +$PALANG['pAdminMenu_list_domain'] = 'Domain List'; +$PALANG['pAdminMenu_list_virtual'] = 'Virtual List'; +$PALANG['pAdminMenu_viewlog'] = 'View Log'; +$PALANG['pAdminMenu_backup'] = 'Backup'; +$PALANG['pAdminMenu_create_domain_admins'] = 'Domain Admins'; +$PALANG['pAdminMenu_create_admin'] = 'New Admin'; +$PALANG['pAdminMenu_create_domain'] = 'New Domain'; +$PALANG['pAdminMenu_create_alias'] = 'Add Alias'; +$PALANG['pAdminMenu_create_mailbox'] = 'Add Mailbox'; + +$PALANG['pAdminList_admin_domain'] = 'Domain'; +$PALANG['pAdminList_admin_username'] = 'Admin'; +$PALANG['pAdminList_admin_count'] = 'Domains'; +$PALANG['pAdminList_admin_modified'] = 'Last Modified'; +$PALANG['pAdminList_admin_active'] = 'Active'; + +$PALANG['pAdminList_domain_domain'] = 'Domain'; +$PALANG['pAdminList_domain_description'] = 'Description'; +$PALANG['pAdminList_domain_aliases'] = 'Aliases'; +$PALANG['pAdminList_domain_mailboxes'] = 'Mailboxes'; +$PALANG['pAdminList_domain_maxquota'] = 'Quota (MB)'; +$PALANG['pAdminList_domain_transport'] = 'Transport'; +$PALANG['pAdminList_domain_backupmx'] = 'Backup MX'; +$PALANG['pAdminList_domain_modified'] = 'Last Modified'; +$PALANG['pAdminList_domain_active'] = 'Active'; + +$PALANG['pAdminList_virtual_button'] = 'Go'; +$PALANG['pAdminList_virtual_welcome'] = 'Overview for '; +$PALANG['pAdminList_virtual_alias_alias_count'] = 'Aliases'; +$PALANG['pAdminList_virtual_alias_mailbox_count'] = 'Mailboxes'; +$PALANG['pAdminList_virtual_alias_address'] = 'From'; +$PALANG['pAdminList_virtual_alias_goto'] = 'To'; +$PALANG['pAdminList_virtual_alias_modified'] = 'Last Modified'; +$PALANG['pAdminList_virtual_mailbox_username'] = 'Email'; +$PALANG['pAdminList_virtual_mailbox_name'] = 'Name'; +$PALANG['pAdminList_virtual_mailbox_quota'] = 'Quota (MB)'; +$PALANG['pAdminList_virtual_mailbox_modified'] = 'Last Modified'; +$PALANG['pAdminList_virtual_mailbox_active'] = 'Active'; + +$PALANG['pAdminCreate_domain_welcome'] = 'Add a new domain'; +$PALANG['pAdminCreate_domain_domain'] = 'Domain'; +$PALANG['pAdminCreate_domain_domain_text_error'] = 'The domain already exists.'; +$PALANG['pAdminCreate_domain_description'] = 'Description'; +$PALANG['pAdminCreate_domain_aliases'] = 'Aliases'; +$PALANG['pAdminCreate_domain_aliases_text'] = '-1 = disable | 0 = unlimited'; +$PALANG['pAdminCreate_domain_mailboxes'] = 'Mailboxes'; +$PALANG['pAdminCreate_domain_mailboxes_text'] = '-1 = disable | 0 = unlimited'; +$PALANG['pAdminCreate_domain_maxquota'] = 'Max Quota'; +$PALANG['pAdminCreate_domain_maxquota_text'] = 'MB
-1 = disable | 0 = unlimited'; +$PALANG['pAdminCreate_domain_transport'] = 'Transport'; +$PALANG['pAdminCreate_domain_transport_text'] = 'Define transport'; +$PALANG['pAdminCreate_domain_defaultaliases'] = 'Add default mail aliases'; +$PALANG['pAdminCreate_domain_backupmx'] = 'Mail server is backup MX'; +$PALANG['pAdminCreate_domain_button'] = 'Add Domain'; +$PALANG['pAdminCreate_domain_result_error'] = 'Unable to add domain.'; +$PALANG['pAdminCreate_domain_result_succes'] = 'Domain has been added.'; + +$PALANG['pAdminEdit_domain_welcome'] = 'Edit a domain'; +$PALANG['pAdminEdit_domain_domain'] = 'Domain'; +$PALANG['pAdminEdit_domain_description'] = 'Description'; +$PALANG['pAdminEdit_domain_aliases'] = 'Aliases'; +$PALANG['pAdminEdit_domain_aliases_text'] = '-1 = disable | 0 = unlimited'; +$PALANG['pAdminEdit_domain_mailboxes'] = 'Mailboxes'; +$PALANG['pAdminEdit_domain_mailboxes_text'] = '-1 = disable | 0 = unlimited'; +$PALANG['pAdminEdit_domain_maxquota'] = 'Max Quota'; +$PALANG['pAdminEdit_domain_maxquota_text'] = 'MB
-1 = disable | 0 = unlimited'; +$PALANG['pAdminEdit_domain_transport'] = 'Transport'; +$PALANG['pAdminEdit_domain_transport_text'] = 'Define transport'; +$PALANG['pAdminEdit_domain_backupmx'] = 'Mail server is backup MX'; +$PALANG['pAdminEdit_domain_active'] = 'Active'; +$PALANG['pAdminEdit_domain_button'] = 'Edit Domain'; +$PALANG['pAdminEdit_domain_result_error'] = 'Unable to modify domain.'; + +$PALANG['pAdminCreate_admin_welcome'] = 'Add a new domain admin'; +$PALANG['pAdminCreate_admin_username'] = 'Admin'; +$PALANG['pAdminCreate_admin_username_text'] = 'email address'; +$PALANG['pAdminCreate_admin_username_text_error1'] = 'Email address
Admin is not a valid email address.'; +$PALANG['pAdminCreate_admin_username_text_error2'] = 'Email address
The admin already exists or is not valid'; +$PALANG['pAdminCreate_admin_password'] = 'Password'; +$PALANG['pAdminCreate_admin_password2'] = 'Password (again)'; +$PALANG['pAdminCreate_admin_password_text_error'] = 'The passwords that you supplied don\'t match, or are empty.'; +$PALANG['pAdminCreate_admin_button'] = 'Add Admin'; +$PALANG['pAdminCreate_admin_result_error'] = 'Unable to add admin.'; +$PALANG['pAdminCreate_admin_result_succes'] = 'Admin has been added.'; +$PALANG['pAdminCreate_admin_address'] = 'Domain'; + +$PALANG['pAdminEdit_admin_welcome'] = 'Edit a domain admin'; +$PALANG['pAdminEdit_admin_username'] = 'Admin'; +$PALANG['pAdminEdit_admin_password'] = 'Password'; +$PALANG['pAdminEdit_admin_password2'] = 'Password (again)'; +$PALANG['pAdminEdit_admin_password_text_error'] = 'The passwords that you supplied don\'t match, or are empty.'; +$PALANG['pAdminEdit_admin_active'] = 'Active'; +$PALANG['pAdminEdit_admin_button'] = 'Edit Admin'; +$PALANG['pAdminEdit_admin_result_error'] = 'Unable to modify admin.'; +$PALANG['pAdminEdit_admin_result_succes'] = 'Admin has been modified.'; + +$PALANG['pUsersLogin_welcome'] = 'Mailbox users login to change your password and aliases.'; +$PALANG['pUsersLogin_username'] = 'Login (email)'; +$PALANG['pUsersLogin_password'] = 'Password'; +$PALANG['pUsersLogin_button'] = 'Login'; +$PALANG['pUsersLogin_username_incorrect'] = 'Your login is not correct. Make sure that you login with your email address.'; +$PALANG['pUsersLogin_password_incorrect'] = 'Your password is not correct.'; + +$PALANG['pUsersMenu_vacation'] = 'Auto Response'; +$PALANG['pUsersMenu_edit_alias'] = 'Change your forward'; +$PALANG['pUsersMenu_password'] = 'Change Password'; + +$PALANG['pUsersMain_vacation'] = 'Set an "out of office" message or auto responder for your mail.'; +$PALANG['pUsersMain_edit_alias'] = 'Change your email forwarding.'; +$PALANG['pUsersMain_password'] = 'Change your current password.'; + +$PALANG['pUsersVacation_welcome'] = 'Auto Response.'; +$PALANG['pUsersVacation_welcome_text'] = 'You already have an auto response configured.'; +$PALANG['pUsersVacation_subject'] = 'Subject'; +$PALANG['pUsersVacation_subject_text'] = 'Out of Office'; +$PALANG['pUsersVacation_body'] = 'Body'; +$PALANG['pUsersVacation_body_text'] = << until . +For urgent matters you can contact . +EOM; +$PALANG['pUsersVacation_button_away'] = 'Going Away'; +$PALANG['pUsersVacation_button_back'] = 'Coming Back'; +$PALANG['pUsersVacation_result_error'] = 'Unable to update your auto response settings.'; +$PALANG['pUsersVacation_result_succes'] = 'Your auto response has been removed.'; + +$PALANG['pCreate_dbLog_createmailbox'] = 'create mailbox'; +$PALANG['pCreate_dbLog_createalias'] = 'create alias'; +$PALANG['pDelete_dbLog_deletealias'] = 'delete alias'; +$PALANG['pDelete_dbLog_deletemailbox'] = 'delete mailbox'; + +$PALANG['pEdit_dbLog_editactive'] = 'change active state'; +$PALANG['pEdit_dbLog_editalias'] = 'edit alias'; +$PALANG['pEdit_dbLog_editmailbox'] = 'edit mailbox'; + +$PALANG['pSearch_welcome'] = 'Searching for: '; +?> blob - /dev/null blob + a8b62bd60cf949801863d1e910f26965a1aed4fc (mode 644) --- /dev/null +++ languages/index.php @@ -0,0 +1,22 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: index.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +header("Location: ../login.php"); +exit; +?> blob - /dev/null blob + 412495dc5381afaa6b006b9a7a3c692ba6532ed2 (mode 644) --- /dev/null +++ login.php @@ -0,0 +1,54 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: login.php +// +// Template File: login.tpl +// +// Template Variables: +// +// tMessage +// tUsername +// +// Form POST \ GET Variables: +// +// fUsername +// fPassword +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language () . ".lang"); + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fUsername = escape_string ($_POST['fUsername']); + $fPassword = escape_string ($_POST['fPassword']); + + $result = db_query("SELECT password FROM admin WHERE username='$fUsername' AND active='1'"); + if ($result['rows'] == 1) { + $row = db_array($result['result']); + if (!password_verify($fPassword, $row['password'])) { + $error = 1; + $tMessage = $PALANG['pLogin_password_incorrect']; + $tUsername = $fUsername; + } + } else { + $error = 1; + $tMessage = $PALANG['pLogin_username_incorrect']; + } + + if ($error != 1) { + session_start(); + $_SESSION['sessid']['username'] = $fUsername; + header("Location: main.php"); + exit; + } +} +include("./templates/header.tpl"); +include("./templates/login.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 550fccf1c997f6cdad8f81523503fbb0d05be909 (mode 644) --- /dev/null +++ logout.php @@ -0,0 +1,30 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: logout.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +require("./config.inc.php"); +require("./functions.inc.php"); + +$SESSID_USERNAME = check_session(); + +session_unset(); +session_destroy(); + +header("Location: login.php"); +exit; +?> blob - /dev/null blob + e92daaf53493bf97e523c1803b3aff8af2a24eb9 (mode 644) --- /dev/null +++ main.php @@ -0,0 +1,30 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: main.php +// +// Template File: main.tpl +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); + +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/main.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 16df579ccc8af9e7ba0b6fb1ce4e8cd82314275f (mode 644) --- /dev/null +++ overview.php @@ -0,0 +1,142 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: overview.php +// +// Template File: overview.tpl +// +// Template Variables: +// +// tAlias +// tDomain +// tMailbox +// tDisplay_back +// tDisplay_next +// +// Form POST \ GET Variables: +// +// domain +// fDomain +// limit +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); +$list_domains = list_domains_for_admin($SESSID_USERNAME); + +$tAlias = array(); +$tMailbox = array(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $fDisplay = 0; + $page_size = $CONF['page_size']; + + if (isset($_GET['domain'])) $fDomain = escape_string($_GET['domain']); + if (isset($_GET['limit'])) $fDisplay = escape_string($_GET['limit']); + + if (check_owner($SESSID_USERNAME, $fDomain)) { + $limit = get_domain_properties($fDomain); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } + + $result = db_query("$query"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tAlias[] = $row; + } + } + + $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tMailbox[] = $row; + } + } + $template = "overview.tpl"; + } else { + $template = "overview-get.tpl"; + } + + $tDomain = $fDomain; + + if (isset($limit)) { + if ($fDisplay >= $page_size) { + $tDisplay_back_show = 1; + $tDisplay_back = $fDisplay - $page_size; + } + if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { + $tDisplay_up_show = 1; + } + if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) { + $tDisplay_next_show = 1; + $tDisplay_next = $fDisplay + $page_size; + } + } + include("./templates/header.tpl"); + include("./templates/menu.tpl"); + include("./templates/$template"); + include("./templates/footer.tpl"); +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fDisplay = 0; + $page_size = $CONF['page_size']; + + if (isset($_POST['limit'])) $fDisplay = escape_string($_POST['limit']); + + if (check_owner($SESSID_USERNAME, escape_string($_POST['fDomain']))) { + $fDomain = escape_string($_POST['fDomain']); + + $limit = get_domain_properties($fDomain); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias WHERE alias.domain='$fDomain' ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain='$fDomain' AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT $fDisplay, $page_size"; + } + + $result = db_query("$query"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tAlias[] = $row; + } + } + + $result = db_query("SELECT * FROM mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tMailbox[] = $row; + } + } + } + + if (isset($limit)) { + if ($fDisplay >= $page_size) { + $tDisplay_back_show = 1; + $tDisplay_back = $fDisplay - $page_size; + } + if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { + $tDisplay_up_show = 1; + } + if ((($fDisplay + $page_size) < $limit['alias_count']) or (($fDisplay + $page_size) < $limit['mailbox_count'])) { + $tDisplay_next_show = 1; + $tDisplay_next = $fDisplay + $page_size; + } + } + include("./templates/header.tpl"); + include("./templates/menu.tpl"); + include("./templates/overview.tpl"); + include("./templates/footer.tpl"); +} +?> blob - /dev/null blob + 0ca3d13fa91f10ea31125e0cf2f20f1a2bafe9d7 (mode 644) --- /dev/null +++ password.php @@ -0,0 +1,68 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: password.php +// +// Template File: password.tpl +// +// Template Variables: +// +// tMessage +// +// Form POST \ GET Variables: +// +// fPassword_current +// fPassword +// fPassword2 +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fPassword_current = escape_string($_POST['fPassword_current']); + $fPassword = escape_string($_POST['fPassword']); + $fPassword2 = escape_string($_POST['fPassword2']); + + $username = $SESSID_USERNAME; + + $result = db_query("SELECT * FROM admin WHERE username='$username'"); + if ($result['rows'] == 1) { + $row = db_array($result['result']); + if (!password_verify($fPassword_current, $row['password'])) { + $error = 1; + $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; + } + } else { + $error = 1; + $pPassword_email_text = $PALANG['pPassword_email_text_error']; + } + + if (empty($fPassword) or ($fPassword != $fPassword2)) + { + $error = 1; + $pPassword_password_text = $PALANG['pPassword_password_text_error']; + } + + if ($error != 1) { + $password = pacrypt($fPassword); + $result = db_query("UPDATE admin SET password='$password',modified=NOW() WHERE username='$username'"); + if ($result['rows'] == 1) { + $tMessage = $PALANG['pPassword_result_succes']; + } else { + $tMessage = $PALANG['pPassword_result_error']; + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/password.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + f69a9861891f9e9cf38ea584afa3905e10779a10 (mode 644) --- /dev/null +++ search.php @@ -0,0 +1,92 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: search.php +// +// Template File: search.tpl +// +// Template Variables: +// +// tAlias +// tMailbox +// +// Form POST \ GET Variables: +// +// fSearch +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); + +$tAlias = array(); +$tMailbox = array(); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + if (isset($_GET['search'])) $fSearch = escape_string($_GET['search']); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias WHERE alias.address LIKE '%$fSearch%' OR alias.goto LIKE '%$fSearch%' ORDER BY alias.address"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE '%$fSearch%' AND mailbox.maildir IS NULL ORDER BY alias.address"; + } + + $result = db_query("$query"); + + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + if (check_owner($SESSID_USERNAME, $row['domain'])) { + $tAlias[] = $row; + } + } + } + + $result = db_query("SELECT * FROM mailbox WHERE username LIKE '%$fSearch%' ORDER BY username"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + if (check_owner($SESSID_USERNAME, $row['domain'])) { + $tMailbox[] = $row; + } + } + } +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + if (isset($_POST['search'])) $fSearch = escape_string($_POST['search']); + + if ($CONF['alias_control'] == "YES") { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias WHERE alias.address LIKE '%$fSearch%' OR alias.goto LIKE '%$fSearch%' ORDER BY alias.address"; + } else { + $query = "SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE '%$fSearch%' AND mailbox.maildir IS NULL ORDER BY alias.address"; + } + + $result = db_query("$query"); + + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + if (check_owner($SESSID_USERNAME, $row['domain'])) { + $tAlias[] = $row; + } + } + } + + $result = db_query("SELECT * FROM mailbox WHERE username LIKE '%$fSearch%' ORDER BY username"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + if (check_owner($SESSID_USERNAME, $row['domain'])) { + $tMailbox[] = $row; + } + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/search.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 779b05e89646745cb93b296641d0751dcda86444 (mode 644) --- /dev/null +++ sendmail.php @@ -0,0 +1,59 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: sendmail.php +// +// Template File: sendmail.tpl +// +// Template Variables: +// +// tMessage +// tFrom +// tSubject +// tBody +// +// Form POST \ GET Variables: +// +// fTo +// fSubject +// fBody +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fTo = escape_string($_POST['fTo']); + $fSubject = escape_string($_POST['fSubject']); + $fHeaders = "From: " . $SESSID_USERNAME . "\r\n"; + $fHeaders .= "Content-Type: text/plain; charset=utf-8\r\n"; + $fBody = escape_string($_POST['fBody']); + + if (empty($fTo) or !check_email($fTo)) { + $error = 1; + $tTo = escape_string($_POST['fTo']); + $tSubject = escape_string($_POST['fSubject']); + $tBody = escape_string($_POST['fBody']); + $tMessage = $PALANG['pSendmail_to_text_error']; + } + + if ($error != 1) { + if (!mail($fTo, $fSubject, $fBody, $fHeaders)) { + $tMessage .= $PALANG['pSendmail_result_error']; + } else { + $tMessage .= $PALANG['pSendmail_result_succes']; + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/sendmail.tpl"); +include("./templates/footer.tpl"); +?> blob - /dev/null blob + 81eae7fd60e51870e917af89de4587d81e73cdf0 (mode 644) --- /dev/null +++ setup.php @@ -0,0 +1,143 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: index.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +?> + + +OpenSMTPD Admin Setup Checker + + + + +

OpenSMTPD Admin Setup Checker 1.0

+Running software:
+

+= 8) $phpversion = 8; + print "- PHP version " . phpversion() . "
\n"; +} else { + print "

  • Unable to check for PHP version. (missing function: phpversion())
    \n"; +} +print "

    \n"; +print "Checking for dependencies:
    \n"; +print "

    \n"; + +// +// Check for config.inc.php +// +if ($file_config == 1) { + print "- Depends on: presence config.inc.php - OK
    \n"; +} else { + print "

  • Error: Depends on: presence config.inc.php - NOT FOUND
    \n"; + print "Create the file.
    "; + print "For example:
    \n"; + print "
    % cp config.inc.php.sample config.inc.php
    \n"; + $error =+ 1; +} +print "

    \n"; + +// +// Check if there is support for at least 1 database +// +if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 0)) { + print "

  • Error: There is no database support in your PHP setup
    \n"; + print "To install MariaDB 10 support on OpenBSD:
    \n"; + print "% pkg_add php-mysqli\n"; + print "To install PostgreSQL support on OpenBSD:
    \n"; + print "% pkg_add php-pgsql\n"; + $error =+ 1; +} +// +// MariaDB functions +// +if ($f_mysqli_connect == 1) { + print "- Depends on: MariaDB - OK
    \n"; +} +print "

    \n"; + +// +// PostgreSQL functions +// +if ($f_pg_connect == 1) { + print "- Depends on: PostgreSQL - OK (change the database_type in config.inc.php!!)
    \n"; +} +print "

    \n"; + +// +// Session functions +// +if ($f_session_start == 1) { + print "- Depends on: session - OK
    \n"; +} else { + print "

  • Error: Depends on: session - NOT FOUND
    \n"; + print "To install session support on FreeBSD:
    \n"; + print "
    % cd /usr/ports/www/php$phpversion-session/\n";
    +	print "% make clean install\n";
    +	print " - or with portupgrade -\n";
    +	print "% portinstall php$phpversion-session
    \n"; + $error =+ 1; +} +print "

    \n"; + +// +// PCRE functions +// +if ($f_preg_match == 1) { + print "- Depends on: pcre - OK
    \n"; +} else { + print "

  • Error: Depends on: pcre - NOT FOUND
    \n"; + print "To install pcre support on FreeBSD:
    \n"; + print "
    % cd /usr/ports/devel/php$phpversion-pcre/\n";
    +	print "% make clean install\n";
    +	print " - or with portupgrade -\n";
    +	print "% portinstall php$phpversion-pcre
    \n"; + $error =+ 1; +} +print "

    \n"; + +if ($error == 0) { + print "Everything seems fine... you are ready to rock & roll!
    \n"; + print "Make sure you delete this setup.php file!
    \n"; + print "Also check the config.inc.php file for any settings that you might need to change!
    \n"; + print "Click here to go to the admin section (make sure that your .htaccess is setup properly)\n"; +} +?> + + blob - /dev/null blob + 779666dd033ecc149584a759fa59de1a120da0d9 (mode 644) --- /dev/null +++ stylesheet.css @@ -0,0 +1,236 @@ +body { + background: #ffffff; + color: #000000; + font-family: BitStream Vera Sans, Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + font-weight: normal; + text-align: center; +} + +a { + text-decoration: none; + color: #888888; +} + +a:hover { + text-decoration: underline; + color: #888888; +} + +a:visited, a:active { + color: #888888; +} + +.button { + border: 1px solid #aaaaaa; + color: #777777; + background: #dddddd; + padding: 3px 3px 3px 3px; + font-size: 12px; +} + +.button:hover { + background: #BCFF36; + color: #888888; +} + +.flat { + border: 1px solid #888888; +} + +.error_msg { + color: #d01313; +} + +.standout { + color: maroon; + padding: 3px 3px 3px 3px; + text-align: center; +} + +#login_header { + width: 800px; + margin: 0 auto; + padding-bottom: 10px; + text-align: left; +} + + +#login { + width: 750px; + margin: 0 auto; +} + +#login_table { + border-left: 8px solid gray; + border-right: 8px solid gray; + background: #eeeeee; + width: 350px; + margin: 0 auto; +} + +#login_table h4 { + font-size: 13px; +} + +#menu { + width: 800px; + margin: 0 auto; + padding-top: 10px; +} + +#menu ul li { + display: inline; + background: #efefef; + padding: 20px 5px 5px 5px; + margin-right: 3px; + border-top: 4px solid #aaaaaa; +} + +#menu ul li:hover { + background: #BFFF00; /* #F32121; */ + color: white; +} + +#menu ul li a { + color: #888888; +} + +#menu ul li a:hover { + color: #888888; +} + + +#main_menu, #edit_form { + width: 800px; + margin: 0 auto; +} + +#edit_form table { + margin: 0 auto; + padding-top: 10px; + text-align: left; + width: 500px; + border: 1px solid #efefef; +} + +#edit_form h3 { + text-align: center; + font-size: 12px; + margin: 0; + background: #AFE1A6; /*#b4004a;*/ + border: 1px solid #bbb; + line-height: 25px; + color: #555555; +} + +/* Helper class to center some attribs */ +.hlp_center { + text-align: center; +} + +.help_text{ + background: #efefef; + border-left: 1px solid #bbbbbb; + border-right: 1px solid #bbbbbb; + text-align: center; + padding-top: 5px; + padding-bottom: 5px; +} + +#main_menu table { + margin: 0 auto; + text-align: left; + padding-top: 20px; + padding-bottom: 20px; +} + +#main_menu table td { + padding-left: 30px; + padding-bottom: 5px; +} + +#main_menu a { + color: #888888; + padding-left: 8px; +} + +#main_menu a:hover { + color: #40B33C; /*#CD6A6A;*/ + text-decoration: none; + padding-left: 4px; + border-bottom: 1px solid #40B33C; + border-left: 4px solid #40B33C; +} + +#overview, #admin_domains, #admin_virtual { + width: 800px; + margin: 0 auto; + background: #AFE1A6; /*#9ACD32;*/ + border: 1px solid #bbb; +} + +#overview h4, #overview P, #overview FORM, #admin_virtual h4, #admin_virtual P, #admin_virtual FORM { + display: inline; + padding-right: 20px; + line-height: 30px; +} + +#nav_bar { + text-align: right; + width: 800px; + margin: 0 auto; +} + +#alias_table, #mailbox_table, #overview_table, #log_table, #admin_table { + width: 800px; + margin: 0px auto; + border: 1px solid #efefef; +} + +#alias_table .header, #mailbox_table .header, #overview_table .header, #log_table .header, #admin_table .header { + line-height: 20px; + background: #efefef; + color: black; +} + +#alias_table .hilightoff, #mailbox_table .hilightoff, #overview_table .hilightoff, #log_table .hilightoff, #admin_table .hilighoff { + background: white; +} + +#alias_table .hilighton, #mailbox_table .hilighton, #overview_table .hilighton, #log_table .hilighton, #admin_table .hilighton { + background: #D9FF43; /*#D6FF85;*/ /*#ffdddd;*/ +} + +#alias_table h3, #mailbox_table h3, #overview_table h3, #log_table h3, #admin_table h3 { + background: silver; + text-align: left; + font-size: 12px; + font-weight: bold; + padding-left: 20px; + line-height: 25px; + margin: 0; +} + +#footer { + width: 800px; + margin: 20px auto; + border-top: 1px solid #bbbbbb; + background: #efefef; + color: #999999; + line-height: 20px; + text-align: left; + padding-left: 15px; + font-size: 11px; +} + +#footer a { + text-decoration: none; + color: #999999; +} + +#footer a:hover { + text-decoration: underline; + color: #777777; +} + blob - /dev/null blob + 3bdc8e206e7fa7c7f9900ebaf710bb26c8e15793 (mode 644) --- /dev/null +++ templates/admin_create-admin.tpl @@ -0,0 +1,47 @@ +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
    + +  
    +
    +
    blob - /dev/null blob + 9e0efb87e4410a01eec2a1123ce75979f93a2d77 (mode 644) --- /dev/null +++ templates/admin_create-domain.tpl @@ -0,0 +1,62 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
    + /> +
    + /> +  
    +
    +
    blob - /dev/null blob + e679e2793bdfe075de0aa6a8cabe0b37e741b2cf (mode 644) --- /dev/null +++ templates/admin_edit-admin.tpl @@ -0,0 +1,49 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
     
    > 
    + +
    +
    +
    blob - /dev/null blob + 8c640173b4ef1eb60b2d847ecc2da1a39480b332 (mode 644) --- /dev/null +++ templates/admin_edit-domain.tpl @@ -0,0 +1,60 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
     
    + /> 
    + /> 
    +
    +
    blob - /dev/null blob + 9d031a2aca1d65b42edeeceab5837987d5e15177 (mode 644) --- /dev/null +++ templates/admin_list-admin.tpl @@ -0,0 +1,31 @@ + 0) { + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < $list_admins_count; $i++) { + if ((is_array($list_admins) and $list_admins_count > 0)) { + print " \n"; + print " "; + print " "; + print " "; + $active = ($admin_properties[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print " "; + print " "; + print " "; + print " \n"; + } + } + print "
    " . $PALANG['pAdminList_admin_username'] . "" . $PALANG['pAdminList_admin_count'] . "" . $PALANG['pAdminList_admin_modified'] . "" . $PALANG['pAdminList_admin_active'] . " 
    " . $list_admins[$i] . "" . $admin_properties[$i]['domain_count'] . "" . $admin_properties[$i]['modified'] . "" . $active . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; + } +} +?> blob - /dev/null blob + a19af99a3c05e24856837dd3177db8a7eb1446c7 (mode 644) --- /dev/null +++ templates/admin_list-domain.tpl @@ -0,0 +1,61 @@ +
    +
    + + +
    +
    + +
    +
    + + 0) { + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + if ($CONF['transport'] == 'YES') print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($list_domains); $i++) { + if ((is_array($list_domains) and count($list_domains) > 0)) { + print " \n"; + print ""; + print ""; + print ""; + print ""; + if ($CONF['quota'] == 'YES') print ""; + if ($CONF['transport'] == 'YES') print ""; + $backupmx = ($domain_properties[$i]['backupmx'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print ""; + print ""; + $active = ($domain_properties[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print ""; + print ""; + print ""; + print "\n"; + } + } + + print "
    " . $PALANG['pAdminList_domain_domain'] . "" . $PALANG['pAdminList_domain_description'] . "" . $PALANG['pAdminList_domain_aliases'] . "" . $PALANG['pAdminList_domain_mailboxes'] . "" . $PALANG['pAdminList_domain_maxquota'] . "" . $PALANG['pAdminList_domain_transport'] . "" . $PALANG['pAdminList_domain_backupmx'] . "" . $PALANG['pAdminList_domain_modified'] . "" . $PALANG['pAdminList_domain_active'] . " 
    " . $list_domains[$i] . "" . $domain_properties[$i]['description'] . "" . $domain_properties[$i]['alias_count'] . " / " . $domain_properties[$i]['aliases'] . "" . $domain_properties[$i]['mailbox_count'] . " / " . $domain_properties[$i]['mailboxes'] . "" . $domain_properties[$i]['maxquota'] . "" . $domain_properties[$i]['transport'] . "$backupmx" . $domain_properties[$i]['modified'] . "" . $active . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} +?> blob - /dev/null blob + a2c391c1df0c2358ef87a177ba02c6080b6c6407 (mode 644) --- /dev/null +++ templates/admin_list-virtual.tpl @@ -0,0 +1,94 @@ +
    +
    + + + +
    +

    +

    +

    +
    + +
    +
    + +\n"; +if ($tDisplay_back_show == 1) { + print "\""\n"; +} +if ($tDisplay_up_show == 1) { + print "\""\n"; +} +if ($tDisplay_next_show == 1) { + print "\""\n"; +} +print "\n"; + +if (count($tAlias) > 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tAlias); $i++) { + if ((is_array($tAlias) and count($tAlias) > 0)) { + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    " . $PALANG['pOverview_alias_title'] . "

    " . $PALANG['pAdminList_virtual_alias_address'] . "" . $PALANG['pAdminList_virtual_alias_goto'] . "" . $PALANG['pAdminList_virtual_alias_modified'] . " 
    " . $tAlias[$i]['address'] . "" . preg_replace("/,/", "
    ", $tAlias[$i]['goto']) . "
    " . $tAlias[$i]['modified'] . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} + +if (count($tMailbox) > 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tMailbox); $i++) { + if ((is_array($tMailbox) and count($tMailbox) > 0)) { + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    " . $PALANG['pOverview_mailbox_title'] . "

    " . $PALANG['pAdminList_virtual_mailbox_username'] . "" . $PALANG['pAdminList_virtual_mailbox_name'] . "" . $PALANG['pAdminList_virtual_mailbox_quota'] . "" . $PALANG['pAdminList_virtual_mailbox_modified'] . "" . $PALANG['pAdminList_virtual_mailbox_active'] . " 
    " . $tMailbox[$i]['username'] . "" . $tMailbox[$i]['name'] . "" . $tMailbox[$i]['quota'] / $CONF['quota_multiplier'] . "" . $tMailbox[$i]['modified'] . "" . $active . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} +?> blob - /dev/null blob + 9437ae62732372dd406441030766a276aeae1678 (mode 644) --- /dev/null +++ templates/admin_menu.tpl @@ -0,0 +1,22 @@ + +\n"; + include("../motd-admin.txt"); + print ""; +} +?> blob - /dev/null blob + 4d0cc583860d053d7540f7bed569d164f2944fd5 (mode 644) --- /dev/null +++ templates/admin_search.tpl @@ -0,0 +1,64 @@ +
    +

    +
    + +
    +
    + 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tAlias); $i++) { + if ((is_array($tAlias) and count($tAlias) > 0)) { + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    ".$PALANG['pOverview_alias_title']."

    " . $PALANG['pOverview_alias_address'] . "" . $PALANG['pOverview_alias_goto'] . "" . $PALANG['pOverview_alias_modified'] . " 
    " . $tAlias[$i]['address'] . "" . preg_replace("/,/", "
    ", $tAlias[$i]['goto']) . "
    " . $tAlias[$i]['modified'] . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} + +if (count($tMailbox) > 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tMailbox); $i++) { + if ((is_array($tMailbox) and count($tMailbox) > 0)) { + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    ".$PALANG['pOverview_mailbox_title']."

    " . $PALANG['pOverview_mailbox_username'] . "" . $PALANG['pOverview_mailbox_name'] . "" . $PALANG['pOverview_mailbox_quota'] . "" . $PALANG['pOverview_mailbox_modified'] . "" . $PALANG['pOverview_mailbox_active'] . " 
    " . $tMailbox[$i]['username'] . "" . $tMailbox[$i]['name'] . "" . $tMailbox[$i]['quota'] / $CONF['quota_multiplier'] . "" . $tMailbox[$i]['modified'] . "" . $active . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} +?> blob - /dev/null blob + 384b8b2f191de0fbca2fcd72b4a9f069b442a999 (mode 644) --- /dev/null +++ templates/create-alias.tpl @@ -0,0 +1,40 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +

    + + +
    +
    blob - /dev/null blob + b6c680f1567f366eeed3cd60430986ec53ac2801 (mode 644) --- /dev/null +++ templates/create-mailbox.tpl @@ -0,0 +1,65 @@ +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + + +
     
     
     
    + +
    blob - /dev/null blob + 69c21a9c3328d972c4be2a215f9beb8754d0a4ee (mode 644) --- /dev/null +++ templates/edit-alias.tpl @@ -0,0 +1,35 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + +

     
    + +  
    +
    +
    blob - /dev/null blob + 929d046b1916ec525e4e0dd6d1811282d0ffa9a0 (mode 644) --- /dev/null +++ templates/edit-mailbox.tpl @@ -0,0 +1,47 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
     
    > 
    +
    +
    blob - /dev/null blob + 47328c811a27fd4fd8dc93decb8445763c1b16d0 (mode 644) --- /dev/null +++ templates/footer.tpl @@ -0,0 +1,11 @@ + + + blob - /dev/null blob + aaff17bea3f69dff9984a52be0bdc91d1c184f46 (mode 644) --- /dev/null +++ templates/header.tpl @@ -0,0 +1,34 @@ + + + + + + +\n"; +if (file_exists(realpath("../stylesheet.css"))) print "\n"; +?> +OpenSMTPD Admin - <?php print $_SERVER['HTTP_HOST']; ?> + + +
    +\n"; + print "\n"; +} +if (file_exists(realpath("../stylesheet.css"))) { + print "\n"; + print "\n"; +} +if (($CONF['show_header_text'] == "YES") and ($CONF['header_text'])) { + print "

    " . $CONF['header_text'] . "

    \n"; +} +?> +
    blob - /dev/null blob + 1bbc9657ec974d1fae4f577ad21fd0e95e96d55c (mode 644) --- /dev/null +++ templates/index.php @@ -0,0 +1,22 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: index.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +header ("Location: ../login.php"); +exit; +> blob - /dev/null blob + 9b5a0f0f010ababfebb2687c93c2132c4db1d3d5 (mode 644) --- /dev/null +++ templates/login.tpl @@ -0,0 +1,26 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + +

    +
    +
    blob - /dev/null blob + 51b9c0100973d6201eab4e10a6cb601823b3644c (mode 644) --- /dev/null +++ templates/main.tpl @@ -0,0 +1,32 @@ + blob - /dev/null blob + a38efffcbeb15d611687dd1a5b114b6cef093844 (mode 644) --- /dev/null +++ templates/menu.tpl @@ -0,0 +1,20 @@ + +\n"; + include("motd.txt"); + print ""; +} +?> blob - /dev/null blob + cab095f747a7ac5bc035271c68580cfe8344574d (mode 644) --- /dev/null +++ templates/menu.tpl.orig @@ -0,0 +1,24 @@ + + + +

    blob - /dev/null blob + be874e8d2180be9f49f98ef4d290d391efe5ce90 (mode 644) --- /dev/null +++ templates/message.tpl @@ -0,0 +1 @@ + blob - /dev/null blob + ac41c3d497a7385b7e13a3c450597286899ae6a6 (mode 644) --- /dev/null +++ templates/overview-get.tpl @@ -0,0 +1,52 @@ +

    +
    + + +
    +
    + +
    +
    +\n"; + print " \n"; + print "

    ".$PALANG['pOverview_title']."

    "; + print " "; + print " \n"; + print " " . $PALANG['pOverview_get_domain'] . "\n"; + print " " . $PALANG['pOverview_get_aliases'] . "\n"; + print " " . $PALANG['pOverview_get_mailboxes'] . "\n"; + if ($CONF['quota'] == 'YES') print " " . $PALANG['pOverview_get_quota'] . "\n"; + print " \n"; + + for ($i = 0; $i < count($list_domains); $i++) { + if ((is_array($list_domains) and count($list_domains) > 0)) { + $limit = get_domain_properties($list_domains[$i]); + + if ($limit['aliases'] == 0) $limit['aliases'] = $PALANG['pOverview_unlimited']; + if ($limit['mailboxes'] == 0) $limit['mailboxes'] = $PALANG['pOverview_unlimited']; + if ($limit['maxquota'] == 0) $limit['maxquota'] = $PALANG['pOverview_unlimited']; + if ($limit['aliases'] < 0) $limit['aliases'] = $PALANG['pOverview_disabled']; + if ($limit['mailboxes'] < 0) $limit['mailboxes'] = $PALANG['pOverview_disabled']; + if ($limit['maxquota'] < 0) $limit['maxquota'] = $PALANG['pOverview_disabled']; + + print " \n"; + print " " . $list_domains[$i] . "\n"; + print " " . $limit['alias_count'] . " / " . $limit['aliases'] . "\n"; + print " " . $limit['mailbox_count'] . " / " . $limit['mailboxes'] . "\n"; + if ($CONF['quota'] == 'YES') print " " . $limit['maxquota'] . "\n"; + print " \n"; + } + } + print "\n"; +?> blob - /dev/null blob + f1008d8ab91792a4506cb966e3615e9c7de3ac04 (mode 644) --- /dev/null +++ templates/overview.tpl @@ -0,0 +1,117 @@ +
    +
    + + + +
    +

    +

    +

    +
    + +
    +
    + +\n"; +if ($tDisplay_back_show == 1) print "\""\n"; +if ($tDisplay_up_show == 1) print "\""\n"; +if ($tDisplay_next_show == 1) print "\""\n"; +print "\n"; + +if (count($tAlias) > 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tAlias); $i++) { + if ((is_array($tAlias) and count($tAlias) > 0)) { + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + if ($CONF['special_alias_control'] == 'YES') { + print " \n"; + print " \n"; + } else { + if (!in_array($tAlias[$i]['goto'], $CONF['default_aliases'])) { + print " \n"; + print " \n"; + } else { + print " \n"; + print " \n"; + } + } + print " \n"; + } + } + + print "

    ".$PALANG['pOverview_alias_title']."

    " . $PALANG['pOverview_alias_address'] . "" . $PALANG['pOverview_alias_goto'] . "" . $PALANG['pOverview_alias_modified'] . " 
    " . $tAlias[$i]['address'] . "" . preg_replace("/,/", "
    ", $tAlias[$i]['goto']) . "
    " . $tAlias[$i]['modified'] . "" . $PALANG['edit'] . "" . $PALANG['del'] . "" . $PALANG['edit'] . "" . $PALANG['del'] . "  
    \n"; +} + +if (count($tMailbox) > 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tMailbox); $i++) { + if ((is_array($tMailbox) and count($tMailbox) > 0)) { + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') { + print " \n"; + } + print " \n"; + $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    ".$PALANG['pOverview_mailbox_title']."

    " . $PALANG['pOverview_mailbox_username'] . "" . $PALANG['pOverview_mailbox_name'] . "" . $PALANG['pOverview_mailbox_quota'] . "" . $PALANG['pOverview_mailbox_modified'] . "" . $PALANG['pOverview_mailbox_active'] . " 
    " . $tMailbox[$i]['username'] . "" . $tMailbox[$i]['name'] . ""; + if ($tMailbox[$i]['quota'] == 0) { + print $PALANG['pOverview_unlimited']; + } elseif ($tMailbox[$i]['quota'] < 0) { + print $PALANG['pOverview_disabled']; + } else { + print $tMailbox[$i]['quota'] / $CONF['quota_multiplier']; + } + print "" . $tMailbox[$i]['modified'] . "" . $active . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} +?> blob - /dev/null blob + cefcf5c905c7b7c4a548eb040a6cd3359eedc4a1 (mode 644) --- /dev/null +++ templates/password.tpl @@ -0,0 +1,35 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
    +
    +
    blob - /dev/null blob + 58386c3f0c07cdf073428a4240ed267f7a9e7c3d (mode 644) --- /dev/null +++ templates/search.tpl @@ -0,0 +1,65 @@ +
    +

    +
    + +
    +
    + 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tAlias); $i++) { + if ((is_array($tAlias) and count($tAlias) > 0)) { + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + + print "

    ".$PALANG['pOverview_alias_title']."

    " . $PALANG['pOverview_alias_address'] . "" . $PALANG['pOverview_alias_goto'] . "" . $PALANG['pOverview_alias_modified'] . " 
    " . $tAlias[$i]['address'] . "" . preg_replace("/,/", "
    ", $tAlias[$i]['goto']) . "
    " . $tAlias[$i]['modified'] . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} + +if (count($tMailbox) > 0) { + print "\n"; + print " \n"; + print " "; + print " "; + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < count($tMailbox); $i++) { + if ((is_array($tMailbox) and count($tMailbox) > 0)) { + print " \n"; + print " \n"; + print " \n"; + if ($CONF['quota'] == 'YES') print " \n"; + print " \n"; + $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    ".$PALANG['pOverview_mailbox_title']."

    " . $PALANG['pOverview_mailbox_username'] . "" . $PALANG['pOverview_mailbox_name'] . "" . $PALANG['pOverview_mailbox_quota'] . "" . $PALANG['pOverview_mailbox_modified'] . "" . $PALANG['pOverview_mailbox_active'] . " 
    " . $tMailbox[$i]['username'] . "" . $tMailbox[$i]['name'] . "" . $tMailbox[$i]['quota'] / $CONF['quota_multiplier'] . "" . $tMailbox[$i]['modified'] . "" . $active . "" . $PALANG['edit'] . "" . $PALANG['del'] . "
    \n"; +} +?> blob - /dev/null blob + f244ad650fb3a3daa0d533ff6788c21a4e528a22 (mode 644) --- /dev/null +++ templates/sendmail.tpl @@ -0,0 +1,37 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
     
     
    + +  
    +
    +
    blob - /dev/null blob + 8111c3bd4cfd1a694af71cb637ced8980258b179 (mode 644) --- /dev/null +++ templates/users_edit-alias.tpl @@ -0,0 +1,36 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + +

     
    +  
    +
    +
    blob - /dev/null blob + 93a4aa9ac8152d44c97ce3bab3991bd4917630e4 (mode 644) --- /dev/null +++ templates/users_login.tpl @@ -0,0 +1,23 @@ +
    +
    + + + + + + + + + + + + + + + + + + +

    +
    +
    blob - /dev/null blob + 555b8d8c8688559724d1c1ccddb3dd1b12c82e00 (mode 644) --- /dev/null +++ templates/users_main.tpl @@ -0,0 +1,26 @@ + blob - /dev/null blob + 804fdf41ff7c84948919e0c5ecad595648c8f3ae (mode 644) --- /dev/null +++ templates/users_menu.tpl @@ -0,0 +1,18 @@ + + +\n"; + include("../motd-users.txt"); + print ""; +} +?> blob - /dev/null blob + 4e7c8c5f16fdeaa2ad257b223dbc262184b329fa (mode 644) --- /dev/null +++ templates/users_password.tpl @@ -0,0 +1,35 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

     
    +
    +
    blob - /dev/null blob + 2b6b42fce704c8098f61af28deeeef07c5dd8c15 (mode 644) --- /dev/null +++ templates/users_vacation-get.tpl @@ -0,0 +1,9 @@ +
    +
    + + + + +
    +
    +
    blob - /dev/null blob + 1f36a35045f40f188da2b475df6898e1800a6196 (mode 644) --- /dev/null +++ templates/users_vacation.tpl @@ -0,0 +1,29 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + +

     
    + +  
    +
    +
    blob - /dev/null blob + 669bae16a9c3e91c035cfeba242d68e85c464e4d (mode 644) --- /dev/null +++ templates/viewlog.tpl @@ -0,0 +1,53 @@ +
    +
    + + +
    +
    + 0) { + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + + for ($i = 0; $i < $tLog_count; $i++) { + if ((is_array($tLog) and $tLog_count > 0)) { + $log_data = $tLog[$i]['data']; + $data_length = strlen($log_data); + if ($data_length > 35) $log_data = substr($log_data, 0, 35) . " ..."; + + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + } + } + print "

    ".$PALANG['pViewlog_welcome']." ".$fDomain."

    " . $PALANG['pViewlog_timestamp'] . "" . $PALANG['pViewlog_username'] . "" . $PALANG['pViewlog_domain'] . "" . $PALANG['pViewlog_action'] . "" . $PALANG['pViewlog_data'] . "
    " . $tLog[$i]['timestamp'] . "" . $tLog[$i]['username'] . "" . $tLog[$i]['domain'] . "" . $tLog[$i]['action'] . "" . $log_data . "
    \n"; + print "

    \n"; + } +} +?> blob - /dev/null blob + b8a233f9aa11298a2f05ce59bafadacaa9798175 (mode 644) --- /dev/null +++ users/edit-alias.php @@ -0,0 +1,85 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: edit-alias.php +// +// Template File: users_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"); + +$USERID_USERNAME = check_user_session(); +$USERID_DOMAIN = substr(strrchr($USERID_USERNAME, "@"), 1); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $result = db_query("SELECT * FROM alias WHERE address='$USERID_USERNAME'"); + if ($result['rows'] == 1) { + $row = db_array($result['result']); + $tGoto = preg_replace('/vmail/', '', $row['goto']); + #$tGoto = $row['goto']; + } else { + $tMessage = $PALANG['pEdit_alias_address_error']; + } +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; + + if (isset($_POST['fGoto'])) $fGoto = escape_string($_POST['fGoto']); + $fGoto = strtolower($fGoto); + + $goto = preg_replace('/\\\r\\\n/', ',', $fGoto); + $goto = preg_replace('/\r\n/', ',', $fGoto); + $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]"; + } + } + + if ($error != 1) { + if (empty($goto)) { + $goto = "vmail"; + } else { + $goto = "vmail," . $goto; + } + + $result = db_query("UPDATE alias SET goto='$goto',modified=NOW() WHERE address='$USERID_USERNAME'"); + if ($result['rows'] != 1) { + $tMessage = $PALANG['pEdit_alias_result_error']; + } else { + db_log($USERID_USERNAME, $USERID_DOMAIN, "edit alias", "$USERID_USERNAME -> $goto"); + + header("Location: main.php"); + exit; + } + } +} +include("../templates/header.tpl"); +include("../templates/users_menu.tpl"); +include("../templates/users_edit-alias.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + 9c7dcefd96211dab8ee4744ad293817fa63438ac (mode 644) --- /dev/null +++ users/index.php @@ -0,0 +1,22 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: index.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +header("Location: login.php"); +exit; +?> blob - /dev/null blob + 17676c28d1ab5aa5b5a6b3a7f05bd49dd643df88 (mode 644) --- /dev/null +++ users/login.php @@ -0,0 +1,54 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: login.php +// +// Template File: login.tpl +// +// Template Variables: +// +// tMessage +// tUsername +// +// Form POST \ GET Variables: +// +// fUsername +// fPassword +// +require("../variables.inc.php"); +require("../config.inc.php"); +require("../functions.inc.php"); +include("../languages/" . check_language() . ".lang"); + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fUsername = escape_string($_POST['fUsername']); + $fPassword = escape_string($_POST['fPassword']); + + $result = db_query("SELECT password FROM mailbox WHERE username='$fUsername' AND active='1'"); + if ($result['rows'] == 1) { + $row = db_array($result['result']); + if (!password_verify($fPassword, $row['password'])) { + $error = 1; + $tMessage = $PALANG['pLogin_password_incorrect']; + $tUsername = $fUsername; + } + } else { + $error = 1; + $tMessage = $PALANG['pLogin_username_incorrect']; + } + + if ($error != 1) { + session_start(); + $_SESSION['userid']['username'] = $fUsername; + header("Location: main.php"); + exit; + } +} +include("../templates/header.tpl"); +include("../templates/users_login.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + 2f7ebf8240839b62d9674d44c44e9170a58c9ad7 (mode 644) --- /dev/null +++ users/logout.php @@ -0,0 +1,30 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: logout.php +// +// Template File: -none- +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +require("../config.inc.php"); +require("../functions.inc.php"); + +$USERID_USERNAME = check_user_session(); + +session_unset(); +session_destroy(); + +header("Location: login.php"); +exit; +?> blob - /dev/null blob + f40bd2c77b1f5cf88b96d9d3ef333a45ee7ffb41 (mode 644) --- /dev/null +++ users/main.php @@ -0,0 +1,29 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: main.php +// +// Template File: main.tpl +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// -none- +// +require("../config.inc.php"); +require("../functions.inc.php"); +include("../languages/" . check_language() . ".lang"); + +$USERID_USERNAME = check_user_session(); + +include("../templates/header.tpl"); +include("../templates/users_menu.tpl"); +include("../templates/users_main.tpl"); +include("../templates/footer.tpl"); blob - /dev/null blob + a3175fb3febfe5b75adf348bb39398bbf808a2b9 (mode 644) --- /dev/null +++ users/password.php @@ -0,0 +1,70 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: password.php +// +// Template File: users_password.tpl +// +// Template Variables: +// +// tMessage +// +// Form POST \ GET Variables: +// +// fPassword_current +// fPassword +// fPassword2 +// +require("../variables.inc.php"); +require("../config.inc.php"); +require("../functions.inc.php"); +include("../languages/" . check_language() . ".lang"); + +$USERID_USERNAME = check_user_session(); +$USERID_DOMAIN = substr(strrchr($USERID_USERNAME, "@"), 1); + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fPassword_current = escape_string($_POST['fPassword_current']); + $fPassword = escape_string($_POST['fPassword']); + $fPassword2 = escape_string($_POST['fPassword2']); + + $username = $USERID_USERNAME; + + $result = db_query("SELECT * FROM mailbox WHERE username='$username'"); + if ($result['rows'] == 1) { + $row = db_array($result['result']); + if (!password_verify($fPassword_current, $row['password'])) { + $error = 1; + $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; + } + } else { + $error = 1; + $pPassword_email_text = $PALANG['pPassword_email_text_error']; + } + + if (empty($fPassword) or ($fPassword != $fPassword2)) + { + $error = 1; + $pPassword_password_text = $PALANG['pPassword_password_text_error']; + } + + if ($error != 1) { + $password = pacrypt($fPassword); + $result = db_query("UPDATE mailbox SET password='$password',modified=NOW(),scheme='' WHERE username='$username'"); + if ($result['rows'] == 1) { + $tMessage = $PALANG['pPassword_result_succes']; + db_log($USERID_USERNAME, $USERID_DOMAIN, "change password", "$USERID_USERNAME"); + } else { + $tMessage = $PALANG['pPassword_result_error']; + } + } +} +include("../templates/header.tpl"); +include("../templates/users_menu.tpl"); +include("../templates/users_password.tpl"); +include("../templates/footer.tpl"); +?> blob - /dev/null blob + 162c9a34c56e136834f685893fe4f7c4093d34b7 (mode 644) --- /dev/null +++ users/vacation.php @@ -0,0 +1,77 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: vacation.php +// +// Template File: users_vacation.tpl +// +// Template Variables: +// +// tMessage +// tSubject +// tBody +// +// Form POST \ GET Variables: +// +// fSubject +// fBody +// +require("../variables.inc.php"); +require("../config.inc.php"); +require("../functions.inc.php"); +include("../languages/" . check_language() . ".lang"); + +$USERID_USERNAME = check_user_session(); +$USERID_DOMAIN = substr(strrchr($USERID_USERNAME, "@"), 1); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $result = db_query("SELECT * FROM vacation WHERE email='$USERID_USERNAME'"); + if ($result['rows'] == 1) { + $row = db_array($result['result']); + $tMessage = $PALANG['pUsersVacation_welcome_text']; + $template = "users_vacation-get.tpl"; + } else { + $template = "users_vacation.tpl"; + } + + include("../templates/header.tpl"); + include("../templates/users_menu.tpl"); + include("../templates/$template"); + include("../templates/footer.tpl"); +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + if (isset($_POST['fSubject'])) $fSubject = escape_string($_POST['fSubject']); + if (isset($_POST['fBody'])) $fBody = escape_string($_POST['fBody']); + + if (!empty($_POST['fBack'])) { + $result = db_query("DELETE FROM vacation WHERE email='$USERID_USERNAME'"); + if ($result['rows'] != 1) { + $error = 1; + $tMessage = $PALANG['pUsersVacation_result_error']; + } else { + $tMessage = $PALANG['pUsersVacation_result_succes']; + } + } + + if (!empty($_POST['fAway'])) { + $result = db_query("INSERT INTO vacation (email,subject,body,cache,domain,created,active) VALUES ('$USERID_USERNAME','$fSubject','$fBody','','$USERID_DOMAIN',NOW(),'1')"); + if ($result['rows'] != 1) { + $error = 1; + $tMessage = $PALANG['pUsersVacation_result_error']; + } else { + header("Location: main.php"); + exit; + } + } + + include("../templates/header.tpl"); + include("../templates/users_menu.tpl"); + include("../templates/users_vacation.tpl"); + include("../templates/footer.tpl"); +} +?> blob - /dev/null blob + cb0ed0dc9ca61ef6a69161b42923e1b19e72541f (mode 644) --- /dev/null +++ variables.inc.php @@ -0,0 +1,88 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: variables.inc.php +// +if (preg_match("/variables.inc.php/", $_SERVER['SCRIPT_NAME'])) { + header ("Location: login.php"); + exit; +} + +$error = ""; +$escaped_string = ""; +$quota = ""; +$vacation = ""; +$fActive = ""; +$fAddress = ""; +$fAliases = ""; +$fBackupmx = ""; +$fDefaultaliases = ""; +$fDelete = ""; +$fDescription = ""; +$fDomain = ""; +$fDomains = ""; +#$fDomains[0] = ""; +$fGoto = ""; +$fMail = ""; +$fMailboxes = ""; +$fMaxquota = ""; +$fName = ""; +$fPassword = ""; +$fPassword2 = ""; +$fQuota = ""; +$fSearch = ""; +$fTable = ""; +$fTransport = ""; +$fUsername = ""; +$fVacation = ""; +$fWhere = ""; +$tActive = ""; +$tActive = ""; +$tAddress = ""; +$tAlias = ""; +$tAliases = ""; +$tBody = ""; +$tDefaultaliases = ""; +$tDescription = ""; +$tDisplay_back = ""; +$tDisplay_back_show = ""; +$tDisplay_up_show = ""; +$tDisplay_next = ""; +$tDisplay_next_show = ""; +$tDomain = ""; +$tDomains = ""; +$tFrom = ""; +$tGoto = ""; +$tLog = array(); +$tMailbox = ""; +$tMailboxes = ""; +$tMaxquota = ""; +$tMessage = " "; +$tName = ""; +$tQuota = ""; +$tSubject = ""; +$tUsername = ""; +$tTransport = ""; + +$pAdminCreate_admin_password_text = " "; +$pAdminCreate_admin_username_text = " "; +$pAdminCreate_domain_defaultaliases_text = " "; +$pAdminCreate_domain_domain_text = " "; +$pAdminEdit_admin_password_text = " "; +$pCreate_alias_address_text = " "; +$pCreate_alias_goto_text = " "; +$pCreate_mailbox_name_text = " "; +$pCreate_mailbox_password_text = " "; +$pCreate_mailbox_quota_text = " "; +$pCreate_mailbox_username_text = " "; +$pEdit_mailbox_password_text = " "; +$pEdit_mailbox_quota_text = " "; +$pEdit_mailbox_username_text = " "; +$pPassword_admin_text = " "; +$pPassword_password_current_text = " "; +$pPassword_password_text = " "; +?> blob - /dev/null blob + dabb73aa57f712129861761015376f6a3e0c9cf1 (mode 644) --- /dev/null +++ viewlog.php @@ -0,0 +1,68 @@ + +// Copyright (c) 2022 High5! +// License Info: LICENSE.TXT +// +// File: viewlog.php +// +// Template File: viewlog.tpl +// +// Template Variables: +// +// tMessage +// tLog +// +// Form POST \ GET Variables: +// +// fDomain +// +require("./variables.inc.php"); +require("./config.inc.php"); +require("./functions.inc.php"); +include("./languages/" . check_language() . ".lang"); + +$SESSID_USERNAME = check_session(); +$list_domains = list_domains_for_admin($SESSID_USERNAME); + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + if ((is_array($list_domains) and count($list_domains) > 0)) $fDomain = $list_domains[0]; + + if (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tMessage = $PALANG['pViewlog_result_error']; + } + + if ($error != 1) { + $result = db_query("SELECT * FROM log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tLog[] = $row; + } + } + } +} + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + $fDomain = escape_string($_POST['fDomain']); + + if (!check_owner($SESSID_USERNAME, $fDomain)) { + $error = 1; + $tMessage = $PALANG['pViewlog_error']; + } + + if ($error != 1) { + $result = db_query("SELECT * FROM log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT 10"); + if ($result['rows'] > 0) { + while ($row = db_array($result['result'])) { + $tLog[] = $row; + } + } + } +} +include("./templates/header.tpl"); +include("./templates/menu.tpl"); +include("./templates/viewlog.tpl"); +include("./templates/footer.tpl"); +?>