From 9779a0bebe8651abfdd93d481558336e0bc681a5 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 26 Dec 2013 02:54:05 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E4=B8=89=E6=B1=9F=E6=BA=90=E5=AD=90?= =?UTF-8?q?=E7=AB=99=E4=B8=AD=E6=B7=BB=E5=8A=A0=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=8A=A9=E6=89=8Bhelpers\Captcha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/module/Helpers/Captcha.php | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 application/module/Helpers/Captcha.php diff --git a/application/module/Helpers/Captcha.php b/application/module/Helpers/Captcha.php new file mode 100644 index 00000000..dc61b759 --- /dev/null +++ b/application/module/Helpers/Captcha.php @@ -0,0 +1,52 @@ +loadCaptcha(); + } + + public function loadCaptcha() + { + $this->captcha = new \Zend_Captcha_Image(array( + 'captcha' => 'Image', + 'wordLen' => 4, + 'fontsize'=>16, + 'width' => 100, + 'height' => 38, + 'dotNoiseLevel'=>2, + 'lineNoiseLevel'=>1, + 'timeout' => 300, + 'font' => '../data/fonts/ggbi.ttf', + 'imgDir' => 'vdimg/', + 'imgUrl' => '/vdimg', + )); + } + + public function setCaptcha(){ + $this->captcha->generate(); + $_SESSION[$this->sessionName] = $this->captcha->getWord(); + $url = $this->captcha->getImgUrl() + .$this->captcha->getId() + .$this->captcha->getSuffix(); + + return $url; + } + + public function isValid($captchaword) + { + if($captchaword == $_SESSION[$this->sessionName]) + { + return true; + }else{ + return false; + } + } + +} \ No newline at end of file