~ubuntu-branches/debian/sid/ampache/sid

« back to all changes in this revision

Viewing changes to lostpassword.php

  • Committer: Package Import Robot
  • Author(s): Charlie Smotherman
  • Date: 2013-08-27 13:19:48 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20130827131948-1czew0zxn6u70dtv
Tags: 3.6-rzb2752+dfsg-1
* New upsteam snapshot.  Contains important bug fixes to the installer.
* Correct typo in ampache-common.postrm.
* Remove courtousy copy of php-getid3, during repack.  Closes: #701526
* Update package to use dh_linktree to make the needed sym links to the
  needed system libs that were removed during repack.
* Update debian/rules to reflect upstreams removing/moving of modules.
* Update debian/ampache-common.install to reflect upstreams removal of files.
* Updated to use new apache2.4 API. Closes: #669756
* Updated /debian/po/de.po thx David Prévot for the patch.  Closes:  #691963
* M3U import is now ordered, fixed upstream.  Closes: #684984
* Text input area has been resized so IPv6 addresses will now fit, fixed
  upstream.  Closes:  #716230
* Added ampache-common.preinst to make sure that the courtousy copies of code
  dirs are empty so dh_linktree can do it's magic on upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
 
2
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
3
3
/**
4
 
 * LostPassword
5
 
 *
6
4
 *
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
9
7
 *
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.
22
20
 *
23
 
 * @package     Ampache
24
 
 * @copyright   2001 - 2011 Ampache.org
25
 
 * @license     http://opensource.org/licenses/gpl-2.0 GPLv2
26
 
 * @link        http://www.ampache.org/
27
21
 */
28
22
 
29
23
define('NO_SESSION','1');
32
26
$action = (isset($_POST['action'])) ? $_POST['action'] : "";
33
27
 
34
28
switch ($action) {
35
 
        case 'send':
36
 
                /* Check for posted email */
37
 
                $result = false;
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);
43
 
                }
44
 
                if ($result) {
45
 
                        Error::add('general', T_('Password has been sent'));
46
 
                } else {
47
 
                        Error::add('general', T_('Password has not been sent'));
48
 
                }
 
29
    case 'send':
 
30
        /* Check for posted email */
 
31
        $result = false;
 
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);
 
37
        }
 
38
        if ($result) {
 
39
            Error::add('general', T_('Password has been sent'));
 
40
        } else {
 
41
            Error::add('general', T_('Password has not been sent'));
 
42
        }
49
43
 
50
 
                require Config::get('prefix') . '/templates/show_login_form.inc.php';
51
 
                break;
52
 
        default:
53
 
                require Config::get('prefix') . '/templates/show_lostpassword_form.inc.php';
 
44
        require Config::get('prefix') . '/templates/show_login_form.inc.php';
 
45
        break;
 
46
    default:
 
47
        require Config::get('prefix') . '/templates/show_lostpassword_form.inc.php';
54
48
}
55
49
 
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);
62
 
 
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;
68
 
 
69
 
                $message  = sprintf(T_("A user from %s has requested a password reset for '%s'."), $current_ip, $client->username);
70
 
                $message .= "\n";
71
 
                $message .= sprintf(T_("The password has been set to: %s"), $newpassword);
72
 
                $mailer->message = $message;
73
 
 
74
 
                return $mailer->send();
75
 
        }
76
 
        return false;
 
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);
 
56
 
 
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;
 
62
 
 
63
        $message  = sprintf(T_("A user from %s has requested a password reset for '%s'."), $current_ip, $client->username);
 
64
        $message .= "\n";
 
65
        $message .= sprintf(T_("The password has been set to: %s"), $newpassword);
 
66
        $mailer->message = $message;
 
67
 
 
68
        return $mailer->send();
 
69
    }
 
70
    return false;
77
71
}
78
72
?>