2
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
2
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
7
5
* LICENSE: GNU General Public License, version 2 (GPLv2)
8
* Copyright (c) 2001 - 2011 Ampache.org All Rights Reserved
6
* Copyright 2001 - 2013 Ampache.org
10
8
* This program is free software; you can redistribute it and/or
11
9
* modify it under the terms of the GNU General Public License v2
20
18
* along with this program; if not, write to the Free Software
21
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
* @copyright 2001 - 2011 Ampache.org
25
* @license http://opensource.org/licenses/gpl-2.0 GPLv2
26
* @link http://www.ampache.org/
29
23
define('NO_SESSION','1');
32
26
$action = (isset($_POST['action'])) ? $_POST['action'] : "";
36
/* Check for posted email */
38
if (isset($_POST['email']) && $_POST['email']) {
39
/* Get the email address and the current ip*/
40
$email = scrub_in($_POST['email']);
41
$current_ip =(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] :$_SERVER['REMOTE_ADDR'];
42
$result = send_newpassword($email, $current_ip);
45
Error::add('general', T_('Password has been sent'));
47
Error::add('general', T_('Password has not been sent'));
30
/* Check for posted email */
32
if (isset($_POST['email']) && $_POST['email']) {
33
/* Get the email address and the current ip*/
34
$email = scrub_in($_POST['email']);
35
$current_ip =(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] :$_SERVER['REMOTE_ADDR'];
36
$result = send_newpassword($email, $current_ip);
39
Error::add('general', T_('Password has been sent'));
41
Error::add('general', T_('Password has not been sent'));
50
require Config::get('prefix') . '/templates/show_login_form.inc.php';
53
require Config::get('prefix') . '/templates/show_lostpassword_form.inc.php';
44
require Config::get('prefix') . '/templates/show_login_form.inc.php';
47
require Config::get('prefix') . '/templates/show_lostpassword_form.inc.php';
56
50
function send_newpassword($email,$current_ip){
57
/* get the Client and set the new password */
58
$client = User::get_from_email($email);
59
if ($client->email == $email) {
60
$newpassword = generate_password(6);
61
$client->update_password($newpassword);
63
$mailer = new AmpacheMail();
64
$mailer->set_default_sender();
65
$mailer->subject = T_("Lost Password");
66
$mailer->recipient_name = $client->fullname;
67
$mailer->recipient = $client->email;
69
$message = sprintf(T_("A user from %s has requested a password reset for '%s'."), $current_ip, $client->username);
71
$message .= sprintf(T_("The password has been set to: %s"), $newpassword);
72
$mailer->message = $message;
74
return $mailer->send();
51
/* get the Client and set the new password */
52
$client = User::get_from_email($email);
53
if ($client->email == $email) {
54
$newpassword = generate_password(6);
55
$client->update_password($newpassword);
57
$mailer = new Mailer();
58
$mailer->set_default_sender();
59
$mailer->subject = T_("Lost Password");
60
$mailer->recipient_name = $client->fullname;
61
$mailer->recipient = $client->email;
63
$message = sprintf(T_("A user from %s has requested a password reset for '%s'."), $current_ip, $client->username);
65
$message .= sprintf(T_("The password has been set to: %s"), $newpassword);
66
$mailer->message = $message;
68
return $mailer->send();