Skip to content

Commit

Permalink
Merge branch '3.0' into fix-refresh-parameter-error
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-coder authored Oct 3, 2019
2 parents 3f8e0dc + 0b4305d commit fc39117
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"think": {
"services": [
"think\\captcha\\CaptchaService"
]
],
"config":{
"captcha": "src/config.php"
}
}
},
"minimum-stability": "dev"
Expand Down
3 changes: 2 additions & 1 deletion src/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ protected function generate(): array
$bag = '';

if ($this->math) {
$this->useZh = false;
$this->useZh = false;
$this->length = 5;

$x = random_int(10, 30);
$y = random_int(1, 9);
Expand Down
39 changes: 39 additions & 0 deletions src/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | Captcha配置文件
// +----------------------------------------------------------------------

return [
//验证码位数
'length' => 5,
// 验证码字符集合
'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
// 验证码过期时间
'expire' => 1800,
// 是否使用中文验证码
'useZh' => false,
// 是否使用算术验证码
'math' => false,
// 是否使用背景图
'useImgBg' => false,
//验证码字符大小
'fontSize' => 25,
// 是否使用混淆曲线
'useCurve' => true,
//是否添加杂点
'useNoise' => true,
// 验证码字体 不设置则随机
'fontttf' => '',
//背景颜色
'bg' => [243, 251, 254],
// 验证码图片高度
'imageH' => 0,
// 验证码图片宽度
'imageW' => 0,

// 添加额外的验证码设置
// verify => [
// 'length'=>4,
// ...
//],
];
4 changes: 2 additions & 2 deletions src/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ function captcha_src($config = null): string
function captcha_img($id = '', $domid = ''): string
{
$src = captcha_src($id);

$domid = empty($domid) ? $domid : "id='" . $domid . "'";

return "<img src='{$src}' alt='captcha' " . $domid . " onclick='this.src=\"{$src}?timestamp=\"+Math.random();' />";
return "<img src='{$src}' alt='captcha' " . $domid . " onclick='this.src=\"{$src}?\"+Math.random();' />";
}

/**
Expand Down

0 comments on commit fc39117

Please sign in to comment.