鱼儿/无验证码

一个完全没有用的验证码

1.1.1 2017-01-18 14:46 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:25:23 UTC


README

构建...

如何渲染页面?

public function getCode()
{
    $ctl = new Template();
    return $ctl->view('code', [
        'generate' => 'http://127.0.0.1/auth/code-generate',
        'valid' => 'http://127.0.0.1/auth/code-valid',
        'query' => 'http://127.0.0.1/auth/code-query',
        'name' => 'Muyu',
        'sign' => 'Inc',
        'message' => '吾,非机器人也',
    ]);
}

如何使用?

private $captcha;
    
public function __construct()
{
    $this->captcha = new Captcha();
    
    /**
     * you can choose
     * useFile | useRedis | useMemcache
     * param is driver connection instance
     */
              
    $this->captcha->useMemcache($memcached);
}
    
public function postLogin()
{
    if(! $this->getCodeQuery())
    {
        throw new Exception('you are robot');
    }
}
    
public function getCodeGenerate()
{
    return $this->captcha->generate();
}
    
public function getCodeValid()
{
    return $this->captcha->valid();
}
    
private function getCodeQuery()
{
    return $this->captcha->query();
}