From 9572406f5ed6637f0e12f6106514d488e2cc1a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=92=E5=8D=9A?= Date: Wed, 28 Dec 2016 16:10:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=8B=E5=8A=A8=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E6=96=B9=E5=BC=8F=E9=AA=8C=E8=AF=81=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99captcha=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84bug?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=97=B6=E8=A7=84=E8=8C=83=E4=BA=86=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=9A=84=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=96=87=E6=9C=AC!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helper.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/helper.php b/src/helper.php index 488e5a5..914c749 100644 --- a/src/helper.php +++ b/src/helper.php @@ -11,49 +11,53 @@ \think\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index"); -\think\Validate::extend('captcha', function ($value, $id = "") { - return captcha_check($value, $id, (array) \think\Config::get('captcha')); +\think\Validate::extend('captcha', function ($value, $id = '') { + return captcha_check($value, $id); }); -\think\Validate::setTypeMsg('captcha', '验证码错误!'); +\think\Validate::setTypeMsg('captcha', ':attribute错误!'); + /** * @param string $id * @param array $config * @return \think\Response */ -function captcha($id = "", $config = []) +function captcha($id = '', $config = []) { $captcha = new \think\captcha\Captcha($config); return $captcha->entry($id); } + /** * @param $id * @return string */ -function captcha_src($id = "") +function captcha_src($id = '') { return \think\Url::build('/captcha' . ($id ? "/{$id}" : '')); } + /** * @param $id * @return mixed */ -function captcha_img($id = "") +function captcha_img($id = '') { return 'captcha'; } + /** * @param $value * @param string $id * @param array $config * @return bool */ -function captcha_check($value, $id = "", $config = []) +function captcha_check($value, $id = '') { - $captcha = new \think\captcha\Captcha($config); + $captcha = new \think\captcha\Captcha((array)\think\Config::get('captcha')); return $captcha->check($value, $id); }