Changeset 2546304
- Timestamp:
- 06/11/2021 02:41:38 PM (5 years ago)
- Location:
- humancaptcha/trunk
- Files:
-
- 2 edited
-
outerbridge-humancaptcha.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
humancaptcha/trunk/outerbridge-humancaptcha.php
r2228470 r2546304 5 5 Description: HumanCaptcha uses questions that require human logic to answer them and which machines cannot easily answer. 6 6 Author: Outerbridge 7 Version: 3.17 Version: 4.0.0 8 8 Author URI: https://outerbridge.co.uk/ 9 9 Text Domain: humancaptcha … … 14 14 /** 15 15 * 16 * v4.0.0 210611 Fixed session issue, thanks to @tmuk. Working with WP5.7 17 * 16 18 * v3.1 200116 Improved foreign character handling 17 *18 19 * v3.0 180105 Improved accessibility (thanks to Ondrej), moved admin menu to Settings, tidied admin page, added Settings link to Plugins page 19 20 * v2.1 150130 General code tidy plus remove references to HCAC … … 52 53 53 54 // version 54 public $obr_humancaptcha_version = ' 3.1';55 public $obr_humancaptcha_version = '4.0.0'; 55 56 56 57 function __construct(){ … … 69 70 add_action('admin_menu', array($this, 'obr_admin_menu')); 70 71 add_action('init', array($this, 'obr_init')); 72 add_action( 'wp_loaded', array( $this, 'obr_close_session' ), 30 ); 71 73 72 74 add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'obr_plugin_settings_link')); … … 187 189 $question = $selected['question']; 188 190 $answer = $selected['answer']; 191 session_start(); 189 192 $_SESSION['obr_answer'] = md5(strtolower(trim($answer))); 193 session_write_close(); 190 194 // use the comment-form-email class as it works better with 2011 191 195 $outputfield = '<p class="comment-form-email"><label for="answer">' . stripslashes( $question ) . ' <span class="required">*</span></label><input id="answer" name="answer" size="30" type="text" aria-required=\'true\' /></p>'; 192 $fields['obr_hlc'] = $outputfield; 196 if( isset( $fields ) ) { 197 $fields['obr_hlc'] = $outputfield; 198 } 193 199 return $fields; 194 200 } … … 218 224 $question = $selected[ 'question' ]; 219 225 $answer = $selected[ 'answer' ]; 226 session_start(); 220 227 $_SESSION[ 'obr_answer' ] = md5( strtolower( trim( $answer ) ) ); 228 session_write_close(); 221 229 $outputfield = '<p><label for="answer">' . stripslashes( $question ) . '</label><br /><input type="text" name="answer" id="answer" class="input" value="" size="25" tabindex="20" /></p>'; 222 230 echo $outputfield; 223 $fields[ 'obr_hlc' ] = $outputfield; 231 if( true !== empty( $fields ) ) { 232 $fields[ 'obr_hlc' ] = $outputfield; 233 } 224 234 return $fields; 225 235 } … … 244 254 245 255 function obr_register_validate_answer($errors, $sanitized_user_login, $user_email){ 246 if (!session_id()){247 session_start();248 }249 256 if ((!isset($_POST['answer'])) || ($_POST['answer'] == '')){ 250 257 $errors->add('obr_error', __('Error: please fill the required field (humancaptcha).', 'humancaptcha')); 251 258 } else { 252 259 $user_answer = md5(strtolower(trim($_POST['answer']))); 260 session_start(); 253 261 $obr_answer = strtolower(trim($_SESSION['obr_answer'])); 262 session_write_close(); 254 263 if ($user_answer != $obr_answer){ 255 264 $errors->add('obr_error', __('Error: your answer to the humancaptcha question is incorrect.', 'humancaptcha')); … … 275 284 $user_answer = md5(strtolower(trim($_POST['answer']))); 276 285 $obr_answer = strtolower(trim($_SESSION['obr_answer'])); 286 session_write_close(); 277 287 if ($user_answer != $obr_answer){ 278 288 wp_die(__('Error: your answer to the humancaptcha question is incorrect. Use your browser\'s back button to try again.', 'humancaptcha')); … … 493 503 $login_on = $this->obr_get_setting_value(3); 494 504 } 505 506 function obr_close_session() { 507 if ( PHP_SESSION_ACTIVE == session_status() ) { 508 session_write_close(); 509 } 510 } 495 511 } 496 512 ?> -
humancaptcha/trunk/readme.txt
r2273866 r2546304 1 1 === HumanCaptcha by Outerbridge === 2 2 Contributors: outerbridge 3 Author URI: http ://outerbridge.co.uk/3 Author URI: https://outerbridge.co.uk/ 4 4 Tags: captcha, text-based, human, logic, questions, answers 5 5 Requires at least: 4.7 6 Tested up to: 5. 46 Tested up to: 5.7 7 7 Stable tag: trunk 8 8 … … 64 64 == Changelog == 65 65 66 = 4.X = 67 * v4.0.0 (11 Jun 21) Fixed session issue, thanks to @tmuk. Working with WP5.7 68 66 69 = 3.X = 67 70 * v3.1 (16 Jan 20) Improved foreign character handling … … 95 98 96 99 == Upgrade Notice == 100 101 = v4.0.0 = 102 * Fixed session issue, thanks to @tmuk. Working with WP5.7 97 103 98 104 = v3.1 =
Note: See TracChangeset
for help on using the changeset viewer.