mirror of
https://gitee.com/fastadminnet/think-captcha.git
synced 2026-07-07 00:12:48 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02eb4a2667 | ||
|
|
f7670c78cd | ||
|
|
e1a0260861 | ||
|
|
988d165aae | ||
|
|
6ab79cc547 |
@@ -98,7 +98,7 @@ class Captcha
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// session 过期
|
// session 过期
|
||||||
if (NOW_TIME - $secode['verify_time'] > $this->expire) {
|
if (time() - $secode['verify_time'] > $this->expire) {
|
||||||
Session::delete($key);
|
Session::delete($key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ class Captcha
|
|||||||
$code = $this->authcode(strtoupper(implode('', $code)));
|
$code = $this->authcode(strtoupper(implode('', $code)));
|
||||||
$secode = [];
|
$secode = [];
|
||||||
$secode['verify_code'] = $code; // 把校验码保存到session
|
$secode['verify_code'] = $code; // 把校验码保存到session
|
||||||
$secode['verify_time'] = NOW_TIME; // 验证码创建时间
|
$secode['verify_time'] = time(); // 验证码创建时间
|
||||||
Session::set($key . $id, $secode);
|
Session::set($key . $id, $secode);
|
||||||
|
|
||||||
header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate');
|
header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate');
|
||||||
|
|||||||
@@ -12,9 +12,8 @@
|
|||||||
namespace think\captcha;
|
namespace think\captcha;
|
||||||
|
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Controller;
|
|
||||||
|
|
||||||
class CaptchaController extends Controller
|
class CaptchaController
|
||||||
{
|
{
|
||||||
public function index($id = "")
|
public function index($id = "")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// | Author: yunwuxin <448901948@qq.com>
|
// | Author: yunwuxin <448901948@qq.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
\think\Route::get('captcha/[:id]', ["\\think\\captcha\\CaptchaController", 'index']);
|
\think\Route::get('captcha/[:id]', "\\think\\captcha\\CaptchaController@index");
|
||||||
|
|
||||||
\think\Validate::extend('captcha', function ($value, $id = "") {
|
\think\Validate::extend('captcha', function ($value, $id = "") {
|
||||||
return captcha_check($value, $id, (array)\think\Config::get('captcha'));
|
return captcha_check($value, $id, (array)\think\Config::get('captcha'));
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
function captcha($id = "", $config = [])
|
function captcha($id = "", $config = [])
|
||||||
{
|
{
|
||||||
$captcha = new \think\Captcha($config);
|
$captcha = new \think\captcha\Captcha($config);
|
||||||
$captcha->entry($id);
|
$captcha->entry($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ function captcha($id = "", $config = [])
|
|||||||
*/
|
*/
|
||||||
function captcha_src($id = "")
|
function captcha_src($id = "")
|
||||||
{
|
{
|
||||||
return \think\Url::build('/captcha' . $id ? "/{$id}" : '');
|
return \think\Url::build('/captcha' . ($id ? "/{$id}" : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user