Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/forgot_passwd.php,v $
15
  $Revision: 1.6 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:10 $
18
**********************************************/
19
 
20
define('IN_COPPERMINE', true);
21
define('FORGOT_PASSWD_PHP', true);
22
global $CONFIG;
23
 
24
require('include/init.inc.php');
25
include_once('include/mailer.inc.php');
26
 
27
if (USER_ID) cpg_die(ERROR, $lang_forgot_passwd_php['err_already_logged_in'], __FILE__, __LINE__);
28
 
29
 
30
$lookup_failed = '';
31
 
32
if ($_POST['username']) {
33
    $results = db_query("SELECT user_group,user_active,user_name, user_password, user_email  FROM {$CONFIG['TABLE_USERS']} WHERE (user_name = '" . addslashes($HTTP_POST_VARS['username']) . "' OR  user_email = '" . addslashes($HTTP_POST_VARS['username']) . "') AND user_active = 'YES'");
34
    if (mysql_num_rows($results))
35
        { // something has been found start
36
        $USER_DATA = mysql_fetch_array($results);
37
        // check if we have an admin account (with empty email address)
38
        if ($USER_DATA['user_email'] == '') {
39
          // the password is empty. Is the current user the gallery admin?
40
          if ($USER_DATA['user_group'] == 1) {
41
            $USER_DATA['user_email'] = $CONFIG['gallery_admin_email'];
42
          } else {
43
            cpg_die(CRITICAL_ERROR, $lang_forgot_passwd_php['failed_sending_email'], __FILE__, __LINE__); //not the gallery admin account
44
            }
45
        }
46
 
47
        // send the email
48
        if (!cpg_mail($USER_DATA['user_email'], sprintf($lang_forgot_passwd_php['passwd_reminder_subject'], $CONFIG['gallery_name']), sprintf($lang_forgot_passwd_php['passwd_reminder_body'], $USER_DATA['user_name'],$USER_DATA['user_password'],  $CONFIG['ecards_more_pic_target'].'login.php' ))) {
49
            cpg_die(CRITICAL_ERROR, $lang_forgot_passwd_php['failed_sending_email'], __FILE__, __LINE__);
50
            }
51
 
52
        // output the message
53
        pageheader($lang_forgot_passwd_php['forgot_passwd'], "<META http-equiv=\"refresh\" content=\"3;url=login.php\">");
54
        $referer = 'login.php';
55
        msg_box($lang_forgot_passwd_php['forgot_passwd'], sprintf($lang_forgot_passwd_php['email_sent'], $USER_DATA['user_email']), $lang_continue, $referer);
56
        $USER_DATA['user_password'] = '***********';
57
        pagefooter();
58
        exit;
59
        // something has been found end
60
    } else {
61
        $lookup_failed = <<<EOT
62
                  <tr>
63
                          <td colspan="2" align="center" class="tableh2">
64
                        <font size="1" color="red"><b>{$lang_forgot_passwd_php['err_unk_user']}<b></font>
65
                        </td>
66
                  </tr>
67
 
68
EOT;
69
    }
70
}
71
 
72
pageheader($lang_forgot_passwd_php['forgot_passwd']);
73
 
74
 
75
echo '<form action="forgot_passwd.php" method="post" name="passwordreminder">';
76
starttable('-1', $lang_forgot_passwd_php['forgot_passwd'], 2);
77
echo <<< EOT
78
            $lookup_failed
79
                 <tr>
80
                        <td class="tableb" width="40%">{$lang_forgot_passwd_php['enter_username_email']}</td>
81
                        <td class="tableb" width="60%"><input type="text" class="textinput" name="username" style="width: 100%"></td>
82
                        <script language="javascript" type="text/javascript">
83
                        <!--
84
                        document.passwordreminder.username.focus();
85
                        -->
86
                        </script>
87
                  </tr>
88
                  <tr>
89
                        <td colspan="2" align="center" class="tablef"><input name="submitted" type="submit" class="button" value="{$lang_forgot_passwd_php['submit']}"></td>
90
                  </tr>
91
 
92
EOT;
93
 
94
endtable();
95
echo '</form>';
96
pagefooter();
97
ob_end_flush();
98
 
99
?>