2007-03-24 08:27:00 +01:00
|
|
|
<?php
|
2007-09-30 17:53:54 +02:00
|
|
|
/**
|
|
|
|
* Postfix Admin
|
|
|
|
*
|
|
|
|
* LICENSE
|
|
|
|
* This source file is subject to the GPL license that is bundled with
|
|
|
|
* this package in the file LICENSE.TXT.
|
|
|
|
*
|
2013-11-10 16:57:32 +01:00
|
|
|
* Further details on the project are available at http://postfixadmin.sf.net
|
2007-09-30 17:53:54 +02:00
|
|
|
*
|
|
|
|
* @version $Id$
|
|
|
|
* @license GNU GPL v2 or later.
|
|
|
|
*
|
|
|
|
* File: password.php
|
|
|
|
* Used by users to change their mailbox (and login) password.
|
2011-07-29 21:48:17 +02:00
|
|
|
* Template File: password.tpl
|
2007-09-30 17:53:54 +02:00
|
|
|
*
|
|
|
|
* Template Variables:
|
|
|
|
*
|
2011-07-19 00:36:38 +02:00
|
|
|
* none
|
2007-09-30 17:53:54 +02:00
|
|
|
*
|
|
|
|
* Form POST \ GET Variables:
|
|
|
|
*
|
|
|
|
* fPassword_current
|
|
|
|
* fPassword
|
|
|
|
* fPassword2
|
|
|
|
*/
|
2007-03-24 08:27:00 +01:00
|
|
|
|
2012-05-28 20:01:31 +02:00
|
|
|
$rel_path = '../';
|
2007-09-22 12:54:00 +02:00
|
|
|
require_once('../common.php');
|
|
|
|
|
|
|
|
authentication_require_role('user');
|
2009-03-25 15:51:12 +01:00
|
|
|
$username = authentication_get_username();
|
2007-09-22 12:54:00 +02:00
|
|
|
|
2011-03-14 21:21:13 +01:00
|
|
|
$pPassword_password_text = "";
|
|
|
|
$pPassword_password_current_text = "";
|
|
|
|
|
2007-03-24 08:27:00 +01:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
|
|
|
{
|
2007-11-12 01:46:52 +01:00
|
|
|
if(isset($_POST['fCancel'])) {
|
|
|
|
header("Location: main.php");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2009-03-25 15:51:12 +01:00
|
|
|
$fPassword_current = $_POST['fPassword_current'];
|
|
|
|
$fPassword = $_POST['fPassword'];
|
|
|
|
$fPassword2 = $_POST['fPassword2'];
|
2007-09-22 12:54:00 +02:00
|
|
|
|
2010-09-27 01:14:42 +02:00
|
|
|
$error = 0;
|
2011-09-25 20:39:20 +02:00
|
|
|
|
|
|
|
$validpass = validate_password($fPassword);
|
|
|
|
if(count($validpass) > 0) {
|
|
|
|
flash_error($validpass[0]); # TODO: honor all error messages, not only the first one
|
2010-09-27 01:14:42 +02:00
|
|
|
$error += 1;
|
2007-12-17 08:01:50 +01:00
|
|
|
}
|
2013-06-23 19:56:16 +02:00
|
|
|
|
|
|
|
$mh = new MailboxHandler;
|
|
|
|
|
|
|
|
if(!$mh->login($username, $fPassword_current)) {
|
2009-03-13 21:48:24 +01:00
|
|
|
$error += 1;
|
|
|
|
$pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
|
2007-09-22 12:54:00 +02:00
|
|
|
}
|
|
|
|
if (empty ($fPassword) or ($fPassword != $fPassword2))
|
|
|
|
{
|
2010-09-27 01:14:42 +02:00
|
|
|
$error += 1;
|
2007-09-22 12:54:00 +02:00
|
|
|
$pPassword_password_text = $PALANG['pPassword_password_text_error'];
|
|
|
|
}
|
2007-03-24 08:27:00 +01:00
|
|
|
|
2010-09-27 01:14:42 +02:00
|
|
|
if ($error == 0)
|
2007-09-22 12:54:00 +02:00
|
|
|
{
|
2012-04-09 17:02:16 +02:00
|
|
|
$mh->init($username); # TODO: error handling
|
|
|
|
if($mh->change_pw($fPassword, $fPassword_current) ) {
|
2007-11-12 01:46:52 +01:00
|
|
|
flash_info($PALANG['pPassword_result_success']);
|
|
|
|
header("Location: main.php");
|
|
|
|
exit(0);
|
2007-09-22 12:54:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-19 00:36:38 +02:00
|
|
|
flash_error($PALANG['pPassword_result_error']);
|
2007-09-22 12:54:00 +02:00
|
|
|
}
|
|
|
|
}
|
2007-03-24 08:27:00 +01:00
|
|
|
}
|
2007-11-12 01:46:52 +01:00
|
|
|
|
2011-07-29 21:48:17 +02:00
|
|
|
$smarty->assign ('SESSID_USERNAME', $username);
|
2009-12-24 15:58:01 +01:00
|
|
|
$smarty->assign ('pPassword_password_current_text', $pPassword_password_current_text, false);
|
|
|
|
$smarty->assign ('pPassword_password_text', $pPassword_password_text, false);
|
2009-11-05 15:55:39 +01:00
|
|
|
|
2011-07-29 21:48:17 +02:00
|
|
|
$smarty->assign ('smarty_template', 'password');
|
2009-11-05 15:55:39 +01:00
|
|
|
$smarty->display ('index.tpl');
|
2007-11-12 01:46:52 +01:00
|
|
|
|
|
|
|
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
2007-03-24 08:27:00 +01:00
|
|
|
?>
|