get_transient( 'jpp_math_pass_' . $_COOKIE[ 'jpp_math_pass' ] ); if( !$transient || $transient < 1 ) { Jetpack_Protect_Math_Authenticate::generate_math_page(); } return true; } if ( ! $correct_ans || !$_POST['jetpack_protect_num'] ) { Jetpack_Protect_Math_Authenticate::generate_math_page(); } elseif ( $salted_ans != $correct_ans ) { wp_die( __( 'You failed to correctly answer the math problem. This is used to combat spam when the Protect API is unavailable. Please use your browser\'s back button to return to the login form, press the "refresh" button to generate a new math problem, and try to log in again.', 'jetpack' ), '', array ( 'response' => 401 ) ); } else { return true; } } /** * Creates an interim page to collect answers to a math captcha * * @return none, execution stopped */ static function generate_math_page( $error = false ) { $salt = get_site_option( 'jetpack_protect_key' ) . get_site_option( 'admin_email' ); $num1 = rand( 0, 10 ); $num2 = rand( 1, 10 ); $sum = $num1 + $num2; $ans = sha1( $salt . $sum ); ob_start(); ?>

401 ) ); } public function process_generate_math_page() { $salt = get_site_option( 'jetpack_protect_key' ) . get_site_option( 'admin_email' ); $ans = (int)$_POST['jetpack_protect_num']; $salted_ans = sha1( $salt . $ans ); $correct_ans = $_POST[ 'jetpack_protect_answer' ]; if ( $salted_ans != $correct_ans ) { Jetpack_Protect_Math_Authenticate::generate_math_page(true); } else { $temp_pass = substr( sha1( rand( 1, 100000000 ) . get_site_option( 'jetpack_protect_key' ) ), 5, 25 ); $jetpack_protect = Jetpack_Protect_Module::instance(); $jetpack_protect->set_transient( 'jpp_math_pass_' . $temp_pass, 3, DAY_IN_SECONDS ); setcookie('jpp_math_pass', $temp_pass, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false); return true; } } /** * Requires a user to solve a simple equation. Added to any WordPress login form. * * @return VOID outputs html */ static function math_form() { $salt = get_site_option( 'jetpack_protect_key' ) . get_site_option( 'admin_email' ); $num1 = rand( 0, 10 ); $num2 = rand( 1, 10 ); $sum = $num1 + $num2; $ans = sha1( $salt . $sum ); ?>
  +     =