configs->get_value('aiowps_unlock_request_secret_key');
$unlock_temp_string = isset($_POST['aiowps-unlock-temp-string'])?strip_tags($_POST['aiowps-unlock-temp-string']):'';
$submitted_encoded_string = base64_encode($unlock_temp_string.$unlock_secret_string);
if($submitted_encoded_string !== $unlock_encoded_info)
{
//Someone somehow landed on this page directly without clicking the unlock button on login form
echo '
'.__('ERROR: Unable to process your request!','all-in-one-wp-security-and-firewall').'
';
die();
}
else if($display_form)
{
echo display_unlock_form();
}
} //End if block
if (isset($_POST['aiowps_wp_submit_unlock_request']))
{
//This catches the $_POST when someone submits the form from our special unlock request page where visitor enters email address
$errors = '';
$email = trim($_POST['aiowps_unlock_request_email']);
if (empty($email) || !is_email($email))
{
$errors .= '
'.__('Please enter a valid email address','all-in-one-wp-security-and-firewall').'
';
}
if($errors){
$display_form = true;
echo '
'.$errors.'
';
$sanitized_email = sanitize_email($email);
echo display_unlock_form($sanitized_email);
}else{
$locked_user = get_user_by('email', $email);
if(!$locked_user){
//user with this email does not exist in the system
$errors .= '
'.__('User account not found!','all-in-one-wp-security-and-firewall').'
';
echo '
'.$errors.'
';
}else{
//Process unlock request
//Generate a special code and unlock url
$ip = AIOWPSecurity_Utility_IP::get_user_ip_address(); //Get the IP address of user
$ip_range = AIOWPSecurity_Utility_IP::get_sanitized_ip_range($ip); //Get the IP range of the current user
if(empty($ip_range)){
$unlock_url = false;
}else{
$unlock_url = AIOWPSecurity_User_Login::generate_unlock_request_link($ip_range);
}
if (!$unlock_url){
//No entry found in lockdown table with this IP range
$error_msg = '
'.__('Error: No locked entry was found in the DB with your IP address range!','all-in-one-wp-security-and-firewall').'
';
echo '
'.$error_msg.'
';
}else{
//Send an email to the user
AIOWPSecurity_User_Login::send_unlock_request_email($email, $unlock_url);
echo '
' . __('An email has been sent to you with the unlock instructions.', 'all-in-one-wp-security-and-firewall') . '
';
}
}
$display_form = false;
}
}
?>