function getRecaptchaField()
 {
     $field = null;
     $spamProtector = SpamProtectorManager::get_spam_protector();
     if ($spamProtector == "RecaptchaProtector") {
         $field = new RecaptchaField("Recaptcha", "Please enter text");
         $field->jsOptions = array('theme' => 'clean');
         $field->addExtraClass("required");
     }
     return $field;
 }
 function testValidate()
 {
     $form = new Form(new Controller(), 'Form', new FieldList(), new FieldList());
     $f = new RecaptchaField('MyField');
     $f->setHTTPClient(new RecaptchaFieldTest_HTTPClient());
     $f->setForm($form);
     $v = new RequiredFields();
     $_REQUEST['recaptcha_challenge_field'] = 'valid';
     $_REQUEST['recaptcha_response_field'] = 'response';
     $this->assertTrue($f->validate($v));
     $_REQUEST['recaptcha_challenge_field'] = 'invalid';
     $_REQUEST['recaptcha_response_field'] = 'response';
     $this->assertFalse($f->validate($v));
     unset($_REQUEST['recaptcha_challenge_field']);
     unset($_REQUEST['recaptcha_response_field']);
 }
Beispiel #3
0
 public function ContestEntryForm()
 {
     $validator = RequiredFields::create('Name', 'Email', 'Title', 'myCaptcha');
     $recaptchaField = RecaptchaField::create('myCaptcha', 'Are You a Robot?');
     $recaptchaField->jsOptions = array('theme' => 'clean');
     // optional
     // Create fields
     $fields = new FieldList(Textfield::create('Name'), Textfield::create('Email'), Textfield::create('Title'), HTMLEditorField::create('Content'), $recaptchaField);
     // Create actions
     $actions = new FieldList(FormAction::create('doContestEnter', 'Submit')->addExtraClass('btn btn-secondary'));
     return Form::create($this, 'ContestEntryForm', $fields, $actions);
 }
 function Form()
 {
     $form = new Form($this, 'Form', new FieldList($f = new RecaptchaField('MyRecaptchaField')), new FieldList(new FormAction('doSubmit', 'submit')));
     $f->setHTTPClient(new RecaptchaFieldTest_HTTPClient());
     return $form;
 }
Beispiel #5
0
<?php

global $project;
$project = 'mysite';
global $databaseConfig;
$databaseConfig = array('type' => 'MySQLDatabase', 'server' => 'localhost', 'username' => 'root', 'password' => 'root', 'database' => 'mystica_smx', 'path' => '');
RecaptchaField::$public_api_key = '6Lc3GhoTAAAAAK_ZYEepykSDFC7Y2lVm1-Bv52DU';
RecaptchaField::$private_api_key = '6Lc3GhoTAAAAAGQ2kZP77_CVWZjD1etdMufEszIE';
// If using on a site requiring a proxy server for outgoing traffic then you can set these additional
// options in your `mysite/_config.php`.
// RecaptchaField::$proxy_server = "<proxy address>";
// RecaptchaField::$proxy_auth = "<proxy_username>:<proxy_password>";
// Set the site locale
i18n::set_locale('en_US');
Beispiel #6
0
<?php

global $project;
$project = 'mysite';
global $databaseConfig;
$databaseConfig = array("type" => 'MySQLDatabase', "server" => 'localhost', "username" => '', "password" => '', "database" => '', "path" => '');
MySQLDatabase::set_connection_charset('utf8');
// This line set's the current theme. More themes can be
// downloaded from http://www.silverstripe.org/themes/
SSViewer::set_theme('comperio');
// Set the site locale
i18n::set_locale('it_IT');
// enable nested URLs for this site (e.g. page/sub-page/)
SiteTree::enable_nested_urls();
//Enable site search
FulltextSearchable::enable();
// Logging
SS_Log::add_writer(new SS_LogFileWriter(__DIR__ . '/../logs/silverstripe.log'), SS_Log::NOTICE, '<=');
HtmlEditorConfig::get('cms')->setOption('valid_elements', '*[*]');
HtmlEditorConfig::get('cms')->setOption('extended_valid_elements', str_replace('img[', 'img[style|', HtmlEditorConfig::get('cms')->getOption('extended_valid_elements')));
// Recaptcha api keys
RecaptchaField::$public_api_key = '';
RecaptchaField::$private_api_key = '';
//Integrate with spam protector
SpamProtectorManager::set_spam_protector("RecaptchaProtector");
//Add featured image to blog entry
DataObject::add_extension('BlogEntry', 'BlogEntryDecorator');