2005-08-09 18:46:53 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-09 18:46:53 +00:00
|
|
|
|
2007-11-12 22:28:17 +00:00
|
|
|
require_once("../inc/boinc_db.inc");
|
2005-08-09 18:46:53 +00:00
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/user.inc");
|
|
|
|
|
2008-06-11 19:36:10 +00:00
|
|
|
$auth = post_str("auth", true);
|
|
|
|
$email_addr = strtolower(post_str("email_addr", true));
|
2005-08-09 18:46:53 +00:00
|
|
|
|
2008-06-11 19:36:10 +00:00
|
|
|
$old_passwd = post_str("old_passwd", true);
|
|
|
|
$passwd = post_str("passwd");
|
|
|
|
$passwd2 = post_str("passwd2");
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
if ($passwd != $passwd2) {
|
2005-08-26 22:26:26 +00:00
|
|
|
error_page("New passwords are different");
|
|
|
|
}
|
2005-10-07 19:19:07 +00:00
|
|
|
|
|
|
|
$config = get_config();
|
|
|
|
$min_passwd_length = parse_config($config, "<min_passwd_length>");
|
|
|
|
if (!$min_passwd_length) $min_passwd_length = 6;
|
|
|
|
|
2005-10-08 19:12:43 +00:00
|
|
|
if (!is_ascii($passwd)) {
|
2005-10-07 23:19:20 +00:00
|
|
|
error_page("Passwords may only include ASCII characters.");
|
|
|
|
}
|
|
|
|
|
2005-10-07 19:19:07 +00:00
|
|
|
if (strlen($passwd)<$min_passwd_length) {
|
|
|
|
error_page(
|
|
|
|
"New password is too short:
|
|
|
|
minimum password length is $min_passwd_length characters."
|
|
|
|
);
|
2005-10-07 14:28:08 +00:00
|
|
|
}
|
2005-08-26 22:26:26 +00:00
|
|
|
if ($auth) {
|
|
|
|
$user = lookup_user_auth($auth);
|
|
|
|
if (!$user) {
|
|
|
|
error_page("Invalid account key");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$user = lookup_user_email_addr($email_addr);
|
|
|
|
if (!$user) {
|
|
|
|
error_page("No account with that email address was found");
|
|
|
|
}
|
|
|
|
$passwd_hash = md5($old_passwd.$email_addr);
|
|
|
|
if ($user->passwd_hash != $passwd_hash) {
|
|
|
|
error_page("Invalid password");
|
|
|
|
}
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
|
|
|
|
2005-08-26 22:26:26 +00:00
|
|
|
page_head("Change password");
|
2005-08-09 18:46:53 +00:00
|
|
|
$passwd_hash = md5($passwd.$user->email_addr);
|
2007-11-12 22:28:17 +00:00
|
|
|
$result = $user->update("passwd_hash='$passwd_hash'");
|
2005-08-09 18:46:53 +00:00
|
|
|
if ($result) {
|
2005-08-26 22:26:26 +00:00
|
|
|
echo "Your password has been changed.";
|
2005-08-09 18:46:53 +00:00
|
|
|
} else {
|
|
|
|
echo "
|
|
|
|
We can't update your password due to a database problem.
|
|
|
|
Please try again later.
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
page_tail();
|
|
|
|
?>
|