45 if ( !$this->_sText ) {
48 $this->_sText .= strtolower( $this->_sMacChars{ rand( 0, strlen( $this->_sMacChars ) - 1 ) } );
70 if ( $session->isSessionStarted() ) {
72 $aHash = $session->getVariable(
"aCaptchaHash" );
73 $aHash[$sHash] = array( $sTextHash => $iTime );
74 $session->setVariable(
"aCaptchaHash", $aHash );
77 $sQ =
"insert into oxcaptcha ( oxhash, oxtime ) values ( '{$sTextHash}', '{$iTime}' )";
79 $sHash = $oDb->getOne(
"select LAST_INSERT_ID()",
false,
false );
97 $sText = strtolower($sText);
98 return md5(
"ox{$sText}" );
108 $sUrl = $this->
getConfig()->getCoreUtilsURL() .
"verificationimg.php?e_mac=";
109 $sKey = $this->
getConfig()->getConfigParam(
'captchaKey');
110 $sKey = empty($sKey) ? null : $sKey;
123 return ( ( function_exists(
'imagecreatetruecolor' ) || function_exists(
'imagecreate' ) ) && $this->
getConfig()->getConfigParam(
'iUseGDVersion' ) > 1 );
139 if ( ( $aHash = $oSession->getVariable(
"aCaptchaHash" ) ) ) {
140 $blPass = ( isset( $aHash[$sMacHash][$sHash] ) && $aHash[$sMacHash][$sHash] >= $iTime ) ?
true :
false;
141 unset( $aHash[$sMacHash] );
142 if ( !empty( $aHash ) ) {
143 $oSession->setVariable(
"aCaptchaHash", $aHash );
145 $oSession->deleteVariable(
"aCaptchaHash" );
165 $sQ =
"select 1 from oxcaptcha where oxid = {$iMacHash} and oxhash = '{$sHash}'";
166 if ( ( $blPass = (
bool) $oDb->getOne( $sQ,
false,
false ) ) ) {
168 $sQ =
"delete from oxcaptcha where oxid = {$iMacHash} and oxhash = '{$sHash}'";
169 $oDb->execute( $sQ );
173 $sQ =
"delete from oxcaptcha where oxtime < $iTime";
174 $oDb->execute( $sQ );
187 public function pass( $sMac, $sMacHash )
195 if ( $blPass === null ) {
196 $blPass = $this->
_passFromDb( (
int) $sMacHash, $sHash, $iTime );
199 return (
bool) $blPass;