1975 */ |
1975 */ |
1976 |
1976 |
1977 function mail_password_reset($user) |
1977 function mail_password_reset($user) |
1978 { |
1978 { |
1979 global $db, $session, $paths, $template, $plugins; // Common objects |
1979 global $db, $session, $paths, $template, $plugins; // Common objects |
|
1980 global $lang; |
|
1981 |
1980 if(is_int($user)) |
1982 if(is_int($user)) |
1981 { |
1983 { |
1982 $q = $this->sql('SELECT user_id,username,email FROM '.table_prefix.'users WHERE user_id='.$user.';'); // This is SAFE! This is only called if $user is an integer |
1984 $q = $this->sql('SELECT user_id,username,email FROM '.table_prefix.'users WHERE user_id='.$user.';'); // This is SAFE! This is only called if $user is an integer |
1983 } |
1985 } |
1984 elseif(is_string($user)) |
1986 elseif(is_string($user)) |
1994 $temp_pass = $this->random_pass(); |
1996 $temp_pass = $this->random_pass(); |
1995 |
1997 |
1996 $this->register_temp_password($row['user_id'], $temp_pass); |
1998 $this->register_temp_password($row['user_id'], $temp_pass); |
1997 |
1999 |
1998 $site_name = getConfig('site_name'); |
2000 $site_name = getConfig('site_name'); |
1999 |
2001 |
2000 $message = "Dear {$row['username']}, |
2002 $message = $lang->get('userfuncs_passreset_email', array( |
2001 |
2003 'username' => $row['username'], |
2002 Someone (hopefully you) on the {$site_name} website requested that a new password be created. |
2004 'site_name' => $site_name, |
2003 |
2005 'remote_addr' => $_SERVER['REMOTE_ADDR'], |
2004 The request was sent from the IP address {$_SERVER['REMOTE_ADDR']}. |
2006 'temp_pass' => $temp_pass |
2005 |
2007 )); |
2006 If you did not request the new password, then you do not need to do anything; the password will be invalidated after 24 hours. |
|
2007 |
|
2008 If you did request this password, then please log in using the password shown below: |
|
2009 |
|
2010 Password: {$temp_pass} |
|
2011 |
|
2012 After you log in using this password, you will be able to reset your real password. You can only log in using this temporary password once. |
|
2013 |
|
2014 Sincerely yours, |
|
2015 The {$site_name} administration team |
|
2016 "; |
|
2017 |
2008 |
2018 if(getConfig('smtp_enabled') == '1') |
2009 if(getConfig('smtp_enabled') == '1') |
2019 { |
2010 { |
2020 $result = smtp_send_email($row['email'], getConfig('site_name').' password reset', preg_replace("#(?<!\r)\n#s", "\n", $message), getConfig('contact_email')); |
2011 $result = smtp_send_email($row['email'], getConfig('site_name').' password reset', preg_replace("#(?<!\r)\n#s", "\n", $message), getConfig('contact_email')); |
2021 if($result == 'success') |
2012 if($result == 'success') |