authorise('core.admin', 'com_vikbooking')) { // not authorised to view this resource VBOHttpDocument::getInstance()->close(403, JText::translate('RESOURCE_AUTH_ERROR')); } $input = JFactory::getApplication()->input; // get input key $key = $input->getString('key'); // get license model $model = $this->getModel(); // dispatch license key validation $response = $model->validate($key); // make sure the validation went fine if ($response === false) { // nope, retrieve the error $error = $model->getError(null, $toString = false); // an error will be always an exception VBOHttpDocument::getInstance()->close($error->getCode(), $error->getMessage()); } VBOHttpDocument::getInstance()->json($response); } /** * Downloads the PRO version from VikWP servers. * * @return void */ public function downloadpro() { if (!JFactory::getUser()->authorise('core.admin', 'com_vikbooking')) { // not authorised to view this resource VBOHttpDocument::getInstance()->close(403, JText::translate('RESOURCE_AUTH_ERROR')); } $input = JFactory::getApplication()->input; // get input key $key = $input->getString('key'); // get license model $model = $this->getModel(); // dispatch pro version download $response = $model->download($key); // make sure the download went fine if ($response === false) { // nope, retrieve the error $error = $model->getError(null, $toString = false); if (!$error instanceof Exception) { $error = new Exception($error, 500); } // terminate the response with a proper error code VBOHttpDocument::getInstance()->close($error->getCode(), $error->getMessage()); } // downloaded successfully VBOHttpDocument::getInstance()->close(200, 'e4j.OK'); } }