Example #1
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;
         }
     }
 }
Example #2
0
 /**
  * Render login form
  *
  * @return  void
  */
 public function loginAction()
 {
     // 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']) {
             $templateInfo = $item;
             break;
         }
     }
     if (isset($templateInfo)) {
         if (isset($templateInfo['editions']) and is_array($templateInfo['editions'])) {
             foreach ($templateInfo['editions'] as $info) {
                 $edition = trim($info['edition']);
                 if (str_replace('PRO ', '', $this->template['edition']) == str_replace('PRO ', '', $edition)) {
                     break;
                 }
             }
         } elseif (isset($templateInfo['edition']) and !empty($templateInfo['edition'])) {
             $edition = trim($templateInfo['edition']);
             if (str_replace('PRO ', '', $this->template['edition']) == str_replace('PRO ', '', $edition)) {
                 $info = $templateInfo;
             }
         }
         if (!isset($info) or $info['authentication'] == false) {
             $this->setResponse(array('auth' => false, 'id' => $this->template['id'], 'edition' => $info['edition'], 'joomlaVersion' => JSNTplHelper::getJoomlaVersion(2)));
         } else {
             // Render login view
             $this->render('login', array('template' => $this->template));
         }
     }
 }
Example #3
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;
         }
     }
 }