acl.php
1 month ago
feedback.php
1 month ago
license.php
1 month ago
override.php
1 month ago
rss.php
1 month ago
shortcode.php
1 month ago
shortcodes.php
1 month ago
license.php
98 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | VAPLoader::import('libraries.mvc.controllers.admin'); |
| 15 | |
| 16 | /** |
| 17 | * VikAppointments plugin License controller. |
| 18 | * |
| 19 | * @since 1.0 |
| 20 | */ |
| 21 | class VikAppointmentsControllerLicense extends VAPControllerAdmin |
| 22 | { |
| 23 | /** |
| 24 | * License Key validation through ajax request. |
| 25 | * This task takes also the change-log for the current version. |
| 26 | * |
| 27 | * @return void |
| 28 | */ |
| 29 | public function validate() |
| 30 | { |
| 31 | if (!JFactory::getUser()->authorise('core.admin', 'com_vikappointments')) |
| 32 | { |
| 33 | // not authorised to view this resource |
| 34 | throw new Exception(JText::translate('RESOURCE_AUTH_ERROR'), 403); |
| 35 | } |
| 36 | |
| 37 | $input = JFactory::getApplication()->input; |
| 38 | |
| 39 | // get input key |
| 40 | $key = $input->getString('key'); |
| 41 | |
| 42 | // get license model |
| 43 | $model = $this->getModel(); |
| 44 | |
| 45 | // dispatch license key validation |
| 46 | $response = $model->validate($key); |
| 47 | |
| 48 | // make sure the validation went fine |
| 49 | if ($response === false) |
| 50 | { |
| 51 | // nope, retrieve the error |
| 52 | $error = $model->getError(null, $toString = false); |
| 53 | |
| 54 | // an error will be always an exception |
| 55 | throw $error; |
| 56 | } |
| 57 | |
| 58 | $this->sendJSON($response); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Downloads the PRO version from VikWP servers. |
| 63 | * |
| 64 | * @return void |
| 65 | */ |
| 66 | public function downloadpro() |
| 67 | { |
| 68 | if (!JFactory::getUser()->authorise('core.admin', 'com_vikappointments')) |
| 69 | { |
| 70 | // not authorised to view this resource |
| 71 | throw new Exception(JText::translate('RESOURCE_AUTH_ERROR'), 403); |
| 72 | } |
| 73 | |
| 74 | $input = JFactory::getApplication()->input; |
| 75 | |
| 76 | // get input key |
| 77 | $key = $input->getString('key'); |
| 78 | |
| 79 | // get license model |
| 80 | $model = $this->getModel(); |
| 81 | |
| 82 | // dispatch pro version download |
| 83 | $response = $model->download($key); |
| 84 | |
| 85 | // make sure the download went fine |
| 86 | if ($response === false) |
| 87 | { |
| 88 | // nope, retrieve the error |
| 89 | $error = $model->getError(null, $toString = false); |
| 90 | |
| 91 | // an error will be always an exception |
| 92 | throw $error; |
| 93 | } |
| 94 | |
| 95 | // downloaded successfully |
| 96 | } |
| 97 | } |
| 98 |