Modified:
trunk/Tipos/Captcha/Image.php
Log:
Small improvement|: try to delete the image file every time a session flash
is get, and not only when the captcha is valid.
Modified: trunk/Tipos/Captcha/Image.php
==============================================================================
--- trunk/Tipos/Captcha/Image.php (original)
+++ trunk/Tipos/Captcha/Image.php Wed Oct 8 13:37:22 2008
@@ -121,20 +121,20 @@
settype($key, 'string');
list($solution, $file) = explode(':', $key . ':');
+ // sanitize file name and try to delete file
+ $file = preg_replace('/[^a-z0-9]/i', '', $file);
+ $path = $this->_config['save_path'] . $file . '.jpg';
+ if (file_exists($path)) {
+ unlink($path);
+ }
+
// hash the attempted value
$hash = hash($this->_config['hash_algo'],
$this->_config['salt'] . $value);
// valid solution?
if ($solution == $hash) {
- // valid: sanitize file name and delete file
- $file = preg_replace('/[^a-z0-9]/i', '', $file);
- $path = $this->_config['save_path'] . $file . '.jpg';
- if (file_exists($path)) {
- unlink($path);
- }
-
- // done
+ // yes, it is valid
return true;
}
}