From 195ce213d4adb7886eab87b7a515d18baf55343d Mon Sep 17 00:00:00 2001 From: Steeve Andrian Salim Date: Wed, 11 Apr 2018 09:11:23 +0700 Subject: [PATCH] captcha bugs fixes --- src/Protections/Captcha.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Protections/Captcha.php b/src/Protections/Captcha.php index c38838d..31409fe 100644 --- a/src/Protections/Captcha.php +++ b/src/Protections/Captcha.php @@ -105,10 +105,14 @@ public function regenerate() */ public function getImage() { - $tempFilePath = tempnam( - sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'o2system' . DIRECTORY_SEPARATOR, - 'captcha' - ); + if(class_exists('O2System\Framework')) { + $tempFilePath = @tempnam(PATH_CACHE, 'captcha'); + } else { + $tempFilePath = @tempnam( + sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'o2system' . DIRECTORY_SEPARATOR, + 'captcha' + ); + } if ( $image = imagecreatetruecolor( 200, 50 ) ) { $backgroundColor = imagecolorallocate( $image, 255, 255, 255 );