summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorGeorge Petculescu <gxgpet@gmail.com>2016-09-25 18:52:58 +0200
committerGeorge Petculescu <gxgpet@gmail.com>2016-09-25 18:52:58 +0200
commitfd8d3987226bcde81db0682eee9c9acca0beb9a1 (patch)
tree44ac431f2db34c8bc46790806d0338553d8fd226 /system/helpers
parent4b94152a48d8053ab72669278abfec18e1793310 (diff)
- captcha helper uses now filemtime to get file timestamp
- captcha generated files are a sha1 of current timestamp and word - changed the usage of microtime to time, as this is a more realistic approach Signed-off-by: George Petculescu <gxgpet@gmail.com>
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/captcha_helper.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 3c1e006f8..c2a1dcfbd 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -105,12 +105,13 @@ if ( ! function_exists('create_captcha'))
// Remove old images
// -----------------------------------
- $now = microtime(TRUE);
+ $now = time();
$current_dir = @opendir($img_path);
while ($filename = @readdir($current_dir))
{
- if (substr($filename, -4) === '.jpg' && (str_replace('.jpg', '', $filename) + $expiration) < $now)
+ if (in_array(substr($filename, -4), array('.jpg', '.png'))
+ && (filemtime($img_path.$filename) + $expiration) < $now)
{
@unlink($img_path.$filename);
}
@@ -319,12 +320,12 @@ if ( ! function_exists('create_captcha'))
if (function_exists('imagejpeg'))
{
- $img_filename = $now.'.jpg';
+ $img_filename = sha1($now.$word).'.jpg';
imagejpeg($im, $img_path.$img_filename);
}
elseif (function_exists('imagepng'))
{
- $img_filename = $now.'.png';
+ $img_filename = sha1($now.$word).'.png';
imagepng($im, $img_path.$img_filename);
}
else