public function getVerify() { $_tmps = array(); Wind::import('LIB:utility.verifycode.PwGDCode'); $_tmps = $this->_config['content.type']; $_key = array_rand($_tmps, 1); switch ($_tmps[$_key]) { case '1': case '2': case '3': case '5': PwGDCode::$verifyLength = $this->_config['content.length']; PwGDCode::$verifyType = $_tmps[$_key]; PwGDCode::$verifyWidth = $this->_config['width']; PwGDCode::$verifyHeight = $this->_config['height']; break; case '4': $askAnswer = $this->_getVerifyCalculate(); PwGDCode::$verifyType = $_tmps[$_key]; PwGDCode::$askCode = $this->_config['content.showanswer'] ? $askAnswer['ask'] . '(' . $askAnswer['answer'] . ')' : $askAnswer['ask']; PwGDCode::$answerCode = $askAnswer['answer']; PwGDCode::$verifyWidth = $this->_config['width']; PwGDCode::$verifyHeight = $this->_config['height']; break; case '6': $askAnswer = $this->_getVerifyAsk(); //PwGDCode::$verifyWidth = 300; PwGDCode::$verifyType = $_tmps[$_key]; PwGDCode::$askCode = $this->_config['content.showanswer'] ? $askAnswer['ask'] . '(' . $askAnswer['answer'] . ')' : $askAnswer['ask']; PwGDCode::$answerCode = $askAnswer['answer']; PwGDCode::$verifyWidth = $this->_config['width']; PwGDCode::$verifyHeight = $this->_config['height']; break; default: PwGDCode::$verifyLength = 4; PwGDCode::$verifyType = 3; PwGDCode::$verifyWidth = $this->_config['width']; PwGDCode::$verifyHeight = $this->_config['height']; break; } $this->_getGDRandType(); if (!PwGDCode::init()) { return false; } $this->_saveVerifyCode(); if ($this->_config['type'] == 'image') { PwGDCode::outputImage(); } else { PwGDCode::outputFlash(); } }
private static function _setRandDistortion() { if (!self::$isRandDistortion) { return true; } $_tmp = self::$_image; self::$verifyWidth = self::$verifyWidth; self::_creatImage(); self::_creatBackground(); for ($i = 0; $i < self::$verifyWidth; $i++) { for ($j = 0; $j < self::$verifyHeight; $j++) { $_color = imagecolorat($_tmp, $i, $j); if (intval($i + sin($j / self::$verifyHeight * 2 * M_PI) * 10) <= self::$verifyWidth && intval($i + sin($j / self::$verifyHeight * 2 * M_PI) * 10) >= 0) { imagesetpixel(self::$_image, intval($i + sin($j / self::$verifyHeight * 2 * M_PI - 0.6) * 5), $j, $_color); } } } }