public function postAction() { if (!(Mage::getStoreConfig("fontis_recaptcha/recaptcha/when_loggedin") && Mage::getSingleton('customer/session')->isLoggedIn())) { if (Mage::getStoreConfig("fontis_recaptcha/recaptcha/contacts")) { $privatekey = Mage::getStoreConfig("fontis_recaptcha/setup/private_key"); // check response $resp = Mage::helper("fontis_recaptcha")->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp == true) { // if recaptcha response is correct, use core functionality parent::postAction(); } else { // if recaptcha response is incorrect, reload the page Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Your reCAPTCHA entry is incorrect. Please try again.')); $_SESSION['contact_comment'] = $_POST['comment']; $_SESSION['contact_name'] = $_POST['name']; $_SESSION['contact_email'] = $_POST['email']; $_SESSION['contact_telephone'] = $_POST['telephone']; $this->_redirect('contacts/'); return; } } else { // if recaptcha is not enabled, use core function alone parent::postAction(); } } else { // if recaptcha is not enabled, use core function alone parent::postAction(); } }
public function postAction() { if (!(Mage::getStoreConfig("OutsourceOnline_Captcha/captcha/when_loggedin") && Mage::getSingleton('customer/session')->isLoggedIn())) { if (Mage::getStoreConfig("OutsourceOnline_Captcha/captcha/contacts")) { //echo "<pre>";print_r($_POST);echo "</pre>"; // check response $resp = Mage::helper("outsourceonline_captcha")->validate(); //validate botscout Mage::helper("outsourceonline_captcha")->validateBotScout(Mage::getSingleton('core/app')->getRequest()->getParam('email')); if ($resp == true) { // if captcha response is correct, use core functionality parent::postAction(); } else { // if captcha response is incorrect, reload the page Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Your CAPTCHA entry is incorrect. Please try again.')); $_SESSION['contact_comment'] = $_POST['comment']; $_SESSION['contact_name'] = $_POST['name']; $_SESSION['contact_email'] = $_POST['email']; $_SESSION['contact_telephone'] = $_POST['telephone']; $this->_redirect('contacts/'); return; } } else { // if captcha is not enabled, use core function alone parent::postAction(); } } else { // if captcha is not enabled, use core function alone parent::postAction(); } }
public function postAction() { $post = $this->getRequest()->getPost(); if ($post) { $aMessage = array(); $aMessage['type'] = 'comment'; $aMessage['sender_email'] = isset($post['email']) ? $post['email'] : ''; $aMessage['sender_nickname'] = isset($post['name']) ? $post['name'] : ''; $aMessage['message_title'] = isset($post['telephone']) ? $post['telephone'] : ''; $aMessage['message_body'] = isset($post['comment']) ? $post['comment'] : ''; $aMessage['example_title'] = ''; $aMessage['example_body'] = ''; $aMessage['example_comments'] = ''; $model = Mage::getModel('antispam/api'); $aResult = $model->CheckSpam($aMessage, FALSE); if (isset($aResult) && is_array($aResult)) { if ($aResult['errno'] == 0) { if ($aResult['allow'] == 0) { if (preg_match('//u', $aResult['ct_result_comment'])) { $comment_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']); $comment_str = preg_replace('/<[^<>]*>/iu', '', $comment_str); } else { $comment_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']); $comment_str = preg_replace('/<[^<>]*>/i', '', $comment_str); } Mage::getSingleton('customer/session')->addError($comment_str); $this->_redirect('*/*/'); return; } } } } parent::postAction(); }
public function postAction() { $post = $this->getRequest()->getPost(); if ($post) { if (Zend_Validate::is(trim($post['first_name']), 'NotEmpty')) { Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later')); $this->_redirect('*/*/'); return; } } parent::postAction(); }
/** * Handle post request of Contact form * @return [type] [description] */ public function postAction() { if (Mage::getStoreConfigFlag(self::XML_PATH_CFC_ENABLED)) { try { $post = $this->getRequest()->getPost(); $formData = new Varien_Object(); $formData->setData($post); Mage::getSingleton('core/session')->setData('contactForm', $formData); if ($post) { //include reCaptcha library require_once Mage::getBaseDir('lib') . DS . 'reCaptcha' . DS . 'recaptchalib.php'; //validate captcha $privatekey = Mage::getStoreConfig(self::XML_PATH_CFC_PRIVATE_KEY); $remote_addr = $this->getRequest()->getServer('REMOTE_ADDR'); $captcha = recaptcha_check_answer($privatekey, $remote_addr, $post["recaptcha_challenge_field"], $post["recaptcha_response_field"]); if (!$captcha->is_valid) { throw new Exception($this->__("The reCAPTCHA wasn't entered correctly. Go back and try it again."), 1); } Mage::getSingleton('core/session')->unsetData('contactForm'); } else { throw new Exception('', 1); } } catch (Exception $e) { if (strlen($e->getMessage()) > 0) { Mage::getSingleton('customer/session')->addError($this->__($e->getMessage())); } $this->_redirect('*/*/'); return; } } //everything is OK - call parent action parent::postAction(); }