WordPress.org

Plugin Directory

Changeset 617505


Ignore:
Timestamp:
10/25/12 20:21:10 (18 months ago)
Author:
mordauk
Message:

Uploading v1.0.4. Fixes problem with conflicting plugins also using recaptcha, improved sanitization, and improved code formatting

Location:
bbpress-recaptcha
Files:
1 edited
4 copied

Legend:

Unmodified
Added
Removed
  • bbpress-recaptcha/tags/1.0.4/bbpress-recaptcha.php

    r495314 r617505  
    55Plugin URI: http://pippinsplugins.com/bbpress-recaptcha 
    66Description: Adds reCaptcha to the bbPress 2.0 topic reply form  
    7 Version: 1.0.3 
     7Version: 1.0.4 
    88Author: Pippin Williamson 
    99Contributors: mordauk 
     
    1111*/ 
    1212 
    13 require_once('recaptchalib.php'); 
     13if( !function_exists('_recaptcha_qsencode') ) { 
    1414 
    15 $bbpc_options = get_option('bbpc_settings'); 
     15    require_once( dirname( __FILE__ ) . '/recaptchalib.php'); 
     16 
     17} 
    1618 
    1719// adds the reCaptcha to the reply to topic form 
    1820function bbpc_display_reply_recaptcha() { 
    1921     
    20     global $bbpc_options; 
    21     if(!current_user_can('manage_options')) { 
    22         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     22    $bbpc_options = get_option('bbpc_settings'); 
     23    if( ! current_user_can('manage_options') ) { 
     24        if( is_user_logged_in() && ! isset( $bbpc_options['show_to_logged_in'] ) ) 
    2325            return; 
    2426         
    25         $publickey = $bbpc_options['public_key']; // you got this from the signup page 
    26         echo recaptcha_get_html($publickey); 
     27        $publickey = trim( $bbpc_options['public_key'] ); 
     28        echo recaptcha_get_html( $publickey ); 
    2729    } 
    2830} 
     
    3234function bbpc_display_topic_recaptcha() { 
    3335     
    34     global $bbpc_options; 
    35     if(!current_user_can('manage_options')) {    
    36         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     36    $bbpc_options = get_option('bbpc_settings'); 
     37    if( ! current_user_can('manage_options') ) {     
     38        if( is_user_logged_in() && !isset( $bbpc_options['show_to_logged_in'] ) ) 
    3739            return; 
    3840             
    39         $publickey = $bbpc_options['public_key']; // you got this from the signup page 
     41        $publickey = trim( $bbpc_options['public_key'] ); // you got this from the signup page 
    4042        echo recaptcha_get_html($publickey); 
    4143    } 
     
    4345add_action('bbp_theme_before_topic_form_submit_wrapper', 'bbpc_display_topic_recaptcha'); 
    4446 
    45 function bbpc_validate_reply_recaptcha($reply_id) { 
    46     if(!current_user_can('manage_options')) {    
    47         global $bbpc_options; 
     47function bbpc_validate_reply_recaptcha( $reply_id ) { 
     48    if( ! current_user_can('manage_options') ) { 
    4849 
    49         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     50        $bbpc_options = get_option('bbpc_settings'); 
     51 
     52        if( is_user_logged_in() && !isset( $bbpc_options['show_to_logged_in'] ) ) 
    5053            return; 
    5154         
    52         $privatekey = $bbpc_options['private_key']; 
     55        $privatekey = trim( $bbpc_options['private_key'] ); 
    5356        $resp = recaptcha_check_answer( 
    5457            $privatekey, 
     
    5861        ); 
    5962         
    60         if (!$resp->is_valid) { 
     63        if ( ! $resp->is_valid ) { 
    6164            bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: The words you entered were incorrect', 'bbpress' ) ); 
    6265        } 
     
    6568add_action('bbp_new_reply_pre_extras', 'bbpc_validate_reply_recaptcha'); 
    6669 
    67 function bbpc_validate_topic_recaptcha($reply_id) { 
    68     if(!current_user_can('manage_options')) {    
    69         global $bbpc_options; 
     70function bbpc_validate_topic_recaptcha( $reply_id ) { 
     71    if( ! current_user_can('manage_options') ) {     
     72         
     73        $bbpc_options = get_option('bbpc_settings'); 
    7074 
    71         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     75        if( is_user_logged_in() && !isset( $bbpc_options['show_to_logged_in'] ) ) 
    7276            return; 
    7377         
    74         $privatekey = $bbpc_options['private_key']; 
     78        $privatekey = trim( $bbpc_options['private_key'] ); 
    7579        $resp = recaptcha_check_answer( 
    7680            $privatekey, 
     
    8084        ); 
    8185         
    82         if (!$resp->is_valid) { 
     86        if ( ! $resp->is_valid ) { 
    8387            bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: The words you entered were incorrect', 'bbpress' ) ); 
    8488        } 
     
    9296*******************************************/ 
    9397 
    94 function bbpc_settings_page() 
    95 { 
    96     global $bbpc_options; 
     98function bbpc_settings_page() { 
     99    $bbpc_options = get_option('bbpc_settings'); 
    97100         
    98101    ?> 
     
    113116            <p> 
    114117                <label for="bbpc_settings[public_key]"><?php _e( 'reCaptcha Public Key' ); ?></label><br/> 
    115                 <input id="bbpc_settings[public_key]" style="width: 300px;" name="bbpc_settings[public_key]" type="text" value="<?php echo $bbpc_options['public_key'];?>" /> 
     118                <input id="bbpc_settings[public_key]" style="width: 300px;" name="bbpc_settings[public_key]" type="text" value="<?php echo esc_attr( $bbpc_options['public_key'] ); ?>" /> 
    116119                <p class="description">This your own personal reCaptcha Public key. Go to <a href="https://www.google.com/recaptcha/admin/list">your account</a>, then click on your domain (or add a new one) to find your public key.</p> 
    117120            </p> 
    118121            <p> 
    119122                <label for="bbpc_settings[private_key]"><?php _e( 'reCaptcha Private Key' ); ?></label><br/> 
    120                 <input id="bbpc_settings[private_key]" style="width: 300px;" name="bbpc_settings[private_key]" type="text" value="<?php echo $bbpc_options['private_key'];?>" /> 
     123                <input id="bbpc_settings[private_key]" style="width: 300px;" name="bbpc_settings[private_key]" type="text" value="<?php echo esc_attr( $bbpc_options['private_key'] ); ?>" /> 
    121124                <p class="description">This your own personal reCaptcha Private key. Go to <a href="https://www.google.com/recaptcha/admin/list">your account</a>, then click on your domain (or add a new one) to find your private key.</p> 
    122125            </p> 
    123126            <p> 
    124                 <input id="bbpc_settings[show_to_logged_in]" name="bbpc_settings[show_to_logged_in]" type="checkbox" value="1" <?php checked('1', $bbpc_options['show_to_logged_in']); ?>/> 
     127                <input id="bbpc_settings[show_to_logged_in]" name="bbpc_settings[show_to_logged_in]" type="checkbox" value="1" <?php checked( true, isset( $bbpc_options['show_to_logged_in'] ) ); ?>/> 
    125128                <label for="bbpc_settings[show_to_logged_in]"><?php _e( 'Show to logged-in users?' ); ?></label><br/> 
    126129                <p class="description">Require the logged in users fill out the reCaptcha form? Note, admins are always excluded.</p> 
  • bbpress-recaptcha/trunk/bbpress-recaptcha.php

    r495314 r617505  
    55Plugin URI: http://pippinsplugins.com/bbpress-recaptcha 
    66Description: Adds reCaptcha to the bbPress 2.0 topic reply form  
    7 Version: 1.0.3 
     7Version: 1.0.4 
    88Author: Pippin Williamson 
    99Contributors: mordauk 
     
    1111*/ 
    1212 
    13 require_once('recaptchalib.php'); 
     13if( !function_exists('_recaptcha_qsencode') ) { 
    1414 
    15 $bbpc_options = get_option('bbpc_settings'); 
     15    require_once( dirname( __FILE__ ) . '/recaptchalib.php'); 
     16 
     17} 
    1618 
    1719// adds the reCaptcha to the reply to topic form 
    1820function bbpc_display_reply_recaptcha() { 
    1921     
    20     global $bbpc_options; 
    21     if(!current_user_can('manage_options')) { 
    22         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     22    $bbpc_options = get_option('bbpc_settings'); 
     23    if( ! current_user_can('manage_options') ) { 
     24        if( is_user_logged_in() && ! isset( $bbpc_options['show_to_logged_in'] ) ) 
    2325            return; 
    2426         
    25         $publickey = $bbpc_options['public_key']; // you got this from the signup page 
    26         echo recaptcha_get_html($publickey); 
     27        $publickey = trim( $bbpc_options['public_key'] ); 
     28        echo recaptcha_get_html( $publickey ); 
    2729    } 
    2830} 
     
    3234function bbpc_display_topic_recaptcha() { 
    3335     
    34     global $bbpc_options; 
    35     if(!current_user_can('manage_options')) {    
    36         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     36    $bbpc_options = get_option('bbpc_settings'); 
     37    if( ! current_user_can('manage_options') ) {     
     38        if( is_user_logged_in() && !isset( $bbpc_options['show_to_logged_in'] ) ) 
    3739            return; 
    3840             
    39         $publickey = $bbpc_options['public_key']; // you got this from the signup page 
     41        $publickey = trim( $bbpc_options['public_key'] ); // you got this from the signup page 
    4042        echo recaptcha_get_html($publickey); 
    4143    } 
     
    4345add_action('bbp_theme_before_topic_form_submit_wrapper', 'bbpc_display_topic_recaptcha'); 
    4446 
    45 function bbpc_validate_reply_recaptcha($reply_id) { 
    46     if(!current_user_can('manage_options')) {    
    47         global $bbpc_options; 
     47function bbpc_validate_reply_recaptcha( $reply_id ) { 
     48    if( ! current_user_can('manage_options') ) { 
    4849 
    49         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     50        $bbpc_options = get_option('bbpc_settings'); 
     51 
     52        if( is_user_logged_in() && !isset( $bbpc_options['show_to_logged_in'] ) ) 
    5053            return; 
    5154         
    52         $privatekey = $bbpc_options['private_key']; 
     55        $privatekey = trim( $bbpc_options['private_key'] ); 
    5356        $resp = recaptcha_check_answer( 
    5457            $privatekey, 
     
    5861        ); 
    5962         
    60         if (!$resp->is_valid) { 
     63        if ( ! $resp->is_valid ) { 
    6164            bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: The words you entered were incorrect', 'bbpress' ) ); 
    6265        } 
     
    6568add_action('bbp_new_reply_pre_extras', 'bbpc_validate_reply_recaptcha'); 
    6669 
    67 function bbpc_validate_topic_recaptcha($reply_id) { 
    68     if(!current_user_can('manage_options')) {    
    69         global $bbpc_options; 
     70function bbpc_validate_topic_recaptcha( $reply_id ) { 
     71    if( ! current_user_can('manage_options') ) {     
     72         
     73        $bbpc_options = get_option('bbpc_settings'); 
    7074 
    71         if(is_user_logged_in() && !isset($bbpc_options['show_to_logged_in'])) 
     75        if( is_user_logged_in() && !isset( $bbpc_options['show_to_logged_in'] ) ) 
    7276            return; 
    7377         
    74         $privatekey = $bbpc_options['private_key']; 
     78        $privatekey = trim( $bbpc_options['private_key'] ); 
    7579        $resp = recaptcha_check_answer( 
    7680            $privatekey, 
     
    8084        ); 
    8185         
    82         if (!$resp->is_valid) { 
     86        if ( ! $resp->is_valid ) { 
    8387            bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: The words you entered were incorrect', 'bbpress' ) ); 
    8488        } 
     
    9296*******************************************/ 
    9397 
    94 function bbpc_settings_page() 
    95 { 
    96     global $bbpc_options; 
     98function bbpc_settings_page() { 
     99    $bbpc_options = get_option('bbpc_settings'); 
    97100         
    98101    ?> 
     
    113116            <p> 
    114117                <label for="bbpc_settings[public_key]"><?php _e( 'reCaptcha Public Key' ); ?></label><br/> 
    115                 <input id="bbpc_settings[public_key]" style="width: 300px;" name="bbpc_settings[public_key]" type="text" value="<?php echo $bbpc_options['public_key'];?>" /> 
     118                <input id="bbpc_settings[public_key]" style="width: 300px;" name="bbpc_settings[public_key]" type="text" value="<?php echo esc_attr( $bbpc_options['public_key'] ); ?>" /> 
    116119                <p class="description">This your own personal reCaptcha Public key. Go to <a href="https://www.google.com/recaptcha/admin/list">your account</a>, then click on your domain (or add a new one) to find your public key.</p> 
    117120            </p> 
    118121            <p> 
    119122                <label for="bbpc_settings[private_key]"><?php _e( 'reCaptcha Private Key' ); ?></label><br/> 
    120                 <input id="bbpc_settings[private_key]" style="width: 300px;" name="bbpc_settings[private_key]" type="text" value="<?php echo $bbpc_options['private_key'];?>" /> 
     123                <input id="bbpc_settings[private_key]" style="width: 300px;" name="bbpc_settings[private_key]" type="text" value="<?php echo esc_attr( $bbpc_options['private_key'] ); ?>" /> 
    121124                <p class="description">This your own personal reCaptcha Private key. Go to <a href="https://www.google.com/recaptcha/admin/list">your account</a>, then click on your domain (or add a new one) to find your private key.</p> 
    122125            </p> 
    123126            <p> 
    124                 <input id="bbpc_settings[show_to_logged_in]" name="bbpc_settings[show_to_logged_in]" type="checkbox" value="1" <?php checked('1', $bbpc_options['show_to_logged_in']); ?>/> 
     127                <input id="bbpc_settings[show_to_logged_in]" name="bbpc_settings[show_to_logged_in]" type="checkbox" value="1" <?php checked( true, isset( $bbpc_options['show_to_logged_in'] ) ); ?>/> 
    125128                <label for="bbpc_settings[show_to_logged_in]"><?php _e( 'Show to logged-in users?' ); ?></label><br/> 
    126129                <p class="description">Require the logged in users fill out the reCaptcha form? Note, admins are always excluded.</p> 
Note: See TracChangeset for help on using the changeset viewer.