class-aw-license.php
1.64 KB
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
<?php
class awlicense_class{
public $awlic;
public $server;
public $api_key;
private $wp_option = 'ActiveWoo';
private $product_id = 'ActiveWoo';
public $err;
public function __construct($awlic=false , $server , $api_key){
$this->lic = $awlic;
$this->server = $server;
$this->api_key = $api_key;
}
/**
* check for current product if licensed
* @return boolean
*/
public function is_licensed(){
$awlic = get_option($this->wp_option);
if(!empty( $awlic )){
return true;
}
return false;
}
/**
* send query to server and try to active lisence
* @return boolean
*/
public function active(){
$url = AW_LICENSE_KEY_URL . '/?secret_key=' . AW_LICENSE_KEY_REQ . '&slm_action=slm_activate&license_key=' . $awlicense_key . '®istered_domain=' . get_bloginfo('siteurl').'&item_reference='.$this->product_id;
$response = wp_remote_get($url, array('timeout' => 20, 'sslverify' => false));
if(is_array($response)){
$json = $response['body']; // use the content
$json = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', utf8_encode($json));
$awlicense_data = json_decode($json);
}
if($awlicense_data->result == 'success'){
update_option( $this->wp_option, $this->lic );
return true;
}else{
$this->err = $awlicense_data->message;
return false;
}
}
/**
* send query to server and try to deactive lisence
* @return boolean
*/
public function deactive(){
}
}