From 8d030053ad03f50f64047bef653bdedcc2fd3e8d Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Wed, 15 Jun 2005 15:22:30 +0000 Subject: [PATCH] Replaced require_variable() and optional_variable() with required_param() & optional_param(). Added sesskey check to forgot password form too. --- login/confirm.php | 9 ++++++--- login/forgot_password.php | 8 ++++++-- login/forgot_password_form.html | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/login/confirm.php b/login/confirm.php index 0a1ed3a90ed..2c6108d939d 100644 --- a/login/confirm.php +++ b/login/confirm.php @@ -3,9 +3,12 @@ require_once("../config.php"); require_once("../auth/$CFG->auth/lib.php"); - if (isset($_GET['p']) and isset($_GET['s']) ) { # p = user.secret s = user.username + $p = required_param( 'p' ); // user.secret + $s = required_param( 's' ); // user.username - $user = get_complete_user_data('username', $_GET['s']); + if (!empty($p) and !empty($s) ) { + + $user = get_complete_user_data('username', $s ); if (!empty($user)) { @@ -18,7 +21,7 @@ exit; } - if ($user->secret == $_GET['p']) { // They have provided the secret key to get in + if ($user->secret == $p) { // They have provided the secret key to get in if (!set_field("user", "confirmed", 1, "id", $user->id)) { error("Could not confirm this user!"); diff --git a/login/forgot_password.php b/login/forgot_password.php index 0467dd757c9..a73ef19a1c3 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -2,8 +2,8 @@ require_once("../config.php"); - optional_variable($p, ""); - optional_variable($s, ""); + $p = optional_param('p',''); + $s = optional_param('s',''); if (!empty($p) and !empty($s)) { // User trying to authenticate change password routine @@ -38,6 +38,10 @@ if ($frm = data_submitted()) { // Initial request for new password + if (!confirm_sesskey()) { + error( 'sesskey invalid' ); + } + validate_form($frm, $err); if (count((array)$err) == 0) { diff --git a/login/forgot_password_form.html b/login/forgot_password_form.html index c1c14f2058b..ca3ad30356b 100644 --- a/login/forgot_password_form.html +++ b/login/forgot_password_form.html @@ -7,6 +7,7 @@
wwwroot/login/forgot_password.php") ?>" method="post" name="form" id="form"> +
: