public function addReCaptcha($form) { $config = Zend_Registry::get("config"); $publickey = $config->recaptcha->public->key; $privatekey = $config->recaptcha->private->key; $recaptcha = new Zend_Service_ReCaptcha($publickey, $privatekey); //Translate in your language $recaptcha_cn_translation = array('visual_challenge' => "图片验证", 'audio_challenge' => "音频验证", 'refresh_btn' => "看不清,换一张", 'instructions_visual' => "图片验证说明", 'instructions_audio' => "音频验证说明", 'help_btn' => "帮助", 'play_again' => "重放", 'cant_hear_this' => "听不到? 点这里", 'incorrect_try_again' => "验证码错误!"); $recaptcha->setOption('custom_translations', $recaptcha_cn_translation); //Change theme $recaptcha->setOption('theme', 'clean'); $captcha = new Zend_Form_Element_Captcha('challenge', array('captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha), 'ignore' => false)); $captcha->setRequired(true); $form->addElement($captcha); }
/** * Construtor da classe * * @see Twitter_Bootstrap_Form_Vertical * @return Auth_form_login_FormLogin|void */ public function init() { $oTradutor = $this->getTranslator(); $oBaseUrlHelper = new Zend_View_Helper_BaseUrl(); $this->setName('form_login')->setAction($oBaseUrlHelper->baseUrl('/auth/login/post')); $oElm = $this->createElement('text', 'login'); $oElm->setLabel('Login'); $oElm->setAttrib('class', 'span3'); $oElm->setAttrib('autofocus', 'autofocus'); $oElm->setRequired(TRUE); $this->addElement($oElm); $oElm = $this->createElement('password', 'senha'); $oElm->setLabel('Senha'); $oElm->setAttrib('class', 'span3'); $oElm->setRequired(TRUE); $this->addElement($oElm); $iTotalErros = 0; if ($oSessao = new Zend_Session_Namespace('captcha')) { $iTotalErros = $oSessao->errors; } if ($iTotalErros > 0) { $oKeysRecaptcha = Zend_Registry::get('config')->recaptcha; if (!empty($oKeysRecaptcha->publicKey) && !empty($oKeysRecaptcha->privateKey)) { $oRecaptcha = new Zend_Service_ReCaptcha($oKeysRecaptcha->publicKey, $oKeysRecaptcha->privateKey); $oRecaptcha->setOption('theme', 'clean'); $oCaptcha = new Zend_Form_Element_Captcha('challenge', array('captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $oRecaptcha))); $oCaptcha->setLabel('Informe as palavras abaixo:'); $this->addElement($oCaptcha); } else { $oSessao->errors = 0; } } $this->addElement('submit', 'submit', array('label' => 'Entrar', 'class' => 'pull-right', 'data-loading-text' => $oTradutor->_('Aguarde...'), 'buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_PRIMARY)); return $this; }
public function init() { $this->setMethod('post'); //Add your elements here... $config = Zend_Registry::get("config"); $publickey = $config->recaptcha->public->key; $privatekey = $config->recaptcha->private->key; $recaptcha = new Zend_Service_ReCaptcha($publickey, $privatekey); //Translate in your language $recaptcha_it_translation = array('visual_challenge' => "Verifica video", 'audio_challenge' => "Verifica audio", 'refresh_btn' => "Effettua una nuova verifica", 'instructions_visual' => "Scrivi le due parole", 'instructions_audio' => "Scrivi quello che ascolti", 'help_btn' => "Aiuto", 'play_again' => "Riascolto di nuovo l'audio", 'cant_hear_this' => "Scarica l'audio come MP3", 'incorrect_try_again' => "Incorretto. Prova ancora."); $recaptcha->setOption('custom_translations', $recaptcha_it_translation); //Change theme $recaptcha->setOption('theme', 'clean'); $captcha = new Zend_Form_Element_Captcha('challenge', array('captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha), 'ignore' => true)); $this->addElement($captcha); // Add the submit button $this->addElement('submit', 'submit', array('label' => 'Submit')); }
public static function captchaElement() { $registry = Zend_Registry::getInstance(); $config = $registry->get("config"); $keys = $config['services']['recaptcha']['keys']; $recaptcha = new Zend_Service_ReCaptcha($keys['public'], $keys['private'], array("ssl" => true, "xhtml" => true)); $recaptcha->setOption('theme', 'clean'); $captcha = new Zend_Form_Element_Captcha('challenge', array('label' => 'Type the challenge below', 'captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha))); return $captcha; }