First of all, thanks for awesome plugins Takayuki, great job!
I also had this problem with my development machine (Windows + Apache + mod_FCGI + PHP5).
The problem is with the permissions which, on windows, sets the files as read-only and makes PHP unable to delete the files.
I tried to fix this through tweaking the permissions for Apache and PHP and the directory containing the files, but all failed.
The solution turned out to be changing the permissions (chmod) of the files just before deleting (unlink).
so, I added @chmod (@file, 0777); just before the unlink() and it works perfectly now.
To do the same, you can edit really-simple-captcha.php and make the modifications on functions remove and cleanup as follows:
/* Remove temporary files with $prefix */
function remove( $prefix ) {
$suffixes = array( '.jpeg', '.gif', '.png', '.php', '.txt' );
foreach ( $suffixes as $suffix ) {
$filename = sanitize_file_name( $prefix . $suffix );
$file = trailingslashit( $this->tmp_dir ) . $filename;
if ( is_file( $file ) )
{
@chmod( $file, 0777 );
unlink( $file );
}
}
}
/* Clean up dead files older than $minutes in the tmp folder */
function cleanup( $minutes = 60 ) {
$dir = trailingslashit( $this->tmp_dir );
if ( ! is_dir( $dir ) || ! is_readable( $dir ) || ! is_writable( $dir ) )
return false;
$count = 0;
if ( $handle = @opendir( $dir ) ) {
while ( false !== ( $filename = readdir( $handle ) ) ) {
if ( ! preg_match( '/^[0-9]+\.(php|txt|png|gif|jpeg)$/', $filename ) )
continue;
$file = $dir . $filename;
$stat = @stat( $file );
if ( ( $stat['mtime'] + $minutes * 60 ) < time() ) {
@chmod( $file, 0777 );
@unlink( $file );
$count += 1;
}
}
closedir( $handle );
}
return $count;
}
By the way, the plugin works perfectly fine on Linux, so if your host is running Linux, you don’t need to apply these changes there.