我有一个用户填写的Web表单,信息发送到服务器并存储在数据库中.我担心机器人可能会填写表格,我最终会得到一个充满无用记录的数据库.如何防止机器人填写表格?我想也许像Stackoverflow的机器人检测,如果它认为你是一个机器人,它会要求你验证你不是.Perl,Java或PHP中是否有服务器端API?
这个问题可能已被提出 - 但不幸的是,我找不到任何令人满意的答案.我会问我的具体案例,并要求管理员不要删除这个问题至少几天,所以我可以尝试一下......
我有一个页面.它使用验证码.像这样:
<?php
session_start(); // the captcha saves the md5 into the session
?>
<img src="captcha.php" onclick="this.src = this.src" />
Run Code Online (Sandbox Code Playgroud)
这是我的第一个代码.它不起作用,因为如果源是相同的,浏览器认为它无法重新加载图像.我目前的解决方案是传递一个get参数:
onclick="this.src = 'captcha.php?randomNumber='+ranNum"
Run Code Online (Sandbox Code Playgroud)
var ranNum每次onclick事件触发时都会随机生成JavaScript变量.它工作正常,但是,我不喜欢这种可能性,如果 - 虽然不太可能 - 两个数字的情况连续两次相同.虽然随机数在-50,000到50,000之间变化 - 我仍然不喜欢它.我不认为这种方法是对的.我想通过AJAX了解'righter'方法.我知道这是可能的.我希望你知道它是如何可能的^^在这种情况下,请告诉我.
提前致谢!
顺便说一句 - 如果我拼写cap(t)cha不同,没关系,我的代码中对PHP文件的引用是正确的:我使用randomImage.php
编辑:只生成JavaScript中的随机数,以便重新加载图像.Captcha.php不关心$ _GET参数.字符串确实是随机的.
编辑:因此,我想知道的是如何使浏览器重新加载图像,而不是每次事件触发时传递不同的get参数.
我正在尝试使用JFormFieldCaptcha来处理我的自定义jForm.我设法完成了注册和联系表格的工作.但是,我想构建自己的联系表单,它基于XML文件,看起来像这样:
<form>
<fieldset addfieldpath="<path to JFormFieldCaptcha class>">
<field
name="captcha" label="Captcha" description="COM_DEZTOUR_ORDER_CAPTCHA_DESC"
type="text" validate="captcha"
/>
</fieldset>
</form>
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么这段代码不起作用.任何帮助都会得到满足!
我一直在收集有关如何防止日志页面上的暴力攻击或多个帐户创建的破坏的信息.
我得出结论(感谢Stackoverflow的人),最好的方法是使用验证码.
但是不方便阅读验证码或重音字符可能会阻止用户使用网站.
所以,我发现了一个易于使用的小脚本,我适应了我的网站.这是一个简单的数学验证码,建议总结从0到10的 2个数字.它显示的单词"一","两个","三个" ......而不是数字.
我的问题是:
1)这个小验证码本身是否提供足够的安全性?
2)我整合它的方式是否安全?(以任何方式绕过它?)
为了避免粘贴800行代码我做了总结,我希望很清楚.
验证码脚本:
$n1 = mt_rand(0,10);
$n2 = mt_rand(0,10);
$fig = array('zero','one','two','three','four','five','six','seven','eight','nine','ten');
$result = $n1 + $n2;
$sentence = $fig[$n1] .' plus '.$fig[$n2];
$_SESSION['captcha'] = $result;
$captcha_label = "<label for='captcha' >How much does ".$sentence."make?</label>";
echo $captcha_label."</label><input type='text' name='captcha' value=''/><br />";
echo "<input type='submit' name='create' value='create account'>";
Run Code Online (Sandbox Code Playgroud)
页数:
所有'创建帐户'输入字段+验证码
=>测试
test.php的:
if($_POST['captcha'] != $_SESSION['captcha']){
}
$_SESSION['captcha_control'] = "false";
然后所有'创建帐户' $ _POSTS都经过注射测试
如果它们中的任何一个或验证码返回"false",则脚本会偏转到=> …
我有一些错误,当您查看此页面时,在您输入验证码的框中,它显示"缺少翻译".我环顾四周,注意到它可能与i18n或闪光有关,但我不确定,到目前为止我发现的两件事都没有效果.谁能够引导我朝着正确的方向前进?
我已经在单页中实现了两个recaptcha,但只有一个是recaptcha正在工作
我的代码是针对验证码1的
<div class="resumator-label resumator-resume-text" id="resumator-recaptcha_forward-label">Human Check*</div>
<div class="resumator-input" id="resumator-recaptcha_forward-field">
<div id="div_error_resumator-forward-recaptcha-value" class="dv_error"><span>Please enter the text:</span></div><script type="text/javascript" src="//www.google.com/recaptcha/api/challenge?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y"></script>
<noscript>
<iframe src="//www.google.com/recaptcha/api/noscript?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>
</div>
Run Code Online (Sandbox Code Playgroud)
其他其他验证码的代码
<div class="resumator-field-wrapper resumator-resume-text" id="resumator-recaptcha">
<div class="resumator-label resumator-resume-text" id="resumator-recaptcha-label">Human Check*</div>
<div class="resumator-input" id="resumator-recaptcha-field">
<script type="text/javascript" src="//www.google.com/recaptcha/api/challenge?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y"></script>
<noscript>
<iframe src="//www.google.com/recaptcha/api/noscript?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我也使用克隆工作正常
//复制我们的reCapcha
$('#resumator-recaptcha-label').html($('#resumator-recaptcha_forward').clone(true,true));
Run Code Online (Sandbox Code Playgroud)
克隆验证码中的问题,其重新加载验证码和其他链接不适用于新的克隆验证码
我尝试通过PHP GD来制作Captcha。但是不幸的是我遇到了一个问题!PHP告诉我:
The image “http://127.0.0.1/par.php” cannot be displayed because it contains errors.
Run Code Online (Sandbox Code Playgroud)
我的代码是这样
<?php
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
$red = imagecolorallocate($im, 255, 0, 0);
for ($i=0;i<=120;$i=$i+1){
for ($j=0;$j<=20;$j=$j+1){
imagesetpixel($im, $i,$j,$red);
}
}
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>
Run Code Online (Sandbox Code Playgroud) 在ZF2表单中是否有任何方法可以防止多个表单提交?我已经测试Captcha,并CSRF与元素isValid()的功能,但他们不`吨防止多次提交特别是那些有浏览器的刷新按钮.提前致谢
我正在尝试使用最新版本的recaptcha,在视图上,我的验证码看起来像: 
我希望它看起来像https://developers.google.com/recaptcha,这是一张图片:

以我的形式,我有:
= form_for [refinery, :inquiries, @inquiry], html: { id: "contact-form" } do |f|
= recaptcha_tags display: { display: 'red'}
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何实现这一目标gem "recaptcha",https://github.com/ambethia/recaptcha
先感谢您.