Example #1
0
 /**
  * Return link for current sro
  * @return string
  */
 public function GenerateLink()
 {
     if (empty($this->linkid)) {
         $this->linkid = _xls_seo_url(_xls_truncate(_xls_encrypt(md5(date("YmdHis"))), 31, ''));
         $this->save();
         return $this->linkid;
     } else {
         return $this->linkid;
     }
 }
 /**
  * Short Description.
  *
  * @return void
  */
 public function actionEdit()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     $model = Configuration::model()->findAllByAttributes(array('configuration_type_id' => $id), array('order' => 'sort_order'));
     if ($this->IsCloud) {
         $model = $this->sanitizeEditModule($model, 'Cloud');
     }
     if ($this->IsMT) {
         $model = $this->sanitizeEditModule($model, 'MT');
     }
     if ($this->isHosted) {
         $model = $this->sanitizeEditModule($model, 'Hosted');
     }
     if (isset($_POST['Configuration'])) {
         $valid = true;
         foreach ($model as $i => $item) {
             if (isset($_POST['Configuration'][$i])) {
                 $item->attributes = $_POST['Configuration'][$i];
             }
             if ($item->key_name == 'LANG_MENU' && $item->key_value == 1) {
                 $itemLanguages = $model[2];
                 $itemLanguages->attributes = $_POST['Configuration'][2];
                 if (empty($itemLanguages->key_value)) {
                     $valid = false;
                 }
             }
             if ($item->options == "INT") {
                 if ((int) $item->key_value) {
                     $valid = true;
                 } else {
                     $valid = false;
                 }
             }
             if ($item->options == "EMAIL") {
                 $valid = $this->validateEmail($item) && $valid;
             } else {
                 $valid = $item->validate() && $valid;
             }
             if (!$valid) {
                 if ($item->options == 'EMAIL') {
                     Yii::app()->user->setFlash('error', $item->title . ' is not a valid email address');
                 } elseif ($item->key_name == 'LANG_MENU') {
                     Yii::app()->user->setFlash('error', 'Languages field cannot be empty when language menu is enabled');
                 } elseif ($item->options == "INT") {
                     Yii::app()->user->setFlash('error', $item->title . ': ' . 'Only numbers are allowed', true);
                 } else {
                     $err = $item->getErrors();
                     Yii::app()->user->setFlash('error', $item->title . ' -- ' . print_r($err['key_value'][0], true));
                 }
                 break;
             }
         }
         if ($valid) {
             foreach ($model as $i => $item) {
                 $item->attributes = $_POST['Configuration'][$i];
                 if ($item->options == "PASSWORD") {
                     $item->key_value = _xls_encrypt($item->key_value);
                 }
                 if ($item->save() === false) {
                     Yii::app()->user->setFlash('error', print_r($item->getErrors(), true));
                 } else {
                     Yii::app()->user->setFlash('success', Yii::t('admin', 'Configuration updated on {time}.', array('{time}' => date('d F, Y  h:i:sa'))));
                     $item->postConfigurationChange();
                 }
                 if ($item->key_name == 'EMAIL_TEST' && $item->key_value == 1) {
                     $this->sendEmailTest();
                 }
             }
         }
     }
     foreach ($model as $i => $item) {
         if ($item->options == 'BOOL') {
             $this->registerOnOff($item->id, "Configuration_{$i}_key_value", $item->key_value);
         }
         if ($item->options == 'PASSWORD') {
             $model[$i]->key_value = _xls_decrypt($model[$i]->key_value);
         }
         $model[$i]->title = Yii::t('admin', $item->title, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
         $model[$i]->helper_text = Yii::t('admin', $item->helper_text, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
     }
     /*
      * http://www.yiiframework.com/doc/api/1.1/CModel#generateAttributeLabel-detail
      *
      * Unless we define the label attribute in activeLabelEx htmlOptions in the view,
      * the label will be generated when it calls CModel::generateAttributeLabel().
      * This is a problem for the labels we want to display on pages like the Google Integration
      * page that have labels which deliberately require dashes and camel-case formatting.
      */
     $defineLabel = false;
     switch (CPropertyValue::ensureInteger($id)) {
         case 20:
             // IntegrationController::GOOGLE = 20
             $defineLabel = true;
             break;
         default:
             break;
     }
     $this->render('admin.views.default.edit', array('model' => $model, 'defineLabel' => $defineLabel));
 }
Example #3
0
 public function savePage($page)
 {
     switch ($page) {
         case 2:
             if (!_xls_get_conf('LIGHTSPEED_CLOUD', 0) > 0) {
                 _xls_set_conf('LSKEY', strtolower(md5($this->LSKEY)));
             }
             _xls_set_conf('TIMEZONE', $this->TIMEZONE);
             Configuration::exportKeys($this->encryptionKey, $this->encryptionSalt);
             //Now that we have encryption keys written, save the account if we have it
             if (!empty($this->loginemail) && !empty($this->loginpassword)) {
                 $objCustomer = Customer::LoadByEmail($this->loginemail);
                 if (!$objCustomer instanceof Customer) {
                     $objCustomer = new Customer();
                     $objCustomer->first_name = "Admin";
                     $objCustomer->last_name = "User";
                     $objCustomer->record_type = 1;
                     $objCustomer->pricing_level = 1;
                     $objCustomer->preferred_language = "en";
                     $objCustomer->currency = "USD";
                     $objCustomer->email = $this->loginemail;
                     $objCustomer->mainphone = _xls_get_conf('STORE_PHONE');
                 }
                 $objCustomer->password = _xls_encrypt($this->loginpassword);
                 $objCustomer->allow_login = 2;
                 $objCustomer->save();
             }
             break;
         case 3:
             _xls_set_conf('STORE_NAME', $this->STORE_NAME);
             _xls_set_conf('EMAIL_FROM', $this->EMAIL_FROM);
             _xls_set_conf('STORE_ADDRESS1', $this->STORE_ADDRESS1);
             _xls_set_conf('STORE_ADDRESS2', $this->STORE_ADDRESS2);
             _xls_set_conf('STORE_CITY', $this->STORE_CITY);
             _xls_set_conf('STORE_STATE', $this->STORE_STATE);
             _xls_set_conf('STORE_COUNTRY', $this->STORE_COUNTRY);
             _xls_set_conf('STORE_ZIP', $this->STORE_ZIP);
             _xls_set_conf('STORE_HOURS', $this->STORE_HOURS);
             _xls_set_conf('STORE_PHONE', $this->STORE_PHONE);
             break;
         case 4:
             if (is_null($this->EMAIL_SMTP_SERVER)) {
                 $this->EMAIL_SMTP_SERVER = '';
             }
             if (is_null($this->EMAIL_SMTP_PORT)) {
                 $this->EMAIL_SMTP_PORT = '';
             }
             if (is_null($this->EMAIL_SMTP_USERNAME)) {
                 $this->EMAIL_SMTP_USERNAME = '';
             }
             if (is_null($this->EMAIL_SMTP_PASSWORD)) {
                 $this->EMAIL_SMTP_PASSWORD = '';
             }
             _xls_set_conf('EMAIL_SMTP_SERVER', $this->EMAIL_SMTP_SERVER);
             _xls_set_conf('EMAIL_SMTP_PORT', $this->EMAIL_SMTP_PORT);
             _xls_set_conf('EMAIL_SMTP_USERNAME', $this->EMAIL_SMTP_USERNAME);
             _xls_set_conf('EMAIL_SMTP_PASSWORD', _xls_encrypt($this->EMAIL_SMTP_PASSWORD));
             _xls_set_conf('EMAIL_SMTP_SECURITY_MODE', $this->EMAIL_SMTP_SECURITY_MODE);
             break;
     }
 }
 /**
  * Receiving function for flipping sides on common SSL. Depending on inbound information
  * we need to assign the CartID to the session so we're using it on both sides
  */
 public function actionSharedSSLReceive()
 {
     if (!Yii::app()->params['LIGHTSPEED_HOSTING_COMMON_SSL']) {
         _xls_404();
     }
     //Parse the information we were sent (encrypted) on the command line
     $strLink = Yii::app()->getRequest()->getQuery('link');
     if (empty($strLink)) {
         _xls_404();
     }
     $link = _xls_decrypt($strLink);
     $arrItems = explode(',', $link);
     $arrParams = array();
     //$strIdentity = $userID.",".$cartID.",".$controller.",".$action;
     $userID = $arrItems[0];
     $cartID = $arrItems[1];
     $controller = $arrItems[2];
     $action = $arrItems[3];
     if (isset($arrItems[6])) {
         $arrParams['orderId'] = $arrItems[5];
         $arrParams['errorNote'] = $arrItems[6];
     } elseif (isset($arrItems[4])) {
         $arrParams['linkid'] = $arrItems[4];
     }
     //If our session was previously logged in on this side of SSL, we overwrite, otherwise log out
     if ($userID > 0) {
         //we were logged in on the other URL so re-login here
         $objCustomer = Customer::model()->findByPk($userID);
         $identity = new UserIdentity($objCustomer->email, _xls_decrypt($objCustomer->password));
         $identity->authenticate();
         if ($identity->errorCode == UserIdentity::ERROR_NONE) {
             Yii::app()->user->login($identity, 3600 * 24 * 30);
         } else {
             Yii::log('Error attempting to switch to shared SSL and logging in, error ' . $identity->errorCode, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
     } elseif (!Yii::app()->user->isGuest) {
         Yii::app()->user->logout();
     }
     Yii::app()->user->setState('sharedssl', '1');
     if ($cartID > 0) {
         Yii::app()->user->setState('cartid', $cartID);
         Yii::app()->shoppingcart->setModelById($cartID);
         //Explicitly make this cart current under this URL
     }
     //Create our URL
     $url = $this->createUrl($controller . "/" . $action, $arrParams);
     //To avoid double-intercepting, we have to manually build URL instead of using createURL in this case
     if ($controller == "cart" && $action == "checkout") {
         $url = "https://" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . "/cart/checkout";
         if ($userID == 0) {
             $url .= "?c=" . urlencode(_xls_encrypt($cartID . "," . date("His")));
         }
     }
     if ($controller == 'checkout' && $action == 'index') {
         $url = 'https://' . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . '/checkout/' . $action;
         if ($userID == 0) {
             $url .= "?c=" . urlencode(_xls_encrypt($cartID . "," . date("His")));
         }
     }
     // We are setting this cookie here
     // TODO: Move this code to the extension itself so that we don't have to perform tasks that are extension-specific.
     Yii::app()->request->cookies['access_warning'] = new CHttpCookie('access_warning', 'false');
     //Finally, onward to the page
     $this->redirect($url);
 }
    /**
     * Create a new account from Registration and then login
     * @param $model
     * @param $strPassword
     */
    protected function createAndLogin($model, $strPassword)
    {
        if (Yii::app()->params['MODERATE_REGISTRATION'] == 1) {
            $this->triggerEmailCampaign($model, 'onAddCustomer');
            Yii::app()->user->setFlash('success', Yii::t('customer', 'Your account has been created but must be approved before you can log in.
					 You will receive confirmation when you have been approved.'));
            $this->triggerEmailCampaign($model, 'onAddCustomer');
            $this->redirect($this->createUrl("/site"));
        }
        //We've successfully created the account, so just log in
        $loginModel = new LoginForm();
        $loginModel->email = $model->email;
        $loginModel->password = $strPassword;
        // validate user input and redirect to the previous page if valid
        if ($loginModel->validate() && $loginModel->login()) {
            Yii::app()->user->setFlash('success', Yii::t('customer', 'Your account has been created and you have been logged in automatically.'));
        } else {
            Yii::log("Error logging in our newly created user " . print_r($loginModel->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
            Yii::app()->user->setFlash('error', Yii::t('customer', 'Your account has been created but we had an error logging you in.'));
        }
        $this->triggerEmailCampaign($model, 'onAddCustomer');
        //Common SSL mode means we need to pass back to the original URL and log in again automatically
        if (Yii::app()->isCommonSSL) {
            $strIdentity = Yii::app()->user->id . "," . Yii::app()->shoppingcart->id . ",site,index";
            Yii::log('Log in ' . $strIdentity, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
            $redirString = _xls_encrypt($strIdentity);
            $url = Yii::app()->controller->createAbsoluteUrl('commonssl/login', array('link' => $redirString));
            $url = str_replace("https://" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'], "http://" . Yii::app()->params['LIGHTSPEED_HOSTING_CUSTOM_URL'], $url);
        } else {
            $url = $this->createUrl("/site");
        }
        //No matter what happens, we always go home.
        $this->redirect($url);
    }
 public function actionEdit()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     $model = Configuration::model()->findAllByAttributes(array('configuration_type_id' => $id), array('order' => 'sort_order'));
     if (isset($_POST['Configuration'])) {
         $valid = true;
         foreach ($model as $i => $item) {
             if (isset($_POST['Configuration'][$i])) {
                 $item->attributes = $_POST['Configuration'][$i];
             }
             $valid = $item->validate() && $valid;
             if (!$valid) {
                 $err = $item->getErrors();
                 Yii::app()->user->setFlash('error', $item->title . " -- " . print_r($err['key_value'][0], true));
                 break;
             }
         }
         if ($valid) {
             foreach ($model as $i => $item) {
                 $item->attributes = $_POST['Configuration'][$i];
                 if ($item->options == "PASSWORD") {
                     $item->key_value = _xls_encrypt($item->key_value);
                 }
                 if (!$item->save()) {
                     Yii::app()->user->setFlash('error', print_r($item->getErrors(), true));
                 } else {
                     $item->postConfigurationChange();
                 }
                 if ($item->key_name == 'EMAIL_TEST' && $item->key_value == 1) {
                     $this->sendEmailTest();
                 }
             }
             Yii::app()->user->setFlash('success', Yii::t('admin', 'Configuration updated on {time}.', array('{time}' => date("d F, Y  h:i:sa"))));
         }
     }
     foreach ($model as $i => $item) {
         if ($item->key_name == "EMAIL_TEST") {
             $item->key_value = 0;
         }
         if ($item->options == "BOOL") {
             $this->registerOnOff($item->id, "Configuration_{$i}_key_value", $item->key_value);
         }
         if ($item->options == "PASSWORD") {
             $model[$i]->key_value = _xls_decrypt($model[$i]->key_value);
         }
         $model[$i]->title = Yii::t('admin', $item->title, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
         $model[$i]->helper_text = Yii::t('admin', $item->helper_text, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
     }
     $this->render('edit', array('model' => $model));
 }
Example #7
0
 /**
  * Redirect to the receipt page.
  * TODO: make work with legacy checkout
  *
  * @param Cart->linkid $strLink
  * @return void
  */
 protected static function redirectToReceipt($strLink)
 {
     if (Yii::app()->theme->advancedCheckout === true) {
         $route = 'checkout/thankyou';
     } else {
         $route = 'cart/receipt';
     }
     if (Yii::app()->user->getState('sharedssl') && Yii::app()->isCommonSSL) {
         Yii::app()->user->setState('cartid', null);
         //If we have created a login on checkout that should survive, route through login first
         //on original URL. Otherwise, we can just to straight to the receipt
         if (Yii::app()->user->getState('createdoncheckout') == 1) {
             Yii::app()->user->setState('createdoncheckout', 0);
             //In case we submit on the same login later
             $strIdentity = Yii::app()->user->id . ",0,cart,receipt," . $strLink;
             Yii::log('Routing to receipt via common login: '******'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
             $redirString = _xls_encrypt($strIdentity);
             $url = Yii::app()->controller->createAbsoluteUrl('commonssl/sharedsslreceive', array('link' => $redirString));
         } else {
             $url = Yii::app()->controller->createAbsoluteUrl($route, array('getuid' => $strLink));
         }
         $url = _xls_url_common_to_custom($url);
         Yii::app()->controller->redirect($url);
         return;
     }
     if (isset($_POST['noredirect'])) {
         return;
     }
     Yii::app()->controller->redirect(Yii::app()->controller->createAbsoluteUrl($route, array('getuid' => $strLink)));
 }
 /**
  * Process login from the popup Login box
  */
 public function actionLogin()
 {
     if (!Yii::app()->user->isGuest && Yii::app()->isCommonSSL) {
         Yii::app()->user->logout();
     }
     if (!Yii::app()->user->isGuest) {
         $this->redirect($this->createAbsoluteUrl("/site"));
     }
     $model = new LoginForm();
     $model->setScenario('Existing');
     $response_array = array();
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         Yii::log("Attempting login", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
         $model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             // remove any existing form information in cache
             unset(Yii::app()->session[MultiCheckoutForm::$sessionKey]);
             //If we're doing this as a shared login, redirect
             if (Yii::app()->isCommonSSL) {
                 Yii::log("Common login redirecting", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
                 //We logged in under the common URL but we don't stay here, so pass our login back
                 $strTimestamp = date("YmdHis");
                 $intCart = Yii::app()->shoppingcart->id;
                 $strIdentity = Yii::app()->user->id . "," . $intCart . "," . $strTimestamp;
                 Yii::log("Going to Shared URL with info: " . $strIdentity, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
                 $redirString = _xls_encrypt($strIdentity);
                 $url = Yii::app()->createAbsoluteUrl("commonssl/login", array('link' => $redirString), 'http');
                 $strCustomUrl = Yii::app()->params['LIGHTSPEED_HOSTING_CUSTOM_URL'];
                 $strLightSpeedUrl = Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'];
                 $url = str_replace($strLightSpeedUrl, $strCustomUrl, $url);
                 Yii::app()->getRequest()->redirect($url, true);
             } else {
                 $this->redirect($this->createAbsoluteUrl("site/index", array(), 'http'));
             }
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         echo json_encode($response_array);
     } else {
         $this->render('login', array('model' => $model));
     }
 }
 protected static function redirectToReceipt($strLink)
 {
     if (Yii::app()->user->getState('sharedssl') && Yii::app()->isCommonSSL) {
         Yii::app()->user->setState('cartid', null);
         //If we have created a login on checkout that should survive, route through login first
         //on original URL. Otherwise, we can just to straight to the receipt
         if (Yii::app()->user->getState('createdoncheckout') == 1) {
             Yii::app()->user->setState('createdoncheckout', 0);
             //In case we submit on the same login later
             $strIdentity = Yii::app()->user->id . ",0,cart,receipt," . $strLink;
             Yii::log("Routing to receipt via common login: "******"." . __FUNCTION__);
             $redirString = _xls_encrypt($strIdentity);
             $url = Yii::app()->controller->createAbsoluteUrl('commonssl/sharedsslreceive', array('link' => $redirString));
         } else {
             $url = Yii::app()->controller->createAbsoluteUrl('cart/receipt', array('getuid' => $strLink));
         }
         $url = str_replace("https://" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'], "http://" . Yii::app()->params['LIGHTSPEED_HOSTING_CUSTOM_URL'], $url);
         Yii::app()->controller->redirect($url);
         return;
     }
     if (isset($_POST['noredirect'])) {
         return;
     }
     Yii::app()->controller->redirect(Yii::app()->controller->createAbsoluteUrl('cart/receipt', array('getuid' => $strLink)));
 }