| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; |
| 3 |
|
| 4 |
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_GET['berqwp_webhook']) && $_GET['berqwp_webhook'] == 'check_status') { |
| 5 |
|
| 6 |
$jsonData = file_get_contents('php://input'); |
| 7 |
$data = json_decode($jsonData, true); |
| 8 |
|
| 9 |
if ($data === null) { |
| 10 |
echo wp_json_encode(['status' => 'error', 'msg' => 'Invalid request body']); |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
$license_key = berqwp_get_license_key(); |
| 15 |
$license_key_hash = sanitize_text_field($data['license_key_hash'] ?? ''); |
| 16 |
|
| 17 |
if (empty($license_key)) { |
| 18 |
echo wp_json_encode(['status' => 'inactive']); |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
if (empty($license_key_hash) || $license_key_hash !== md5($license_key)) { |
| 23 |
echo wp_json_encode(['status' => 'error', 'msg' => 'Request authentication failed']); |
| 24 |
http_response_code(403); |
| 25 |
exit; |
| 26 |
} |
| 27 |
|
| 28 |
echo wp_json_encode([ |
| 29 |
'status' => 'active', |
| 30 |
'version' => BERQWP_VERSION, |
| 31 |
'site_url' => home_url(), |
| 32 |
]); |
| 33 |
exit; |
| 34 |
} |
| 35 |
|