| @@ -8,8 +8,12 @@ | ||
| 8 | 8 | Text Domain: really-simple-captcha |
| 9 | 9 | Version: 1.9 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 13 | + exit; // Exit if accessed directly. | |
| 14 | +} | |
| 15 | + | |
| 12 | 16 | /* Copyright 2007-2016 Takayuki Miyoshi (email: takayukister at gmail.com) |
| 13 | 17 | |
| 14 | 18 | This program is free software; you can redistribute it and/or modify |
| 15 | 19 | it under the terms of the GNU General Public License as published by |
| @@ -284,8 +288,13 @@ | ||
| 284 | 288 | |
| 285 | 289 | $file = $this->normalize_path( $dir . $filename ); |
| 286 | 290 | |
| 287 | 291 | $stat = @stat( $file ); |
| 292 | + if ( false === $stat || ! isset( $stat['mtime'] ) ) { | |
| 293 | + // A concurrent CAPTCHA cleanup can remove the file after readdir(). | |
| 294 | + continue; | |
| 295 | + } | |
| 296 | + | |
| 288 | 297 | if ( ( $stat['mtime'] + $minutes * 60 ) < time() ) { |
| 289 | 298 | // phpcs:ignore WordPress.WP.AlternativeFunctions.unlink_unlink |
| 290 | 299 | if ( ! @wp_delete_file( $file ) ) { |
| 291 | 300 | // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_chmod |
| @@ -420,5 +429,5 @@ | ||
| 420 | 429 | $path = str_replace( '\\', '/', $path ); |
| 421 | 430 | $path = preg_replace( '|/+|', '/', $path ); |
| 422 | 431 | return $path; |
| 423 | 432 | } |
| 424 | -} | |
| 433 | +} | |