Esempio n. 1
0
 /**
  * Authentication action before install sample data
  *
  * @return  void
  */
 public function loadEditionsAction()
 {
     // Process posted back data that sent from client
     if ($this->request->getMethod() == 'POST') {
         $username = $this->request->getString('username', '');
         $password = $this->request->getString('password', '');
         // Create new HTTP Request
         try {
             // Prepare current edition
             $currentEdition = strtoupper($this->template['edition']);
             if (!preg_match('/^PRO /i', $currentEdition)) {
                 $currentEdition = "PRO {$currentEdition}";
             }
             foreach (JSNTplApiLightcart::getOrderedEditions($this->template['id'], $username, $password) as $edition) {
                 if (strcasecmp($currentEdition, $edition) != 0) {
                     $editions[] = $edition;
                 }
             }
         } catch (Exception $e) {
             throw $e;
         }
         if (!isset($editions)) {
             throw new Exception(JText::_('JSN_TPLFW_ERROR_API_ERR02'));
         }
         $this->setResponse($editions);
     }
 }
Esempio n. 2
0
 /**
  * Authentication action before install sample data
  *
  * @return  void
  */
 public function confirmAction()
 {
     $target = $this->request->getString('target');
     if ($target == 'framework') {
         // Check if template has update also
         $this->checkUpdateAction();
         $result = $this->getResponse();
         $this->render('framework_confirm', array('manifest' => JSNTplHelper::getManifestCache('jsntplframework'), 'template' => $this->template['name'], 'templateHasUpdate' => $result['template']['hasUpdate']));
         return;
     }
     // Process posted back data that sent from client
     if ($this->request->getMethod() == 'POST') {
         // Checking customer information
         $input = JFactory::getApplication()->input;
         $username = $input->getString('username', '');
         $password = $input->getString('password', '');
         // Try retrieve ordered editions to check customer information
         try {
             JSNTplApiLightcart::getOrderedEditions($this->template['id'], $username, $password);
         } catch (Exception $e) {
             throw $e;
         }
         return;
     }
     // Retrieve version data
     try {
         $versionData = JSNTplHelper::getVersionData();
     } catch (Exception $e) {
         throw $e;
     }
     // Find template information by identify name
     foreach ($versionData['items'] as $item) {
         if ($item['identified_name'] == $this->template['id']) {
             if (isset($item['edition']) and !empty($item['edition']) or @is_array($item['editions']) and count($item['editions']) == 1) {
                 $template = @is_array($item['editions']) ? $item['editions'][0] : $item;
                 // Render login view
                 $this->render('confirm', array('template' => $this->template, 'authenticate' => $template['authentication']));
             } else {
                 foreach ($item['editions'] as $template) {
                     $edition = trim($template['edition']);
                     if (str_replace('PRO ', '', $this->template['edition']) == str_replace('PRO ', '', $edition)) {
                         // Render login view
                         $this->render('confirm', array('template' => $this->template, 'authenticate' => $template['authentication']));
                         break;
                     }
                 }
             }
             break;
         }
     }
 }
Esempio n. 3
0
 /**
  * Process checking customer information
  *
  * @return  void
  */
 public function authAction()
 {
     // Process posted back data that sent from client
     if ($this->request->getMethod() == 'POST') {
         $username = $this->request->getString('username', '');
         $password = $this->request->getString('password', '');
         // Create new HTTP Request
         try {
             $orderedEditions = JSNTplApiLightcart::getOrderedEditions($this->template['id'], $username, $password);
         } catch (Exception $e) {
             throw $e;
         }
         $edition = $this->template['edition'];
         if ($edition != 'FREE' and strpos($edition, 'PRO ') === false) {
             $edition = 'PRO ' . $edition;
         }
         if (in_array($edition, $orderedEditions)) {
             $this->setResponse(array('id' => $this->template['id'], 'edition' => $edition, 'joomlaVersion' => JSNTplHelper::getJoomlaVersion(2), 'username' => urlencode($username), 'password' => urlencode($password)));
         } else {
             throw new Exception(JText::_('JSN_TPLFW_ERROR_API_ERR02'));
         }
     }
 }
Esempio n. 4
0
 /**
  * Authentication action before install sample data
  *
  * @return  void
  */
 public function confirmAction()
 {
     $target = $this->request->getString('target');
     if ($target == 'framework') {
         // Check if template has update also
         $this->checkUpdateAction();
         $result = $this->getResponse();
         $this->render('framework_confirm', array('manifest' => JSNTplHelper::getManifestCache('jsntplframework'), 'template' => $this->template['name'], 'templateHasUpdate' => $result['template']['hasUpdate']));
         return;
     }
     // Check if user account was stored before
     $db = JFactory::getDbo();
     $q = $db->getQuery(true);
     $q->select('params');
     $q->from('#__extensions');
     $q->where('`type` = ' . $q->quote('template'));
     $q->where('`element` = ' . $q->quote($this->template['name']));
     $db->setQuery($q);
     $account = json_decode($db->loadResult());
     $account = $account && isset($account->username) && isset($account->password) ? $account : false;
     // Process posted back data that sent from client
     if ($account || $this->request->getMethod() == 'POST') {
         // Checking customer information
         $input = JFactory::getApplication()->input;
         $username = $this->request->getMethod() == 'POST' ? $input->getString('username', '') : $account->username;
         $password = $this->request->getMethod() == 'POST' ? $input->getString('password', '') : $account->password;
         // Try retrieve ordered editions to check customer information
         try {
             JSNTplApiLightcart::getOrderedEditions($this->template['id'], $username, $password);
             // Store user account for later reference
             if ($this->request->getMethod() == 'POST') {
                 $q = $db->getQuery(true);
                 $q->update('#__extensions');
                 $q->set("`params` = '" . json_encode(array('username' => $input->getString('username'), 'password' => $input->getString('password'))) . "'");
                 $q->where('`type` = ' . $q->quote('template'));
                 $q->where('`element` = ' . $q->quote($this->template['name']));
                 $db->setQuery($q);
                 if (method_exists($db, 'execute')) {
                     $db->execute();
                 } else {
                     $db->query();
                 }
             }
             return;
         } catch (Exception $e) {
             if ($this->request->getMethod() == 'POST') {
                 throw $e;
             }
         }
     }
     // Retrieve version data
     try {
         $versionData = JSNTplHelper::getVersionData();
     } catch (Exception $e) {
         throw $e;
     }
     // Find template information by identify name
     foreach ($versionData['items'] as $item) {
         if ($item['identified_name'] == $this->template['id']) {
             if (isset($item['edition']) and !empty($item['edition']) or @is_array($item['editions']) and count($item['editions']) == 1) {
                 $template = @is_array($item['editions']) ? $item['editions'][0] : $item;
                 // Render login view
                 $this->render('confirm', array('template' => $this->template, 'authenticate' => $template['authentication']));
             } else {
                 foreach ($item['editions'] as $template) {
                     $edition = trim($template['edition']);
                     if (str_replace('PRO ', '', $this->template['edition']) == str_replace('PRO ', '', $edition)) {
                         // Render login view
                         $this->render('confirm', array('template' => $this->template, 'authenticate' => $template['authentication']));
                         break;
                     }
                 }
             }
             break;
         }
     }
 }