PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.20
VikAppointments Services Booking Calendar v1.2.20
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / mvc / admin / views / getpro / view.html.php
vikappointments / libraries / mvc / admin / views / getpro Last commit date
tmpl 1 month ago index.html 1 month ago view.html.php 1 month ago
view.html.php
114 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 /**
15 * VikAppointments PRO download view.
16 *
17 * @since 1.0
18 */
19 class VikAppointmentsViewGetpro extends JViewVAP
20 {
21 /**
22 * VikAppointments view display method.
23 *
24 * @return void
25 */
26 function display($tpl = null)
27 {
28 JHtml::fetch(
29 'stylesheet',
30 VIKAPPOINTMENTS_CORE_MEDIA_URI . 'css/license.css',
31 array('version' => VIKAPPOINTMENTS_SOFTWARE_VERSION),
32 array('id' => 'vap-license-style')
33 );
34
35 $app = JFactory::getApplication();
36
37 // set the toolbar
38 $this->addToolBar();
39
40 VikAppointmentsLoader::import('update.changelog');
41 VikAppointmentsLoader::import('update.license');
42
43 // get version from request
44 $version = $app->input->getString('version');
45
46 if ($version)
47 {
48 // init HTTP transport
49 $http = new JHttp();
50
51 /**
52 * Always re-download the changelog of VikAppointments
53 * before upgrading the files to the PRO version.
54 *
55 * @since 1.1.3
56 */
57 $url = 'https://vikwp.com/api/?task=products.changelog';
58
59 // use version set in request because the constant and the
60 // database, at this point, are always up to date
61 $data = array(
62 'sku' => 'vap',
63 'version' => $version,
64 );
65
66 // build headers
67 $headers = array(
68 /**
69 * Always bypass SSL validation while reaching our end-point.
70 *
71 * @since 1.2
72 */
73 'sslverify' => false,
74 );
75
76 $response = $http->post($url, $data, $headers);
77
78 if ($response->code == 200)
79 {
80 // save changelog on success
81 VikAppointmentsChangelog::store(json_decode($response->body));
82 }
83 }
84
85 $changelog = VikAppointmentsChangelog::build();
86 $lic_key = VikAppointmentsLicense::getKey();
87 $lic_date = VikAppointmentsLicense::getExpirationDate();
88 $is_pro = VikAppointmentsLicense::isPro();
89
90 if (!$is_pro)
91 {
92 $app->enqueueMessage(__('No valid and active license key found.', 'vikappointments'), 'error');
93 $app->redirect('index.php?option=com_vikappointments&view=gotopro');
94 exit;
95 }
96
97 $this->changelog = $changelog;
98 $this->licenseKey = $lic_key;
99
100 // display the template
101 parent::display($tpl);
102 }
103
104 /**
105 * Setting the toolbar.
106 *
107 * @return void
108 */
109 protected function addToolBar()
110 {
111 JToolBarHelper::title(__('VikAppointments - Downloading Pro version', 'vikappointments'), 'vikappointments');
112 }
113 }
114