【问题标题】:CAPTCHA in Fat Free frameworkFat Free 框架中的验证码
【发布时间】:2012-05-08 22:09:03
【问题描述】:

如何在 Fat Free 框架的登录表单中使用 CAPTCHA 插件?我以前从未使用过 CAPTCHA,所以我正在寻找某种教程来学习 FatFree 框架。

谁能指出一些资源或告诉我如何做到这一点?具体来说,我希望在模板的表单中插入验证码,然后在提交表单时检查其正确性。

【问题讨论】:

    标签: php fat-free-framework


    【解决方案1】:

    Fat Free 框架已经内置了验证码

    <img src="/captcha" title="captcha image" alt="captcha"/>
    <label for="code">Security Code</label>
    <input type="text" name="code"/>
    <p>{@message}</p>
    

    然后在您的应用程序中,您应该有一个路由来处理 src 属性中指定的 /captcha URL:

    F3::route('GET /captcha','securityCode');
    function securityCode() {
        Graphics::captcha(150,60,5);
    }
    

    输入验证脚本类似于:-

    F3::input('code',
        function($value) {
            if (empty($value))
                F3::set('message','Security code is required');
            elseif ($value!=$_SESSION['captcha'])
                F3::set('message','Invalid security code');
        }
    );
    

    查看http://bcosca.github.com/fatfree/获取完整文档

    Fat Free Captch 存在已知错误,希望您使用最新版本来修复它

    You know about the bug with captcha ()?
    It's easy to fix!
    Line number 81 in graphics.php with the error:
    $ file = self:: $ global ['FONTS'].
    
    Corrected version:
    $ file = __DIR__ .'/../ fonts / '. self:: $ global [' FONTS '].
    

    见:http://techzinger.blogspot.com/2011/02/fat-free-framework-for.html?showComment=1298024374012#c4330544534362949394

    【讨论】:

    • 感谢您的回答。但是,我收到一些错误,例如 filesize() [function.filesize]: stat failed for /var/www/cube.ttf。在 graphics.php 中,没有您告诉要修复的那一行。该行是 $file=&self::vars['FONTS']。我该怎么办?
    • 我真的明白了。我必须设置 F3::set('FONTS', /path/to/fonts/folder') 因为它不同。
    • 我使用 Google Recaptcha,它与 F3 一起使用非常棒:p
    猜你喜欢
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    • 1970-01-01
    • 2017-12-16
    • 2015-10-30
    • 2013-07-16
    相关资源
    最近更新 更多