如何使用ATK4实现图像验证
我正在开发一个简单的网络表单来收集网站访问者的反馈。由于访问者未经身份验证,我想为用户实施图像验证步骤。我在 atk4 文档中进行了搜索,但找不到任何类似实现的参考。我还检查了 at4-addons 源代码并找到了两个资源 - View_ReCaptcha 和 Form_Field_Verification。
我不确定我应该遵循哪一个。是否有任何示例代码或教程可供我参考以实现网络表单的图像验证步骤?
I am developing a simple web form to collect feedback from visitors of my website. Since the visitor is not authenticated, I would like to implement an image verification step for the users. I have searched in atk4 documentation and couldn't find any reference for a similar implementation. I have also checked at4-addons source and found two resources - View_ReCaptcha and Form_Field_Verification.
I'm not sure which one should I follow. Is there any example code or tutorial which I can refer to implement a image verification step for my web form?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
KCapcha 在 Agile Toolkit
这实现了验证码的非常硬核的实现,而不使用任何控制器或视图。当然,不鼓励这样做,但如果您有截止日期,这是您可以使用的最后手段:
注意:您需要从他们的网站下载 kcapcha 并将其安装到 /lib/kcapcha/ 中。
示例:http://agiletech.ie/contact
敏捷工具包 中的 ReCapcha
您发现 ReCapcha 实现要好得多,但并不理想。它手动查看 POST 数据并简单地设置标志来告诉您输入是否正确。以下是用法示例:
注意:您需要安装 recapcha lib。参见来源。
制作更好的 Capcha
可能最好的方法是引入一种新的字段类型(Form_Field_Capcha),它完全自动完成整个事情。它不应捆绑任何 PHP 库,而应依赖第三方服务来生成图像。它还必须使用标准表单验证。
KCapcha in Agile Toolkit
This implements a very hard-core implementation of a captcha, without use of any controllers or views. Of course it's discouraged to code like that, but if you have your deadline, this is the last resort you can use:
Note: you'll need to download and install kcapcha into /lib/kcapcha/ from their website.
Example: http://agiletech.ie/contact
ReCapcha in Agile Toolkit
ReCapcha implementation you have found is much more decent, but not Ideal. It manually looks into the POST data and simply sets flag telling you if it was typed properly or not. Here is example usage:
Note: You would need recapcha lib installed. See source.
Making better Capcha
Probably the best way would be to introduce a new field type, (Form_Field_Capcha) which does the whole thing completely automatically. It shouldn't bundle any PHP libraries but would rely on 3rd party service for image generation. It also must use the standard form validation.