简体   繁体   English

在没有PHP的情况下保护Web联系表单免受垃

[英]Protecting a web contact form from spam without PHP?

I'm supposed to implement some sort of spam protection (captcha, etc.) for an existing web contact form. 我应该为现有的Web联系表单实现某种垃圾邮件保护(验证码等)。 However the original form uses a .cgi file on the virtual server that I can't access, so I can't work with this script. 但是,原始表单使用我无法访问的虚拟服务器上的.cgi文件,因此我无法使用此脚本。 The PHP mail function is turned off . PHP邮件功能已关闭

I'm guessing I need my own cgi file but I'm not really into perl and cgi :-) 我猜我需要自己的cgi文件,但我不是真的进入perl和cgi :-)

Maybe you can point me to some kind of solution for this problem. 也许你可以指出我对这个问题的某种解决方案。

You can make some kind of askew antibot, if you suppose, that all your users have turned on javascript. 如果你想的话,你可以制作某种歪斜的抗体,你所有的用户都开启了javascript。

Set forms action to some 404 page and in javascript change it back to proper action page. 将表单action设置为某些404页面,然后在javascript中将其更改回正确的action页面。 Example: 例:

<form action="nowhere_ahaha" id="myform">
   ...
</form>
<script>
document.getElementById('myform').action = '/form_action.cgi';
</script>

All this works, because bots usualy do not run js, but human visitors do. 所有这一切都有效,因为机器人通常不会运行js,但人类访问者会这样做。

You can add a Negative Captcha: 你可以添加一个否定的Captcha:

A negative captcha has the exact same purpose as your run-of-the-mill image captcha: To keep bots from submitting forms. 负验证码与您的普通图像验证码具有完全相同的目的:防止机器人提交表单。 Image (“positive”) captchas do this by implementing a step which only humans can do, but bots cannot: read jumbled characters from an image. 图像(“正面”)验证码通过实现仅人类可以执行的步骤来完成此操作,但机器人不能:从图像中读取混乱的字符。 But this is bad. 但这很糟糕。 It creates usability problems, it hurts conversion rates, and it confuses the shit out of lots of people. 它会产生可用性问题,会损害转换率,并且会让很多人感到困惑。 Why not do it the other way around? 为什么不反过来呢? Negative captchas create a form that has tasks that only bots can perform, but humans cannot. 负验证码创建一个表单,其中只有机器人可以执行的任务,但人类不能。 This has the exact same effect, with (anecdotally) a much lower false positive identification rate when compared with positive captchas. 这具有完全相同的效果,(与传闻相比)与正验证码相比,假阳性识别率低得多。 All of this comes without making humans go through any extra trouble to submit the form. 所有这一切都没有让人类在提交表格时遇到任何额外的麻烦。 It really is win-win. 这真的是双赢。 [source] . [来源]

In your case, you probably best use a Honeypot: add a new field: 在您的情况下,您最好使用蜜罐:添加一个新字段:

<div style="position: absolute; left: -2000px;"><input type="text" name="surname"  value="" /></div>

This assumes you are not interested in recieving the surname. 这假设您对收到姓氏不感兴趣。 If people manage to fill this field and submit it, they are most probably a bot: Normal browsers will not show the field: normal users will not see it, and hence not fill it in. 如果人们设法填写此字段并提交,则他们很可能是机器人:普通浏览器不会显示该字段:普通用户不会看到它,因此不会填写它。

Now, in your CGI script, simply filter on "surname"; 现在,在你的CGI脚本中,只需过滤“surname”; if set, stop processing and give an error, or just leave it at that. 如果设置,停止处理并给出错误,或者只是保留它。

Or, if that is not possible, try to filter the results of the posted forms by "where record does not have surname set". 或者,如果无法做到这一点,请尝试通过“where record has surname set”过滤已发布表单的结果。 Say, if you get the results in an excel/CSV: just use excel to filter out the items that have a surname. 比如说,如果您在excel / CSV中获得结果:只需使用excel过滤掉具有姓氏的项目。 Or use your email-filters to move any mail where surname: .... has a value, into a special directory. 或者使用您的电子邮件过滤器将姓氏:....的任何邮件移动到特殊目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM