0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 19:22:14 +02:00

merge fix

This commit is contained in:
David Goodwin 2021-05-15 21:28:19 +01:00
commit 659b242b59
11 changed files with 83 additions and 20 deletions

View File

@ -6,18 +6,31 @@
#
# Further details on the project are available at https://github.com/postfixadmin/postfixadmin
MASTER (should have all changes from 3.3.9 plus)
MASTER (should have all changes from 3.3.10 plus)
------
- Add optional Dovecot mail-crypt plugin support - see https://github.com/postfixadmin/postfixadmin/issues/408
- Add $CONF['site_url'] to allow administrators to override a detected site url (e.g. used in password recovery emails; see https://github.com/postfixadmin/postfixadmin/issues/446 )
- Code reformat as PHPCS has a mind of it's own (function/method opening brace change of position)
- Improved UTF8 support in vacation (see https://github.com/postfixadmin/postfixadmin/pull/484)
- Fix quota levels losing config control (see bfc7af5c8efe2a68c47286cc870b56cb4f929a3f)
- vacation.pl: improve autoreply detection (see https://github.com/postfixadmin/postfixadmin/pull/482
- vacation.pl: improve headers in auto-reply mails (add: "Auto-Submitted: auto-replied") see https://github.com/postfixadmin/postfixadmin/pull/483
- vacation.pl: allow smtp helo to be customised; see https://github.com/postfixadmin/postfixadmin/pull/495
Version 3.3.9 - ??????????
Version 3.3.10 - ???
-------------------------------------------------
- Improve Ukrainian language (thanks: andrew.kudrinov) (forgot to cherry-pick 4a960a0ce06b0754fa7b39aed0d5c57a88b20720 from master)
- Merge password expiration fixes from https://github.com/postfixadmin/postfixadmin/pull/493
- Remove html readonly attribute from user's vacation page to/from selectors.
Version 3.3.9 - 2021/05/12
-------------------------------------------------
- Improve Ukrainian language (ua.lang) (thanks: andrew.kudrinov)
- Ensure we update timestamp fields (created / modified) when performing db operations, see: https://github.com/postfixadmin/postfixadmin/issues/469
- Add domain_admins.id pk column for non-sqlite users, see: https://github.com/postfixadmin/postfixadmin/issues/475
- Add fix for MySQL error where a default datetime value in the domain field breaks the upgrade.php db schema update, see https://github.com/postfixadmin/postfixadmin/issues/489
- Bug fix quota levels (now user configurable again; thanks @csware, see https://github.com/postfixadmin/postfixadmin/commit/bfc7af5c8efe2a68c47286cc870b56cb4f929a3f
Version 3.3.8 - 2021/03/04
-------------------------------------------------

View File

@ -85,7 +85,7 @@ do
QUERY="SELECT username,password_expiry FROM mailbox WHERE password_expiry > now() + interval $LOWER DAY AND password_expiry < NOW() + interval $INTERVAL DAY"
mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -e "$QUERY" | while read -a RESULT ; do
mysql --defaults-extra-file="$MYSQL_CREDENTIALS_FILE" "$POSTFIX_DB" -B -N -e "$QUERY" | while IFS=$'\t' read -a RESULT ; do
echo -e "Dear User, \n Your password will expire on ${RESULT[1]}" | mail -s "Password 30 days before expiration notication" -r $REPLY_ADDRESS ${RESULT[0]}
done
done

View File

@ -58,9 +58,12 @@ our $smtp_server = 'localhost';
# port to connect to; defaults to 25 for non-SSL, 465 for 'ssl', 587 for 'starttls'
our $smtp_server_port = 25;
# this is the local address from which to connect
our $smtp_client = 'localhost';
# this is the helo we [the vacation script] use on connection; you may need to change this to your hostname or something,
# depending upon what smtp helo restrictions you have in place within Postfix.
our $smtp_client = 'localhost';
our $smtp_helo = 'localhost.localdomain';
# send mail encrypted or plaintext
# if 'starttls', use STARTTLS; if 'ssl' (or 1), connect securely; otherwise, no security
@ -479,6 +482,7 @@ sub send_vacation_email {
ssl => $smtp_ssl,
timeout => $smtp_timeout,
localaddr => $smtp_client,
helo => $smtp_helo,
debug => 0,
};

View File

@ -15,7 +15,7 @@
*/
$min_db_version = 1843; # update (at least) before a release with the latest function numbrer in upgrade.php
$min_db_version = 1844; # update (at least) before a release with the latest function numbrer in upgrade.php
/**
* check_session

View File

@ -276,11 +276,13 @@ $PALANG['domain_updated'] = 'Домен %s успішно оновлено.';
$PALANG['pAdminDelete_admin_error'] = 'Неможливо видалити адміністратора!';
$PALANG['domain_postdel_failed'] = 'Не вдалося коректно виконати скрипт після видалення домену, подробиці дивіться у журналі помилок!';
$PALANG['domain_postedit_failed'] = 'Не вдалося коректно виконати скрипт після редагування домену, подробиці дивіться у журналі помилок!';
$PALANG['domain_postcreate_failed'] = 'Не вдалося коректно виконати скрипт після створення домену, подробиці дивіться у журналі помилок!';
$PALANG['mailbox_postdel_failed'] = 'Не вдалося коректно виконати скрипт після видалення поштової скриньки, подробиці дивіться у журналі помилок!';
$PALANG['mailbox_postedit_failed'] = 'Не вдалося коректно виконати скрипт після редагування поштової скриньки, подробиці дивіться у журналі помилок!';
$PALANG['mailbox_postcreate_failed'] = 'Не вдалося коректно виконати скрипт після створення поштової скриньки, подробиці дивіться у журналі помилок!';
$PALANG['mailbox_postpassword_failed'] = 'Не вдалося коректно виконати скрипт після зміни пароля поштової скриньки, подробиці дивіться у журналі помилок!';
$PALANG['pAdminDelete_alias_domain_error'] = 'Неможливо видалити псевдоним (аліас) домену!';
$PALANG['domain_conflict_vacation_domain'] = 'Ви не можете використовувати домен автовідповідача у якості поштового домену!';

View File

@ -91,6 +91,30 @@ class Login
return false;
}
/**
* returns user's domain name
* @param $username
* @return string|null
* @throws Exception
*/
protected function getUserDomain(string $username)
{
$sql = "SELECT domain FROM {$this->table} WHERE username = :username AND active = :active";
$values = [
'username' => $username,
'active' => db_get_boolean(true),
];
// Fetch the domain
$result = db_query_one($sql, $values);
if (is_array($result) && isset($result['domain'])) {
return $result['domain'];
} else {
return null;
}
}
/**
* @param string $username
@ -115,6 +139,14 @@ class Login
'password' => pacrypt($new_password),
);
if (Config::bool('password_expiration')) {
$domain = $this->getUserDomain($username);
if (!is_null($domain)) {
$password_expiration_value = (int)get_password_expiration_value($domain);
$set['password_expiry'] = date('Y-m-d H:i', strtotime("+$password_expiration_value day"));
}
}
$result = db_update($this->table, 'username', $username, $set);
if ($result != 1) {

View File

@ -231,9 +231,15 @@ class VacationHandler extends PFAHandler
{
$this->remove(); // clean out any notifications that might already have been sent.
$E_username = escape_string($this->username);
$activeFrom = date("Y-m-d 00:00:00", strtotime($activeFrom)); # TODO check if result looks like a valid date
$activeUntil = date("Y-m-d 23:59:59", strtotime($activeUntil)); # TODO check if result looks like a valid date
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $activeFrom)) {
$activeFrom .= ' 00:00:00';
}
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $activeUntil)) {
$activeUntil .= ' 23:59:59';
}
$activeFrom = date("Y-m-d H:i", strtotime($activeFrom)); # TODO check if result looks like a valid date
$activeUntil = date("Y-m-d H:i", strtotime($activeUntil)); # TODO check if result looks like a valid date
list(/*NULL*/, $domain) = explode('@', $this->username);
$vacation_data = array(

View File

@ -334,23 +334,28 @@ EOF;
<h2 class="h2">Database Update</h2>
<?php
if ($authenticated) {
$db = false;
try {
$db = db_connect();
} catch (\Exception $e) {
error_log("Couldn't perform PostfixAdmin database update - " . $e->getMessage());
echo "<p class='h3 text-danger'>Something went wrong while trying to connect to the database. A message should be logged - check PHP's error_log (" . ini_get('error_log') . ')</p>\n';
error_log("Couldn't perform PostfixAdmin database update - failed to connect to db? " . $e->getMessage() . " Trace: " . $e->getTraceAsString());
}
if ($db) {
print "<p>Everything seems fine... attempting to create/update database structure</p>\n";
require_once(dirname(__FILE__) . '/upgrade.php');
echo "<p>Everything seems fine... attempting to create/update database structure</p>\n";
try {
require_once(dirname(__FILE__) . '/upgrade.php');
} catch (\Exception $e) {
if ($authenticated) {
echo "<p class='h3 text-danger'>Exception message: {$e->getMessage()} - check logs!</p>";
}
echo "<p class='h3 text-danger'>Something went wrong while trying to apply database updates, a message should be logged - check PHP's error_log (" . ini_get('error_log') . ')</p>\n';
error_log("Couldn't perform PostfixAdmin database update via upgrade.php - " . $e->getMessage() . " Trace: " . $e->getTraceAsString());
}
} else {
echo "<h3 class='h3 text-danger'>Could not connect to database to perform updates; check PHP error log.</h3>";
}
} else {
echo "<h3 class='h3 text-warning'>Please login to see perform database update.</h3>";
}
?>
</div>

View File

@ -256,7 +256,7 @@ function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "")
'{UNSIGNED}' => 'unsigned' ,
'{FULLTEXT}' => 'FULLTEXT',
'{BOOLEAN}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(false) . "'",
'{UTF-8}' => '/*!40100 CHARACTER SET utf8 */',
'{UTF-8}' => '/*!40100 CHARACTER SET utf8mb4 */',
'{LATIN1}' => '/*!40100 CHARACTER SET latin1 COLLATE latin1_general_ci */',
'{IF_NOT_EXISTS}' => 'IF NOT EXISTS',
'{RENAME_COLUMN}' => 'CHANGE COLUMN',
@ -1903,6 +1903,7 @@ function upgrade_1837()
_db_add_field($table, 'token_validity', '{DATETIME}', 'token');
}
}
# TODO MySQL:
# - various varchar fields do not have a default value
# https://sourceforge.net/projects/postfixadmin/forums/forum/676076/topic/3419725

View File

@ -154,7 +154,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
if ($action == 'fChange') {
## check if ActiveUnitl is not back in time,
## check if ActiveUntil is not back in time,
## because vacation.pl will report SMTP recipient $smtp_recipient which resolves to $email does not have an active vacation (rv: $rv, email: $email)"
## and will not send message

View File

@ -17,7 +17,7 @@
class="form-control hidden"/>
<div class="input-group date" id="datetimepicker-fActiveFrom">
<input type='text' name="fActiveFromForm" id="fActiveFromForm" value="{$tActiveFrom}"
class="form-control" readonly="readonly"/>
class="form-control" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
@ -31,7 +31,7 @@
<div class="input-group date" id="datetimepicker-fActiveUntil">
<input type='text'
name="fActiveUntilForm" id="fActiveUntilForm" value="{$tActiveUntil}"
class="form-control" readonly="readonly"/>
class="form-control" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>