opensmtpdadmin/users/password.php

71 lines
1.9 KiB
PHP
Raw Normal View History

2022-08-18 14:01:52 +02:00
<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// 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']);
2022-09-03 11:30:40 +02:00
if (!password_verify($fPassword_current, $row['assword'])) {
2022-08-18 14:01:52 +02:00
$error = 1;
2022-09-03 11:30:40 +02:00
$pPassword_password_current_text = $LANG['Password_password_current_text_error'];
2022-08-18 14:01:52 +02:00
}
} else {
$error = 1;
2022-09-03 11:30:40 +02:00
$pPassword_email_text = $LANG['Password_email_text_error'];
2022-08-18 14:01:52 +02:00
}
if (empty($fPassword) or ($fPassword != $fPassword2))
{
$error = 1;
2022-09-03 11:30:40 +02:00
$pPassword_password_text = $LANG['Password_password_text_error'];
2022-08-18 14:01:52 +02:00
}
if ($error != 1) {
$password = pacrypt($fPassword);
$result = db_query("UPDATE mailbox SET password='$password',modified=NOW(),scheme='' WHERE username='$username'");
if ($result['rows'] == 1) {
2022-09-03 11:30:40 +02:00
$tMessage = $LANG['Password_result_succes'];
2022-08-18 14:01:52 +02:00
db_log($USERID_USERNAME, $USERID_DOMAIN, "change password", "$USERID_USERNAME");
} else {
2022-09-03 11:30:40 +02:00
$tMessage = $LANG['Password_result_error'];
2022-08-18 14:01:52 +02:00
}
}
}
include("../templates/header.tpl");
include("../templates/users_menu.tpl");
include("../templates/users_password.tpl");
include("../templates/footer.tpl");
?>