4 Commits

Author SHA1 Message Date
yunwuxin
f7670c78cd 废除NOW_TIME常量 2016-06-03 12:25:17 +08:00
yunwuxin
e1a0260861 Merge pull request #1 from zhaishuaigan/master
修复验证码不显示问题
2016-05-12 05:02:08 -05:00
翟帅干
988d165aae 修复验证码不显示问题 2016-05-12 17:19:22 +08:00
yunwuxin
6ab79cc547 修正 2016-05-11 15:26:20 +08:00
3 changed files with 5 additions and 6 deletions

View File

@@ -98,7 +98,7 @@ class Captcha
return false;
}
// session 过期
if (NOW_TIME - $secode['verify_time'] > $this->expire) {
if (time() - $secode['verify_time'] > $this->expire) {
Session::delete($key);
return false;
}
@@ -182,7 +182,7 @@ class Captcha
$code = $this->authcode(strtoupper(implode('', $code)));
$secode = [];
$secode['verify_code'] = $code; // 把校验码保存到session
$secode['verify_time'] = NOW_TIME; // 验证码创建时间
$secode['verify_time'] = time(); // 验证码创建时间
Session::set($key . $id, $secode);
header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate');

View File

@@ -12,9 +12,8 @@
namespace think\captcha;
use think\Config;
use think\Controller;
class CaptchaController extends Controller
class CaptchaController
{
public function index($id = "")
{

View File

@@ -24,7 +24,7 @@
*/
function captcha($id = "", $config = [])
{
$captcha = new \think\Captcha($config);
$captcha = new \think\captcha\Captcha($config);
$captcha->entry($id);
}
@@ -35,7 +35,7 @@ function captcha($id = "", $config = [])
*/
function captcha_src($id = "")
{
return \think\Url::build('/captcha' . $id ? "/{$id}" : '');
return \think\Url::build('/captcha' . ($id ? "/{$id}" : ''));
}