PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.15
VikBooking Hotel Booking Engine & PMS v1.8.15
1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 All 36 releases
vikbooking / admin / controllers / license.php

license.php in VikBooking Hotel Booking Engine & PMS 1.8.15, at admin/controllers/license.php

105 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2019 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 JLoader::import('adapter.mvc.controllers.admin');
15
16 /**
17 * VikBooking plugin License controller.
18 *
19 * @since 1.3.12
20 * @see JControllerAdmin
21 */
22 class VikBookingControllerLicense extends JControllerAdmin
23 {
24 /**
25 * License Key validation through ajax request.
26 * This task takes also the change-log for the current version.
27 *
28 * @return void
29 */
30 public function validate()
31 {
32 if (!JFactory::getUser()->authorise('core.admin', 'com_vikbooking'))
33 {
34 // not authorised to view this resource
35 VBOHttpDocument::getInstance()->close(403, JText::translate('RESOURCE_AUTH_ERROR'));
36 }
37
38 $input = JFactory::getApplication()->input;
39
40 // get input key
41 $key = $input->getString('key');
42
43 // get license model
44 $model = $this->getModel();
45
46 // dispatch license key validation
47 $response = $model->validate($key);
48
49 // make sure the validation went fine
50 if ($response === false)
51 {
52 // nope, retrieve the error
53 $error = $model->getError(null, $toString = false);
54
55 // an error will be always an exception
56 VBOHttpDocument::getInstance()->close($error->getCode(), $error->getMessage());
57 }
58
59 VBOHttpDocument::getInstance()->json($response);
60 }
61
62 /**
63 * Downloads the PRO version from VikWP servers.
64 *
65 * @return void
66 */
67 public function downloadpro()
68 {
69 if (!JFactory::getUser()->authorise('core.admin', 'com_vikbooking'))
70 {
71 // not authorised to view this resource
72 VBOHttpDocument::getInstance()->close(403, JText::translate('RESOURCE_AUTH_ERROR'));
73 }
74
75 $input = JFactory::getApplication()->input;
76
77 // get input key
78 $key = $input->getString('key');
79
80 // get license model
81 $model = $this->getModel();
82
83 // dispatch pro version download
84 $response = $model->download($key);
85
86 // make sure the download went fine
87 if ($response === false)
88 {
89 // nope, retrieve the error
90 $error = $model->getError(null, $toString = false);
91
92 if (!$error instanceof Exception)
93 {
94 $error = new Exception($error, 500);
95 }
96
97 // terminate the response with a proper error code
98 VBOHttpDocument::getInstance()->close($error->getCode(), $error->getMessage());
99 }
100
101 // downloaded successfully
102 VBOHttpDocument::getInstance()->close(200, 'e4j.OK');
103 }
104 }
105