Really Simple CAPTCHA - Version 2.0.2

Version Description

  • "Stable tag" refers to trunk.
Download this release

Release Info

Developer takayukister
Plugin Icon 128x128 Really Simple CAPTCHA
Version 2.0.2
Comparing to
See all releases

Code changes from version 2.0.1 to 2.0.2

Files changed (3) hide show
  1. license.txt +2 -2
  2. readme.txt +6 -2
  3. really-simple-captcha.php +21 -13
license.txt CHANGED
@@ -1,4 +1,4 @@
1
- Really Simple CAPTCHA - WordPress Plugin, 2007-2017 Takayuki Miyoshi
2
  Really Simple CAPTCHA is distributed under the terms of the GNU GPL
3
 
4
  This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@ Really Simple CAPTCHA WordPress Plugin bundles the following third-party resourc
20
 
21
  Gentium Basic Release 1.102
22
  Gentium is released under the SIL Open Font License
23
- Source: http://software.sil.org/gentium/
24
 
25
 
26
  =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1
+ Really Simple CAPTCHA - WordPress Plugin, 2007-2019 Takayuki Miyoshi
2
  Really Simple CAPTCHA is distributed under the terms of the GNU GPL
3
 
4
  This program is free software; you can redistribute it and/or modify
20
 
21
  Gentium Basic Release 1.102
22
  Gentium is released under the SIL Open Font License
23
+ Source: https://software.sil.org/gentium/
24
 
25
 
26
  =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: takayukister
3
  Donate link: https://contactform7.com/donate/
4
  Tags: captcha
5
  Requires at least: 4.7
6
- Tested up to: 4.8.1
7
- Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -91,6 +91,10 @@ If you have any further questions, please submit them [to the support forum](htt
91
 
92
  == Changelog ==
93
 
 
 
 
 
94
  = 2.0.1 =
95
 
96
  * Does a file existence check before attempting to remove the file.
3
  Donate link: https://contactform7.com/donate/
4
  Tags: captcha
5
  Requires at least: 4.7
6
+ Tested up to: 5.2
7
+ Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
91
 
92
  == Changelog ==
93
 
94
+ = 2.0.2 =
95
+
96
+ * "Stable tag" refers to trunk.
97
+
98
  = 2.0.1 =
99
 
100
  * Does a file existence check before attempting to remove the file.
really-simple-captcha.php CHANGED
@@ -6,10 +6,10 @@ Description: Really Simple CAPTCHA is a CAPTCHA module intended to be called fro
6
  Author: Takayuki Miyoshi
7
  Author URI: https://ideasilo.wordpress.com/
8
  Text Domain: really-simple-captcha
9
- Version: 2.0.1
10
  */
11
 
12
- define( 'REALLYSIMPLECAPTCHA_VERSION', '2.0.1' );
13
 
14
  class ReallySimpleCaptcha {
15
 
@@ -107,7 +107,12 @@ class ReallySimpleCaptcha {
107
  $dir = trailingslashit( $this->tmp_dir );
108
  $filename = null;
109
 
110
- if ( $im = imagecreatetruecolor( $this->img_size[0], $this->img_size[1] ) ) {
 
 
 
 
 
111
  $bg = imagecolorallocate( $im, $this->bg[0], $this->bg[1], $this->bg[2] );
112
  $fg = imagecolorallocate( $im, $this->fg[0], $this->fg[1], $this->fg[2] );
113
 
@@ -143,7 +148,7 @@ class ReallySimpleCaptcha {
143
  }
144
 
145
  imagedestroy( $im );
146
- chmod( $file, $this->file_mode );
147
  }
148
 
149
  $this->generate_answer_file( $prefix, $word );
@@ -171,7 +176,7 @@ class ReallySimpleCaptcha {
171
  fclose( $fh );
172
  }
173
 
174
- chmod( $answer_file, $this->answer_file_mode );
175
  }
176
 
177
  /**
@@ -193,12 +198,13 @@ class ReallySimpleCaptcha {
193
  $filename = sanitize_file_name( $prefix . '.txt' );
194
  $file = $this->normalize_path( $dir . $filename );
195
 
196
- if ( is_readable( $file ) && ( $code = file_get_contents( $file ) ) ) {
 
197
  $code = explode( '|', $code, 2 );
198
  $salt = $code[0];
199
  $hash = $code[1];
200
 
201
- if ( hash_hmac( 'md5', $response, $salt ) == $hash ) {
202
  return true;
203
  }
204
  }
@@ -220,7 +226,7 @@ class ReallySimpleCaptcha {
220
  $file = $this->normalize_path( $dir . $filename );
221
 
222
  if ( is_file( $file ) ) {
223
- unlink( $file );
224
  }
225
  }
226
  }
@@ -235,7 +241,8 @@ class ReallySimpleCaptcha {
235
  $dir = trailingslashit( $this->tmp_dir );
236
  $dir = $this->normalize_path( $dir );
237
 
238
- if ( ! is_dir( $dir ) || ! is_readable( $dir ) ) {
 
239
  return false;
240
  }
241
 
@@ -255,14 +262,15 @@ class ReallySimpleCaptcha {
255
 
256
  $file = $this->normalize_path( $dir . $filename );
257
 
258
- if ( ! file_exists( $file ) || ! ( $stat = stat( $file ) ) ) {
 
259
  continue;
260
  }
261
 
262
  if ( ( $stat['mtime'] + $minutes * 60 ) < time() ) {
263
- if ( ! unlink( $file ) ) {
264
- chmod( $file, 0644 );
265
- unlink( $file );
266
  }
267
 
268
  $count += 1;
6
  Author: Takayuki Miyoshi
7
  Author URI: https://ideasilo.wordpress.com/
8
  Text Domain: really-simple-captcha
9
+ Version: 2.0.2
10
  */
11
 
12
+ define( 'REALLYSIMPLECAPTCHA_VERSION', '2.0.2' );
13
 
14
  class ReallySimpleCaptcha {
15
 
107
  $dir = trailingslashit( $this->tmp_dir );
108
  $filename = null;
109
 
110
+ $im = imagecreatetruecolor(
111
+ $this->img_size[0],
112
+ $this->img_size[1]
113
+ );
114
+
115
+ if ( $im ) {
116
  $bg = imagecolorallocate( $im, $this->bg[0], $this->bg[1], $this->bg[2] );
117
  $fg = imagecolorallocate( $im, $this->fg[0], $this->fg[1], $this->fg[2] );
118
 
148
  }
149
 
150
  imagedestroy( $im );
151
+ @chmod( $file, $this->file_mode );
152
  }
153
 
154
  $this->generate_answer_file( $prefix, $word );
176
  fclose( $fh );
177
  }
178
 
179
+ @chmod( $answer_file, $this->answer_file_mode );
180
  }
181
 
182
  /**
198
  $filename = sanitize_file_name( $prefix . '.txt' );
199
  $file = $this->normalize_path( $dir . $filename );
200
 
201
+ if ( is_readable( $file )
202
+ and $code = file_get_contents( $file ) ) {
203
  $code = explode( '|', $code, 2 );
204
  $salt = $code[0];
205
  $hash = $code[1];
206
 
207
+ if ( hash_hmac( 'md5', $response, $salt ) === $hash ) {
208
  return true;
209
  }
210
  }
226
  $file = $this->normalize_path( $dir . $filename );
227
 
228
  if ( is_file( $file ) ) {
229
+ @unlink( $file );
230
  }
231
  }
232
  }
241
  $dir = trailingslashit( $this->tmp_dir );
242
  $dir = $this->normalize_path( $dir );
243
 
244
+ if ( ! is_dir( $dir )
245
+ or ! is_readable( $dir ) ) {
246
  return false;
247
  }
248
 
262
 
263
  $file = $this->normalize_path( $dir . $filename );
264
 
265
+ if ( ! file_exists( $file )
266
+ or ! $stat = stat( $file ) ) {
267
  continue;
268
  }
269
 
270
  if ( ( $stat['mtime'] + $minutes * 60 ) < time() ) {
271
+ if ( ! @unlink( $file ) ) {
272
+ @chmod( $file, 0644 );
273
+ @unlink( $file );
274
  }
275
 
276
  $count += 1;