\n"; $emailHeaders .= "Reply-To: ".get_setting('emailAdministrator')."\n"; $emailHeaders .= "X-Sender: ".get_setting('emailAdministrator')."\n"; $emailHeaders .= "X-Mailer: PHP / ".phpversion()."\n"; $emailHeaders .= "Content-Type: text/plain;\n\tcharset=\"".$charset."\"\n"; $emailHeaders .= "Mime-Version: 1.0"; return $emailHeaders; } /*** By Olivier Cauberghe, UGent ***/ //----------------------------------------------------------------------------- function get_user_account_list($user, $reset = false) { global $rootWeb; foreach ($user as $thisUser) { $secretword = get_secret_word($thisUser["email"]); if ($reset) $reset_link = "\tReset link : $rootWeb"."main/auth/lostPassword.php?reset=$secretword&id=$thisUser[uid]"; else $reset_link = "\t".get_lang('Pass')." : $thisUser[password]"; $userAccountList[] = $thisUser["firstName"]." ".$thisUser["lastName"]."\n\n"."\t".get_lang('Username')." : ".$thisUser["loginName"]."\n"."$reset_link\n\n"; } if ($userAccountList) $userAccountList = implode("------------------------\n", $userAccountList); return $userAccountList; } /*** By Olivier Cauberghe, UGent ***/ //----------------------------------------------------------------------------- function send_password_to_user($user, $success_msg) { global $charset; global $rootWeb; $emailHeaders = get_email_headers(); // Email Headers $emailSubject = "[".get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT $userAccountList = get_user_account_list($user); // BODY $emailBody = get_lang('YourAccountParam')." $rootWeb\n\n$userAccountList"; // SEND MESSAGE $emailTo = $user[0]["email"]; if (@ api_send_mail($emailTo, $emailSubject, $emailBody, $emailHeaders)) return $success_msg; else return "
The system is unable to send you an e-mail.
Please contact the ".Display :: encrypted_mailto_link(get_setting('emailAdministrator'), "Platform administrator").".
", "The system is unable to send you an e-mail.
", "Please contact the ", Display::encrypted_mailto_link(get_setting('emailAdministrator'),"platform administrator"), ".
"; return ""; } //----------------------------------------------------------------------------- function get_secret_word($add) { global $security_key; return $secretword = md5($security_key.$add); } //----------------------------------------------------------------------------- function reset_password($secret, $id) { global $your_password_has_been_reset,$userPasswordCrypted; $tbl_user = Database::get_main_table(MAIN_USER_TABLE); $sql = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email FROM ".$tbl_user." WHERE user_id=$id"; $result = api_sql_query($sql,__FILE__,__LINE__); if ($result && mysql_num_rows($result)) $user[] = mysql_fetch_array($result); else return "Could not reset password."; if (get_secret_word($user[0]["email"]) == $secret) // OK, secret word is good. Now change password and mail it. { $user[0]["password"] = api_generate_password(); $crypted = $user[0]["password"]; if( $userPasswordCrypted) { $crypted = md5($crypted); } api_sql_query("UPDATE ".$tbl_user." SET password='$crypted' WHERE user_id=$id"); return send_password_to_user($user, $your_password_has_been_reset); } else return "Not allowed."; } ?>