-
Notifications
You must be signed in to change notification settings - Fork 5
/
class.wpzabbix.php
71 lines (48 loc) · 1.33 KB
/
class.wpzabbix.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
<?php
class WpZabbix
{
const METHODS = 'GET, POST';
public function __construct()
{
}
/**
* Initializes WordPress hooks
*/
public function init()
{
add_action('rest_api_init', [$this, 'add_endpoints']);
}
/**
* Add the endpoints to the API
*/
public function add_endpoints()
{
$health_controller = new WP_ZABBIX_SiteHealth_Controller();
$health_controller->register_routes();
$updates_controller = new WP_ZABBIX_Updates_Controller();
$updates_controller->register_routes();
}
public static function permission_check()
{
$secret_key = defined('WPZABBIX_KEY') ? WPZABBIX_KEY : false;
if (!$secret_key) {
return new WP_Error(
'wpzabbix_bad_config',
__('wp-zabbix is not configurated properly, please contact the admin', 'wp-zabbix'),
[
'status' => 500,
]
);
}
if (!isset($_REQUEST['wpzabbix-key'])) {
return new WP_Error(
'wpzabbix_bad_parameter',
__('no key set', 'wp-zabbix'),
[
'status' => 500,
]
);
}
return ($_REQUEST['wpzabbix-key'] === $secret_key);
}
}