add(new DateInterval('P3D')) < UOJTime::$time_now) { becomeMsgPage('链接已过期'); } function resetPassword() { global $user; if (!isset($_POST['newPW']) || !validatePassword($_POST['newPW'])) { return '操作失败,无效密码'; } $newPW = $_POST['newPW']; $newPW = getPasswordToStore($newPW, $user['username']); $oj_name = UOJConfig::$data['profile']['oj-name']; $oj_name_short = UOJConfig::$data['profile']['oj-name-short']; $name = $user['username']; $remote_addr = UOJContext::remoteAddr(); $http_x_forwarded_for = UOJContext::httpXForwardedFor(); $user_agent = UOJContext::httpUserAgent(); if ($user['realname']) { $name .= ' (' . $user['realname'] . ')'; } sendEmail($user['username'], "密码被重置", <<您刚刚重置了您在 {$oj_name_short} 上账号的密码。如果这是您进行的操作,请忽略本邮件。如果您没有请求重置密码,请立即联系管理员进行处理。

EOD, 5); DB::update([ "update user_info", "set", [ "password" => $newPW, "remember_token" => '', "extra" => DB::json_remove('extra', '$.reset_password_check_code', '$.reset_password_time'), ], "where", [ "username" => $user['username'], ], ]); return 'ok'; } if (isset($_POST['reset'])) { die(resetPassword()); } ?>