2016-12-02 19:19:11 +00:00
< ? php
if ( isset ( $_POST [ 'Change' ] ) && ( $_POST [ 'step' ] == '1' ) ) {
// Hide the CAPTCHA form
$hide_form = true ;
// Get input
$pass_new = $_POST [ 'password_new' ];
$pass_conf = $_POST [ 'password_conf' ];
// Check CAPTCHA from 3rd party
2018-10-12 15:49:58 +00:00
$resp = recaptcha_check_answer (
$_DVWA [ 'recaptcha_private_key' ],
$_POST [ 'g-recaptcha-response' ]
);
2016-12-02 19:19:11 +00:00
// Did the CAPTCHA fail?
2018-10-12 15:49:58 +00:00
if ( ! $resp ) {
2016-12-02 19:19:11 +00:00
// What happens when the CAPTCHA was entered incorrectly
$html .= " <pre><br />The CAPTCHA was incorrect. Please try again.</pre> " ;
$hide_form = false ;
return ;
}
else {
// CAPTCHA was correct. Do both new passwords match?
if ( $pass_new == $pass_conf ) {
// Show next stage for the user
$html .= "
< pre >< br /> You passed the CAPTCHA ! Click the button to confirm your changes .< br /></ pre >
< form action = \ " # \" method= \" POST \" >
< input type = \ " hidden \" name= \" step \" value= \" 2 \" />
< input type = \ " hidden \" name= \" password_new \" value= \" { $pass_new } \" />
< input type = \ " hidden \" name= \" password_conf \" value= \" { $pass_conf } \" />
< input type = \ " submit \" name= \" Change \" value= \" Change \" />
</ form > " ;
}
else {
// Both new passwords do not match.
$html .= " <pre>Both passwords must match.</pre> " ;
$hide_form = false ;
}
}
}
if ( isset ( $_POST [ 'Change' ] ) && ( $_POST [ 'step' ] == '2' ) ) {
// Hide the CAPTCHA form
$hide_form = true ;
// Get input
$pass_new = $_POST [ 'password_new' ];
$pass_conf = $_POST [ 'password_conf' ];
// Check to see if both password match
if ( $pass_new == $pass_conf ) {
// They do!
2018-10-12 15:49:58 +00:00
$pass_new = (( isset ( $GLOBALS [ " ___mysqli_ston " ]) && is_object ( $GLOBALS [ " ___mysqli_ston " ])) ? mysqli_real_escape_string ( $GLOBALS [ " ___mysqli_ston " ], $pass_new ) : (( trigger_error ( " [MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work. " , E_USER_ERROR )) ? " " : " " ));
2016-12-02 19:19:11 +00:00
$pass_new = md5 ( $pass_new );
// Update database
$insert = " UPDATE `users` SET password = ' $pass_new ' WHERE user = ' " . dvwaCurrentUser () . " '; " ;
2018-10-12 15:49:58 +00:00
$result = mysqli_query ( $GLOBALS [ " ___mysqli_ston " ], $insert ) or die ( '<pre>' . (( is_object ( $GLOBALS [ " ___mysqli_ston " ])) ? mysqli_error ( $GLOBALS [ " ___mysqli_ston " ]) : (( $___mysqli_res = mysqli_connect_error ()) ? $___mysqli_res : false )) . '</pre>' );
2016-12-02 19:19:11 +00:00
// Feedback for the end user
$html .= " <pre>Password Changed.</pre> " ;
}
else {
// Issue with the passwords matching
$html .= " <pre>Passwords did not match.</pre> " ;
$hide_form = false ;
}
2018-10-12 15:49:58 +00:00
(( is_null ( $___mysqli_res = mysqli_close ( $GLOBALS [ " ___mysqli_ston " ]))) ? false : $___mysqli_res );
2016-12-02 19:19:11 +00:00
}
?>