设置ReCaptcha垃圾邮件验证后,我收到以下错误消息。 ReCaptcha正常工作我只关心错误。
使用Silverstripe版本2.4.5 模块: - spamprotection - recaptcha
Error: RecatpchaField::validate(): Recaptcha-service error: 'invalid-request-cookie'
At line 285 in /var/www/example/public/recaptcha/code/RecaptchaField.php
RecatpchaField::validate(): Recaptcha-service error: 'invalid-request-cookie'
Line 285 of RecaptchaField.php
RecaptchaField->validate(RequiredFields)
Line 98 of RequiredFields.php
RequiredFields->php(Array)
Line 106 of Validator.php
Validator->validate()
Line 888 of Form.php
Form->validate()
Line 293 of Form.php
Form->httpSubmission(SS_HTTPRequest)
Line 143 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
Line 161 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
Line 147 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
Line 199 of ContentController.php
ContentController->handleRequest(SS_HTTPRequest)
Line 67 of ModelAsController.php
ModelAsController->handleRequest(SS_HTTPRequest)
Line 282 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
Line 125 of Director.php
Director::direct(/contact-us/ContactForm)
Line 127 of main.php
ContactPage.php
<?php
class ContactPage extends Page {
static $db = array(
'Mailto' => 'Varchar(100)',
'SubmitText' => 'Text',
'GoogleMapsAPI' => 'Varchar(255)'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main", "Graphic");
$fields->addFieldToTab("Root.Content.Contact", new TextField('Mailto', 'Email address to recieve the contact message'));
$fields->addFieldToTab("Root.Content.Contact", new TextareaField('SubmitText', 'Text to display sucsesfully sending a message'));
$fields->addFieldToTab("Root.Content.Contact", new TextareaField('GoogleMapsAPI', 'Google Maps API Key'));
return $fields;
}
static $icon = "cms/images/treeicons/sent";
}
class ContactPage_Controller extends Page_Controller {
function ContactForm() {
// Create fields
$fields = new FieldSet(
new TextField('Name', 'Name<sup></sup>'),
new EmailField('Email', 'Email<sup></sup>'),
new TextField('Website', 'Website (if you have one already)'),
new TextField('Telephone', 'Telephone'),
new TextareaField('Message','Message<sup></sup>'),
new OptionsetField('SendMeEmail', 'Send a copy to your email also', array('Yes'=>'Yes','No'=>'No'))
);
// Create action
$actions = new FieldSet(
new FormAction('SendContactForm', ' ')
);
// Create Validators
$validator = new RequiredFields('Name', 'Email', 'Message');
$form = new Form($this, 'ContactForm', $fields, $actions, $validator);
SpamProtectorManager::update_form($form, 'SendMeEmail');
return $form;
}
function SendContactForm($data) {
$From = $data['Email'];
$To = $this->Mailto;
$Subject = "Contact Message";
$email = new Email($From, $To, $Subject);
$email->setTemplate('ContactAdminEmail');
$email->populateTemplate($data);
$email->send();
if($data['SendMeEmail'] == 'Yes'){
$email_client = new Email($To, $From, $Subject);
$email_client->setTemplate('ContactClientEmail');
$email_client->populateTemplate($data);
$email_client->send();
}
//return to submitted message
Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
}
}
答案 0 :(得分:2)
如何重现:
因此,对于没有正确阅读指定说明的禁用JavaScript的用户来说,这是一个问题。
您可能还想查看https://groups.google.com/group/recaptcha/browse_thread/thread/f881b776f3192703了解更多详情。
虽然它在我的手机上工作正常,但如果这在某些移动设备上不起作用,那就非常讨厌了。填写第一个框只是为了将相当长的字符串复制到第二个字段,这在繁琐到不可能之间,取决于设备。
答案 1 :(得分:0)
已修复https://github.com/chillu/silverstripe-recaptcha/commit/59034ab - 我怀疑这些错误是由垃圾邮件机器人而非用户造成的。