-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjomres_check_support_key.class.php
152 lines (130 loc) · 5.56 KB
/
jomres_check_support_key.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* Core file.
*
* @author Vince Wooll <sales@jomres.net>
*
* @version Jomres 9.9.10
*
* @copyright 2005-2017 Vince Wooll
* Jomres (tm) PHP, CSS & Javascript files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project, and use it accordingly
**/
// ################################################################
defined('_JOMRES_INITCHECK') or die('');
// ################################################################
#[AllowDynamicProperties]
class jomres_check_support_key
{
public function __construct($task)
{
$this->task = $task;
$this->key_valid = false;
if (isset($_REQUEST[ 'support_key' ]) && strlen($_REQUEST[ 'support_key' ]) > 0) {
$this->save_key($task);
}
$task = jomresGetParam($_REQUEST, 'task', '');
$this->shop_status = 'CLOSED';
$this->check_license_key();
}
public function get_shop_status()
{
$request = 'request=shop_status';
$response = query_shop($request);
if (is_object($response)) {
$this->shop_status = $response->status;
} else {
$this->shop_status = 'CLOSED';
}
}
public function remove_plugin_licenses_file()
{
unlink(JOMRES_TEMP_ABSPATH.$this->user_plugin_license_temp_file_name);
}
public function get_user_plugin_licenses()
{
include_once JOMRES_TEMP_ABSPATH.$this->user_plugin_license_temp_file_name;
$this->plugin_licenses = plugin_licenses();
}
public function check_license_key($force = false)
{
$siteConfig = jomres_singleton_abstract::getInstance('jomres_config_site_singleton');
$jrConfig = $siteConfig->get();
$str = 'key='.$jrConfig['licensekey'];
$this->key_hash = $jrConfig['licensekey'];
$license_data = new stdClass();
$license_data->license_name = 'Unknown';
$license_data->expires = 'Unknown';
$license_data->key_status = 'Unknown';
$license_data->owner = 'Unknown';
$license_data->license_valid = false;
$license_data->allows_plugins = false;
$license_data->is_trial_license = false;
if (file_exists(JOMRES_TEMP_ABSPATH.'license_key_check_cache.php')) {
$last_modified = filemtime(JOMRES_TEMP_ABSPATH.'license_key_check_cache.php');
$seconds_timediff = time() - $last_modified;
if ($seconds_timediff > 86400) {
unlink(JOMRES_TEMP_ABSPATH.'license_key_check_cache.php');
} else {
include JOMRES_TEMP_ABSPATH.'license_key_check_cache.php';
}
}
if (!file_exists(JOMRES_TEMP_ABSPATH.'license_key_check_cache.php') || $force) {
$buffer = queryUpdateServer('check_key.php', $str, 'updates');
if ($buffer != '') {
$license_data = json_decode($buffer);
if (!is_object( $license_data)) {
$license_data = new stdClass();
}
if ($license_data->license_valid === true) {
$license_data->license_valid = '1';
} else {
$license_data->license_valid = '0';
}
if (is_null($license_data->expires)) {
$license_data->expires = 'Unknown';
}
if (is_null($license_data->allows_plugins)) {
$license_data->allows_plugins = 'Unknown';
}
if (is_null($license_data->is_trial_license)) {
$license_data->is_trial_license = 'Unknown';
}
if (!isset($license_data->status)) {
$license_data->key_status = 'Unknown';
} else {
$license_data->key_status = $license_data->status;
}
$lic_data = '<?php
defined( \'_JOMRES_INITCHECK\' ) or die( \'\' );
$license_data = new stdClass;
$license_data->license_name = "'.$license_data->license_name.'";
$license_data->expires = "'.$license_data->expires.'";
$license_data->key_status = "'.$license_data->key_status.'";
$license_data->owner = "'.$license_data->owner.'";
$license_data->license_valid = "'.$license_data->license_valid.'";
$license_data->allows_plugins = "'.$license_data->allows_plugins.'";
$license_data->is_trial_license = "'.$license_data->is_trial_license.'";
$license_data->allowed_plugins = "'.$license_data->allowed_plugins.'";
';
file_put_contents(JOMRES_TEMP_ABSPATH.'license_key_check_cache.php', $lic_data);
}
}
if (!empty($license_data)) { // Query failed for some reason, perhaps slow connection
$this->expires = $license_data->expires;
$this->key_status = $license_data->key_status;
$this->owner = $license_data->owner;
$this->license_name = $license_data->license_name;
$this->allowed_plugins = array();
if ( isset($license_data->allowed_plugins))
$this->allowed_plugins = explode("," , $license_data->allowed_plugins);
if ($license_data->license_valid == true) {
$this->key_valid = true;
}
$this->allows_plugins = $license_data->allows_plugins;
if ($license_data->is_trial_license == 'Unknown') {
$license_data->is_trial_license = false;
}
$this->is_trial_license = (bool) $license_data->is_trial_license;
}
}
}