Images.php
928 Bytes
<?php
use Action\WebAction;
use WebPlugin\Captcha;
class ImagesController extends WebAction
{
/**
* 验证码-生成
* $len 生成图片验证码长度
* @return mixed 验证码图片
*/
public function indexAction()
{
$g = trim($this->get('g'));
$len = intval($this->get('len',4));
$namespace = !empty($g) ? $g : 'passport_istration';
$imgCode = new Captcha();
$imgCode->setWidth(150)->setHeight(50)->setWordLen($len)->generate($namespace);
exit();
}
/**
* 验证码-检测
*
* @param string auth_code (验证码)
* @return string true|false
*/
public function verifyimgcodeAction ()
{
if (strtolower($this->get('auth_code')) !== strtolower(Captcha::getFromSession('passport_istration')))
{
die('false');
}
die('true');
}
}