oxcaptcha.php
Go to the documentation of this file.00001 <?php
00002
00008 class oxCaptcha extends oxSuperCfg
00009 {
00015 protected $_dMacLength = 5;
00016
00022 protected $_sText = null;
00023
00029 private $_sMacChars = 'abcdefghijkmnpqrstuvwxyz23456789';
00030
00036 public function getText()
00037 {
00038 if (!$this->_sText) {
00039 for ( $i=0; $i < $this->_dMacLength; $i++ ) {
00040 $this->_sText .= strtolower($this->_sMacChars{ rand( 0, strlen($this->_sMacChars) - 1 ) });
00041 }
00042 }
00043
00044
00045 return $this->_sText;
00046 }
00047
00055 public function getHash($sText = null)
00056 {
00057 if (!$sText) {
00058 $sText = $this->getText();
00059 }
00060
00061 $sText = strtolower($sText);
00062
00063 return md5( "ox{$sText}" );
00064 }
00065
00071 public function getImageUrl()
00072 {
00073 $sUrl = $this->getConfig()->getCoreUtilsURL() . "verificationimg.php?e_mac=";
00074 $sUrl .= oxUtils::getInstance()->strMan( $this->getText() );
00075
00076 return $sUrl;
00077 }
00078
00084 public function isImageVisible()
00085 {
00086 return (( function_exists('imagecreatetruecolor') || function_exists( 'imagecreate' ) ) && $this->getConfig()->getConfigParam( 'iUseGDVersion' ) > 1 );
00087 }
00088
00097 public function pass($sMac, $sMacHash)
00098 {
00099 return strlen( $sMacHash ) == 32 && $this->getHash($sMac) == $sMacHash;
00100 }
00101 }
00102