public function createPostAction()
 {
     $post = $this->getRequest()->getPost();
     if ($post) {
         $aUser = array();
         $aUser['type'] = 'register';
         $aUser['sender_email'] = isset($post['email']) ? $post['email'] : '';
         $aUser['sender_nickname'] = isset($post['firstname']) ? $post['firstname'] : '';
         $aUser['sender_nickname'] .= isset($post['lastname']) ? ' ' . $post['lastname'] : '';
         $model = Mage::getModel('antispam/api');
         $aResult = $model->CheckSpam($aUser, 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('*/*/');
                     $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
                     return;
                 }
             }
         }
     }
     parent::createPostAction();
 }
 /**
  * Supress account registration action if disabled
  * 
  * @see Mage_Customer_AccountController::createPostAction
  */
 public function createPostAction()
 {
     if (!Mage::helper('privatesales')->canShowRegistration()) {
         $this->_getSession()->addError(Mage::helper('privatesales')->getRegistrationErrorMessage());
         $this->_redirect('*/*');
         return;
     }
     return parent::createPostAction();
 }
 public function createPostAction()
 {
     $alreadyLoggedin = false;
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $alreadyLoggedin = true;
     }
     parent::createPostAction();
     if ($session->isLoggedIn() && !$alreadyLoggedin) {
         $product_id = $this->getRequest()->getParam('productalert_product');
         if ($product_id != 'hello') {
             $this->stockAction($product_id, '/accessories', true);
         }
     }
 }
 public function createPostAction()
 {
     if (Mage::getStoreConfig("fontis_recaptcha/recaptcha/customer")) {
         // check that recaptcha is actually enabled
         $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::createPostAction();
         } else {
             $this->_getSession()->addError($this->__('Your reCAPTCHA entry is incorrect. Please try again.'));
             $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
             $this->_redirectReferer();
             return;
         }
     } else {
         // if recaptcha is not enabled, use core function
         parent::createPostAction();
     }
 }
 public function createPostAction()
 {
     if (Mage::getStoreConfig("OutsourceOnline_Captcha/captcha/customer")) {
         // check that captcha is actually enabled
         $privatekey = Mage::getStoreConfig("OutsourceOnline_Captcha/setup/private_key");
         // 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::createPostAction();
         } else {
             $this->_getSession()->addError($this->__('Your CAPTCHA entry is incorrect. Please try again.'));
             $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
             $this->_redirectReferer();
             return;
         }
     } else {
         // if captcha is not enabled, use core function
         parent::createPostAction();
     }
 }
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $this->_redirect('*/*/');
         return;
     }
     $isMarketplaceEnabled = Mage::Helper("marketplace")->isMarketplaceEnabled();
     if ($isMarketplaceEnabled == false) {
         return parent::createPostAction();
     }
     $session->setEscapeMessages(true);
     // prevent XSS injection in user input
     if (!$this->getRequest()->isPost()) {
         $errUrl = $this->_getUrl('*/*/create', array('_secure' => true));
         $this->_redirectError($errUrl);
         return;
     }
     $customer = $this->_getCustomer();
     try {
         $errors = $this->_getCustomerErrors($customer);
         if ($this->getRequest()->getParam('check_seller_form')) {
             $customer->setCompanyLocality($this->getRequest()->getPost('company_locality'));
             $customer->setCompanyName($this->getRequest()->getPost('company_name'));
             $customerErrors = Mage::getModel('marketplace/customer')->customValidate($customer);
         }
         if (is_array($customerErrors)) {
             $errors = array_merge($customerErrors, $errors);
         }
         if (empty($errors)) {
             $customer->cleanPasswordsValidationData();
             // saving seller information
             if ($this->getRequest()->getParam('check_seller_form')) {
                 $customerId = $customer->getEntityId();
                 /******************** company banner upload code ******************************** */
                 if (isset($_FILES['company_banner']['name']) && $_FILES['company_banner']['name'] != '') {
                     $fileName = $_FILES['company_banner']['name'];
                     $fieldName = 'company_banner';
                     $companyBanner = $this->_uploadImage($fileName, $fieldName, $customerId);
                     $customer->setCompanyBanner($companyBanner);
                 }
                 /******************* end of company banner code ******************************** */
                 /******************** company logo upload code ******************************** */
                 if (isset($_FILES['company_logo']['name']) && $_FILES['company_logo']['name'] != '') {
                     $fileName = $_FILES['company_logo']['name'];
                     $fieldName = 'company_logo';
                     $companyLogo = $this->_uploadImage($fileName, $fieldName, $customerId);
                     $customer->setCompanyLogo($companyLogo);
                 }
                 /******************* end of company logo code ******************************** */
                 $customer->setCompanyLocality($this->getRequest()->getPost('company_locality'));
                 $customer->setCompanyName($this->getRequest()->getPost('company_name'));
                 $customer->setCompanyDescription($this->getRequest()->getPost('company_description'));
                 $customer->setSellerSubscriber(1);
                 // Auto approval of seller check
                 if (Mage::getStoreConfig('marketplace/marketplace/auto_approval_seller')) {
                     $customer->setStatus(Mage::getStoreConfig('marketplace/status/approved'));
                 } else {
                     $customer->setStatus(Mage::getStoreConfig('marketplace/status/pending'));
                 }
             } else {
                 $customer->setSellerSubscriber(0);
             }
             $customer->save();
             $this->_dispatchRegisterSuccess($customer);
             $this->_successProcessRegistration($customer);
             return;
         } else {
             $this->_addSessionError($errors);
         }
     } catch (Mage_Core_Exception $e) {
         $session->setCustomerFormData($this->getRequest()->getPost());
         if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
             $url = $this->_getUrl('customer/account/forgotpassword');
             $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
             $session->setEscapeMessages(false);
         } else {
             $message = $e->getMessage();
         }
         $session->addError($message);
     } catch (Exception $e) {
         $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
     }
     $errUrl = $this->_getUrl('*/*/create', array('_secure' => true));
     $this->_redirectError($errUrl);
 }
示例#7
0
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     $session = $this->_getSession();
     if ($session->isLoggedIn()) {
         $this->_redirect('*/*/');
         return;
     }
     $isMarketplaceEnabled = Mage::Helper("marketplace")->isMarketplaceEnabled();
     if ($isMarketplaceEnabled == false) {
         return parent::createPostAction();
     }
     $session->setEscapeMessages(true);
     // prevent XSS injection in user input
     if ($this->getRequest()->isPost()) {
         $errors = array();
         if (!($customer = Mage::registry('current_customer'))) {
             $customer = Mage::getModel('customer/customer')->setId(null);
         }
         /* @var $customerForm Mage_Customer_Model_Form */
         $customerForm = Mage::getModel('customer/form');
         $customerForm->setFormCode('customer_account_create')->setEntity($customer);
         $customerData = $customerForm->extractData($this->getRequest());
         if ($this->getRequest()->getParam('is_subscribed', false)) {
             $customer->setIsSubscribed(1);
         }
         /**
          * Initialize customer group id
          */
         //$customer->getGroupId();
         if ($this->getRequest()->getPost('group_id')) {
             $customer->setGroupId($this->getRequest()->getPost('group_id'));
         } else {
             $customer->getGroupId();
         }
         if ($this->getRequest()->getPost('create_address')) {
             /* @var $address Mage_Customer_Model_Address */
             $address = Mage::getModel('customer/address');
             /* @var $addressForm Mage_Customer_Model_Form */
             $addressForm = Mage::getModel('customer/form');
             $addressForm->setFormCode('customer_register_address')->setEntity($address);
             $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
             $addressErrors = $addressForm->validateData($addressData);
             if ($addressErrors === true) {
                 $address->setId(null)->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
                 $addressForm->compactData($addressData);
                 $customer->addAddress($address);
                 $addressErrors = $address->validate();
                 if (is_array($addressErrors)) {
                     $errors = array_merge($errors, $addressErrors);
                 }
             } else {
                 $errors = array_merge($errors, $addressErrors);
             }
         }
         try {
             $customerErrors = $customerForm->validateData($customerData);
             if ($customerErrors !== true) {
                 $errors = array_merge($customerErrors, $errors);
             } else {
                 $customerForm->compactData($customerData);
                 $customer->setPassword($this->getRequest()->getPost('password'));
                 $customer->setPasswordConfirmation($this->getRequest()->getPost('confirmation'));
                 //var_dump($customer->getData());die;
                 if ($this->getRequest()->getParam('check_seller_form')) {
                     $validationFlag = 1;
                 } else {
                     $validationFlag = 0;
                 }
                 $validationFlag = 1;
                 if ($validationFlag == 1) {
                     $customer->setData($this->getRequest()->getPost());
                     $customerErrors = Mage::getModel('marketplace/customer')->customValidate($customer);
                 }
                 $customerErrors = $customer->validate();
                 if (is_array($customerErrors)) {
                     $errors = array_merge($customerErrors, $errors);
                 }
             }
             $validationResult = count($errors) == 0;
             if (true === $validationResult) {
                 $customer->save();
                 Mage::dispatchEvent('customer_register_success', array('account_controller' => $this, 'customer' => $customer));
                 $validationFlag = 0;
                 // saving seller information
                 if ($this->getRequest()->getParam('check_seller_form')) {
                     $customerId = $customer->getEntityId();
                     /******************** company banner upload code ******************************** */
                     if (isset($_FILES['company_banner']['name']) && $_FILES['company_banner']['name'] != '') {
                         $fileName = $_FILES['company_banner']['name'];
                         $fieldName = 'company_banner';
                         $companyBanner = $this->_uploadImage($fileName, $fieldName, $customerId);
                         $customer->setCompanyBanner($companyBanner);
                     }
                     /******************* end of company banner code ******************************** */
                     /******************** company logo upload code ******************************** */
                     if (isset($_FILES['company_logo']['name']) && $_FILES['company_logo']['name'] != '') {
                         $fileName = $_FILES['company_logo']['name'];
                         $fieldName = 'company_logo';
                         $companyLogo = $this->_uploadImage($fileName, $fieldName, $customerId);
                         $customer->setCompanyLogo($companyLogo);
                     }
                     /******************* end of company logo code ******************************** */
                     $customer->setCompanyLocality($this->getRequest()->getPost('company_locality'));
                     $customer->setCompanyName($this->getRequest()->getPost('company_name'));
                     $customer->setCompanyDescription($this->getRequest()->getPost('company_description'));
                     $customer->setSellerSubscriber(1);
                     // Auto approval of seller check
                     if (Mage::getStoreConfig('marketplace/marketplace/auto_approval_seller')) {
                         $customer->setStatus(Mage::getStoreConfig('marketplace/status/approved'));
                     } else {
                         $customer->setStatus(Mage::getStoreConfig('marketplace/status/pending'));
                     }
                     $validationFlag = 1;
                 } else {
                     $customer->setSellerSubscriber(0);
                 }
                 if ($customer->isConfirmationRequired()) {
                     Mage::getModel('marketplace/customer')->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl(), Mage::app()->getStore()->getId());
                     $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
                     $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
                     return;
                 } else {
                     $session->setCustomerAsLoggedIn($customer);
                     $url = $this->_welcomeCustomer($customer);
                     $this->_redirectSuccess($url);
                     return;
                 }
             } else {
                 $session->setCustomerFormData($this->getRequest()->getPost());
                 if (is_array($errors)) {
                     foreach ($errors as $errorMessage) {
                         $session->addError($errorMessage);
                     }
                 } else {
                     $session->addError($this->__('Invalid customer data'));
                 }
             }
         } catch (Mage_Core_Exception $e) {
             $session->setCustomerFormData($this->getRequest()->getPost());
             if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                 $url = Mage::getUrl('customer/account/forgotpassword');
                 $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                 $session->setEscapeMessages(false);
             } else {
                 $message = $e->getMessage();
             }
             $session->addError($message);
         } catch (Exception $e) {
             $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
         }
     }
     $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
 }
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     try {
         $invitation = $this->_initInvitation();
         $customer = Mage::getModel('customer/customer')->setId(null)->setSkipConfirmationIfEmail($invitation->getEmail());
         Mage::register('current_customer', $customer);
         if ($groupId = $invitation->getGroupId()) {
             $customer->setGroupId($groupId);
         }
         parent::createPostAction();
         if ($customerId = $customer->getId()) {
             $invitation->accept(Mage::app()->getWebsite()->getId(), $customerId);
             Mage::dispatchEvent('enterprise_invitation_customer_accepted', array('customer' => $customer, 'invitation' => $invitation));
         }
         return;
     } catch (Mage_Core_Exception $e) {
         $_definedErrorCodes = array(Enterprise_Invitation_Model_Invitation::ERROR_CUSTOMER_EXISTS, Enterprise_Invitation_Model_Invitation::ERROR_INVALID_DATA);
         if (in_array($e->getCode(), $_definedErrorCodes)) {
             $this->_getSession()->addError($e->getMessage())->setCustomerFormData($this->getRequest()->getPost());
         } else {
             if (Mage::helper('customer')->isRegistrationAllowed()) {
                 $this->_getSession()->addError(Mage::helper('enterprise_invitation')->__('Your invitation is not valid. Please create an account.'));
                 $this->_redirect('customer/account/create');
                 return;
             } else {
                 $this->_getSession()->addError(Mage::helper('enterprise_invitation')->__('Your invitation is not valid. Please contact us at %s.', Mage::getStoreConfig('trans_email/ident_support/email')));
                 $this->_redirect('customer/account/login');
                 return;
             }
         }
     } catch (Exception $e) {
         $this->_getSession()->setCustomerFormData($this->getRequest()->getPost())->addException($e, Mage::helper('customer')->__('Unable to save the customer.'));
     }
     $this->_redirectError('');
     return $this;
 }
	public function createPostAction() {
		$session = $this->_getSession();
		parent::createPostAction();

		$messages = $session->getMessages();
		$isError = false;

		foreach ($messages->getItems() as $message) {
			if ($message->getType() == 'error') {
				$isError = true;
			}
		}

		if ($isError) {
			$email = $this->getRequest()->getPost('email');
			$firstname = $this->getRequest()->getPost('firstname');
			$lastname = $this->getRequest()->getPost('lastname');
			Mage::getSingleton('engage/session')
				->setEmail($email)
				->setFirstname($firstname)
				->setLastname($lastname);
			$this->_redirect('engage/rpx/duplicate');
		}

		return;
	}
示例#10
0
 /**
  * Create customer account action
  */
 public function createPostAction()
 {
     if (Mage::getStoreConfig('fastregistration/general/enabled')) {
         $session = $this->_getSession();
         if ($session->isLoggedIn()) {
             $this->_redirect('*/*/');
             return;
         }
         $session->setEscapeMessages(true);
         // prevent XSS injection in user input
         if ($this->getRequest()->isPost()) {
             $errors = array();
             if (!($customer = Mage::registry('current_customer'))) {
                 $customer = Mage::getModel('customer/customer')->setId(null);
             }
             /* @var $customerForm Mage_Customer_Model_Form */
             $customerForm = Mage::getModel('customer/form');
             $customerForm->setFormCode('customer_account_create')->setEntity($customer);
             $customerData = $customerForm->extractData($this->getRequest());
             /**
              * Initialize customer group id
              */
             $customer->getGroupId();
             $password = $this->getRequest()->getPost('password');
             if (!Mage::getStoreConfig('fastregistration/general/show_password')) {
                 $password = Mage::helper('core')->getRandomString(8, Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS . Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS . Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS . Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS);
             }
             try {
                 $customerErrors = $customerForm->validateData($customerData);
                 if ($customerErrors !== true) {
                     $errors = array_merge($customerErrors, $errors);
                 } else {
                     $customerForm->compactData($customerData);
                     $customer->setPassword($password);
                     $customer->setConfirmation($password);
                 }
                 $validationResult = count($errors) == 0;
                 if (true === $validationResult) {
                     $customer->save();
                     Mage::dispatchEvent('customer_register_success', array('account_controller' => $this, 'customer' => $customer));
                     if ($customer->isConfirmationRequired()) {
                         $customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl(), Mage::app()->getStore()->getId());
                         $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
                         $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
                         return;
                     } else {
                         $session->setCustomerAsLoggedIn($customer);
                         $url = $this->_welcomeCustomer($customer);
                         $this->_redirectSuccess($url);
                         return;
                     }
                 } else {
                     $session->setCustomerFormData($this->getRequest()->getPost());
                     if (is_array($errors)) {
                         foreach ($errors as $errorMessage) {
                             $session->addError($errorMessage);
                         }
                     } else {
                         $session->addError($this->__('Invalid customer data'));
                     }
                 }
             } catch (Mage_Core_Exception $e) {
                 $session->setCustomerFormData($this->getRequest()->getPost());
                 if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                     $url = Mage::getUrl('customer/account/forgotpassword');
                     $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                     $session->setEscapeMessages(false);
                 } else {
                     $message = $e->getMessage();
                 }
                 $session->addError($message);
             } catch (Exception $e) {
                 $session->setCustomerFormData($this->getRequest()->getPost())->addException($e, $this->__('Cannot save the customer.'));
             }
         }
         $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
     } else {
         parent::createPostAction();
     }
 }