KCAPTCHA php5.3 버전 이하에서 나는 오류 수정

This commit is contained in:
thisgun
2022-07-26 11:35:33 +09:00
parent 0c275d0907
commit a6e302ff84
2 changed files with 7 additions and 2 deletions

View File

@ -18,6 +18,8 @@
class KCAPTCHA{ class KCAPTCHA{
private $keystring;
// generates keystring and image // generates keystring and image
function image(){ function image(){
require(dirname(__FILE__).'/kcaptcha_config.php'); require(dirname(__FILE__).'/kcaptcha_config.php');

View File

@ -4,10 +4,13 @@ include_once('captcha.lib.php');
$captcha = new KCAPTCHA(); $captcha = new KCAPTCHA();
$ss_captcha_key = get_session("ss_captcha_key"); $ss_captcha_key = get_session("ss_captcha_key");
$ss_captcha_key_decrypt = '';
if( $ss_captcha_key && !preg_match('/^[0-9]/', $ss_captcha_key) && function_exists('get_string_decrypt') ){ if( $ss_captcha_key && !preg_match('/^[0-9]/', $ss_captcha_key) && function_exists('get_string_decrypt') ){
$ip = md5(sha1($_SERVER['REMOTE_ADDR'])); $ip = md5(sha1($_SERVER['REMOTE_ADDR']));
$ss_captcha_key = str_replace($ip, '', get_string_decrypt($ss_captcha_key)); $ss_captcha_key_decrypt = str_replace($ip, '', get_string_decrypt($ss_captcha_key));
} }
$captcha->setKeyString($ss_captcha_key); # php 5.2 또는 5.3 버전에서 포인터처럼 해당 세션값이 변경되는 버그가 있어서 아래와 같이 조치함
if(! $ss_captcha_key_decrypt) $ss_captcha_key_decrypt = $ss_captcha_key;
$captcha->setKeyString($ss_captcha_key_decrypt);
$captcha->getKeyString(); $captcha->getKeyString();
$captcha->image(); $captcha->image();