Plugin Directory

Changeset 2589865


Ignore:
Timestamp:
08/27/2021 01:39:59 PM (5 years ago)
Author:
outerbridge
Message:

v4.1.0 - 210827 - Fixed problem with comments form validation. Working with WP5.8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • humancaptcha/trunk/outerbridge-humancaptcha.php

    r2546304 r2589865  
    55Description: HumanCaptcha uses questions that require human logic to answer them and which machines cannot easily answer.
    66Author: Outerbridge
    7 Version: 4.0.0
     7Version: 4.1.0
    88Author URI: https://outerbridge.co.uk/
    99Text Domain: humancaptcha
     
    1414/**
    1515 *
     16 *  v4.1.0  210827  Fixed problem with comments form validation.  Working with WP5.8
     17 *
    1618 *  v4.0.0  210611  Fixed session issue, thanks to @tmuk.  Working with WP5.7
    17  *
    1819 *  v3.1    200116  Improved foreign character handling
    1920 *  v3.0    180105  Improved accessibility (thanks to Ondrej), moved admin menu to Settings, tidied admin page, added Settings link to Plugins page
     
    4041 */
    4142
    42 $obr_humancaptcha = new obr_humancaptcha;
    43 
    4443global $wpdb;
    4544   
     
    5352   
    5453    // version
    55     public $obr_humancaptcha_version = '4.0.0';
     54    public $obr_humancaptcha_version = '4.1.0';
    5655   
    5756    function __construct(){
     
    7069        add_action('admin_menu', array($this, 'obr_admin_menu'));
    7170        add_action('init', array($this, 'obr_init'));
    72         add_action( 'wp_loaded', array( $this, 'obr_close_session' ), 30 );
     71        //add_action( 'wp_loaded', array( $this, 'obr_close_session' ), 30 );
    7372
    7473        add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'obr_plugin_settings_link'));
     
    186185        global $user_ID;
    187186        if (!$user_ID){
     187            if (!session_id()){
     188                session_start();
     189            }
    188190            $selected = $this->obr_select_question();
    189191            $question = $selected['question'];
    190192            $answer = $selected['answer'];
    191             session_start();
    192             $_SESSION['obr_answer'] = md5(strtolower(trim($answer)));
     193            $_SESSION[ 'obranswer' ] = md5( strtolower( trim( $answer ) ) );
    193194            session_write_close();
    194195            // use the comment-form-email class as it works better with 2011
     
    224225        $question = $selected[ 'question' ];
    225226        $answer = $selected[ 'answer' ];
    226         session_start();
    227         $_SESSION[ 'obr_answer' ] = md5( strtolower( trim( $answer ) ) );
     227        if ( !session_id() ) {
     228            session_start();
     229        }
     230        $_SESSION[ 'obranswer' ] = md5( strtolower( trim( $answer ) ) );
    228231        session_write_close();
    229232        $outputfield = '<p><label for="answer">' . stripslashes( $question ) . '</label><br /><input type="text" name="answer" id="answer" class="input" value="" size="25" tabindex="20" /></p>';
     
    257260            $errors->add('obr_error', __('Error: please fill the required field (humancaptcha).', 'humancaptcha'));
    258261        } else {
    259             $user_answer = md5(strtolower(trim($_POST['answer'])));
    260             session_start();
    261             $obr_answer = strtolower(trim($_SESSION['obr_answer']));
     262            $useranswer = md5(strtolower(trim($_POST['answer'])));
     263            if ( !session_id() ) {
     264                session_start();
     265            }
     266            $obranswer = strtolower(trim($_SESSION['obranswer']));
    262267            session_write_close();
    263             if ($user_answer != $obr_answer){
     268            if ($useranswer != $obranswer){
    264269                $errors->add('obr_error', __('Error: your answer to the humancaptcha question is incorrect.', 'humancaptcha'));
    265270            }
     
    282287            wp_die(__('Error: please fill the required field (humancaptcha).', 'humancaptcha'));
    283288        }
    284         $user_answer = md5(strtolower(trim($_POST['answer'])));
    285         $obr_answer = strtolower(trim($_SESSION['obr_answer']));
     289        $useranswer = md5(strtolower(trim($_POST['answer'])));
     290        $obranswer = strtolower(trim($_SESSION['obranswer']));
    286291        session_write_close();
    287         if ($user_answer != $obr_answer){
     292        if ($useranswer != $obranswer){
    288293            wp_die(__('Error: your answer to the humancaptcha question is incorrect.  Use your browser\'s back button to try again.', 'humancaptcha'));
    289294        }
     
    510515    }
    511516}
    512 ?>
     517
     518$obr_humancaptcha = new obr_humancaptcha;
     519
Note: See TracChangeset for help on using the changeset viewer.